Exemple #1
0
 public function action_conversationController_answer($sender, $postId)
 {
     $conversation = ET::conversationModel()->getByPostId($postId);
     if (!$conversation or !$sender->validateToken()) {
         return;
     }
     // Stop here with an error if the user isn't allowed to mark the conversation as answered.
     if ($conversation["startMemberId"] != ET::$session->userId and !$conversation["canModerate"]) {
         $sender->renderMessage(T("Error"), T("message.noPermission"));
         return false;
     }
     $model = ET::conversationModel();
     $model->updateById($conversation["conversationId"], array("answered" => $postId));
     redirect(URL(R("return", postURL($postId))));
 }
 /**
  * Returns a formatted email subject+body for the "mention" activity type.
  *
  * @param array $item The activity item's details.
  * @param array $member The details of the member this activity is for.
  * @return array 0 => email subject, 1 => email body
  */
 public static function mentionEmail($item, $member)
 {
     $content = ET::formatter()->init($item["data"]["content"])->format()->get();
     $url = URL(postURL($item["data"]["postId"]), true);
     return array(sprintf(T("email.mention.subject"), name($item["fromMemberName"], false), $item["data"]["title"]), sprintf(T("email.mention.body"), name($item["fromMemberName"]), sanitizeHTML($item["data"]["title"]), $content, "<a href='{$url}'>{$url}</a>"));
 }
 /**
  * Format post data into an array which can be used to display the post template view (conversation/post).
  *
  * @param array $post The post data.
  * @param array $conversation The details of the conversation which the post is in.
  * @return array A formatted array which can be used in the post template view.
  */
 public function formatPostForTemplate($post, $conversation)
 {
     $canEdit = ET::postModel()->canEditPost($post, $conversation);
     $avatar = avatar($post);
     // Construct the post array for use in the post view (conversation/post).
     $formatted = array("id" => "p" . $post["postId"], "title" => memberLink($post["memberId"], $post["username"]), "avatar" => (!$post["deleteTime"] and $avatar) ? "<a href='" . URL(memberURL($post["memberId"], $post["username"])) . "'>{$avatar}</a>" : false, "class" => $post["deleteTime"] ? array("deleted") : array(), "info" => array(), "controls" => array(), "body" => !$post["deleteTime"] ? $this->displayPost($post["content"]) : false, "footer" => array(), "data" => array("id" => $post["postId"], "memberid" => $post["memberId"]));
     $date = smartTime($post["time"], true);
     // Add the date/time to the post info as a permalink.
     $formatted["info"][] = "<a href='" . URL(postURL($post["postId"])) . "' class='time' title='" . _strftime(T("date.full"), $post["time"]) . "' data-timestamp='" . $post["time"] . "'>" . (!empty($conversation["searching"]) ? T("Show in context") : $date) . "</a>";
     // If the post isn't deleted, add a lot of stuff!
     if (!$post["deleteTime"]) {
         // Add the user's online status / last action next to their name.
         if (empty($post["preferences"]["hideOnline"])) {
             $lastAction = ET::memberModel()->getLastActionInfo($post["lastActionTime"], $post["lastActionDetail"]);
             if ($lastAction[0]) {
                 $lastAction[0] = " (" . sanitizeHTML($lastAction[0]) . ")";
             }
             if ($lastAction) {
                 array_unshift($formatted["info"], "<" . (!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span") . " class='online' title='" . T("Online") . "{$lastAction[0]}'><i class='icon-circle'></i></" . (!empty($lastAction[1]) ? "a" : "span") . ">");
             }
         }
         // Show the user's group type.
         $formatted["info"][] = "<span class='group'>" . memberGroup($post["account"], $post["groups"]) . "</span>";
         $formatted["class"][] = "group-" . $post["account"];
         foreach ($post["groups"] as $k => $v) {
             if ($k) {
                 $formatted["class"][] = "group-" . $k;
             }
         }
         // If the post has been edited, show the time and by whom next to the controls.
         if ($post["editMemberId"]) {
             $formatted["controls"][] = "<span class='editedBy'>" . sprintf(T("Edited %s by %s"), "<span title='" . _strftime(T("date.full"), $post["editTime"]) . "' data-timestamp='" . $post["editTime"] . "'>" . relativeTime($post["editTime"], true) . "</span>", memberLink($post["editMemberId"], $post["editMemberName"])) . "</span>";
         }
         // If the user can reply, add a quote control.
         if ($conversation["canReply"]) {
             $formatted["controls"][] = "<a href='" . URL(conversationURL($conversation["conversationId"], $conversation["title"]) . "/?quote=" . $post["postId"] . "#reply") . "' title='" . T("Quote") . "' class='control-quote'><i class='icon-quote-left'></i></a>";
         }
         // If the user can edit the post, add edit/delete controls.
         if ($canEdit) {
             $formatted["controls"][] = "<a href='" . URL("conversation/editPost/" . $post["postId"]) . "' title='" . T("Edit") . "' class='control-edit'><i class='icon-edit'></i></a>";
             $formatted["controls"][] = "<a href='" . URL("conversation/deletePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Delete") . "' class='control-delete'><i class='icon-remove'></i></a>";
         } elseif (!$conversation["locked"] && !ET::$session->isSuspended() && $post["memberId"] == ET::$session->userId && (!$post["deleteMemberId"] || $post["deleteMemberId"] == ET::$session->userId) && C("esoTalk.conversation.editPostTimeLimit") == "reply") {
             $formatted["controls"][] = "<span title='" . sanitizeHTML(T("message.cannotEditSinceReply")) . "' class='control-edit disabled'><i class='icon-edit'></i></span>";
             $formatted["controls"][] = "<span title='" . sanitizeHTML(T("message.cannotEditSinceReply")) . "' class='control-delete disabled'><i class='icon-remove'></i></span>";
         }
     } else {
         // Add the "deleted by" information.
         if ($post["deleteMemberId"]) {
             $formatted["controls"][] = "<span>" . sprintf(T("Deleted %s by %s"), "<span title='" . _strftime(T("date.full"), $post["deleteTime"]) . "' data-timestamp='" . $post["deleteTime"] . "'>" . relativeTime($post["deleteTime"], true) . "</span>", memberLink($post["deleteMemberId"], $post["deleteMemberName"])) . "</span>";
         }
         // If the user can edit the post, add a restore control.
         if ($canEdit) {
             $formatted["controls"][] = "<a href='" . URL("conversation/restorePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Restore") . "' class='control-restore'><i class='icon-reply'></i></a>";
         }
     }
     $this->trigger("formatPostForTemplate", array(&$formatted, $post, $conversation));
     return $formatted;
 }
Exemple #4
0
// This file is part of esoTalk. Please see the included license file for usage information.
if (!defined("IN_ESOTALK")) {
    exit;
}
$conversation = $data["conversation"];
$post = $data["answer"];
?>
<div class='answer thing hasControls'>
	<div class='postHeader'>
		<div class='info'>
			<h3><i class="icon-ok-sign"></i> <?php 
printf(T("Answered by %s"), memberLink($post["memberId"], $post["username"]));
?>
</h3>
			<a href='<?php 
echo URL(postURL($post["postId"]));
?>
' rel='post' data-id='<?php 
echo $post["postId"];
?>
'><?php 
echo T("See post in context");
?>
</a>
		</div>
		<div class='controls'>
			<?php 
if ($conversation["startMemberId"] == ET::$session->userId or $conversation["canModerate"]) {
    ?>
			<a href='<?php 
    echo URL("conversation/unanswer/" . $conversation["conversationId"] . "?token=" . ET::$session->token);
Exemple #5
0
 /**
  * The callback function to get quote HTML, given the quote text and its citation.
  *
  * @param string $text The quoted text.
  * @param string $citation The citation text.
  * @return string The quote HTML.
  */
 public function makeQuote($text, $citation = "")
 {
     // If there is a citation and it has a : in it, split it into a post ID and the rest.
     if ($citation and strpos($citation, ":") !== false) {
         list($postId, $citation) = explode(":", $citation, 2);
     }
     // Construct the quote.
     $quote = "<blockquote><p>";
     // If we extracted a post ID from the citation, add a "find this post" link.
     if (!empty($postId)) {
         $quote .= "<a href='" . URL(postURL($postId), true) . "' rel='post' data-id='{$postId}' class='control-search postRef'><i class='icon-search'></i></a> ";
     }
     // If there is a citation, add it.
     if (!empty($citation)) {
         $quote .= "<cite>{$citation}</cite> ";
     }
     // Finish constructing and return the quote.
     $quote .= "{$text}\n</p></blockquote>";
     return $quote;
 }
function startTestsInSandcastle($applyDiff, $workflow, $diffID)
{
    // Default options don't terminate on failure, but that's what we want. In
    // the current case we use assertions intentionally as "terminate on failure
    // invariants".
    assert_options(ASSERT_BAIL, true);
    // In case of a diff we'll send notificatios to the author. Else it'll go to
    // the entire team because failures indicate that build quality has regressed.
    $username = $applyDiff ? exec("whoami") : CONT_RUN_ALIAS;
    assert(strlen($username) > 0);
    if ($applyDiff) {
        assert($workflow);
        assert(strlen($diffID) > 0);
        assert(is_numeric($diffID));
    }
    if (strcmp(getenv("ROCKSDB_CHECK_ALL"), 1) == 0) {
        // Extract all tests from the CI definition.
        $output = file_get_contents("build_tools/rocksdb-lego-determinator");
        assert(strlen($output) > 0);
        preg_match_all('/[ ]{2}([a-zA-Z0-9_]+)[\\)]{1}/', $output, $matches);
        $tests = $matches[1];
        assert(count($tests) > 0);
    } else {
        // Manually list of tests we want to run in Sandcastle.
        $tests = array("unit", "unit_481", "clang_unit", "tsan", "asan", "lite_test", "valgrind", "release");
    }
    $send_email_template = array('type' => 'email', 'triggers' => array('fail'), 'emails' => array($username . '@fb.com'));
    // Construct a job definition for each test and add it to the master plan.
    foreach ($tests as $test) {
        $stepName = "RocksDB diff " . $diffID . " test " . $test;
        if (!$applyDiff) {
            $stepName = "RocksDB continuous integration test " . $test;
        }
        $arg[] = array("name" => $stepName, "report" => array($send_email_template), "steps" => getSteps($applyDiff, $diffID, $username, $test));
    }
    // We cannot submit the parallel execution master plan to Sandcastle and
    // need supply the job plan as a determinator. So we construct a small job
    // that will spit out the master job plan which Sandcastle will parse and
    // execute. Why compress the job definitions? Otherwise we run over the max
    // string size.
    $cmd = "echo " . base64_encode(json_encode($arg)) . " | gzip -f | base64 -w0";
    assert(strlen($cmd) > 0);
    $arg_encoded = shell_exec($cmd);
    assert(strlen($arg_encoded) > 0);
    $runName = "Run diff " . $diffID . "for user " . $username;
    if (!$applyDiff) {
        $runName = "RocksDB continuous integration build and test run";
    }
    $command = array("name" => $runName, "steps" => array());
    $command["steps"][] = array("name" => "Generate determinator", "shell" => "echo " . $arg_encoded . " | base64 --decode | gzip -d" . " | base64 --decode", "determinator" => true, "user" => "root");
    // Submit to Sandcastle.
    $url = 'https://interngraph.intern.facebook.com/sandcastle/generate?' . 'command=SandcastleUniversalCommand' . '&vcs=rocksdb-git&revision=origin%2Fmaster&type=lego' . '&user='******'&alias=rocksdb-precommit' . '&command-args=' . urlencode(json_encode($command));
    // Fetch the configuration necessary to submit a successful HTTPS request.
    $sandcastle_config = getSandcastleConfig();
    $app = $sandcastle_config[0];
    $token = $sandcastle_config[1];
    $cmd = 'https_proxy= HTTPS_PROXY= curl -s -k -F app=' . $app . ' ' . '-F token=' . $token . ' "' . $url . '"';
    $output = shell_exec($cmd);
    assert(strlen($output) > 0);
    // Extract Sandcastle URL from the response.
    preg_match('/url": "(.+)"/', $output, $sandcastle_url);
    assert(count($sandcastle_url) > 0, "Unable to submit Sandcastle request.");
    assert(strlen($sandcastle_url[1]) > 0, "Unable to extract Sandcastle URL.");
    if ($applyDiff) {
        echo "\nSandcastle URL: " . $sandcastle_url[1] . "\n";
        // Ask Phabricator to display it on the diff UI.
        postURL($diffID, $sandcastle_url[1]);
    } else {
        echo "Continuous integration started Sandcastle tests. You can look at ";
        echo "the progress at:\n" . $sandcastle_url[1] . "\n";
    }
}
 /**
  * Returns a formatted email subject+body for the "mention" activity type.
  *
  * @param array $item The activity item's details.
  * @param array $member The details of the member this activity is for.
  * @return array 0 => email subject, 1 => email body
  */
 public static function mentionEmail($item, $member)
 {
     return array(sprintf(T("email.mention.subject"), name($item["fromMemberName"])), sprintf(T("email.mention.body"), name($item["fromMemberName"]), sanitizeHTML($item["data"]["title"]), URL(postURL($item["data"]["postId"]), true)));
 }
 /**
  * 投稿単位(post)の出力用編集メソッド
  * Format post data into an array which can be used to display the post template view (conversation/post).
  *
  * @param array $post The post data.
  * @param array $conversation The details of the conversation which the post is in.
  * @return array A formatted array which can be used in the post template view.
  */
 protected function formatPostForTemplate($post, $conversation)
 {
     $canEdit = ET::postModel()->canEditPost($post, $conversation);
     $avatar = avatar($post);
     // Construct the post array for use in the post view (conversation/post).
     // title: SWCユーザ名を表示するように設定対応
     // purl: 追加。SNSボタンリンク用に投稿単位の絶対urlを設定
     // likeCnt: 追加。いいねボタンのカウント数設定
     // mainPostFlg: 追加。テーマのメイン投稿(最初の投稿)フラグ
     $formatted = array("id" => "p" . $post["postId"], "conversationId" => $post["conversationId"], "title" => memberLink($post["memberId"], $post["username"]), "avatar" => (!$post["deleteMemberId"] and $avatar) ? "<a href='" . URL(memberURL($post["memberId"], $post["username"])) . "'>{$avatar}</a>" : false, "class" => $post["deleteMemberId"] ? array("deleted") : array(), "info" => array(), "controls" => array(), "body" => !$post["deleteMemberId"] ? $this->displayPost($post["content"]) : false, "footer" => array(), "purl" => URL(postURL($post["postId"]), TRUE), "likeCnt" => $post["likeCnt"], "mainPostFlg" => $post["mainPostFlg"], "data" => array("id" => $post["postId"], "memberid" => $post["memberId"]));
     // いいね済みフラグ
     $formatted["liked"] = $post["likeActivityId"] ? 1 : "";
     //	$date = smartTime($post["time"], true);
     $date = SwcUtils::getStrfTime($post["time"], T("date.short"));
     // Add the date/time to the post info as a permalink.
     $formatted["info"][] = "<a href='" . URL(postURL($post["postId"])) . "' class='time' title='" . strftime(T("date.full"), $post["time"]) . "'>" . (!empty($conversation["searching"]) ? T("Show in context") : $date) . "</a>";
     // If the post isn't deleted, add a lot of stuff!
     if (!$post["deleteMemberId"]) {
         // Add the user's online status / last action next to their name.
         //		if (empty($post["preferences"]["hideOnline"])) {
         //			$lastAction = ET::memberModel()->getLastActionInfo($post["lastActionTime"], $post["lastActionDetail"]);
         //			if ($lastAction[0]) $lastAction[0] = " (".sanitizeHTML($lastAction[0]).")";
         //			if ($lastAction) array_unshift($formatted["info"], "<".(!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span")." class='online' title='".T("Online")."{$lastAction[0]}'><i class='icon-circle'></i></".(!empty($lastAction[1]) ? "a" : "span").">");
         //		}
         // Show the user's group type.
         //		$formatted["info"][] = "<span class='group'>".memberGroup($post["account"], $post["groups"])."</span>";
         $formatted["class"][] = "group-" . $post["account"];
         foreach ($post["groups"] as $k => $v) {
             if ($k) {
                 $formatted["class"][] = "group-" . $k;
             }
         }
         // If the post has been edited, show the time and by whom next to the controls.
         if ($post["editMemberId"]) {
             $formatted["controls"][] = "<span class='editedBy'>" . sprintf(T("Edited %s by %s"), "<span title='" . strftime(T("date.full"), $post["editTime"]) . "'>" . relativeTime($post["editTime"], true) . "</span>", name($post["editMemberName"])) . "</span>";
         }
         // If the user can reply, add a quote control.
         if ($conversation["canReply"]) {
             $formatted["controls"][] = "<a href='" . URL(conversationURL($conversation["conversationId"], $conversation["title"]) . "/?quote=" . $post["postId"] . "#reply") . "' title='" . T("Quote") . "' class='control-quote'><i class='icon-quote-left'></i></a>";
         }
         // If the user can edit the post, add edit/delete controls.
         if ($canEdit) {
             $formatted["controls"][] = "<a href='" . URL("conversation/editPost/" . $post["postId"]) . "' title='" . T("Edit") . "' class='control-edit'><i class='icon-edit'></i></a>";
             $formatted["controls"][] = "<a href='" . URL("conversation/deletePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Delete") . "' class='control-delete'><i class='icon-remove'></i></a>";
         }
     } else {
         // Add the "deleted by" information.
         if ($post["deleteMemberId"]) {
             $formatted["controls"][] = "<span>" . sprintf(T("Deleted %s by %s"), "<span title='" . strftime(T("date.full"), $post["deleteTime"]) . "'>" . relativeTime($post["deleteTime"], true) . "</span>", name($post["deleteMemberName"])) . "</span>";
         }
         // If the user can edit the post, add a restore control.
         if ($canEdit) {
             $formatted["controls"][] = "<a href='" . URL("conversation/restorePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Restore") . "' class='control-restore'><i class='icon-reply'></i></a>";
         }
     }
     $this->trigger("formatPostForTemplate", array(&$formatted, $post, $conversation));
     return $formatted;
 }
 /**
  * Format post data into an array which can be used to display the post template view (conversation/post).
  *
  * @param array $post The post data.
  * @param array $conversation The details of the conversation which the post is in.
  * @return array A formatted array which can be used in the post template view.
  */
 protected function formatPostForTemplate($post, $conversation)
 {
     $canEdit = $this->canEditPost($post, $conversation);
     $avatar = avatar($post["memberId"], $post["avatarFormat"]);
     // Construct the post array for use in the post view (conversation/post).
     $formatted = array("id" => "p" . $post["postId"], "title" => memberLink($post["memberId"], $post["username"]), "avatar" => (!$post["deleteMemberId"] and $avatar) ? "<a href='" . URL(memberURL($post["memberId"], $post["username"])) . "'>{$avatar}</a>" : false, "class" => $post["deleteMemberId"] ? array("deleted") : array(), "info" => array(), "controls" => array(), "body" => !$post["deleteMemberId"] ? $this->displayPost($post["content"]) : false, "data" => array("id" => $post["postId"], "memberid" => $post["memberId"]));
     // If the post was within the last 24 hours, show a relative time (eg. 2 hours ago.)
     if (time() - $post["time"] < 24 * 60 * 60) {
         $date = relativeTime($post["time"], true);
     } else {
         $date = date("M j", $post["time"]);
     }
     // Add the date/time to the post info as a permalink.
     $formatted["info"][] = "<a href='" . URL(postURL($post["postId"])) . "' class='time' title='" . date(T("date.full"), $post["time"]) . "'>" . (!empty($conversation["searching"]) ? T("Context") : $date) . "</a>";
     // If the post isn't deleted, add a lot of stuff!
     if (!$post["deleteMemberId"]) {
         // Add the user's online status / last action next to their name.
         $lastAction = ET::memberModel()->getLastActionInfo($post["lastActionTime"], $post["lastActionDetail"]);
         if ($lastAction[0]) {
             $lastAction[0] = " (" . sanitizeHTML($lastAction[0]) . ")";
         }
         if ($lastAction) {
             array_unshift($formatted["info"], "<" . (!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span") . " class='online' title='" . T("Online") . "{$lastAction[0]}'>" . T("Online") . "</" . (!empty($lastAction[1]) ? "a" : "span") . ">");
         }
         // Show the user's group type.
         $formatted["info"][] = "<span class='group'>" . memberGroup($post["account"], $post["groups"]) . "</span>";
         // If the post has been edited, show the time and by whom next to the controls.
         if ($post["editMemberId"]) {
             $formatted["controls"][] = "<span class='editedBy'>" . sprintf(T("Edited %s by %s"), "<span title='" . date(T("date.full"), $post["editTime"]) . "'>" . relativeTime($post["editTime"], true) . "</span>", $post["editMemberName"]) . "</span>";
         }
         // If the user can reply, add a quote control.
         if ($conversation["canReply"]) {
             $formatted["controls"][] = "<a href='" . URL(conversationURL($conversation["conversationId"], $conversation["title"]) . "/?quote=" . $post["postId"] . "#reply") . "' title='" . T("Quote") . "' class='control-quote'>" . T("Quote") . "</a>";
         }
         // If the user can edit the post, add edit/delete controls.
         if ($canEdit) {
             $formatted["controls"][] = "<a href='" . URL("conversation/editPost/" . $post["postId"]) . "' title='" . T("Edit") . "' class='control-edit'>" . T("Edit") . "</a>";
             $formatted["controls"][] = "<a href='" . URL("conversation/deletePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Delete") . "' class='control-delete'>" . T("Delete") . "</a>";
         }
     } else {
         // Add the "deleted by" information.
         if ($post["deleteMemberId"]) {
             $formatted["controls"][] = "<span>" . sprintf(T("Deleted %s by %s"), "<span title='" . date(T("date.full"), $post["deleteTime"]) . "'>" . relativeTime($post["deleteTime"], true) . "</span>", $post["deleteMemberName"]) . "</span>";
         }
         // If the user can edit the post, add a restore control.
         if ($canEdit) {
             $formatted["controls"][] = "<a href='" . URL("conversation/restorePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Restore") . "' class='control-restore'>" . T("Restore") . "</a>";
         }
     }
     $this->trigger("formatPostForTemplate", array(&$formatted, $post, $conversation));
     return $formatted;
 }
Exemple #10
0
 public static function postMemberNotification(&$item)
 {
     return array(sprintf(T("%s posted in %s."), "<span class='star starOn'>*</span> " . name($item["fromMemberName"]), "<strong>" . sanitizeHTML($item["data"]["title"]) . "</strong>"), URL(postURL($item["postId"])));
 }
 public static function postChannelNotification(&$item)
 {
     return array(sprintf(T("%s posted in %s"), name($item["fromMemberName"]), "<span class='channel channel-" . $item["data"]["channelId"] . "'><i class='star icon-star'></i> " . $item["data"]["channelTitle"] . "</span> <strong>" . sanitizeHTML($item["data"]["title"]) . "</strong>"), URL(postURL($item["postId"])));
 }