Файл: users/profile/friends/plugins/inc.php
Строк: 77
<?php
IF (ISSET($user)){
/*
-----------------
Удалить из друзей
-----------------
*/
IF (GET('get') == "friends_delete" || GET('get') == "friends_delete_ok"){
//Определение данных
$frend = DB::GET_STRING("SELECT * FROM `FRIENDS` WHERE (`USER_ID` = '".$user['ID']."' AND `MY_ID` = '".INTVAL(GET('id_frend'))."' OR `USER_ID` = '".INTVAL(GET('id_frend'))."' AND `MY_ID` = '".$user['ID']."') AND `ACT` = '0' LIMIT 1");
IF (ISSET($frend['ID'])){
IF (GET('get') == "friends_delete_ok"){
DB::GET_SET("DELETE FROM `FRIENDS` WHERE (`USER_ID` = '".INTVAL(GET('id_frend'))."' AND `MY_ID` = '".$user['ID']."' OR `MY_ID` = '".INTVAL(GET('id_frend'))."' AND `USER_ID` = '".$user['ID']."') AND `ACT` = '0'");
DB::GET_SET("DELETE FROM `SUBSCRIBERS` WHERE (`USER_ID` = '".INTVAL(GET('id_frend'))."' AND `MY_ID` = '".$user['ID']."' OR `MY_ID` = '".INTVAL(GET('id_frend'))."' AND `USER_ID` = '".$user['ID']."')");
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `TIME`, `TYPE`) VALUES ('".INTVAL(GET('id_frend'))."', '".$user['ID']."', '".TIME()."', 'friends_delete')");
}
IF (GET('get') == "friends_delete"){
IF (GET('id_list') > 0){
$ID = INTVAL(GET('id_list'));
}ELSE{
$ID = NULL;
}
ECHO "".LG('Вы хотите удалить пользователя из друзей?')."<br /><br />";
?><a class="btn" onclick="request('friends', '<?=REQUEST_URI?>&get=friends_delete_ok', '#friends<?=$ID?>')" load="none"><?=ICONS('check', 15, 'fa-fw')?> <?=LG('Да, удалить')?></a><?
?><a class="btn-o" onclick="request('friends', '<?=REQUEST_URI?>_no_frend', '#friends<?=$ID?>')" load="none"><?=ICONS('check', 15, 'fa-fw')?> <?=LG('Отменить')?></a><br /><br /><?
}
}
}
/*
---------------------------
Отменить предложение дружбы
---------------------------
*/
IF (GET('get') == "friends_cancel"){
//Определение данных
$frend = DB::GET_STRING("SELECT * FROM `FRIENDS` WHERE `MY_ID` = '".$user['ID']."' AND `USER_ID` = '".INTVAL(GET('id_frend'))."' AND `ACT` = '1' LIMIT 1");
IF (ISSET($frend['ID']) && $user['ID'] != $frend['USER_ID'] && $frend['USER_ID'] > 0){
DB::GET_SET("DELETE FROM `FRIENDS` WHERE `MY_ID` = '".$user['ID']."' AND `USER_ID` = '".$frend['USER_ID']."' AND `ACT` = '1' LIMIT 1");
DB::GET_SET("DELETE FROM `SUBSCRIBERS` WHERE `USER_ID` = '".$frend['USER_ID']."' AND `MY_ID` = '".$user['ID']."' LIMIT 1");
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `TIME`, `TYPE`) VALUES ('".$frend['USER_ID']."', '".$user['ID']."', '".TIME()."', 'friends_cancel')");
}
}
/*
-----------------
Предложить дружбу
-----------------
*/
IF (GET('get') == "friends_add" && $account_settings['FRIENDS_PRIVATE_ADD'] == 1){
//Определение данных
$frend = DB::GET_STRING("SELECT * FROM `FRIENDS` WHERE `MY_ID` = '".$user['ID']."' AND `USER_ID` = '".INTVAL(GET('id_frend'))."' AND `ACT` = '1' LIMIT 1");
IF (!ISSET($frend['ID']) && $user['ID'] != INTVAL(GET('id_frend')) && INTVAL(GET('id_frend')) > 0){
DB::GET_ADD("INSERT INTO `FRIENDS` (`USER_ID`, `MY_ID`, `TIME`) VALUES ('".INTVAL(GET('id_frend'))."', '".$user['ID']."', '".TIME()."')");
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `SUBSCRIBERS` WHERE `USER_ID` = '".INTVAL(GET('id_frend'))."' AND `MY_ID` = '".$user['ID']."'") == 0){
DB::GET_ADD("INSERT INTO `SUBSCRIBERS` (`USER_ID`, `MY_ID`) VALUES ('".INTVAL(GET('id_frend'))."', '".$user['ID']."')");
}
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `TIME`, `TYPE`) VALUES ('".INTVAL(GET('id_frend'))."', '".$user['ID']."', '".TIME()."', 'friends_add')");
}
}
/*
---------------
Принятие заявки
---------------
*/
IF (GET('get') == "friends_ok"){
//Определение данных
$frend = DB::GET_STRING("SELECT * FROM `FRIENDS` WHERE `MY_ID` = '".INTVAL(GET('id_frend'))."' AND `USER_ID` = '".$user['ID']."' AND `ACT` = '1'");
IF ($user['ID'] != $frend['MY_ID'] && ISSET($frend['ID'])){
DB::GET_SET("UPDATE `FRIENDS` SET `ACT` = '0' WHERE `MY_ID` = '".$frend['MY_ID']."' AND `USER_ID` = '".$user['ID']."' AND `ACT` = '1' LIMIT 1");
DB::GET_ADD("INSERT INTO `FRIENDS` (`USER_ID`, `MY_ID`, `TIME`, `ACT`) VALUES ('".$frend['MY_ID']."', '".$user['ID']."', '".TIME()."', '0')");
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `SUBSCRIBERS` WHERE `USER_ID` = '".$frend['MY_ID']."' AND `MY_ID` = '".$user['ID']."'") == 0){
DB::GET_ADD("INSERT INTO `SUBSCRIBERS` (`USER_ID`, `MY_ID`) VALUES ('".$frend['MY_ID']."', '".$user['ID']."')");
}
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `TIME`, `TYPE`) VALUES ('".$frend['MY_ID']."', '".$user['ID']."', '".TIME()."', 'friends_success')");
}
}
/*
-----------------
Отклонение заявки
-----------------
*/
IF (GET('get') == "friends_no"){
//Определение данных
$frend = DB::GET_STRING("SELECT * FROM `FRIENDS` WHERE (`MY_ID` = '".$user['ID']."' AND `USER_ID` = '".INTVAL(GET('id_frend'))."' OR `MY_ID` = '".INTVAL(GET('id_frend'))."' AND `USER_ID` = '".$user['ID']."') AND `ACT` = '1'");
IF (ISSET($frend['ID'])){
DB::GET_SET("DELETE FROM `FRIENDS` WHERE (`USER_ID` = '".INTVAL(GET('id_frend'))."' AND `MY_ID` = '".$user['ID']."' OR `MY_ID` = '".INTVAL(GET('id_frend'))."' AND `USER_ID` = '".$user['ID']."') AND `ACT` = '1'");
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `TIME`, `TYPE`) VALUES ('".INTVAL(GET('id_frend'))."', '".$user['ID']."', '".TIME()."', 'friends_no')");
}
}
}
?>