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


PHP ET::postModel方法代码示例

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


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

示例1: handler_conversationController_formatPostForTemplate

 public function handler_conversationController_formatPostForTemplate($sender, &$formatted, $post, $conversation)
 {
     if ($post["deleteTime"]) {
         return;
     }
     $isAnswer = $conversation["answered"] == $post["postId"];
     $isFirstPost = $post["memberId"] == $conversation["startMemberId"] && $post["time"] == $conversation["startTime"];
     $isAuthor = $conversation["startMemberId"] == ET::$session->userId;
     if (!$isFirstPost && ($isAuthor || $conversation["canModerate"]) && !$isAnswer) {
         $label = $conversation["startMemberId"] == ET::$session->userId ? "This answers my question" : "This answers the question";
         addToArray($formatted["footer"], "<a href='" . URL("conversation/answer/" . $post["postId"] . "?token=" . ET::$session->token) . "' class='markAsAnswer'><i class='icon-ok'></i> " . T($label) . "</a>", 0);
     }
     // If this post is the answer...
     if ($isAnswer) {
         $formatted["class"][] = "answer";
         addToArray($formatted["info"], "<span class='label label-answered'><i class='icon-ok-sign'></i> " . T("Answer") . "</span>", 100);
     }
     // If this is the first post in the conversation and there is an answer...
     if ($conversation["answered"] and $isFirstPost) {
         // Get the answer post.
         $answer = ET::postModel()->getById($conversation["answered"]);
         $view = $sender->getViewContents("answers/answer", array("answer" => $answer, "conversation" => $conversation));
         $formatted["body"] = $formatted["body"] . $view;
     }
 }
开发者ID:m-mori,项目名称:forum,代码行数:25,代码来源:plugin.php

