当前位置: 首页>>代码示例>>PHP>>正文


PHP ET::saveLanguageState方法代码示例

本文整理汇总了PHP中ET::saveLanguageState方法的典型用法代码示例。如果您正苦于以下问题:PHP ET::saveLanguageState方法的具体用法?PHP ET::saveLanguageState怎么用?PHP ET::saveLanguageState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ET的用法示例。


在下文中一共展示了ET::saveLanguageState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Create a new activity entry in the database. If the specified activity type has an email projection
  * handler, this method will also send an email notification where appropriate.
  *
  * @todo Add an unsubscribe link to notification email footers.
  *
  * @param string $type The name of the type of activity to create.
  * @param array $member An array of details for the member to create the activity for.
  * @param array $fromMember An array of details for the member that the activity is from.
  * @param array $data An array of custom data that can be used by the type/projection callback functions.
  * @param array $emailData An array of custom data that can be used only by the EMAIL projection callback function.
  *		(i.e. it is not stored in the database.)
  * @return bool|int The activity ID, or false if there were errors.
  */
 public function create($type, $member, $fromMember = null, $data = null, $emailData = null)
 {
     // Make sure we have a definition for this type of activity.
     if (empty(self::$types[$type])) {
         throw new Exception("Cannot create activity with non-existent type '{$type}'.");
     }
     // Get the projections that are handled by this type.
     $projections = self::$types[$type];
     // Construct an array of information about the new activity.
     $activity = array("type" => $type, "memberId" => $member["memberId"], "fromMemberId" => $fromMember ? $fromMember["memberId"] : null, "conversationId" => isset($data["conversationId"]) ? $data["conversationId"] : null, "postId" => isset($data["postId"]) ? $data["postId"] : null, "time" => time());
     $activityId = null;
     // If this activity type has notification or activity projections, we'll need to insert the activity into the database.
     if (!empty($projections[self::PROJECTION_NOTIFICATION]) or !empty($projections[self::PROJECTION_ACTIVITY])) {
         $activityId = parent::create($activity + array("data" => serialize($data)));
     }
     // Set some more information about the activity.
     $activity["data"] = (array) $data + (array) $emailData;
     $activity["fromMemberName"] = $fromMember ? $fromMember["username"] : null;
     $activity["activityId"] = $activityId;
     // If this activity type has an email projection, the member wants to receive an email notification
     // for this type, and we haven't set sent them one in a previous call of this method, then let's send one!
     if (!empty($projections[self::PROJECTION_EMAIL]) and !empty($member["preferences"]["email.{$type}"]) and !in_array($member["memberId"], $this->membersUsed)) {
         // Log the member as "used", so we don't send them any more email notifications about the same subject.
         $this->membersUsed[] = $member["memberId"];
         // Load the member's language into esoTalk's memory.
         ET::saveLanguageState();
         ET::loadLanguage(@$member["preferences"]["language"]);
         // Get the email content by calling the type's email projection function.
         list($subject, $body) = call_user_func($projections[self::PROJECTION_EMAIL], $activity, $member);
         // Send the email, prepending/appending a common email header/footer.
         sendEmail($member["email"], $subject, sprintf(T("email.header"), $member["username"]) . $body . sprintf(T("email.footer"), URL("settings", true)));
         // Revert back to esoTalk's old language definitions.
         ET::revertLanguageState();
     }
     return $activity["activityId"];
 }
开发者ID:19eighties,项目名称:esoTalk,代码行数:50,代码来源:ETActivityModel.class.php


注:本文中的ET::saveLanguageState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。