Exemple #1
0
 /**
  * TuiyoModelFriends::removeFriend()
  * Removes a friend from your friend lists
  * @param mixed $profileID
  * @param mixed $userID
  * @return
  */
 public function removeFriend($profileID, $userID = NULL)
 {
     $tble = TuiyoLoader::table("friends");
     //user1 and user2
     $user1 = !empty($userID) ? (int) $userID : TuiyoAPI::get("user")->id;
     $user2 = !empty($profileID) ? (int) $profileID : JError::raiseError(500, _('Invalid Profile ID'));
     $user2P = TuiyoUser::getInstance($user2);
     if (($rel = $this->isFriendOf($user1, $user2)) !== FALSE) {
         if (!$rel->delete()) {
             JError::raiseError(500, $rel->getErrorMsg());
             return false;
         }
         return sprintf(_("%s has been removed from your friends list"), $user2P->name);
     }
     JError::raiseError(500, sprintf(_("There was a problem removing %s from your friends list"), $user2P->name));
 }
Exemple #2
0
 /**
  * TuiyoUser::getInstance()
  * 
  * Gets an instance of the user object
  * 
  * @param mixed $userid
  * @param bool $ifNotExist
  * @return
  */
 public function getInstance($userid = null, $ifNotExist = TRUE)
 {
     /** Creates new instance if none already exists ***/
     static $instance = array();
     if (isset($instance['uid:' . $userid]) && $ifNotExist && !empty($userid)) {
         if (is_object($instance['uid:' . $userid])) {
             return $instance['uid:' . $userid];
         } else {
             unset($instance['uid:' . $userid]);
             TuiyoUser::getInstance($userid, $ifNotExist);
         }
     } else {
         $object = new TuiyoUser($userid);
         if (!empty($userid)) {
             $instance['uid:' . $userid] = $object;
         }
     }
     return $object;
 }