Example #1
0
 /**
  * TuiyoModelPhotos::getPhotos()
  * An array of all photos belonging to userID
  * @param mixed $userID
  * @param mixed $albumID
  * @param mixed $limit
  * @param mixed $published
  * @param bool $newFirst
  * @return
  */
 public function getPhotos($userID, $albumID = NULL, $published = NULL, $newFirst = TRUE, $uselimit = TRUE, $overiteLimit = NULL)
 {
     $limit = $uselimit ? $this->getState('limit') : NULL;
     $limit = !is_null($overiteLimit) ? (int) $overiteLimit : $limit;
     $limitstart = $this->getState('limitstart');
     //1. Get all Photos
     $photosTable = TuiyoLoader::table("photos", true);
     $photos = $photosTable->getAllPhotos($userID, $albumID, $limitstart, $published, $newFirst, $limit);
     //print_R( $photos );
     //1b. Paginate?
     jimport('joomla.html.pagination');
     $dbo = $photosTable->_db;
     $this->_total = $dbo->loadResult();
     $pageNav = new JPagination($this->_total, $limitstart, $limit);
     $root = JURI::root();
     $this->pageNav = $pageNav->getPagesLinks();
     //Set the total count
     $this->setState('total', $this->_total);
     $this->setState('pagination', $this->pageNav);
     //2. Check the existence of each photo!
     foreach ($photos as $photo) {
         $photo->date_added = TuiyoTimer::diff(strtotime($photo->date_added));
         $photo->last_modified = TuiyoTimer::diff(strtotime($photo->last_modified));
         $photo->src_original = $root . substr($photo->src_original, 1);
         $photo->src_thumb = $root . substr($photo->src_thumb, 1);
     }
     return (array) $photos;
 }
Example #2
0
 /**
  * TuiyoViewProfile::display()
  * @param mixed $tpl
  * @return void
  */
 public function homepage($tpl = null)
 {
     $model = TuiyoLoader::model("applications", true);
     $nModel = TuiyoLoader::model("notifications", true);
     $pModel = TuiyoLoader::model("profile", true);
     $document = $GLOBALS['API']->get("document");
     $user = $GLOBALS['API']->get('user', empty($profileID) ? null : (int) $profileID);
     //$document->enqueMessage( "This is a sample Message" , "notice" );
     $livestyle = TUIYO_LIVE_PATH . '/client/default/';
     $document->addCSS(TUIYO_LIVE_PATH . '/client/default/css/homepage.css');
     $document->addJS(TUIYO_LIVE_PATH . '/client/default/script/homepage.js');
     $document->addJS(TUIYO_STREAM);
     $document->addJS(TUIYO_OEMBED);
     //If guest profile?
     if ($user->joomla->get('guest')) {
         $redirect = JRoute::_(TUIYO_INDEX . "&view=welcome");
         $GLOBALS['mainframe']->redirect($redirect);
     }
     //Who has viewed my Profile
     $uPlugins = $model->getAllUserPlugins($user->id, "services", false);
     //Get the HTML
     $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl";
     $tmplVars = array("user" => $user, "styleDir" => $livestyle, "livePath" => TUIYO_LIVE_PATH, "lastVisted" => TuiyoTimer::diff(strtotime($user->joomla->lastvisitDate)), "countViews" => NULL, "lastUsed" => (array) $model->getRecentlyUsed($user->id, 8), "notices" => $nModel->getAllNotifications($user->id), "pages" => $nModel->getState('pagination'), "plugins" => $uPlugins, "visitors" => $pModel->getProfileRecentVisitors($user->id));
     //Get Timeline 2.0
     $plugins = $model->getAllSystemPlugins("services", false);
     $tplVars2 = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0);
     $activity = $document->parseTmpl("activity", $tmplPath, $tplVars2);
     $content = $document->parseTmpl("dashboard", $tmplPath, $tmplVars);
     $this->assignRef('activity', $activity);
     $this->assignRef('livestyle', $livestyle);
     $this->assignRef("content", $content);
     parent::setLayoutExt('tpl');
     parent::display($tpl);
 }
