function load() { parent::load(); $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0; $m = new FriendsModel(); $rowsCount = $m->getFriendsCount($this->player->playerId); $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1; if (isset($_GET['DFid']) && !empty($_GET['DFid'])) { $FriendID = mysql_real_escape_string(trim($_GET['DFid'])); if ($FriendID != '') { $m->DeleteFriend($FriendID, $this->player->playerId); $m->dispose(); $this->redirect('friends.php'); return null; } } if (isset($_GET['CFid']) && !empty($_GET['CFid'])) { $ConfirmID = mysql_real_escape_string(trim($_GET['CFid'])); if ($ConfirmID != '') { $m->ConfirmInvitation($ConfirmID, $this->player->playerId); $m->dispose(); $this->redirect('friends.php'); return null; } } if ($this->isPost()) { $post = array(); $post['playerId1'] = $this->player->playerId; $post['myname'] = $this->data['name']; $post['playerName'] = isset($_POST['playerName']) && $_POST['playerName'] != '' ? trim($_POST['playerName']) : trim($_POST['playerName']); if ($post['playerName'] != '') { $m->SendInvitation($post); } else { echo '<pre> Error : Wrong name'; } $m->dispose(); } $this->friends = $m->GetFriends($this->player->playerId, $this->pageIndex, $this->pageSize); $m->dispose(); }
public function cancelBanAction() { $response['error'] = 'Wrong data provided to process ban canceling request.'; if (isPost()) { $post = allPost(); $model = new FriendsModel(); if (isset($post['pid'])) { if ($model->userExist($post['pid'])) { $status = $model->friendsStatus(Request::getParam('user')->id, $post['pid']); if (empty($status)) { $response['error'] = "Information about your relationships with this user not found."; } else { if (!$status['status'] && $status['ban']) { if ($status['uid'] == Request::getParam('user')->id) { if ($model->processFriend('cancelBan', Request::getParam('user')->id, $post['pid'])) { $response['error'] = 0; $response['target_h']['#request'] = 'You have remove this user from blacklist.'; } else { $response['error'] = 'Error occurs while processing ban request. Please try later.'; } } else { $response['error'] = 'You is banned by this user.'; } } } } } } echo json_encode($response); exit; }