Exemple #1
0
 /**
  * TuiyoTableMessages::getMessageList()
  * Get All the messages in the Table 
  * and group according to state
  * @param mixed $userID
  * @param mixed $state
  * @return array
  */
 public function getMessageList($userID, array $state)
 {
     $dbo = $this->_db;
     $query = "SELECT m.*, f.name as user_from_name, f.username as user_from_username," . "t.name as user_to_name, t.username as user_to_username, '' as user_from_avatar" . "\nFROM #__messages m" . "\nRIGHT JOIN #__users as f ON m.user_id_from=f.id" . "\nRIGHT JOIN #__users as t ON m.user_id_to=t.id" . "\nWHERE m.user_id_to=" . $dbo->Quote((int) $userID) . "\nOR m.user_id_from=" . $dbo->Quote((int) $userID);
     $dbo->setQuery($query);
     $rows = $dbo->loadObjectList();
     $list = array("inbox" => array(), "sent" => array(), "drafts" => array(), "trash" => array());
     //Sort The messages;
     foreach ((array) $rows as $message) {
         //How many words--crude!!;
         $message->word_count = count(explode(" ", trim($message->message)));
         $message->date_time = TuiyoTimer::diff(strtotime($message->date_time));
         $message->user_to_avatar = TuiyoUser::getUserAvatar($message->user_id_to, "thumb35");
         $message->user_from_avatar = TuiyoUser::getUserAvatar($message->user_id_from, "thumb35");
         $folder = $this->getMessageFolderFromCode($message->folder_id, $message->user_id_from);
         $list[$folder][] = $message;
         //If we sent the messsage, add to sent;
         //if($message->user_id_to <> (int)$userID ):
         //				//Draft
         //				if($message->message_id < 1 ):
         //					$list["drafts"][] = $message;
         //					continue;
         //				endif;
         //				//Trash Sender
         //				if($message->foder_id >= 60 ):
         //					$list["trash"][] = $message;
         //					continue;
         //				endif;
         //				//Sent
         //				$list["sent"][] = $message;
         //				continue;
         //			else:
         //				//Trash Recipient
         //				$sFid = (string)$message->folder_id ;
         //				if(intval($sFid[strlen($sFid)-1]) === 6):
         //					$list["trash"][] = $message;
         //					continue;
         //				endif;
         //				//If we are recieving the message
         //
         //				$list["inbox"][] = $message;
         //				continue;
         //			endif;
     }
     //print_R( $rows );
     return $list;
 }
Exemple #2
0
 /**
  * TuiyoModelFriends::getLists()
  * Returns a list of users related to profileID
  * @param 	mixed $profileID
  * @param 	string $type 2 for mutual friends 1 for pending, 0 for all friends
  * @param 	bool $extended include just username and names or include avatars
  * @return 	mixed array list
  */
 public function getFriendLists($profileID, $userID = NULL, $state = NULL, $genIDs = false)
 {
     $tble = TuiyoLoader::table("friends");
     $user = TuiyoAPI::get("user");
     $user1 = !empty($userID) ? (int) $userID : TuiyoAPI::get("user")->id;
     $user2 = !empty($profileID) ? (int) $profileID : $user1;
     $list = $tble->getUserFriends($user2, $state);
     $ids = array();
     //add Avatar object
     foreach ((array) $list as $friend) {
         if ($genIDs) {
             $ids[] = (int) $friend->userID;
             continue;
         }
         $friend->avatar =& TuiyoUser::getUserAvatar($friend->userID);
     }
     //if we need only IDS
     if ($genIDs) {
         return $ids;
     }
     return $list;
 }
Exemple #3
0
 /**
  * TuiyoTableGroups::getGroupMembers()
  * Gets all Members from widthing a group
  * @param mixed $groupID
  * @param integer $limitstart
  * @param mixed $limit
  * @return void
  */
 private function getGroupMembers($groupID, $creatorID, $limitstart = 0, $limit = NULL)
 {
     $dbo = $this->_db;
     $dbo->setQuery("SELECT m.* FROM #__tuiyo_groups_members AS m " . "\nWHERE m.groupID =" . $dbo->quote((int) $groupID), $limitstart, $limit);
     $rows = $dbo->loadObjectList();
     $members = array();
     //user
     $user = JFactory::getUser(NULL);
     // );
     $this->isMember = 0;
     $this->creator = NULL;
     foreach ((array) $rows as $member) {
         $mUser = TuiyoAPI::get("user", $member->userID);
         $member->data = array("userID" => $mUser->id, "avatar" => TuiyoUser::getUserAvatar($mUser->id), "username" => $mUser->username, "name" => $mUser->name, "email" => $mUser->email);
         $member->isAdmin = $mUser->id != $creatorID ? 0 : 1;
         //Indicators
         if ($creatorID === $mUser->id) {
             $this->creator = $member->data;
         }
         if ($mUser->id === $user->id) {
             $this->isMember = 1;
             $this->gMemberID = $member->memberID;
         }
         $members[] = $member;
         unset($mUser);
     }
     return $members;
 }