Example #3
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;
 }
Example #4
0
 /**
  * TuiyoControllerTimeline::addComment()
  * Adds a comment to an existing user Activity
  * @return void
  */
 public function addComment()
 {
     //
     $this->requireAuthentication("post");
     //1. Get Pre-requisites;
     $postData = JRequest::get("post");
     $server = JRequest::get("server");
     $userID = intval(JRequest::getVar("userID"));
     $method = strtolower($server['REQUEST_METHOD']);
     /** we are dealing with only post data***/
     if ($method !== 'post') {
         JError::raiseError(TUIYO_BAD_REQUEST, _("Invalid request. Method accepts only post data"));
     }
     $model =& $this->getModel("timeline");
     $view =& $this->getView("profile", "json");
     $document =& $GLOBALS['API']->get("document");
     $user =& $GLOBALS['API']->get("user");
     /** Check we have a valid token and Check we have a valid token***/
     if (empty($user->id) || $user->joomla->get('guest')) {
         JError::raiseError(TUIYO_BAD_REQUEST, _("Invalid user ID"));
     }
     //2. prepare a standard response Array
     $resp = array("code" => TUIYO_OK, "error" => null, "data" => null, "extra" => null);
     if ($document->getDOCTYPE() !== "json") {
         $resp["code"] = TUIYO_BAD_REQUEST;
         $resp["error"] = _("Invalid Request format. JSON only");
         //dump
         $view->encode($resp);
         return false;
     }
     //3. Model and store status
     $tData = $model->setStatusComment($user->id, $postData);
     $GLOBALS["events"]->trigger("onAddTimelineComment", $this);
     $resp["data"] = array("status" => $tData->data, "statusID" => $tData->ID, "source" => $tData->source, "username" => $user->username, "time" => TuiyoTimer::diff(strtotime($tData->datetime)));
     //5. Return results
     $view->encode($resp);
 }
Example #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;
 }
Example #6
0
 /**
  * TuiyoHelperSearch::searchProfiles()
  * @param mixed $text
  * @param string $phrase
  * @param string $ordering
  * @return void
  */
 public function searchProfiles($text, $phrase = '', $ordering = '')
 {
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $wheres = array();
     switch ($phrase) {
         case 'exact':
             $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
             $wheres2 = array();
             $wheres2[] = "u.username LIKE " . $text;
             $wheres2[] = "u.name LIKE " . $text;
             $wheres2[] = "u.email LIKE " . $text;
             $where = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = "u.username LIKE " . $word;
                 $wheres2[] = "u.name LIKE " . $word;
                 $wheres2[] = "u.email LIKE " . $word;
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     $morder = '';
     switch ($ordering) {
         case 'alpha':
         case 'newest':
         default:
             $order = 'u.name ASC';
             break;
     }
     $newArray = array();
     $query = "SELECT u.id, u.name, u.username, u.registerDate, u.lastvisitDate, u.usertype, " . "\nCONCAT(u.name, u.username) AS title" . "\nFROM #__users u" . "\nWHERE (" . $where . ")" . "\nAND u.block = " . $db->Quote((int) 0) . "\nGROUP BY u.id" . "\nORDER BY " . $order;
     $db->setQuery($query);
     $rows = $db->loadAssocList();
     if (!sizeof((array) $rows) > 0) {
         return array();
     }
     foreach ($rows as $row) {
         $rowObject = new stdClass();
         $rowObject->href = JRoute::_('index.php?option=com_tuiyo&view=profile&do=view&pid=' . $row["id"]);
         $rowObject->title = ucfirst($row["name"] . " ( " . $row["username"] . " ) ");
         $rowObject->section = "Profile";
         $rowObject->created = $row["lastvisitDate"];
         $rowObject->text = $row["name"] . " is a " . $row["usertype"] . " user, registered with the username @{$row['username']}" . TuiyoTimer::diff(strtotime($row["registerDate"])) . " and last seen here " . TuiyoTimer::diff(strtotime($row["lastvisitDate"]));
         $rowObject->browsernav = 2;
         $newArray[] = $rowObject;
     }
     return $newArray;
 }