示例2: handler_conversationController_formatPostForTemplate

 public function handler_conversationController_formatPostForTemplate($sender, &$formatted, $post, $conversation)
 {
     if ($post["deleteMemberId"]) {
         return;
     }
     if ($conversation["startMemberId"] == ET::$session->userId or $conversation["canModerate"]) {
         addToArray($formatted["controls"], "<a href='" . URL("conversation/answer/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("This post answered my question") . "' class='control-answer'><i class='icon-ok-sign'></i></a>");
     }
     // If this post is the answer...
     if ($conversation["answered"] == $post["postId"]) {
         addToArray($formatted["info"], "<span class='label label-answered'><i class='icon-ok-sign'></i> " . T("Answer") . "</span>", 100);
     }
     // If this is the first post in the conversation and there is an answer...
     if ($conversation["answered"] and $post["memberId"] == $conversation["startMemberId"] and $post["time"] == $conversation["startTime"]) {
         // Get the answer post.
         $answer = ET::postModel()->getById($conversation["answered"]);
         $view = $sender->getViewContents("answers/answer", array("answer" => $answer, "conversation" => $conversation));
         // Add this before the "likes" plugin. Bit hacky, but there's no way to prioritize event handlers in esoTalk :(
         $pos = strpos($formatted["body"], "<p class='likes");
         if (!$pos) {
             $pos = strlen($formatted["body"]);
         }
         $formatted["body"] = substr_replace($formatted["body"], $view, $pos, 0);
     }
 }
开发者ID:ky0ncheng,项目名称:esotalk-for-sae,代码行数:25,代码来源:plugin.php

示例3: action_conversationController_liked

 public function action_conversationController_liked($sender, $postId = false)
 {
     if (!($postId = (int) $postId)) {
         return;
     }
     $post = ET::postModel()->getById($postId);
     if (!$post) {
         return;
     }
     $sender->data("members", $post["likes"]);
     $sender->render($this->view("liked"));
 }
开发者ID:ZerGabriel,项目名称:Likes,代码行数:12,代码来源:plugin.php

示例4: getPostForEditing

 /**
  * Return post data to work with for an editing action (editPost, deletePost, etc.), but only if the post
  * exists and the user has permission to edit it.
  *
  * @param int $postId The post ID.
  * @return bool|array An array of post data, or false if it cannot be edited.
  */
 protected function getPostForEditing($postId)
 {
     // Get the conversation.
     if (!($conversation = $this->getConversation($postId, true))) {
         return false;
     }
     // Get the post.
     $post = ET::postModel()->getById($postId);
     // Stop here with an error if the user isn't allowed to edit this post.
     if (!ET::postModel()->canEditPost($post, $conversation)) {
         // If users only have permission to edit their posts until someone replies, and someone has replied since...
         if (C("esoTalk.conversation.editPostTimeLimit") === "reply" and ($conversation["lastPostTime"] > $post["time"] or $conversation["lastPostMemberId"] != $post["memberId"])) {
             $msg = T("message.cannotEditSinceReply");
         } else {
             $msg = T("message.noPermission");
         }
         $this->renderMessage(T("Error"), $msg);
         return false;
     }
     $post["conversation"] = $conversation;
     return $post;
 }
开发者ID:xiaolvmu,项目名称:Techllage,代码行数:29,代码来源:ETConversationController.class.php

示例5: setTitle

 /**
  * Set the title of a conversation.
  *
  * @param array $conversation The conversation to set the title of. The conversation array's title
  * 		attribute will be updated.
  * @param string $title The new title of the conversation.
  * @return bool Returns true on success, or false if there is an error.
  */
 public function setTitle(&$conversation, $title)
 {
     $this->validate("title", $title, array($this, "validateTitle"));
     if ($this->errorCount()) {
         return false;
     }
     $this->updateById($conversation["conversationId"], array("title" => $title));
     // Update the title column in the posts table as well (which is used for fulltext searching).
     ET::postModel()->update(array("title" => $title), array("conversationId" => $conversation["conversationId"]));
     $conversation["title"] = $title;
     return true;
 }
开发者ID:nowaym,项目名称:esoTalk,代码行数:20,代码来源:ETConversationModel.class.php

示例6: remove

 public function remove($attachmentId)
 {
     if (!$this->validateToken()) {
         return;
     }
     $session = (array) ET::$session->get("attachments");
     if (isset($session[$attachmentId])) {
         unset($session[$attachmentId]);
         ET::$session->store("attachments", $session);
     } else {
         $model = ET::getInstance("attachmentModel");
         $attachment = $model->getById($attachmentId);
         // Make sure the user has permission to edit this post.
         $permission = false;
         if (!empty($attachment["postId"])) {
             $post = ET::postModel()->getById($attachment["postId"]);
             $conversation = ET::conversationModel()->getById($post["conversationId"]);
             $permission = ET::postModel()->canEditPost($post, $conversation);
         } else {
             $permission = ET::$session->userId == $attachment["draftMemberId"];
         }
         if (!$permission) {
             $this->renderMessage(T("Error"), T("message.noPermission"));
             return false;
         }
         // Remove the attachment from the database and filesystem.
         $model->deleteById($attachmentId);
         @unlink($model->path() . $attachmentId . $attachment["secret"]);
     }
 }
开发者ID:AlexandrST,项目名称:esoTalk,代码行数:30,代码来源:AttachmentController.class.php

示例7: setTitle

 /**
  * Set the title of a conversation.
  *
  * @param array $conversation The conversation to set the title of. The conversation array's title
  * 		attribute will be updated.
  * @param string $title The new title of the conversation.
  * @return bool Returns true on success, or false if there is an error.
  */
 public function setTitle(&$conversation, $title)
 {
     $this->validate("title", $title, array($this, "validateTitle"));
     if ($this->errorCount()) {
         return false;
     }
     $this->updateById($conversation["conversationId"], array("title" => $title));
     // Update the title column in the posts table as well (which is used for fulltext searching).
     ET::postModel()->update(array("title" => $title), array("conversationId" => $conversation["conversationId"]));
     $conversation["title"] = $title;
     //Flush conversition cache
     $sm = ET::searchModel();
     ET::$cache->store($sm::CACHE_NS_KEY, time());
     return true;
 }
开发者ID:ky0ncheng,项目名称:esotalk-for-sae,代码行数:23,代码来源:ETConversationModel.class.php

示例8: action_remove

 public function action_remove($attachmentId)
 {
     if (!$this->validateToken()) {
         return;
     }
     //		$session = (array)ET::$session->get("attachments");
     $model = ET::getInstance("attachmentModel");
     $attachment = $model->getById($attachmentId);
     $sessId = ET::$session->getSessId();
     if (is_array($attachment) && count($attachment) > 0) {
         // Make sure the user has permission to edit this post.
         $permission = false;
         if (!empty($attachment["postId"])) {
             $post = ET::postModel()->getById($attachment["postId"]);
             $conversation = ET::conversationModel()->getById($post["conversationId"]);
             $permission = ET::postModel()->canEditPost($post, $conversation);
         } else {
             if ($attachment["sessId"] == $sessId) {
                 $permission = true;
             } else {
                 $permission = ET::$session->userId == $attachment["draftMemberId"];
             }
         }
         if (!$permission) {
             $this->renderMessage(T("Error"), T("message.noPermission"));
             return false;
         }
         // Remove the attachment from the database.
         $model->deleteById($attachmentId);
         // Remove the attachment from the filesystem.
         $model->removeFile($attachment);
     }
 }
开发者ID:m-mori,项目名称:forum,代码行数:33,代码来源:AttachmentController.class.php

示例9: getPostForEditing

 /**
  * Return post data to work with for an editing action (editPost, deletePost, etc.), but only if the post
  * exists and the user has permission to edit it.
  *
  * @param int $postId The post ID.
  * @return bool|array An array of post data, or false if it cannot be edited.
  */
 protected function getPostForEditing($postId)
 {
     // Get the conversation.
     if (!($conversation = $this->getConversation($postId, true))) {
         return false;
     }
     // Get the post.
     $post = ET::postModel()->getById($postId);
     // Stop here with an error if the user isn't allowed to edit this post.
     if (!$this->canEditPost($post, $conversation)) {
         $this->renderMessage(T("Error"), T("message.noPermission"));
         return false;
     }
     $post["conversation"] = $conversation;
     return $post;
 }
开发者ID:nowaym,项目名称:esoTalk,代码行数:23,代码来源:ETConversationController.class.php

示例10: handler_conversationController_like_after

 public function handler_conversationController_like_after($sender, $postId = false)
 {
     $post = ET::postModel()->getById($postId);
     $points = "reputationPoints + " . C("plugin.Reputation.likesRP");
     $this->updateReputationPoints($points, $post["memberId"]);
     return;
 }
开发者ID:ZerGabriel,项目名称:Reputation,代码行数:7,代码来源:plugin.php


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