示例#1
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);
 }
示例#2
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);
     }
 }
示例#3
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;
 }
示例#4
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;
 }
示例#5
0
 /**
  * TuiyoControllerSystemTools::globalConfig()
  * Global system configuration
  * @return
  */
 public function globalConfig()
 {
     $view = $this->getView("tuiyo", "html");
     //$model 	= $this->getModel("tuiyo");
     $MODEL = TuiyoLoader::model('applications', true);
     $data = array();
     /** Do something majical **/
     $data["APPS"] = $MODEL->getApplicationExtendedList();
     $data["params"] = TuiyoParameter::load("global");
     $data["photos_params"] = TuiyoParameter::load("photos");
     $data["groups_params"] = TuiyoParameter::load("groups");
     /** Do nothing majical **/
     $form = $view->showConfigWindow($data);
     $view->display($form);
     $this->docu->addScript("components/com_tuiyo/style/script/config.js");
 }
示例#6
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;
 }