Exemple #4
0
 public function addVote()
 {
     // Check for request forgeries
     JRequest::checkToken("request") or jexit('Invalid Token');
     $auth = TuiyoAPI::get('authentication');
     //Must be loggedIN
     $auth->requireAuthentication('post');
     $user = TuiyoAPI::get('user');
     $storyID = JRequest::getInt("sid", NULL, "post");
     $storyVT = JRequest::getInt("svt", 1, "post");
     //+1 for Like -1 for dislike
     $userID = $user->id;
     $model =& $this->getModel("timeline");
     $view =& $this->getView("profile", "json");
     if (empty($storyID) || empty($storyVT)) {
         JError::raiseError(TUIYO_SERVER_ERROR, 'Invalid story ID or story Vote Type');
         return false;
     }
     if (!$model->storeVote($userID, $storyID, $storyVT)) {
         JError::raiseError(TUIYO_SERVER_ERROR, 'Could not save the vote');
         return false;
     }
     //After Add Timeline Vote
     $GLOBALS["events"]->trigger("onAddTimelineVote", $this);
     return $view->encode(array("code" => TUIYO_OK, "userID" => $user->id, "userPic" => TuiyoUser::getUserAvatar($user->id, "thumb35")));
 }
Exemple #5
0
 /**
  * TuiyoModelTimeline::getReplies()
  * Response should contatin
  * $object->datetime, $object->username
  * $object->id,  	  $object->userid
  * $object->bodytext, $object->source
  * $object->userpic,  $object->candelete (bool)
  * $object->cancomment,
  * @param mixed $storyID
  * @return void
  */
 public function getComments($storyID)
 {
     $user = TuiyoAPI::get("user", null);
     $table = TuiyoLoader::table("timeline");
     $comments = array();
     //1. Get the timelien data from DB
     $replies = $table->loadTimeline(null, null, (int) $storyID, null, 0, null);
     //2. Standardize
     foreach ($replies as $comment) {
         $comment->datetime = TuiyoTimer::diff(strtotime($comment->datetime));
         $comment->id = (int) $comment->id;
         $comment->bodytext = strval($comment->bodytext);
         //No HTML unless defined in template
         $comment->userpic = TuiyoUser::getUserAvatar($comment->userid, "thumb35");
         $comment->source = empty($comment->source) ? "web" : $comment->source;
         //Story Permissions
         $comment->candelete = (int) $comment->userid != (int) $user->id ? false : true;
         $comment->cancomment = !$user->joomla->get('guest') ? true : false;
         //Add to the stories array;
         $comments[] = $comment;
     }
     return (array) $comments;
 }
Exemple #6
0
 /**
  * TuiyoModelResources::getAllMembers()
  * Gets a lists of all members
  * @param mixed $filterOptions
  * @return void
  */
 public function getAllMembers($filterOptions = array())
 {
     $userAPI =& TuiyoAPI::get("user", null);
     $usersTable =& TuiyoLoader::table("users", true);
     $friendsModel =& TuiyoLoader::model("friends", true);
     $limit = $this->getState('limit');
     $limitstart = $this->getState('limitstart');
     $usersList =& $usersTable->getAllUsers(TRUE, FALSE, $limitstart, $limit);
     //1b. Paginate?
     jimport('joomla.html.pagination');
     $dbo = $usersTable->_db;
     $this->_total = $dbo->loadResult();
     $pageNav = new JPagination($this->_total, $limitstart, $limit);
     $this->pageNav = $pageNav->getPagesLinks();
     //Set the total count
     $this->setState('total', $this->_total);
     $this->setState('pagination', $this->pageNav);
     //Its important that this be called after pagination is processed!
     $myFriendsIds = (array) $friendsModel->generateIDs($userAPI->id);
     //add Avatar object
     foreach ((array) $usersList as $user) {
         $user->isUserFriend = !in_array($user->id, $myFriendsIds) && $user->id != $userAPI->id ? FALSE : TRUE;
         $user->avatar =& TuiyoUser::getUserAvatar($user->id);
     }
     return $usersList;
 }