/**
  * TuiyoPluginCheckUpdate::onAdminStart()
  * 
  * @param mixed $args
  * @return void
  */
 public function onAdminStart($args = null)
 {
     //die;
     $version = TuiyoLoader::helper("parameter");
     $version = TuiyoLoader::helper("version");
     $versionXML = new JSimpleXML();
     $document = $GLOBALS['API']->get("document");
     $url = "https://github.com/Tuiyo/ignite/raw/master/VERSION.XML";
     $updateUrl = 'index.php?option=com_tuiyo&context=SystemTools&do=autoCenter&run=systemupdate';
     $vParams = TuiyoAPI::getURL($url);
     //print_r($vParams);
     $vData = new TuiyoParameter();
     $version =& new TuiyoVersion();
     $latest = $vData->get("release") . '.' . $vData->get("devlevel") . '.' . $vData->get("devstatus");
     if ($version->isOutDated($latest)) {
         $document->enqueMessage(sprintf(_('Your version of Tuiyo is outdated. <a href="%s">Please click here to automatically upgrated to Tuiyo %2s</a>'), $updateUrl, $latest), "notice");
     }
 }
示例#2
0
 /**
  * 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);
 }
示例#3
0
 /**
  * TuiyoNotify::_()
  * 
  * @param mixed $userIdTo
  * @param mixed $title
  * @param mixed $actionLink
  * @param mixed $actionTitle
  * @param string $application
  * @param mixed $template
  * @param mixed $templateVars
  * @return void
  */
 public function _($userIdTo, $title, $actionLink, $actionTitle, $application = 'system', $template = NULL, $templateVars = NULL)
 {
     global $mainframe;
     TuiyoLoader::helper("parameter");
     //1. Check App can send Mail
     //2. Load the user message is being sent to
     $document = TuiyoApi::get("document");
     $userFrom = TuiyoApi::get("user", null);
     $user = TuiyoApi::get("user", (int) $userIdTo);
     $notifyTable = TuiyoLoader::table("notifications", true);
     $notifyParams = TuiyoParameter::load("emails");
     if ($userIdTo < 1) {
         $document->enqueMessage(_("Could not notify the user due to a UserID({$userIdTo}) error"), "error");
         return false;
     }
     //3. Add Notification Title to database;
     $notifyTable->title = $title;
     $notifyTable->userid = $userIdTo;
     $notifyTable->link = $actionLink;
     $notifyTable->linktitle = $actionTitle;
     $notifyTable->application = $application;
     $notifyTable->status = 0;
     $notifyTable->type = $template;
     $notifyTable->template = json_encode($templateVars);
     if (!$notifyTable->store()) {
         $document->enqueMessage(sprintf(_("Could not notify the user due to the following error: %s"), $notifyTable->getError()), "error");
         return false;
     }
     if (!empty($template)) {
         $eTitle = $notifyParams->get($template . "Title");
         $eBody = $notifyParams->get($template . "Body");
         $subject = html_entity_decode($eTitle, ENT_QUOTES);
         $message = html_entity_decode($eBody, ENT_QUOTES);
         TuiyoNotify::sendMail($user->joomla->get('email'), $subject, $message);
     }
 }
示例#4
0
 /**
  * TuiyoModelFriends::addInvite()
  * Generates an Invite
  * @param mixed $inviter
  * @param mixed $invitee
  * @return
  */
 public function addInvite($inviter, $invitee, $message = NULL)
 {
     $iTable = TuiyoLoader::table("invites", TRUE);
     $iNotify = TuiyoLoader::library("mail.notify", true);
     if (empty($invitee->email) || !isset($invitee->email) || $iTable->hasExistingAccount($invitee->email)) {
         return false;
     }
     $iTable->load(NULL);
     $iData = array("userid" => $inviter->id, "email" => $invitee->email, "state" => 0, "name" => !empty($invitee->name) ? $invitee->name : $invitee->email, "code" => $iTable->generateCode());
     if (!$iTable->bind($iData)) {
         JError::raiseError(TUIYO_SERVER_ERROR, $iTable->getError());
         return false;
     }
     //We can Now save the table
     if (!$iTable->store($iData)) {
         return false;
     }
     //Send and Email to the user with the activation code;
     TuiyoLoader::helper("parameter");
     TuiyoLoader::library("mail.notify");
     $notifyParams = TuiyoParameter::load("emails");
     $tVars = array($invitee->name, JURI::base(), $inviter->username, $message);
     $tSearch = array("[name]", "[link]", "[username]", "[message]");
     $emailTitle = str_replace($tSearch, $tVars, $notifyParams->get("inviteEmailTitle", null));
     $emailBody = str_replace($tSearch, $tVars, $notifyParams->get("inviteEmailBody", null));
     //echo $notifyEmail ;
     TuiyoNotify::sendMail($invitee->email, $emailTitle, $emailBody);
     return true;
 }
