/** * TuiyoViewPhotos::display() * Displays the photos page ; * @param mixed $tpl * @return void */ function display($tpl = null) { global $mainframe, $API; $doc =& $API->get("document"); $bc =& $mainframe->getPathway(); $user =& $API->get("user", null); $pt =& $mainframe->setPageTitle(_("Photos gallery")); $plugModel =& TuiyoLoader::model('applications', true); $bc->addItem($user->name); $doc->addCSS(TUIYO_LIVE_PATH . '/client/default/css/photospage.css'); $doc->addJS(TUIYO_LIVE_PATH . '/client/default/script/photospage.js'); $doc->addJS(TUIYO_JS . '/includes/jqueryui/effects.core.js'); $doc->addJS(TUIYO_JS . '/includes/jqueryui/ui.core.js'); $doc->addJS(TUIYO_JS . '/includes/jqueryui/ui.draggable.js'); $doc->addJS(TUIYO_JS . '/includes/jqueryui/ui.droppable.js'); $doc->addJS(TUIYO_JS . '/includes/jqueryui/effects.slide.js'); // $doc->addJS( TUIYO_CAROUSEL ); $livestyle = TUIYO_LIVE_PATH . '/client/default/'; $doc->addJS(TUIYO_OEMBED); $doc->addJS(TUIYO_STREAM); $plugins = $plugModel->getAllSystemPlugins("services", false); $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplPath2 = TUIYO_VIEWS . DS . "photos" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0); $activity = $doc->parseTmpl("activity", $tmplPath, $tmplVars); $commenter = $doc->parseTmpl("comments", $tmplPath2, $tmplVars); $this->assignRef("user", $user); $this->assignRef('activity', $activity); $this->assignRef("commenter", $commenter); $this->assignRef('livestyle', $livestyle); parent::display($tpl); }
/** * TuiyoViewTuiyo::display() * Default welcome page for admin view * @param mixed $tpl * @return */ public function display($tpl = null) { $TMPL = $GLOBALS['API']->get('document'); $USER = $GLOBALS['API']->get('user', null); $DOCU = JFactory::getDocument(); $MODEL = TuiyoLoader::model('applications', true); $APPS = $MODEL->getApplicationExtendedList(); $DOCU->addStyleSheet('components/com_tuiyo/style/css/common.css'); $DOCU->addScript('components/com_tuiyo/style/script/global.js'); $DOCU->addScript(TUIYO_OEMBED); $DOCU->addScript(TUIYO_STREAM); $version = TuiyoLoader::helper("version"); $document = $GLOBALS['API']->get("document"); if (!is_a($version, 'TuiyoVersion')) { $version =& new TuiyoVersion(); } $longVersion = $version->getLongVersion(); $plugins = $MODEL->getAllSystemPlugins("services", false); $tmplPath2 = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars2 = array("styleDir" => TUIYO_STYLEDIR, "user" => $USER, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => 0); $activity = $TMPL->parseTmpl("activity", $tmplPath2, $tmplVars2); $tmplVars = array("apps" => $APPS, "activity" => $activity, "styleDir" => $livestyle, "livePath" => TUIYO_LIVE_PATH, "iconPath" => TUIYO_LIVE_PATH . '/client/default/'); $tmplVars["version"] = $longVersion; $tmplPath = JPATH_COMPONENT_ADMINISTRATOR . DS . "views" . DS . "tuiyo" . DS . "tmpl"; $tplData = !is_null($tpl) ? $tpl : $TMPL->parseTmpl("default", $tmplPath, $tmplVars); $tmplVars["adminPage"] = $tplData; $content = $TMPL->parseTmpl("admin", $tmplPath, $tmplVars); echo $content; }
public function test() { $aModel = TuiyoLoader::model("applications", true); $aUser = TuiyoAPI::get("user", null); $aDocument = TuiyoAPI::get("document", null); $aParams = $aModel->getSingleUserPlugin($aUser->id, "twitter"); if (!is_object($aParams)) { $aDocument->enqueMessage(_("Cannot Load the service for this user"), "error"); return false; } echo $aParams->get("oauth_verifier"); /* Build TwitterOAuth object with client credentials. */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); $view =& $this->getView("twitter", "html"); /* Get temporary credentials. */ $access_token = $connection->getAccessToken($aParams->get('oauth_verifier', false)); /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); /* If method is set change API call made. Test is called by default. */ $content = $connection->get('account/verify_credentials'); //print_R($content); $user = $connection->get('account/verify_credentials'); $userPublicFeeds = $connection->get('statuses/public_timeline'); print_R($userPublicFeeds); }
/** * TuiyoViewGroups::display() * @param mixed $tmplData * @return void */ public function display($tmplData) { //Intro $doc = $GLOBALS['API']->get("document"); $user = $GLOBALS['API']->get("user", null); $bc = $GLOBALS['mainframe']->getPathway(); $pt = $GLOBALS['mainframe']->setPageTitle(_("Community groups")); $styleDir = TUIYO_LIVE_PATH . '/client/default/'; $bc->addItem($user->name); $doc->addCSS(TUIYO_LIVE_PATH . '/client/default/css/groupspage.css'); $doc->addJS(TUIYO_LIVE_PATH . '/client/default/script/groupspage.js'); $doc->addJS(TUIYO_STREAM); $doc->addJS(TUIYO_OEMBED); $pModel = TuiyoLoader::model("applications", true); $plugins = $pModel->getAllSystemPlugins("services", false); $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0); $activity = $doc->parseTmpl("activity", $tmplPath, $tmplVars); $this->assignRef("activity", $activity); $this->assignRef('livestyle', $styleDir); $this->assignRef('user', $user); $this->assignRef('data', $tmplData); $this->setLayoutExt('tpl'); //Output parent::display($tpl); }
public function readArticle($articleID, $tpl = null) { $document = $GLOBALS['API']->get("document", null); $user = $GLOBALS['API']->get('user', null); $model = TuiyoLoader::model("articles", true); //styles //$document->addCSS(TUIYO_STYLEDIR.'/css/articles.css'); $document->addJS(TUIYO_STYLEDIR . '/script/articles.js'); $document->addJS(TUIYO_STREAM); $document->addJS(TUIYO_OEMBED); $pModel = TuiyoLoader::model("applications", true); $plugins = $pModel->getAllSystemPlugins("services", false); $styleDir = TUIYO_LIVE_PATH . '/client/default/'; $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0); $activity = $document->parseTmpl("activity", $tmplPath, $tmplVars); $myarticles = $model->getArticlesStream($user->id); $allarticles = $model->getArticlesStream(); $article = $model->getArticle($articleID, $user->id); $this->assignRef("article", $article); $GLOBALS['mainframe']->getPathway()->addItem(_("Articles")); $GLOBALS['mainframe']->setPageTitle($article['story']->posttitle); $this->assignRef("activity", $activity); $this->setLayout("read"); $this->setLayoutExt("tpl"); $canpost = !$user->joomla->get('guest') ? 1 : 0; $categories = $model->getArticlesCategories(); $this->assignRef('livestyle', $styleDir); $this->assignRef("categories", $categories); $this->assignRef("user", $user); $this->assignRef("canpost", $canpost); parent::display($tpl); }
public function display() { $aModel = TuiyoLoader::model("applications", true); $aUser = TuiyoAPI::get("user", null); $aDocument = TuiyoAPI::get("document", null); //Get the parameters of a single user application/service $aParams = $aModel->getSingleUserPlugin($aUser->id, "feed"); //get the feedURl //$aParams->get("feedURL", null); $view = $this->getView("feed", "html"); return $view->display(); }
/** * TuiyoViewGroups::display() * Displays a user Feed * @return void */ public function showFeed() { global $mainframe, $API; static $rendered = false; if ($rendered) { return true; } $groupID = JRequest::getInt('gid'); $auth = $API->get("authentication"); $auth->requireAuthentication(); $tUser = TuiyoAPI::get('user', null); $gModel = TuiyoLoader::model("groups", true); $tModel = TuiyoLoader::model("timeline", true); $gData = $gModel->getGroup($groupID); if (empty($groupID) || !$gData || $gData->isMember < 1) { JError::raiseError(TUIYO_NOT_FOUND, _('The group feed either does not exists or you do not have the necessary permissions')); return false; } $tData = $tModel->getGroupTimeline($gData->groupID, $tUser->id); $document =& JFactory::getDocument(); $params =& $mainframe->getParams(); $feedEmail = @$mainframe->getCfg('feed_email') ? $mainframe->getCfg('feed_email') : 'author'; $siteEmail = $mainframe->getCfg('mailfrom'); $document->title = $gData->gName; $document->description = sprintf(_("Updates from %s / group"), $gData->gName); $document->link = JRoute::_(TUIYO_INDEX . '&view=groups&do=getFeed&format=feed&gid=' . $gData->{$groupID}); foreach ($tData as $stream) { // load individual item creator class $item = new JFeedItem(); // strip html from feed item title $title = $this->escape("@{$stream->username} {$stream->datetime}: {$stream->title} {$stream->bodytext} "); $title = html_entity_decode($title); // url link to article $link = JRoute::_(TUIYO_INDEX . '&view=profile&do=viewStatus&user='******'feed'); //$this->setLayoutExt('tpl'); $rendered = true; }
public function addNewCategory() { $model = TuiyoLoader::model("categories", true); $data = JRequest::get("post"); $referer = JRequest::getVar("HTTP_REFERER", null, "SERVER"); //Referer //Notice messages; $msg = "Category data saved successfully"; $mType = "notice"; if (!$model->addCategory($data)) { $msg = "Could not save category data"; $mType = "error"; } $this->setRedirect($referer, $msg, $mType); $this->redirect(); }
/** * @param mixed $data * @return */ function showChatBox($tpl = null) { $document = TuiyoAPI::get('document', null); $user = TuiyoAPI::get('user', null); $plugModel = TuiyoLoader::model("applications", true); //$this->setLayout("chatroom"); //echo "show chat box"; die; //parent::display($tpl); $document->addJS(TUIYO_OEMBED); $document->addJS(TUIYO_STREAM); $plugins = $plugModel->getAllSystemPlugins("services", false); $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0); $activity = $document->parseTmpl("activity", $tmplPath, $tmplVars); $this->assignRef("activity", $activity); parent::display($tpl); }
public function saveArticle() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $auth = TuiyoAPI::get("authentication"); $auth->requireAuthentication(); $user = TuiyoAPI::get("user"); $data = JRequest::get("post", JREQUEST_ALLOWRAW); $aModel = TuiyoLoader::model("articles", true); $msg = _('The article has been saved successfully'); if (!$aModel->editSaveArticle($user, $data)) { $msg = $aModel->getError(); } //Redirect on success; $referer = JRoute::_(TUIYO_INDEX . '&view=articles'); $this->setRedirect($referer, $msg); }
/** * Overits the parent function * Default display for views control * @see JView::display() */ public function display($tpl = null) { $document = $GLOBALS['API']->get('document', null); $user = $GLOBALS['API']->get('user', null); $GLOBALS['mainframe']->getPathway()->addItem(_("Discussions Boards")); $GLOBALS['mainframe']->setPageTitle(_("Discussion Boards")); //styles $document->addCSS(TUIYO_STYLEDIR . '/css/discussions.css'); $document->addJS(TUIYO_STYLEDIR . '/script/discussions.js'); $document->addJS(TUIYO_STREAM); $document->addJS(TUIYO_OEMBED); $pModel = TuiyoLoader::model("applications", true); $plugins = $pModel->getAllSystemPlugins("services", false); $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0); $activity = $document->parseTmpl("activity", $tmplPath, $tmplVars); $this->assignRef("activity", $activity); parent::display($tpl); }
public function chatBox() { //1. Get Pre-requisites; $participant = JRequest::getVar("participant", null); $server = JRequest::get("server"); $method = strtolower($server['REQUEST_METHOD']); $model =& TuiyoLoader::model("messages", true); $view = $this->getView("system", "html"); $document =& $GLOBALS['API']->get("document"); $user =& $GLOBALS['API']->get("user", null); /** 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")); } $chatRoom = array(); //$model->initiateChatRoom( $user->id, $participant ); $view->assignRef("user", $user); $view->assignRef("chatroom", $chatRoom); $view->showChatBox(); }
public function onAfterTimelineLoad($args = null) { $aModel = TuiyoLoader::model("applications", true); $aUser = TuiyoAPI::get("user", null); $aDocument = TuiyoAPI::get("document", null); $aXMLParser = new JSimpleXML(); //Get the parameters of a single user application/service $aParams = $aModel->getSingleUserPlugin($aUser->id, "feed"); //get the feedURl $feedURL = $aParams->get("feedURL", null); //$feedData = TuiyoAPI::getURL( $feedURL ); //$tempfilename = TUIYO_CACHE.DS.date("YmdHis")."feed.xml"; //$tempFeed = fopen($tempfilename, 'w') ; //fwrite($tempFeed , trim($feedData)); //fclose($tempFeed); //echo $tempfilename; //$feedXML = @$aXMLParser->loadFile($tempfilename); //unlink($tempfilename); //print_R($aXMLParser); }
/** * TuiyoViewWelcome::display() * * @param mixed $tpl * @return void */ public function display($tpl = null) { global $mainframe; $docu = $GLOBALS['API']->get('document', null); $bc =& $mainframe->getPathway(); $rModel = TuiyoLoader::model("resources", true); $plugModel = TuiyoLoader::model("applications", true); $gModel = TuiyoLoader::model("groups", true); $aModel = TuiyoLoader::model("articles", true); $docu->addCSS(TUIYO_LIVE_PATH . '/client/default/css/welcomepage.css'); $docu->addJS(TUIYO_LIVE_PATH . '/client/default/script/welcomepage.js'); $docu->addJS(TUIYO_OEMBED); $docu->addJS(TUIYO_STREAM); $bc->addItem(_('Welcome Lobby'), TUIYO_INDEX . '&view=welcome'); $tdoc = $docu; $user = TuiyoAPI::get("user"); $onlineMembers = $rModel->getOnlineUsers(); $newestMembers = $rModel->getNewestUsers(); $popularGroups = $gModel->getPopularGroups(); $allarticles = $aModel->getArticlesStream(); //@TODO replace with getAllSystemPlugins $plugins = $plugModel->getAllSystemPlugins("services", false); $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user, "sharewith" => array("p00" => "@everyone"), "plugins" => $plugins, "canPost" => !$user->joomla->get('guest') ? 1 : 0); $activity = $tdoc->parseTmpl("activity", $tmplPath, $tmplVars); //Check for the existence of a gravatar TuiyoLoader::helper("parameter"); $sysCfg = TuiyoParameter::load("global"); $this->assignRef("settings", $sysCfg); $this->assignRef("allarticles", $allarticles); $this->assignRef("activity", $activity); $this->assignRef("onlinefriends", $onlineMembers); $this->assignRef("newestmembers", $newestMembers); $this->assignRef("populargroups", $popularGroups); parent::display($tpl); }
public function registerPlugins() { $plugins = TuiyoLoader::model("applications", true); $services = $plugins->getAllSystemPlugins(); $services[] = "system"; //@TODO Crazy way to add the system plugin; $groups = array("timeline" => array(), "profile" => array(), "messages" => array(), "administrator" => array()); foreach ($services as $service) { $timeline = TUIYO_PLUGINS . DS . $service . DS . "events.timeline.php"; $profile = TUIYO_PLUGINS . DS . $service . DS . "events.profile.php"; $messages = TUIYO_PLUGINS . DS . $service . DS . "events.messages.php"; $administrator = TUIYO_PLUGINS . DS . $service . DS . "events.administrator.php"; $authentication = TUIYO_PLUGINS . DS . $service . DS . "events.authentication.php"; //Plugins if (file_exists($timeline)) { $groups["timeline"][$service] = $timeline; } //Profile if (file_exists($profile)) { $groups["profile"][$service] = $profile; } //Administrator if (file_exists($administrator)) { $groups["administrator"][$service] = $administrator; } } $session = JSession::getInstance('none', array()); $session->set("PLUGIN_GROUPS", $groups); $GLOBALS['PLUGIN_GROUPS'] = $groups; }
/** * TuiyoModelGroups::getCategories() * @param bool $published * @return */ public function getCategories($published = TRUE, $sort = TRUE) { $MODEL = TuiyoLoader::model("categories", true); $catAssoc = $MODEL->getCategories(); return $catAssoc; }
/** * TuiyoPrivacy::isFriendTo() * Verifies that $userID is friends with $profileID * @param mixed $profileID * @param mixed $userID * @return boolean */ private function isFriendOf($profileID, $userID = NULL) { $model =& TuiyoLoader::model("friends", true); $user =& TuiyoAPI::get("user", $userID); if (empty($profileID) && $user->joomla->get('guest')) { return false; } $profileID = !empty($profileID) ? (int) $profileID : JError::raiseError(404, _("Profile does not exists")); $userID = !empty($userID) ? (int) $userID : $user->id; if (($rel = $model->isFriendOf($profileID, $userID)) !== FALSE) { if ((int) $rel->state < 1 && $rel->thisUserID != $userID) { return false; } return true; } //Are not friends return false; }
/** * TuiyoModelTimeline::setStatus() * Sets a status for the specified userID * @param mixed $userID * @param mixed $postData * @param mixed $options * @return void */ public function setStatus($userID, $postData, $type = "status", $options = array()) { $table =& TuiyoLoader::table("timeline"); $appTable =& TuiyoLoader::table("applications"); $tTemplate =& TuiyoLoader::table("timelinetmpl"); $tNotify =& TuiyoLoader::library("mail.notify"); $table->load(null); //print_R($postData); $statusText = strval($postData['ptext']); $source = strval($postData['source']); $app = (array) $appTable->getSingleApplication($source); $template = isset($postData['template']) ? (int) $postData['template'] : null; $sharewith = $postData["sharewith"]; $publicity = array(); $isPublic = 0; $embedable = $postData["embedable"]; if (is_array($embedable) && isset($embedable['title']) && !empty($embedable["thumb"])) { //First Save the template $tTemplate->load(null); $tTemplate->appName = strval($source); $tTemplate->identifier = $tTemplate->appName; $tTemplate->title = $embedable['title']; $tTemplate->body = '<i class="embedDescr">' . $embedable['description'] . "</i>"; $tTemplate->type = 1; $resources = array(array("type" => "embedable", "url" => $embedable["thumb"])); $tTemplate->resources = json_encode($resources); $tTemplate->thisUserID = $userID; if (!$tTemplate->store()) { trigger_error($tTemplate->getError(), E_USER_ERROR); return false; } $template = $tTemplate->ID; $type = "activity"; } if (is_array($sharewith)) { foreach ($sharewith as $share) { if (!empty($share)) { $isPublic = strval($share) == "p00" ? 1 : 0; $publicity[] = "%" . trim($share) . "%"; } } $table->sharewith = json_encode($publicity); } //get out all mentions in the update string preg_match_all('#@([\\d\\w]+)#', $statusText, $mentions); preg_match_all('/#([\\d\\w]+)/', $statusText, $hashTags); $table->tags = sizeof($hashTags[1]) > 0 ? json_encode($hashTags[1]) : null; $table->mentions = sizeof($mentions[1]) > 0 ? json_encode($mentions[1]) : null; $table->userID = (int) $userID; $table->template = $template; $table->datetime = date('Y-m-d H:i:s'); $table->data = $statusText; $table->type = $type; $table->appID = is_array($app) && !empty($app) ? $app[0]["extID"] : null; $table->source = isset($source) ? $source : "web"; $table->inreplyto = 0; if (!$table->store()) { trigger_error($table->getError(), E_USER_ERROR); return false; } $table->isPublic = $isPublic; //NOTIFY ALL SHAREWITH USERS // NOT GROUPS $poster = TuiyoAPI::get("user", (int) $table->userID); $participants = array(); $groups = array(); foreach ((array) $sharewith as $key => $el) { if (strpos($el, "p") !== false) { $participants[] = str_replace(array("p", "%"), array("", ""), (string) $el); } elseif (strpos($el, "g") !== false) { $groups[] = str_replace(array("g", "%"), array("", ""), (string) $el); } } foreach ($participants as $notify) { if ((int) $notify > 0 && (int) $notify != $userID) { $userTo = TuiyoAPI::get("user", $notify); $actionLink = JRoute::_(TUIYO_INDEX . "&view=profile&do=viewStatus&user={$userTo->username}&id={$table->ID}"); $emailTitle = sprintf(_("%s shared something on your wall"), "@" . $poster->username); $emailBody = ""; //str_replace( $tSearch , $tVars , $notifyParams->get( "connectionRequestEmailBody" , null ) ); //echo $notifyEmail ; TuiyoNotify::_($userTo->id, $emailTitle, $actionLink, _("View Post")); } } //Load the group MOdel; $gModel =& TuiyoLoader::model("groups", true); foreach ($groups as $group) { $groupData = $gModel->getGroup((int) $group); foreach ((array) $groupData->members as $notify) { if ((int) $notify->data["userID"] > 0 && (int) $notify->data["userID"] != $userID) { $userTo = TuiyoAPI::get("user", $notify->data["userID"]); $actionLink = JRoute::_(TUIYO_INDEX . "&view=groups&do=view&gid={$groupData->groupID}"); $emailTitle = sprintf(_("%s posted something to the '%2s' group"), "@" . $poster->username, $groupData->gName); $emailBody = ""; //str_replace( $tSearch , $tVars , $notifyParams->get( "connectionRequestEmailBody" , null ) ); //echo $notifyEmail ; TuiyoNotify::_($userTo->id, $emailTitle, $actionLink, _("View Group")); } } } return $table; }
/** * 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; }
/** * TuiyoModelWidgets::getAllWidgets() * Gets all available widgets on this system * @return */ public function getAllWidgets() { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $user = TuiyoAPI::get("user", null); $appModel = TuiyoLoader::model("applications", true); $sysPlugins = $appModel->getAllUserPlugins($user->id, "services", false); $widgetData = array(); $widgetFiles = array(); foreach ($sysPlugins as $plugin) { //If the plugin has a widget file; $widgetFile = TUIYO_PLUGINS . DS . $plugin . DS . 'widget.xml'; if (file_exists($widgetFile)) { $widgetFiles[] = $widgetFile; } } foreach ($widgetFiles as $xmlFile) { $wdg = array(); $xml = TuiyoAPI::get("xml", $xmlFile); $root = $xml->file->document; $wdg["version"] = $root->attributes("version"); $wdg["file"] = JURI::root() . str_replace(array(DS), array("/"), $xmlFile); $wdg["file"] = str_replace(JPATH_ROOT, "", $wdg["file"]); foreach ((array) $root->widgetdata[0]->children() as $data) { $dataName = $data->attributes("name"); $dataValue = $data->attributes("content"); if (empty($dataName) || is_array($dataName)) { continue; } if (empty($dataValue) || is_array($dataValue)) { continue; } $wdg[$dataName] = $dataValue; } $widgetData[] = $wdg; } return (array) $widgetData; }
/** * TuiyoLoader::model() * Loads a model from the public models * @param mixed $fileName * @param bool $createInstance * @param mixed $parmaeters * @return */ public function model($fileName, $createInstance = false, $parmaeters = null) { TuiyoLoader::import($fileName, 'model'); if ($createInstance) { $modelClass = ucfirst(TUIYO_LIB) . 'Model' . ucfirst(self::$_loaded[$fileName]); if (in_array($modelClass, self::$_stored["models"])) { $object = self::$_stored["models"][$modelClass]; if (is_object($object)) { return $object; } else { unset(self::$_stored["models"][$modelClass]); TuiyoLoader::model($fileName, $createInstance, $parmaeters); } } $model = new $modelClass($parmaeters); self::$_stored["models"][$modelClass] =& $model; return $model; } }
/** * TuiyoControllerApps::getUserParams() * Gets the Parameters for the current application * @param mixed $userID * @return parameter object; */ public function getUserParams($userID = null) { static $static = array(); if (isset($static[$appName])) { return $static[$appName]; } //Require $tble = TuiyoLoader::table("userapps"); $model = TuiyoLoader::model("applications", true); }
public function getArticlesCategories() { $model = TuiyoLoader::model("categories", true); $categories = $model->getCategories(); return $categories; }
/** * TuiyoControllerSystemTools::getSocialForm() * Method to get the social form * @return */ public function getSocialForm() { $auth = TuiyoAPI::get("authentication"); $postData = JRequest::get("post"); $model = TuiyoLoader::model("profile", true); $view = $this->getView("tuiyo", "json"); //Require authentication; $auth->requireAuthentication(); $resp = array("code" => TUIYO_OK, "error" => false, "data" => $model->buildSocialBookForm(false), "extra" => false); //Return response; return $view->encode($resp); }
/** * TuiyoViewProfile::display() * Displays the default profile page * @param mixed $tpl * @param mixed $profileID * @param mixed $privacy * @return void */ public function display($tpl = null, $profileID = NULL, $privacy = NULL) { $tdoc = TuiyoAPI::get("document"); $params = TuiyoApi::get("params"); $model = TuiyoLoader::model("applications", true); $gModel = TuiyoLoader::model("groups", true); $pModel = TuiyoLoader::model("photos", true); $sModel = TuiyoLoader::model("statistics", true); $tModel = TuiyoLoader::model("timeline", true); $bc = $GLOBALS['mainframe']->getPathway(); $GLOBALS['mainframe']->setPageTitle(sprintf(_("%s | Profile"), $this->thatuser->name)); $bc->addItem($this->thatuser->name); $livestyle = TUIYO_LIVE_PATH . '/client/default/'; $tPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl" . DS; $tFile = "information"; $socialApps = $model->getAllUserApplications((int) $this->thatuser->id); $tInfoVars = array("user" => $this->thatuser, "contact" => $this->thatuser->getUserContact(), "social" => $this->thatuser->getUserSocialBook(), "privacy" => $this->privacy, "rating" => $this->thatuser->getUserRating(), "styleDir" => $livestyle); $information = $tdoc->parseTmpl($tFile, $tPath, $tInfoVars); $groups = $gModel->getUserGroups($this->thatuser->id); $albums = $pModel->getAlbums($this->thatuser->id, "profile", NULL, TRUE, TRUE); $statistics = $sModel->getUserStatistics($this->thatuser->id); $laststatus = $tModel->getLastestUserStatus($this->thatuser->id, $this->thisuser->id); //Get the HTML $sharingWith = array("p00" => "@everyone"); if ($this->thatuser->id != $this->thisuser->id) { $sharingWith = array("p" . $this->thatuser->id => $this->thatuser->name . " (" . $this->thatuser->username . ")"); } $plugins = $model->getAllUserPlugins($this->thatsuser->id, "services", false); $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $this->thisuser, "sharewith" => $sharingWith, "plugins" => $plugins, "canPost" => !$this->thisuser->joomla->get('guest') ? 1 : 0); $activity = $tdoc->parseTmpl("activity", $tmplPath, $tmplVars); $tdoc->addCSS(TUIYO_LIVE_PATH . '/client/default/css/profilepage.css'); $tdoc->addJS(TUIYO_JS . '/includes/jqueryui/effects.core.js'); $tdoc->addJS(TUIYO_JS . '/includes/jqueryui/effects.slide.js'); $tdoc->addJS(TUIYO_JS . '/includes/jqueryui/ui.core.js'); $tdoc->addJS(TUIYO_JS . '/includes/jqueryui/ui.stars.min.js'); $tdoc->addJS(TUIYO_LIVE_PATH . '/client/default/script/profile.js'); $tdoc->addJS(TUIYO_OEMBED); $tdoc->addJS(TUIYO_STREAM); $this->assignRef("rating", $tInfoVars["rating"]); $this->assignRef('information', $information); $this->assignRef('rawinformation', $tInfoVars); $this->assignRef('laststatus', $laststatus); $this->assignRef('externalapps', $socialApps); $this->assignRef('livestyle', $livestyle); $this->assignRef("activity", $activity); $this->assignRef("groups", $groups); $this->assignRef("photoalbums", $albums); $this->assignRef("statistics", $statistics); $this->setLayoutExt('tpl'); parent::display($tpl); $rssLink = JRoute::_(TUIYO_INDEX . '&view=profile&do=getFeed&format=feed&pid=' . $this->thatuser->id); $attribs = JArrayHelper::toString(array("type" => "application/rss+xml", "rel" => "alternate", "title" => "RSS 2.0 {$this->thatuser->name} updates", "href" => $rssLink)); $generatedTag = '<link ' . $attribs . ' />'; //Trigger after profileDraw Events $GLOBALS["mainframe"]->addCustomHeadTag($generatedTag); $GLOBALS["events"]->trigger("onAfterProfileDraw"); }
/** * TuiyoControllerProfile::myFiles() * @return void */ public function filemanager() { $auth = $GLOBALS['API']->get('authentication'); $auth->requireAuthentication("request"); $user = $GLOBALS['API']->get('user'); $document = $GLOBALS['API']->get("document"); $view = $this->getView('profile', "html"); $resources = TuiyoLoader::model("resources", true); //Get the HTML $tmplPath = TUIYO_VIEWS . DS . "profile" . DS . "tmpl"; $tmplVars = array("styleDir" => TUIYO_STYLEDIR, "user" => $user); $myfiles = $resources->getMyResources($user->id); $view->assignRef("myfiles", $myfiles); $view->assignRef("user", $user); $view->filemanager(); }
/** * TuiyoControllerExtensions::editApplication() * Edits an application * @return void */ public function editApplication() { $adminView =& $this->getView("tuiyo", "html"); $extView =& $this->getView("extensions", "html"); $extModel =& $this->getModel("extensions"); $appModel =& TuiyoLoader::model("applications", true); $aName = JRequest::getVar('a', null); $childDo = Jrequest::getVar('childDo', null); $aName = !empty($aName) ? strval(strtolower($aName)) : JError::raiseError(TUIYO_SERVER_ERROR, 'unspecified application'); $pData = array("params" => "", "data" => $appModel->getSingleApplication($aName)); $pageView = $extView->appEditpage($pData); $adminView->display($pageView); $this->docu->addScript("components/com_tuiyo/style/script/applications.js"); }
/** * TuiyoActivity::publishOneLineStory() * Application source * @param mixed $thisUser * @param mixed $storyLine * @param object $thatUser * @param mixed $tmplVars * @return void */ public function publishOneLineStory($thisUser, $storyLine, $source, $thatUser = NULL, $tmplID = NULL, $tmplVars = array(), $type = "activity") { $mTimeline =& TuiyoLoader::model("timeline", true); $tTemplate =& TuiyoLoader::table("timelinetmpl", true); //Whose activity? if (!is_object($thisUser) || empty($thisUser)) { $thisUser = TuiyoAPI::get("user", null); } //ThatUser must be an object; if (!is_null($thatUser) && !is_object($thatUser)) { JError::raiseError(_("ThatUser Must be an object")); return false; } //ThatUser $thatUser = (object) $thatUser; if (empty($tmplID)) { //First Save the template $tTemplate->load(null); $tTemplate->appName = strval($source); $tTemplate->identifier = $tTemplate->appName; $tTemplate->title = $storyLine; $tTemplate->type = 0; $tTemplate->resources = null; $tTemplate->body = null; $tTemplate->variables = json_encode((array) $tmplVars); $tTemplate->thisUserID = $thisUser->id; $tTemplate->thatUserID = $thatUser->id; if (!$tTemplate->store()) { trigger_error($tTemplate->getError(), E_USER_ERROR); return false; } $tmplID = $tTemplate->ID; } //Then save a parsed story in the timeline. $activity = array("ptext" => $storyLine, "source" => strval($source), "template" => $tmplID, "sharewith" => array("p00")); if (($story = $mTimeline->setStatus($thisUser->id, $activity, $type)) === FALSE) { JError::raiseError(_("Tuiyo could not save the activity")); return false; } //Compete return array("code" => TUIYO_OK, "error" => null, "tmpl" => $tmplID, "story" => $story); }
/** * TuiyoTableResources::saveGroupAvatar() * Saves a group Avatar; * @param mixed $fileData * @return */ public function saveGroupAvatar($fileData) { $user = $GLOBALS["API"]->get("user", null); $groupID = JRequest::getInt("groupID", null); //Must have a groupID if (!isset($groupID) || $groupID < 1) { JError::raiseError(TUIYO_SERVER_ERROR, _("Invalid group id specified")); return false; } $gModel = TuiyoLoader::model("groups", true); $gData = $gModel->getGroup($groupID); //If is already a member if (!$gData || $gData->isMember < 1 || $gData->isAdmin < 1 || empty($gData->groupID) || $gData->groupID < 1) { JError::raiseError(TUIYO_SERVER_ERROR, _("You do not have permission to modify this group")); return false; } $fileCache = JPATH_CACHE . DS . basename($fileData['name']); $filePath = TUIYO_FILES . DS . "groups" . DS . $user->id . DS; $newFilePath = $filePath . $this->fileName; //If we cannot create a folder if (!JFolder::exists($filePath)) { JFolder::create($filePath); JPath::setPermissions($filePath); } if (file_exists($newFilePath)) { JFile::delete($fileCache); return true; } //If we cannot copy the file if (!JFile::copy($fileCache, $newFilePath)) { trigger_error("Could not copy the file", E_USER_ERROR); return false; } JFile::delete($fileCache); //2. Complete the File Information $this->filePath = JPath::clean($filePath); $this->url = $this->url . str_replace(array(JPATH_ROOT, DS), array("", "/"), $newFilePath); $this->dimension = json_encode(getimagesize($newFilePath)); //3. Save the Object in the Database if (!$this->store()) { trigger_error($this->getError(), E_USER_ERROR); return false; } //2. Update the User Table with the current user Avatar Details. I.e Avatar id! $thumbs = array("thumb200" => substr($this->createAvatarThumb(200), 1), "thumb70" => substr($this->createAvatarThumb(70), 1), "thumb35" => substr($this->createAvatarThumb(35), 1)); $data = array("groupID" => $groupID, "banner" => json_encode($thumbs), "logo" => $thumbs["thumb70"]); $gModel->storeGroup($data, $user->id, false); return true; }
/** * TuiyoViewMessages::calendar() * @param mixed $tpl * @return */ public function agenda($tpl = null) { $eModel = TuiyoLoader::model('events', true); $doc = $GLOBALS['API']->get("document", null); $user = $GLOBALS['API']->get("user", null); //Default bc; $bc =& $GLOBALS['mainframe']->getPathway(); $pt =& $GLOBALS['mainframe']->setPageTitle(_("Agenda of Events")); $defaultM = date("n"); $defaultY = date("Y"); $cMonth = JRequest::getVar("cMonth", $defaultM); $cYear = JRequest::getVar("cYear", $defaultY); $timestamp = mktime(0, 0, 0, $cMonth, 1, $cYear); $prevMonth = $cMonth - 1; $nextMonth = $cMonth + 1; $prevYear = $nextYear = $cYear; if ($prevMonth == 0) { $prevMonth = 12; $prevYear = $cYear - 1; } if ($nextMonth == 13) { $nextMonth = 1; $nextYear = $cYear + 1; } //Get Months Events $events = $eModel->getUserEvents($user->id, $cMonth, $cYear); //print_R($events ); $cMonthVars = array("numdays" => date("t", $timestamp), "dateInfo" => getdate($timestamp), "nextMonth" => $nextMonth, "nextYear" => $nextYear, "prevMonth" => $prevMonth, "prevYear" => $prevYear, "events" => $events); $this->assignRef("cVars", $cMonthVars); $bc->addItem(_("Agenda of Events")); //styles Sheets $doc->addCSS(TUIYO_LIVE_PATH . '/client/default/css/messages.css'); $doc->addCSS(TUIYO_LIVE_PATH . '/client/default/css/calendar.css'); $doc->addJS(TUIYO_LIVE_PATH . '/client/default/script/messages.js'); $livestyle = TUIYO_LIVE_PATH . '/client/default/'; $this->setLayout("agenda"); $this->setLayoutExt('tpl'); $this->assignRef('livestyle', $livestyle); $this->assignRef('user', $user); parent::display($tpl); }