示例#1
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);
     }
 }
示例#2
0
 /**
  * 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;
 }
示例#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;
 }