/** * Return a member's name wrapped in an anchor tag linking to their profile page. * * @param int $memberId The ID of the member. * @param string $username The username of the member. * @return string */ function memberLink($memberId, $username = "") { $displayName = name($username); if ($username) { return "<a href='" . URL(memberURL($memberId, $username)) . "' title='" . sprintf(sanitizeHTML(T("View %s's profile")), $displayName) . "'>{$displayName}</a>"; } else { return $displayName; } }
/** * Show a sheet to delete a member. * * @param int $memberId The member's ID. * @return void */ public function action_delete($memberId = "") { if (!($member = $this->getMember($memberId))) { return; } // If we don't have permission to delete the member, throw an error. if (!ET::memberModel()->canDelete($member)) { $this->renderMessage(T("Error"), T("message.noPermission")); return; } // Construct a form. $form = ETFactory::make("form"); $form->action = URL("member/delete/" . $member["memberId"]); $redirectURL = URL(memberURL($member["memberId"], $member["username"])); if ($form->isPostBack("cancel")) { $this->redirect($redirectURL); } // If the form was submitted, delete the member and take the appropriate action upon all their posts. if ($form->validPostBack("delete")) { ET::memberModel()->deleteById($member["memberId"], $form->getValue("deletePosts")); $this->message(T("message.changesSaved"), "success autoDismiss"); $this->redirect(URL("members")); } $this->data("member", $member); $this->data("form", $form); $this->render("member/delete"); }
/** * Show the "create member" sheet, containing a form to create a new member. * * @return void */ public function create() { // Non-admins can't do this! Suckers. if (!ET::$session->isAdmin()) { return; } // Set up the form. $form = ETFactory::make("form"); $form->action = URL("members/create"); // Was the cancel button pressed? if ($form->isPostBack("cancel")) { $this->redirect(URL(R("return", "members"))); } // Was the "create" button pressed? if ($form->validPostBack("submit")) { // Make sure the passwords match. if ($form->getValue("confirm") != $form->getValue("password")) { $form->error("confirm", T("message.passwordsDontMatch")); } // If there were no preliminary errors, proceed to attempt to create the member with the model. if (!$form->errorCount()) { $data = array("username" => $form->getValue("username"), "email" => $form->getValue("email"), "password" => $form->getValue("password"), "account" => ACCOUNT_MEMBER, "confirmedEmail" => true); $model = ET::memberModel(); $id = $model->create($data); // If there were any errors, pass them back to the form. if ($model->errorCount()) { $form->errors($model->errors()); } else { $this->redirect(URL(memberURL($id, $form->getValue("username")))); } } } $this->data("form", $form); $this->render("members/create"); }
/** * Returns a formatted notification item for the "groupChange" activity type. For example, '[member] changed * your group to [groups].' * * @see postNotification() for parameter and return information. */ public static function groupChangeNotification($item) { $groups = memberGroup($item["data"]["account"], $item["data"]["groups"], true); return array("<i class='icon-user'></i> " . sprintf(T("%s changed your group to %s."), name($item["fromMemberName"]), "<strong>" . $groups . "</strong>"), URL(memberURL("me"))); }
/** * 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; }
public function handler_memberController_initProfile($sender, $member, $panes, $controls, $actions) { $panes->add("about", "<a href='" . URL(memberURL($member["memberId"], $member["username"], "about")) . "'>" . T("About") . "</a>", 0); }
/** * 投稿単位(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; }
<div class='timeMarker'><?php echo $thisPostTime; ?> </div> <?php } $this->renderView("member/activityItem", array("activity" => $item) + $data); ?> </li> <?php } ?> </ol> <?php if ($data["showViewMoreLink"]) { echo "<a href='" . URL(memberURL($member["memberId"], $member["username"], "activity") . "/" . ($data["page"] + 2)) . "' class='button' id='viewMoreActivity'>" . T("View more") . "</a>"; } ?> <?php // Otherwise, output a "no activity" message. } else { ?> <p class='help'><?php printf(T("message.noActivity"), $member["username"]); ?> </p> <?php }
/** * 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; }