/** * TuiyoControllerProtocol::returnResponse() * Returns a response from the recent request * @return void */ private function returnResponse($status = 200, $body = '', $format = 'json') { $doc =& TuiyoAPI::get("document"); $docType =& $doc->getDOCTYPE(); $view =& $this->getView("protocol", empty($docType) || $docType == "html" ? $format : $docType); /** Response Formulator **/ TuiyoLoader::import("rest.response"); TuiyoLoader::import("rest.utility"); $view->display(); }
/** * TuiyoViewWidgets::display() * @param mixed $tpl * @return void */ function display($tpl = null) { $doc = TuiyoAPI::get("document"); $livestyle = TUIYO_STYLEDIR; $doc->addCSS(TUIYO_LIVE_PATH . '/client/default/css/widgets.css'); $doc->addJS(TUIYO_LIVE_PATH . '/client/default/script/widgets.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.sortable.js'); $doc->addJS(TUIYO_WIDGET); $this->assignRef('livestyle', $livestyle); parent::display($tpl); }
/** * 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; }
/** * TuiyoViewTuiyo::categoryManager * Default function to display the category manager * @param mixed $tpl * @return html */ public function categoryManager($tpl = null) { $TMPL = $GLOBALS["API"]->get("document"); $MODEL = TuiyoLoader::model("categories", true); $USER = TuiyoAPI::get("user"); $ACL = JFactory::getACL(); //Get the Categories $gtree = $ACL->get_group_children_tree(null, 'USERS', false); $aroGrps = JHTML::_('select.genericlist', $gtree, 'gid', 'class="TuiyoFormDropDown"', 'value', 'text', $USER->joomla->get('gid')); $tmplVars = array("styleDir" => $livestyle, "livePath" => TUIYO_LIVE_PATH, "iconPath" => TUIYO_LIVE_PATH . '/client/default/', "user" => JFactory::getUser(), "nodes" => $MODEL->getCategories(), "arogrps" => $aroGrps); $tmplPath = JPATH_COMPONENT_ADMINISTRATOR . DS . "views" . DS . "tuiyo" . DS . "tmpl"; $tmplData = $TMPL->parseTmpl("categories", $tmplPath, $tmplVars); return $tmplData; }
/** * @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); }
/** * (non-PHPdoc) * @see components/com_tuiyo/controllers/TuiyoControllerServices::add() */ public function add() { // 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'); $post =& Jrequest::get("post"); $model =& $this->getModel("fireeagle"); $view =& $this->getView("fireeagle", "json"); $resp = array("code" => 505, "error" => _("could not add service"), "data" => null, "extra" => null); if ($model->addService($post, $user->id)) { $resp = array("code" => TUIYO_OK, "error" => null); } return $view->encode($resp); }
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); }
public function addCategory($data) { $catCreator = TuiyoAPI::get("user", null); $catTree = TuiyoLoader::table("categories", true); $catTree->load(null); $catTree->title = trim($data['cattitle']); $catTree->parent = (int) $data['catpid']; $catTree->slug = trim($data['catslug']); $catTree->creator = (int) $catCreator->id; $catTree->description = trim($data['catdescription']); $catTree->dateadded = date('Y-m-d H:is'); $catTree->status = (int) $data['catstatus']; //print_r( $catTree ); if (!$catTree->store()) { JError::raiseError(TUIYO_SERVER_ERROR, $catTree->getError()); return false; } //Restructure the Tree; $catTree->restructureTree(); return true; }
/** * 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); }
/** * TuiyoControllerGroups::saveEdit() * Updates a group Settings * @param mixed $postData * @param mixed $userID * @return */ private function saveEdit($postData, $userID) { $group = JRequest::getInt('groupID', null); $user = TuiyoAPI::get('user', $userID); $referer = JRequest::getVar("HTTP_REFERER", TUIYO_INDEX, 'server'); $model = $this->getModel('groups'); $gData = $model->getGroup($group); //If is already a member if (!$gData || $gData->isMember < 1 || $gData->isAdmin < 1 || empty($gData->groupID) || $gData->groupID < 1) { $msg = _("You do not have the valid permission to delete this group"); $msgtype = "error"; return $this->setRedirect($explore, $msg, $msgtype); } $stored = $model->storeGroup($postData, $user->id, false); $msg = sprintf(_("The %s group has now been updated"), $gData->gName); $msgtype = "notice"; $this->setRedirect($referer, $msg, $msgtype); $this->redirect(); }
/** * 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; }
/** * Gets a complete Form, for all elements passed * TuiyoForm::getForm() * * @param mixed $formId * @return void */ public function outPutForm($formId = NULL, $front = FALSE, $submit = TRUE) { $token =& JUtility::getToken(); $user = TuiyoAPI::get("user", null); //Add The form Button array_push($this->elements, $this->hidden("option", array("type" => "hidden", "name" => "option", "value" => "com_tuiyo")), $this->hidden($token, array("type" => "hidden", "name" => $token, "value" => "1")), $this->hidden("option", array("type" => "hidden", "name" => "option", "value" => "com_tuiyo")), $this->hidden("do", array("type" => "hidden", "name" => "do", "value" => "saveParams")), $this->hidden("userid", array("type" => "hidden", "name" => "userid", "value" => "" . $user->id . "")), $this->hidden("context", array("type" => "hidden", "name" => "context", "value" => "systemTools"))); //Will you like to add a submit Button? if ($submit) { array_push($this->elements, $this->button("submit", array("type" => "submit", "innerHTML" => "Save Configuration Data"))); } //Are we on the frontpate if ($front) { array_push($this->elements, $this->hidden("view", array("type" => "hidden", "name" => "view", "value" => "profile"))); } //Add form Tags and elements $form = array("tagName" => "form", "action" => "index.php", "method" => !empty($this->formMethod) ? "post" : $this->formMethod, "id" => !empty($formId) ? $formId : $this->formId, "name" => !empty($formId) ? $formId : $this->formId, "class" => "tuiyoTable TuiyoForm", "childNodes" => (array) $this->elements); //print_R( $this->elements ); return $form; }
/** * 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; }
/** * TuiyoControllerResources::getUserNamesLike() * Method for providing autocomplete list by UserName * @return void */ public function getUserNamesLike() { //Must be logged In $auth = TuiyoAPI::get('authentication'); $auth->requireAuthentication("post"); $server = JRequest::get("server"); $userID = JRequest::getInt("userID"); $salt = JRequest::getString("suggestSalt"); $method = strtolower($server['REQUEST_METHOD']); //Get the view; /** we are dealing with only get data***/ if ($method !== 'post') { JError::raiseError(TUIYO_BAD_REQUEST, _("Invalid request. Method accepts only POST request")); } $model =& $this->getModel("resources"); $view =& $this->getView("profile", "json"); //2. prepare a standard response Array $resp = array("code" => TUIYO_OK, "error" => null, "data" => null, "extra" => null); $document =& $GLOBALS['API']->get("document"); $thisUser =& $GLOBALS['API']->get("user", null); //3. JSON or nothing! if ($document->getDOCTYPE() !== "json") { $resp["code"] = TUIYO_BAD_REQUEST; $resp["error"] = _("Invalid Request format. JSON only"); //dump $view->encode($resp); return false; } $resp["data"] = $model->getUsersLike((string) $salt, $thisUser->id, 10); return $view->encode($resp); }
/** * TuiyoModelProfile::buildSocialBookForm() * Builds social form * @return void */ public function buildSocialBookForm($submitFormButton) { $user = TuiyoAPI::get("user"); $params = TuiyoAPI::get("params", "user.social"); $form = $params->getSocialBook($user->id, "user.social", true, $submitFormButton); return $form; }
/** * TuiyoParams::getSocialBook() * Gets social Book Form * @param mixed $formID * @param bool $frontPage * @param bool $showSubmit * @return */ public function getSocialBook($userID, $formID = NULL, $frontPage = TRUE, $showSubmit = TRUE) { $sfTable = TuiyoLoader::table("fields", true); $sfEls = $sfTable->listAll(); /** Load Social Data ***/ $this->loadParams("user.social", $userID); /** Build the form ****/ $form = TuiyoAPI::get("form", "user.social"); foreach ((array) $sfEls as $element) { //Smart Description $description = $element->required > 0 ? _("This field IS required, ") : _("This field IS Not required,"); $description .= $element->indexed > 0 ? _("This field IS searchable, ") : _("This field IS NOT searchable,"); $description .= $element->visible > 0 ? _("This field IS visible on profile. ") : _("This field IS NOT visible on profile. "); $description .= !empty($element->descr) && !is_array($element->descr) ? $element->descr : null; $defaultValue = $this->get($element->name, $element->defaultvalue); //switch element type switch ($element->type) { case "text": case "password": $args = array("name" => $element->name, "label" => $element->title, "description" => $description, "value" => !empty($defaultValue) && !is_array($defaultValue) ? $defaultValue : null); $form->add($element->type, $args["name"], $args); break; case "textarea": $args = array("name" => $element->name, "label" => $element->title, "description" => $description, "innerHTML" => !empty($defaultValue) && !is_array($defaultValue) ? $defaultValue : null); $form->add("textarea", $args["name"], $args); break; case "radiogroup": case "droplist": case "select": $args = array("name" => $element->name, "label" => $element->title, "value" => !empty($defaultValue) && !is_array($defaultValue) ? $defaultValue : null, "options" => array(), "description" => $description); //get Obtions $childOptions = array(); foreach ($childOptions as $child) { $optionValue = $child->attributes("value"); $optionName = $child->data(); $args["options"][$optionName] = $optionValue; } $form->add($element->type, $args["name"], $args); break; default: continue; break; } } //hidden fields $form->add("hidden", "paramKey", array("type" => "hidden", "name" => "paramKey", "value" => "user.social")); return $form->outPutForm($formID, $frontPage, $showSubmit); }
/** * TuiyoActivity::parseActivityStory() * Builds an activity story with template data * @param object $story * @return object */ public function parseActivityStory($story) { //Whose activity? $thisUser = TuiyoAPI::get("user", (int) $story->thisUserID); $thatUser = TuiyoAPI::get("user", (int) $story->thatUserID); //Check that we have the object ready if (!is_object($thisUser) || empty($thisUser)) { $thisUser = TuiyoAPI::get("user", null); } if (!is_object($thatUser) || empty($thatUser)) { $thatUser = TuiyoAPI::get("user", null); } $validVars = array("{*thisUserID*}", "{*thatUserID*}", "{*thisUser*}", "{*thatUser*}", "{*thisGSP1a*}", "{*thisGSP2b*}", "{*thisGSP1c*}", "{*thisGSP2d*}", "{*thatGSP1e*}", "{*thatGSP2f*}", "{*thatGSP1g*}", "{*thatGSP2h*}"); $thisProfileLink = JRoute::_(TUIYO_INDEX . '&view=profile&do=view&user='******'&view=profile&do=view&user='******'@' . $thisUser->username : null, !empty($thatUser) ? '@' . $thatUser->username : null, (int) $thisUser->get("sex", 1) > 0 ? "his" : "her", (int) $thisUser->get("sex", 1) > 0 ? "he" : "she", (int) $thisUser->get("sex", 1) > 0 ? "His" : "Her", (int) $thisUser->get("sex", 1) > 0 ? "He" : "She", (int) $thatUser->get("sex", 1) > 0 ? "his" : "her", (int) $thatUser->get("sex", 1) > 0 ? "he" : "she", (int) $thatUser->get("sex", 1) > 0 ? "His" : "Her", (int) $thatUser->get("sex", 1) > 0 ? "He" : "She"); $story->bodytext = str_replace($validVars, $validVarsData, $story->bodytext); $story->body = str_replace($validVars, $validVarsData, $story->body); $story->title = str_replace($validVars, $validVarsData, $story->title); $story->source = sprintf(_("via %s"), strtolower($story->source)); //Parse Resources if (!empty($story->resources)) { $resources = json_decode($story->resources); $attachment = '<div class="itemResources">'; $count = 0; $actionurl = !empty($story->url) ? $story->url : '#'; foreach ($resources as $r) { if ($count >= 6) { break; } switch ($r->type) { case "image": $actionurl = substr($r->furl, 1); $attachment .= '<a href="' . $actionurl . '" rel="facebox"><img class="rImg" src="' . $r->url . '" width="70" /></a>'; break; case "embedable": $attachment .= '<a href="#" rel="embedPlaceHolder"><img class="rImg" src="' . $r->url . '" width="150" /></a>'; break; } $count++; } $story->body = $attachment . "</div>" . $story->body; } return (object) $story; }
/** * TuiyoModelTimeline::setStatusComment() * @param mixed $userID * @param mixed $postData * @param mixed $options * @return void */ public function setStatusComment($userID, $postData, $options = array()) { $commenter = TuiyoApi::get("user", null); $table = TuiyoLoader::table("timeline"); $table->load(null); //print_R($postData); $statusText = strval($postData['commentbody']); //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 = null; $table->datetime = date('Y-m-d H:i:s'); $table->data = $statusText; $table->type = "comment"; $table->source = isset($postData['source']) ? $postData['source'] : "web"; $table->source = strval($table->source); $table->inreplyto = isset($postData['inreplyto']) ? (int) $postData['inreplyto'] : JError::raiseError(403, _("Invalid activity ID")); if (!$table->store()) { trigger_error($table->getError(), E_USER_ERROR); return false; } //Send Notifications to All users participating in this discussion TuiyoLoader::library("mail.notify"); $getParticipants = $table->getAllCommenters($table->inreplyto); $firstAuthors = array(); //Notify Authors foreach ($getParticipants["author"] as $author) { $firstAuthors[] = $author; if ($userID != $author) { $userTo = TuiyoAPI::get("user", $author); $actionLink = JRoute::_(TUIYO_INDEX . "&view=profile&do=viewStatus&user={$userTo->username}&id={$table->inreplyto}"); $emailTitle = sprintf(_("%s commented on your wall post"), "@" . $commenter->username); $emailBody = ""; //str_replace( $tSearch , $tVars , $notifyParams->get( "connectionRequestEmailBody" , null ) ); //echo $notifyEmail ; TuiyoNotify::_($userTo->id, $emailTitle, $actionLink, _("View Status")); TuiyoNotify::sendMail($userTo->email, $emailTitle, $emailBody); } } //Notify Participants foreach ($getParticipants["participant"] as $tookpart) { if ($userID != $tookpart) { $firstauthor = TuiyoAPI::get("user", (int) $firstAuthors[0]); $userTo = TuiyoAPI::get("user", $tookpart); $actionLink = JRoute::_(TUIYO_INDEX . "&view=profile&do=viewStatus&user={$firstauthor->username}&id={$table->inreplyto}"); $emailTitle = sprintf(_("%s commented on %2s wall post"), "@" . $commenter->username, "@" . $firstauthor->username); $emailBody = ""; //str_replace( $tSearch , $tVars , $notifyParams->get( "connectionRequestEmailBody" , null ) ); //echo $notifyEmail ; TuiyoNotify::_($userTo->id, $emailTitle, $actionLink, _("View Status")); TuiyoNotify::sendMail($userTo->email, $emailTitle, $emailBody); } } return $table; }
/** * TuiyoModelPhotos::editAlbum() * Create, Modifies or Deletes and Album * @param mixed $userID * @param mixed $albumID * @param mixed $isNew * @return */ public function editAlbum($userID, $albumID = NULL, $isNew = NULL) { $aTable = TuiyoLoader::table("albums", TRUE); $post = JRequest::get("post"); $albumID = JRequest::getVar("aid", $albumID); $user = TuiyoAPI::get("user", (int) $userID); //1. Check if this is a new album; if (!empty($albumID) || (int) $albumID > 0) { $aTable->load((int) $albumID); //Check User has permission to edit Album if ($aTable->ownerid != (int) $userID) { JError::raiseError(TUIYO_SERVER_ERROR, _("You do not have permission to edit This album")); return false; } //TODO: Check if album is being deleted and delete } else { //set is New = True; $isNew = TRUE; } //2. Modify the variables $aTable->ownerid = (int) $user->id; $aTable->name = trim($post['name']); $aTable->location = trim($post['location']); $aTable->description = trim($post['description']); $aTable->published = intval($post['published']); $aTable->privacy = intval($post['privacy']); $aTable->last_modified = date("Y-m-d H:i:s"); $aTable->album_type = "profile"; $aTable->photocount = $aTable->photocount; //3 Story Album if (!$aTable->store()) { JError::raiseError(TUIYO_SERVER_ERROR, $aTable->getError()); return false; } if ($isNew) { //4b. Publish Activity Story; $uActivity = TuiyoAPI::get("activity", null); $aLink = JRoute::_(TUIYO_INDEX . '&view=photos&album=' . $aTable->aid); $uStoryLine = sprintf(_('%1s created a <a href="%2s">new album</a> titled <span class="subTitle">%3s</span> <i class="subDescr">%4s</i> '), "@" . $user->username, $aLink, $aTable->name, $aTable->description); $uActivity->publishOneLineStory($user, $uStoryLine, "photos"); } //Unset a few strings; unset($aTable->_db); unset($aTable->_tbl_key); unset($aTable->_tbl); unset($aTable->_errors); return $aTable; //OK }
/** * TuiyoModelFriends::deleteInvite() * @param mixed $inviteID * @return void */ public function deleteInvite($inviteID) { $iTable = TuiyoLoader::table("invites", TRUE); $user = TuiyoAPI::get("user", NULL); if (empty($inviteID) || !$iTable->load((int) $inviteID)) { JError::raiseError(TUIYO_SERVER_ERROR, _("Could not find the specified Invite")); return false; } //Check Permission if ($iTable->userid != $user->id) { JError::raiseError(TUIYO_SERVER_ERROR, _("You do not have permission to delete the invite")); return false; } //Delete the invite if (!$iTable->delete()) { JError::raiseError(TUIYO_SERVER_ERROR, $iTable->getError()); return false; } return TRUE; }
/** * 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"); }
/** * TuiyoViewProfile::returnI() * @param mixed $imageData * @return void */ public function returnI($imageData) { TuiyoAPI::get("image", $imageData); exit(0); }
/** * TuiyoPrivacy::canRateUser() * Checks if userID can rate profileID * @param mixed $profileID * @param mixed $userID * @param mixed $IP * @return true if can rate or false if can't */ public function canRateUser($profileID, $userID = NULL, $IP = NULL) { //joomla !! jimport('joomla.filesystem.file'); jimport('joomla.filesystem.path'); $user =& TuiyoAPI::get("user", $userID); $profile =& TuiyoAPI::get("user", (int) $profileID); //**If guest || if same user if ($user->joomla->get("guest") || (int) $profile->id === (int) $user->id) { return false; } $IP = is_null($IP) || empty($IP) ? getenv('REMOTE_ADDR') : $IP; $IPfile = TUIYO_FILES . DS . "logs" . DS . strval($profile->id) . DS . "rating.log"; if (!JFile::exists($IPfile)) { JFile::write($IPfile, "#Tuiyo Rating log; Profile:" . $profile->id . "\n\n"); return TRUE; } $rateLog = TuiyoAPI::parseINI($IPfile); $rateLogKey = $user->id . "@" . $IP; if (array_key_exists($rateLogKey, $rateLog)) { return false; } //Yes user can vote return TRUE; }
/** * TuiyoModelEvents::addEvent() * Creates and stores a new User Event * @param mixed $userID * @param mixed $postData * @return void */ public function addEvent($userID, $postData) { $eventTable = TuiyoLoader::table('events', true); $rsvpTable = TuiyoLoader::table('eventsrsvp', true); $auth = TuiyoAPI::get('authentication'); $doc = TuiyoAPI::get('document'); //Must be loggged IN $auth->requireAuthentication(); $eventTable->title = trim($postData['title']); if (empty($eventTable->title)) { $doc->enqueMessage(_('You did not specify an event title'), 'error'); return false; } $eventTable->location = trim($postData['location']); $eventTable->street = trim($postData['street']); $eventTable->city = trim($postData['city']); $eventTable->startdate = date('Y-m-d', strtotime($postData['startdate'])); $eventTable->enddate = date('Y-m-d', strtotime($postData['enddate'])); $startYear = date('Y', strtotime($postData['startdate'])); $startMonth = date('m', strtotime($postData['startdate'])); $startDay = date('d', strtotime($postData['startdate'])); $startHour = (int) $postData['startTimeHour']; $startMin = (int) $postData['startTimeMin']; $startSec = (int) $postData['startTimeSec']; $endYear = date('Y', strtotime($postData['enddate'])); $endMonth = date('m', strtotime($postData['enddate'])); $endDay = date('d', strtotime($postData['enddate'])); $endHour = (int) $postData['endTimeHour']; $endMin = (int) $postData['endTimeMin']; $endSec = (int) $postData['endTimeSec']; $startTime = mktime($startHour, $startMin, $startSec, $startMonth, $startDay, $startYear); $endTime = mktime($endHour, $endMin, $endSec, $endMonth, $endDay, $endYear); if ($endTime < $startTime) { $doc->enqueMessage(_('The event end Date/Time cannot be before the start Date/Time'), "error"); return false; } $eventTable->starttime = date('Y-m-d H:i:s', $startTime); $eventTable->endtime = date('Y-m-d H:i:s', $endTime); $eventTable->description = $postData['description']; $eventTable->poster = trim(htmlspecialchars_decode($postData['poster'])); $eventTable->privacy = (int) $postData['privacy']; $eventTable->createdby = (int) $userID; if (!$eventTable->store()) { $doc->enqueueMessage($eventTable->getError(), "error"); return false; } //addHost to Event $rsvpTable->eventid = $eventTable->eventid; $rsvpTable->role = 'host'; $rsvpTable->userid = $eventTable->createdby; $rsvpTable->approved = 1; if (!$rsvpTable->store()) { $eventTable->delete(); $doc->enqueueMessage(_('An error occured whilst adding you to the event'), "error"); $doc->enqueueMessage($eventTable->getError(), "error"); return false; } return true; }
public function finishBuild() { global $mainframe; $userData = TuiyoAPI::get("user"); $profile = TuiyoUser::getUserFromRequest(); $document = JFactory::getDocument(); $template = JFilterInput::clean($mainframe->getTemplate(), 'cmd'); $userStyle = TUIYO_STYLES . DS . $userData->id . DS . $template . ".ini"; if (file_exists($userStyle) && is_file($userStyle) && is_readable($userStyle)) { $content = file_get_contents($userStyle); $params = new JParameter($content); $session = JSession::getInstance('none', array()); $session->set("TUIYO_STYLE", $params); } //User Avatar $mainframe->addMetaTag("thumb70", $userData->getUserAvatar()->thumb70); $mainframe->addMetaTag("thumb35", $userData->getUserAvatar()->thumb35); }
/** * TuiyoControllerSystemTools::getConfigEl() * * @return json page */ public function getConfigEl() { $key = JRequest::getVar("key"); $view = $this->getView("tuiyo", "json"); //Response Array $resp = array("code" => TUIYO_OK, "data" => null, "element" => 0); $params = TuiyoAPI::get("params", $key); $resp["element"] = $params->getForm(); //Return the JSON $view->encode($resp); }
/** * TuiyoInitiate::_localize() * Localizes the system with gettext; * @return void */ private function _localize() { //Initialize gettText $localize =& TuiyoAPI::get("localize"); $language =& JFactory::getLanguage(); $locale = TUIYO_DEFAULT_LOCALE; $domain = 'system'; $encoding = TUIYO_DEFAULT_ENCODING; //print_r( $language->getLocale() ); //return TRUE; $localize->initiate($domain, $locale, $encoding); //return TRUE; }
/** * TuiyoModelGroups::getGroup() * Gets a group from the databse * @param mixed $groupID * @param mixed $userID * @return */ public function getGroup($groupID) { $user = TuiyoAPI::get("user", NULL); $gTable = TuiyoLoader::table("groups", true); $gData = $gTable->loadSingleGroup((int) $groupID); //1. Check that group Exists if (!is_object($gData) || !isset($gData->groupID) || $gData->groupID < 1) { return false; } //2. Is user Createor? $gData->isAdmin = $gData->creatorID != $user->id ? 0 : 1; return $gData; }
public function setMessageFolderCode($folder, $userID = NULL) { $user = TuiyoAPI::get("user", NULL); //Determine if this user is the sender $isSender = (int) $this->user_id_from != $user->id ? FALSE : TRUE; //If its a new message then folder ID is 10; switch ($folder) { case "sent": $sFid = (string) $this->folder_id; if (strlen($sFid) < 2) { $sFid .= "0"; } if ($isSender) { $folder_id = (int) ("1" . $sFid[strlen($sFid) - 1]); } else { $folder_id = (int) ($sFid[0] . "1"); } break; case "read": $sFid = (string) $this->folder_id; if (strlen($sFid) < 2) { $sFid .= "0"; } if ($isSender) { $folder_id = (int) ("2" . $sFid[strlen($sFid) - 1]); } else { $folder_id = (int) ($sFid[0] . "2"); } break; case "delete": $sFid = (string) $this->folder_id; if (strlen($sFid) < 2) { $sFid .= "0"; } if ($isSender) { $folder_id = (int) ("3" . $sFid[strlen($sFid) - 1]); } else { $folder_id = (int) ($sFid[0] . "3"); } break; case "new": default: $folder_id = "10"; break; } $this->folder_id = (int) $folder_id; }