示例#5
0
 /**
  * TuiyoUser::getUserAvatar()
  * @param mixed $userID
  * @return object
  */
 public function getUserAvatar($userID = NULL, $type = NULL)
 {
     $avatar = new userAvatar();
     $self = TuiyoUser::getInstance(empty($userID) ? null : (int) $userID);
     $userID = empty($userID) ? $self->id : (int) $userID;
     /**Returns an object with the current users */
     $params = TuiyoApi::get("params");
     $params->loadParams("user.avatar", $userID);
     $thumb200 = $params->get("thumb200", null);
     $thumb70 = $params->get("thumb70", null);
     $thumb35 = $params->get("thumb35", null);
     //Paths
     $pathThumb200 = JPATH_ROOT . DS . str_replace(array("/"), array(DS), substr($thumb200, 1));
     $pathThumb70 = JPATH_ROOT . DS . str_replace(array("/"), array(DS), substr($thumb70, 1));
     $pathThumb35 = JPATH_ROOT . DS . str_replace(array("/"), array(DS), substr($thumb35, 1));
     $pathRoot = JURI::root();
     //No avatr Urls
     $noAvatarThumb200URL = "components/com_tuiyo/files/noavatar200.jpg";
     $noAvatarThumb70URL = "components/com_tuiyo/files/noavatar70.jpg";
     $noAvatarThumb35URL = "components/com_tuiyo/files/noavatar35.jpg";
     $gravatarURL = "http://www.gravatar.com/avatar.php?gravatar_id=%s&default=%s&size=%s&border=%s&rating=%s";
     $userEmail = $self->joomla->get('email');
     //Finally Tell us What the avatars truley are
     $avatar->thumb200 = !empty($thumb200) && file_exists($pathThumb200) ? $pathRoot . substr($thumb200, 1) : $pathRoot . $noAvatarThumb200URL;
     $avatar->thumb70 = !empty($thumb70) && file_exists($pathThumb70) ? $pathRoot . substr($thumb70, 1) : $pathRoot . $noAvatarThumb70URL;
     $avatar->thumb35 = !empty($thumb35) && file_exists($pathThumb35) ? $pathRoot . substr($thumb35, 1) : $pathRoot . $noAvatarThumb35URL;
     if ($avatar->thumb200 == $noAvatarThumb200URL) {
         //Check for the existence of a gravatar
         TuiyoLoader::helper("parameter");
         $sysCfg = TuiyoParameter::load("global");
         $maxRating = $sysCfg->get("siteGravatarMaxRating", "X");
         if ((bool) $sysCfg->get("siteEnableGravatars", 1)) {
             $hash = md5($userEmail);
             $uri = 'http:www.gravatar.com/avatar/' . $hash . '?d=404';
             $jRoot = JURI::root();
             $avatar->thumb200 = sprintf($gravatarURL, $hash, $jRoot . '/' . $noAvatarThumb200URL, 200, 0, $maxRating);
             $avatar->thumb70 = sprintf($gravatarURL, $hash, $jRoot . '/' . $noAvatarThumb70URL, 70, 0, $maxRating);
             $avatar->thumb35 = sprintf($gravatarURL, $hash, $jRoot . '/' . $noAvatarThumb35URL, 35, 0, $maxRating);
         }
     }
     $params = null;
     unset($params);
     if (isset($type) && !empty($type) && isset($avatar->{$type})) {
         $required = $avatar->{$type};
         unset($avatar);
         return $required;
     }
     $required = clone $avatar;
     unset($avatar);
     //return (object) $instance[$userID];
     return (object) $required;
 }
示例#6
0
 /**
  * TuiyoControllerSystemTools::saveConfig()
  * Saves User aswell as profile configuration Data;
  * @return void
  */
 public function saveConfig()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $type = JRequest::getVar('configType', null, 'post', 'string');
     $key = JRequest::getVar('configKey', null, 'post', 'string');
     $referer = JRequest::getVar("HTTP_REFERER", null, "SERVER");
     //Referer
     //We must know the type and name of the email
     if (empty($type) || empty($key)) {
         JError::raiseError(TUIYO_SERVER_ERROR, _('You did not specify the config key, or type'));
         return false;
     }
     $document = $GLOBALS['API']->get("document");
     $auth = $GLOBALS['API']->get('authentication');
     $resp = array("code" => TUIYO_OK, "msg" => _("Your template parameters have been saved"), "error" => null);
     //Request authentication
     $auth->requireAuthentication();
     $user = $GLOBALS['API']->get('user', null);
     $params = JRequest::getVar('params', array(), 'post', 'array');
     $path = TUIYO_CONFIG;
     print_R($params);
     switch ($type) {
         case "system":
             $return = TuiyoParameter::saveParams($params, $key, "system");
             break;
         default:
             JError::raiseError(TUIYO_SERVER_ERROR, _('Invalid config type'));
             return false;
             break;
     }
     //Notice messages;
     $msg = "{$key} {$type} data saved successfully";
     $mType = "notice";
     if (!$return) {
         $msg = "{$key} {$type} could not be saved";
         $mType = "error";
     }
     //$document->enqueMessage( $msg , $mType );
     $this->setRedirect($referer, $msg, $mType);
     $this->redirect();
 }
