예제 #1
0
 function manageFriends()
 {
     //init variable
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $db = JFactory::getDbo();
     $frnd_id = $app->input->post->get('friend_id', 0, 'INT');
     $choice = $app->input->post->get('choice', 0, 'INT');
     $userid = $log_user->id;
     $res = new stdClass();
     if (!$frnd_id) {
         return 'Friend id not found';
     }
     if ($choice) {
         $frnds_obj = new EasySocialModelFriends();
         $result = $frnds_obj->request($frnd_id, $userid);
         if ($result->id) {
             $res->frnd_id = $frnd_id;
             $res->code = 200;
             $res->message = 'Request send';
         } else {
             $res->code = 403;
             $res->message = $result;
         }
     } else {
         $user = FD::user($id);
         $user->approve();
         $res->result = EasySocialModelUsers::deleteFriends($frnd_id);
         if ($res->result == true) {
             $res->code = 200;
             $res->message = 'Freind deleted';
         } else {
             $res->code = 403;
             $res->message = 'Unable to delete friend';
         }
     }
     return $res;
 }
예제 #2
0
 function manageFriends()
 {
     //init variable
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $db = JFactory::getDbo();
     $frnd_id = $app->input->get('target_userid', 0, 'INT');
     $userid = $log_user->id;
     $res = new stdClass();
     if (!$frnd_id) {
         return 'Friend id not found';
     }
     $frnds_obj = new EasySocialModelFriends();
     $result = $frnds_obj->request($userid, $frnd_id);
     if ($result->id) {
         $res->status = 1;
         /*$res->frnd_id = $frnd_id;
         		$res->code = 200;
         		$res->message = 'Request send';*/
     } else {
         $res->status = 0;
         /*$res->code = 403;
         		$res->message = $result;*/
     }
     return $res;
 }
예제 #3
0
 function createSearchObj($data = null)
 {
     if ($data == null) {
         $ret_arr = new stdClass();
         $ret_arr->status = false;
         $ret_arr->message = "No user found in search";
         return $ret_arr;
     }
     $user = JFactory::getUser($this->plugin->get('user')->id);
     $frnd_mod = new EasySocialModelFriends();
     $list = array();
     foreach ($data as $k => $node) {
         if ($node->id != $user->id) {
             $node->mutual = $frnd_mod->getMutualFriendCount($user->id, $node->id);
             $node->isFriend = $frnd_mod->isFriends($user->id, $node->id);
             $node->approval_pending = $frnd_mod->isPendingFriends($user->id, $node->id);
             $list[] = $node;
         }
     }
     return $list;
 }
예제 #4
0
 function createSearchObj($data = null)
 {
     if ($data == null) {
         $ret_arr = new stdClass();
         $ret_arr->status = false;
         $ret_arr->message = "No user found in search";
         return $ret_arr;
     }
     $user = JFactory::getUser($this->plugin->get('user')->id);
     $frnd_mod = new EasySocialModelFriends();
     $list = array();
     $options['state'] = SOCIAL_FRIENDS_STATE_PENDING;
     $options['isRequest'] = true;
     $req = $frnd_mod->getFriends($user->id, $options);
     $myarr = array();
     if (!empty($req)) {
         foreach ($req as $ky => $row) {
             $myarr[] = $row->id;
         }
     }
     foreach ($data as $k => $node) {
         if ($node->id != $user->id) {
             $node->mutual = $frnd_mod->getMutualFriendCount($user->id, $node->id);
             $node->isFriend = $frnd_mod->isFriends($user->id, $node->id);
             $node->approval_pending = $frnd_mod->isPendingFriends($user->id, $node->id);
             if (in_array($node->id, $myarr)) {
                 $node->isinitiator = true;
             } else {
                 $node->isinitiator = false;
             }
             $list[] = $node;
         }
     }
     return $list;
 }
예제 #5
0
 public function get_friend_request($uid)
 {
     $object = new EasySocialModelFriends();
     $result = $object->getPendingRequests($uid);
     return $result;
 }