本文整理汇总了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;
}
}
示例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);
}
}
示例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"));
}
示例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;
}
示例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;
}
示例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"]);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}