/** * Show the sign up sheet and handle input from its form. * * @return void */ public function action_join() { // If we're already logged in, get out of here. if (ET::$session->user) { $this->redirect(URL("")); } // SWC新規登録へ $this->redirect(SwcUtils::getSwcUrl("entry")); // // If registration is closed, show a message. // if (!C("esoTalk.registration.open")) { // $this->renderMessage(T("Registration Closed"), T("message.registrationClosed")); // return; // } // // // Set the title and make sure this page isn't indexed. // $this->title = T("Sign Up"); // $this->addToHead("<meta name='robots' content='noindex, noarchive'/>"); // // // Construct a form. // $form = ETFactory::make("form"); // $form->action = URL("user/join"); // // // Add the username field to the form structure. // $form->addSection("username", T("Username")); // $form->addField("username", "username", function($form) // { // return $form->input("username"); // }, // function($form, $key, &$data) // { // $data["username"] = $form->getValue($key); // }); // // // Add the email field to the form structure. // $form->addSection("email", T("Email")); // $form->addField("email", "email", function($form) // { // return $form->input("email")."<br><small>".T("Used to verify your account and subscribe to conversations")."</small>"; // }, // function($form, $key, &$data) // { // $data["email"] = $form->getValue($key); // }); // // // Add the password field to the form structure. // $form->addSection("password", T("Password")); // $form->addField("password", "password", function($form) // { // return $form->input("password", "password")."<br><small>".sprintf(T("Choose a secure password of at least %s characters"), C("esoTalk.minPasswordLength"))."</small>"; // }, // function($form, $key, &$data) // { // $data["password"] = $form->getValue($key); // }); // // // Add the confirm password field to the form structure. // $form->addSection("confirm", T("Confirm password")); // $form->addField("confirm", "confirm", function($form) // { // return $form->input("confirm", "password"); // }, // function($form, $key, &$data) // { // // Make sure the passwords match. // if ($form->getValue("password") != $form->getValue($key)) // $form->error($key, T("message.passwordsDontMatch")); // }); // // $this->trigger("initJoin", array($form)); // // // If the cancel button was pressed, return to where the user was before. // if ($form->isPostBack("cancel")) $this->redirect(URL(R("return"))); // // // If the form has been submitted, validate it and add the member into the database. // if ($form->validPostBack("submit")) { // // $data = array(); // if ($form->validPostBack()) $form->runFieldCallbacks($data); // // if (!$form->errorCount()) { // // $data["account"] = ACCOUNT_MEMBER; // // if (!C("esoTalk.registration.requireConfirmation")) $data["confirmed"] = true; // else $data["resetPassword"] = md5(uniqid(rand())); // // // Create the member. // $model = ET::memberModel(); // $memberId = $model->create($data); // // // If there were validation errors, pass them to the form. // if ($model->errorCount()) $form->errors($model->errors()); // // else { // // // If we require the user to confirm their email, send them an email and show a message. // if (C("esoTalk.registration.requireConfirmation") == "email") { // $this->sendConfirmationEmail($data["email"], $data["username"], $memberId.$data["resetPassword"]); // $this->renderMessage(T("Success!"), T("message.confirmEmail")); // } // // // If we require the user account to be approved by an administrator, show a message. // elseif (C("esoTalk.registration.requireConfirmation") == "approval") { // $admin = ET::memberModel()->getById(C("esoTalk.rootAdmin")); // ET::activityModel()->create("unapproved", $admin, null, array("username" => $data["username"])); // $this->renderMessage(T("Success!"), T("message.waitForApproval")); // } // // else { // ET::$session->login($form->getValue("username"), $form->getValue("password")); // $this->redirect(URL("")); // } // // return; // // } // // } // // } // // $this->data("form", $form); // $this->render("user/join"); }
/** * Common initialization for all controllers, called on every page load. This will add basic user links to * the "user" menu, and add core JS files and language definitions. * * If this is overridden, parent::init() should be called to maintain consistency between controllers. * * @return void */ public function init() { // Check for updates to the esoTalk software, but only if we're the root admin and we haven't checked in // a while. // 1/28 掲示板バージョンUPチェック処理 削除 // if (ET::$session->userId == C("esoTalk.rootAdmin") and C("esoTalk.admin.lastUpdateCheckTime") + C("esoTalk.updateCheckInterval") < time()) // ET::upgradeModel()->checkForUpdates(); if ($this->responseType === RESPONSE_TYPE_DEFAULT) { // If the user IS NOT logged in, add the 'login' and 'sign up' links to the bar. if (!ET::$session->user) { // 1/28 リンク先変更 SWC新規登録ページへ $this->addToMenu("user", "join", "<a href='" . URL(SwcUtils::getSwcUrl("entry") . "?return=" . urlencode($this->selfURL)) . "' class='link-join'>" . T("Sign Up") . "</a>"); // 1/28 リンク先変更 SWCログインページへ $this->addToMenu("user", "login", "<a href='/login/index.php' class='link-login'>" . T("Log In") . "</a>"); } else { $this->addToMenu("user", "user", "<a href='" . URL("member/me") . "'>" . avatar(ET::$session->user, "thumb") . name(ET::$session->user["username"]) . "</a>"); $this->addToMenu("user", "settings", "<a href='" . URL("settings") . "' class='link-settings'>" . T("Settings") . "</a>"); if (ET::$session->isAdmin()) { $this->addToMenu("user", "administration", "<a href='" . URL("admin") . "' class='link-administration'>" . T("Administration") . "</a>"); } // リンク先変更 ログアウト $this->addToMenu("user", "logout", "<a href='" . URL("user/logout?token=" . ET::$session->token) . "' class='link-logout'>" . T("Log Out") . "</a>"); } // Get the number of members currently online and add it as a statistic. if (C("esoTalk.members.visibleToGuests") or ET::$session->user) { $online = ET::SQL()->select("COUNT(*)")->from("member")->where("UNIX_TIMESTAMP()-:seconds<lastActionTime")->bind(":seconds", C("esoTalk.userOnlineExpire"))->exec()->result(); $stat = Ts("statistic.online", "statistic.online.plural", number_format($online)); $stat = "<a href='" . URL("members/online") . "' class='link-membersOnline'>{$stat}</a>"; // 2016/1 削除 オンラインリンク // $this->addToMenu("statistics", "statistic-online", $stat); } // 2016/1 削除 copyright // $this->addToMenu("meta", "copyright", "<a href='http://esotalk.org/' target='_blank'>".T("Powered by")." esoTalk</a>"); // Set up some default JavaScript files and language definitions. $this->addJSFile("core/js/lib/jquery.js", true); $this->addJSFile("core/js/lib/jquery.misc.js", true); $this->addJSFile("core/js/lib/jquery.history.js", true); $this->addJSFile("core/js/lib/jquery.scrollTo.js", true); $this->addJSFile("core/js/global.js", true); $this->addJSLanguage("message.ajaxRequestPending", "message.ajaxDisconnected", "Loading...", "Notifications"); $this->addJSVar("notificationCheckInterval", C("esoTalk.notificationCheckInterval")); // If config/custom.css contains something, add it to be included in the page. if (file_exists($file = PATH_CONFIG . "/custom.css") and filesize($file) > 0) { $this->addCSSFile("config/custom.css", true); } } $this->trigger("init"); }
/** * 会話(テーマ)新規作成処理 * Show the start conversation page. * * @param string $member A member's name to make the conversation private with. * @return void */ public function action_start($member = false) { // If the user isn't logged in, redirect them to the login page. if (!ET::$session->user) { $this->redirect(SwcUtils::getSwcUrl('login')); } // If the user is suspended, show an error. if (ET::$session->isSuspended()) { $this->renderMessage("Error!", T("message.suspended")); return; } // Set up a form. $form = ETFactory::make("form"); $form->action = URL("conversation/start"); // Get a list of channels so that we can check to make sure a valid channel is selected. $channels = ET::channelModel()->get("start"); $channelId = $form->validPostBack("content") ? ET::$session->get("channelId") : ET::$session->get("searchChannelId"); ET::$session->store("channelId", isset($channels[$channelId]) ? $channelId : reset(array_keys($channels))); // Get an empty conversation. $model = ET::conversationModel(); $conversation = $model->getEmptyConversation(); $conversation["membersAllowed"] = $model->getMembersAllowed($conversation); $conversation["membersAllowedSummary"] = $model->getMembersAllowedSummary($conversation, $conversation["membersAllowed"]); $conversation["channelPath"] = $model->getChannelPath($conversation); // XXX: タグ入力エリア設定 新規作成フラグ設定 $this->data("isStartFlg", 1); if ($this->responseType === RESPONSE_TYPE_DEFAULT) { $this->title = T("New conversation"); // Update the user's last action to say that they're "starting a conversation". ET::memberModel()->updateLastAction("startingConversation"); // Add a meta tag to the head to prevent search engines from indexing this page. $this->addToHead("<meta name='robots' content='noindex, noarchive'/>"); $this->addJSFile("core/js/lib/jquery.autogrow.js"); $this->addJSFile("core/js/scrubber.js"); $this->addJSFile("core/js/autocomplete.js"); // $this->addJSFile("core/js/conversation.js"); TODO: 4 debug $this->addJSFile("/forum/core/js/conversation.js", "last"); // 共通検索用js 追加 $this->addJSFile("core/js/search.conversation.js"); // $this->addJSFile("/forum/core/js/search.conversation.js","last"); $this->addJSVar("mentions", C("esoTalk.format.mentions")); $this->addJSLanguage("message.confirmLeave", "message.confirmDiscardPost"); // TODO: 名前有りの場合 確認 // If there's a member name in the querystring, make the conversation that we're starting private // with them and redirect. if ($member and ET::$session->validateToken(R("token"))) { ET::$session->remove("membersAllowed"); if (!($member = ET::conversationModel()->getMemberFromName($member))) { $this->message(T("message.memberDoesntExist"), "warning"); } else { ET::conversationModel()->addMember($conversation, $member); } $this->redirect(URL("conversation/start")); } } // If the form was submitted (validate the presence of the content field)... if ($form->validPostBack("content")) { // 新規会話(テーマ) 登録時の処理 $model = ET::conversationModel(); $result = $model->create(array("title" => $_POST["title"], "channelId" => ET::$session->get("channelId"), "content" => $_POST["content"]), ET::$session->get("membersAllowed"), $form->isPostBack("saveDraft")); if ($model->errorCount()) { $this->messages($model->errors(), "warning"); } if ($result) { list($conversationId, $postId) = $result; // タグ情報の更新処理 ET::tagsModel()->editPost($conversationId, 1, $form->getValue("tags")); ET::$session->remove("membersAllowed"); ET::$session->remove("channelId"); if ($this->responseType === RESPONSE_TYPE_JSON) { $this->json("url", URL(conversationURL($conversationId, $form->getValue("title")))); $this->json("conversationId", $conversationId); } else { $this->redirect(URL(conversationURL($conversationId, $form->getValue("title")))); } } } // Make a form to add members allowed. $membersAllowedForm = ETFactory::make("form"); $membersAllowedForm->action = URL("conversation/addMember/"); $this->data("conversation", $conversation); $this->data("form", $form); $this->data("membersAllowedForm", $membersAllowedForm); $this->data("replyControls", $this->getEditControls("reply")); $this->render("conversation/edit"); }
<?php if (!$data["searchString"]) { ?> <!-- Reply area --> <div id='conversationReply'> <?php echo $data["replyForm"]->open(); ?> <?php // If we can't reply, we should show some kind of error message. if (!$conversation["canReply"]) { // If the user simply isn't logged in, show a reply box placeholder saying that they need to log in or sign up. if (!ET::$session->user) { $post = array("id" => "reply", "class" => "logInToReply", "title" => "", "body" => sprintf(T("message.logInToReply"), SwcUtils::getSwcUrl('login'), SwcUtils::getSwcUrl('login')), "avatar" => avatar()); $this->renderView("conversation/post", array("post" => $post)); } elseif (ET::$session->isSuspended()) { echo "<p class='help'>" . T("message.suspended") . "</p>"; } elseif ($conversation["locked"]) { echo "<p class='help'>" . T("message.locked") . "</p>"; } } else { $this->renderView("conversation/reply", array("form" => $data["replyForm"], "conversation" => $conversation, "controls" => $data["replyControls"])); } ?> <?php echo $data["replyForm"]->close(); ?> </div>