示例#7
0
 /**
  * TuiyoAPI::getUrlViaProxy()
  * 
  * @param mixed $URL
  * @param mixed $proxyName
  * @param mixed $proxyPort
  * @return
  */
 public function getUrlViaProxy($URL, $proxyName = NULL, $proxyPort = NULL)
 {
     if (empty($proxyName) || empty($proxyPort)) {
         TuiyoLoader::helper("parameter");
         $params =& TuiyoParameter::load("global");
         $proxyName = $params->get("serverHttpProxyName", null);
         $proxyPort = $params->get("serverHttpProxyPort", null);
     }
     $parsed = parse_url($URL);
     $host = $parsed["host"];
     $path = $parsed["path"];
     $out = "GET {$path} HTTP/1.0\r\nHost: {$host}\r\n\r\n";
     $fp = fsockopen($proxyName, $proxyPort);
     $content = null;
     $body = false;
     if (!$fp) {
         return false;
     }
     $bytes = fputs($fp, "GET {$URL} HTTP/1.0\r\nHost: {$proxyName}\r\n\r\n");
     do {
         $header .= fgets($fp, 128);
     } while (strpos($header, "\r\n\r\n") === false);
     while (!feof($fp)) {
         $lfp = fgets($fp, $bytes);
         $content .= $lfp;
         //if ( $body ) $content.= $lfp;
         //if ( $lfp == "\r\n" ) $body = true;
     }
     fclose($fp);
     //$content 	= substr($content, strpos($content, "\r\n\r\n") + 4);
     return $content;
 }
示例#8
0
 /**
  * Loads system plugins.
  * @param $type
  * @param $pluginXML
  * @param $incSystem
  * @param $excUserPlugins
  */
 public function getAllSystemPlugins($type = "services", $pluginXML = false, $incSystem = false, $excUserPlugins = false, $userID = null)
 {
     //Import the Joomla Folder Library
     jimport('joomla.filesystem.folders');
     //Import the Tuiyo Alias of JParameter
     TuiyoLoader::helper("parameter");
     //Scan the plugin folder
     $plugins = JFolder::folders(TUIYO_PLUGINS);
     $exclude = array("system");
     //If we want to exclude user plugins
     if ($excUserPlugins && isset($userID)) {
         $userPlugins = $this->getAllUserPlugins($userID, $type, false);
         $exclude = array_merge($exclude, (array) $userPlugins);
     }
     $plugins = array_diff($plugins, $exclude);
     if (!$pluginXML) {
         return $plugins;
     }
     //If we have to load the XML files
     $pluginsSpec = array();
     foreach ($plugins as $plugin) {
         $newPluginSpec = array();
         $newPlugin = new stdClass();
         $newPluginID = strtolower($plugin);
         $newPluginXMLf = TUIYO_PLUGINS . DS . $newPluginID . DS . "plugin.xml";
         $newPluginLivePath = TUIYO_LIVE_PATH . '/plugins/' . $newPluginID;
         if (!file_exists($newPluginXMLf)) {
             continue;
         }
         //this is not a plugin
         $newPluginXML = TuiyoAPI::get("xml", $newPluginXMLf);
         $root = $newPluginXML->file->document;
         $rootType = $root->attributes("type");
         if ((string) $rootType != "plugin") {
             continue;
         }
         //this is not a plugin
         //Load data
         $pluginParams = new TuiyoParameter('', $newPluginXMLf);
         $pluginParams->setXML($newPluginXML->file->document);
         $newPluginSpec['serviceID'] = $newPluginID;
         $newPluginSpec['serviceDescription'] = $root->description[0]->_data;
         $newPluginSpec['serviceLivePath'] = $newPluginLivePath;
         $newPluginSpec['serviceExecuteJS'] = $newPluginLivePath . '/' . $newPluginID . '.js';
         $newPluginSpec['settings_default_html'] = $pluginParams->renderHTML("params", "plugin");
         $newPluginSpec['settings_administrator_html'] = $pluginParams->renderHTML("params", "administrator");
         $newPluginSpec['settings_photos_html'] = $pluginParams->renderHTML("params", "photos");
         $newPluginSpec['settings_privacy_html'] = $pluginParams->renderHTML("params", "privacy");
         $pluginsSpec[$newPluginID] = $newPluginSpec;
     }
     return $pluginsSpec;
 }