コード例 #1
0
ファイル: plugin.php プロジェクト: ZerGabriel/Pages
 public function __construct($rootDirectory)
 {
     parent::__construct($rootDirectory);
     ETFactory::register("pagesModel", "PagesModel", dirname(__FILE__) . "/PagesModel.class.php");
     ETFactory::registerAdminController("pages", "PagesAdminController", dirname(__FILE__) . "/PagesAdminController.class.php");
     ETFactory::registerController("pages", "PagesController", dirname(__FILE__) . "/PagesController.class.php");
 }
コード例 #2
0
 public function action_create()
 {
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/profiles/create");
     // Was the cancel button pressed?
     if ($form->isPostBack("cancel")) {
         $this->redirect(URL("admin/profiles"));
     }
     // Was the save button pressed?
     if ($form->validPostBack("save")) {
         $model = $this->model();
         $data = array("name" => $form->getValue("name"), "description" => $form->getValue("description"), "type" => $form->getValue("type"), "options" => $form->getValue("options"), "showOnPosts" => (bool) $form->getValue("showOnPosts"), "hideFromGuests" => (bool) $form->getValue("hideFromGuests"), "searchable" => (bool) $form->getValue("searchable"), "position" => $model->count());
         $model->create($data);
         // If there were errors, pass them on to the form.
         if ($model->errorCount()) {
             $form->errors($model->errors());
         } else {
             $this->redirect(URL("admin/profiles"));
         }
     }
     $this->data("form", $form);
     $this->data("field", null);
     $this->render($this->plugin()->view("admin/editField"));
 }
コード例 #3
0
 /**
  * Initialize the admin controller. Construct a menu to show all admin panels.
  *
  * @return void
  */
 public function init()
 {
     // If the user isn't an administrator, kick them out.
     if (!ET::$session->isAdmin()) {
         $this->redirect(URL("user/login?return=" . urlencode($this->selfURL)));
     }
     parent::init();
     // Construct the menus for the side bar.
     $this->defaultMenu = ETFactory::make("menu");
     $this->menu = ETFactory::make("menu");
     $this->defaultMenu->add("dashboard", "<a href='" . URL("admin/dashboard") . "'><i class='icon-dashboard'></i> " . T("Dashboard") . "</a>");
     $this->defaultMenu->add("settings", "<a href='" . URL("admin/settings") . "'><i class='icon-cog'></i> " . T("Forum Settings") . "</a>");
     $this->defaultMenu->add("appearance", "<a href='" . URL("admin/appearance") . "'><i class='icon-eye-open'></i> " . T("Appearance") . "</a>");
     $this->defaultMenu->add("channels", "<a href='" . URL("admin/channels") . "'><i class='icon-tags'></i> " . T("Channels") . "</a>");
     $this->defaultMenu->add("members", "<a href='" . URL("members") . "'><i class='icon-group'></i> " . T("Members") . "</a>");
     $this->defaultMenu->add("plugins", "<a href='" . URL("admin/plugins") . "'><i class='icon-puzzle-piece'></i> " . T("Plugins") . "</a>");
     $this->defaultMenu->highlight(ET::$controllerName);
     $this->menu->highlight(ET::$controllerName);
     // If new registrations require admin approval, add the 'unapproved' admin page with a count.
     if (C("esoTalk.registration.requireConfirmation") == "approval") {
         $count = ET::SQL()->select("COUNT(1)")->from("member")->where("confirmed", 0)->exec()->result();
         $this->menu->add("unapproved", "<a href='" . URL("admin/unapproved") . "'><i class='icon-lock'></i> " . T("Unapproved") . " <span class='badge'>" . $count . "</span></a>");
     }
     if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
         $this->pushNavigation("admin", "administration", URL($this->selfURL));
     }
     $this->addJSFile("core/js/admin.js");
     $this->addCSSFile("core/skin/admin.css");
     $this->trigger("initAdmin", array($this->menu, $this->defaultMenu));
 }
コード例 #4
0
ファイル: plugin.php プロジェクト: nowaym/esoTalk
 /**
  * Construct and process the settings form for this skin, and return the path to the view that should be 
  * rendered.
  * 
  * @param ETController $sender The page controller.
  * @return string The path to the settings view to render.
  */
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins");
     $form->setValue("server", C("plugin.SMTP.server"));
     $form->setValue("username", C("plugin.SMTP.username"));
     $form->setValue("password", C("plugin.SMTP.password"));
     $form->setValue("port", C("plugin.SMTP.port"));
     $form->setValue("auth", C("plugin.SMTP.auth"));
     // If the form was submitted...
     if ($form->validPostBack("save")) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.SMTP.server"] = $form->getValue("server");
         $config["plugin.SMTP.username"] = $form->getValue("username");
         $config["plugin.SMTP.password"] = $form->getValue("password");
         $config["plugin.SMTP.port"] = $form->getValue("port");
         $config["plugin.SMTP.auth"] = $form->getValue("auth");
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("smtpSettingsForm", $form);
     return $this->getView("settings");
 }
コード例 #5
0
ファイル: skin.php プロジェクト: AlexandrST/esoTalk
 /**
  * Construct and process the settings form for this skin, and return the path to the view that should be 
  * rendered.
  * 
  * @param ETController $sender The page controller.
  * @return string The path to the settings view to render.
  */
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/appearance");
     $form->setValue("headerColor", C("skin.Default.headerColor"));
     $form->setValue("bodyColor", C("skin.Default.bodyColor"));
     $form->setValue("noRepeat", (bool) C("skin.Default.noRepeat"));
     $form->setValue("bodyImage", (bool) C("skin.Default.bodyImage"));
     // If the form was submitted...
     if ($form->validPostBack("save")) {
         // Construct an array of config options to write.
         $config = array();
         $config["skin.Default.headerColor"] = $form->getValue("headerColor");
         $config["skin.Default.bodyColor"] = $form->getValue("bodyColor");
         // Upload a body bg image if necessary.
         if ($form->getValue("bodyImage") and !empty($_FILES["bodyImageFile"]["tmp_name"])) {
             $config["skin.Default.bodyImage"] = $this->uploadBackgroundImage($form);
         } elseif (!$form->getValue("bodyImage")) {
             $config["skin.Default.bodyImage"] = false;
         }
         $config["skin.Default.noRepeat"] = (bool) $form->getValue("noRepeat");
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success");
             $sender->redirect(URL("admin/appearance"));
         }
     }
     $sender->data("skinSettingsForm", $form);
     $sender->addCSSFile("core/js/lib/farbtastic/farbtastic.css");
     $sender->addJSFile("core/js/lib/farbtastic/farbtastic.js");
     return $this->getView("settings");
 }
コード例 #6
0
ファイル: plugin.php プロジェクト: ky0ncheng/esotalk-for-sae
 public function __construct($rootDirectory)
 {
     parent::__construct($rootDirectory);
     // Register the profile_field model which provides convenient methods to
     // manage profile data.
     ETFactory::register("profileFieldModel", "ProfileFieldModel", dirname(__FILE__) . "/ProfileFieldModel.class.php");
     // Register the profiles admin controller which provides an interface for
     // administrators to manage custom profile fields.
     ETFactory::registerAdminController("profiles", "ProfilesAdminController", dirname(__FILE__) . "/ProfilesAdminController.class.php");
 }
コード例 #7
0
ファイル: plugin.php プロジェクト: ZerGabriel/Sitemap
 public function settings($sender)
 {
     $sender->addCSSFile($this->resource("sitemap.css"));
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/Sitemap");
     // Add the section for the restore element.
     $form->addSection("channels");
     // Add the field for the restore select element.
     $form->addField("channels", "channels", array($this, "renderChannelsField"), array($this, "processChannelsField"));
     $form->setValue("channels[]", C("plugin.Sitemap.channels"));
     // Set the values for the sitemap options.
     $form->setValue("cache", C("plugin.Sitemap.cache", "24"));
     $form->setValue("prio1", C("plugin.Sitemap.priority1", "0.5"));
     $form->setValue("prio2", C("plugin.Sitemap.priority2", "0.6"));
     $form->setValue("prio3", C("plugin.Sitemap.priority3", "0.7"));
     $form->setValue("freq1", C("plugin.Sitemap.frequency1", "daily"));
     $form->setValue("freq2", C("plugin.Sitemap.frequency2", "daily"));
     $form->setValue("freq3", C("plugin.Sitemap.frequency3", "hourly"));
     $form->setValue("auto1", C("plugin.Sitemap.google", true));
     $form->setValue("auto2", C("plugin.Sitemap.bing", true));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Get the value from the dynamically created "compress" field.
         $form->runFieldCallbacks($data);
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.Sitemap.cache"] = $form->getValue("cache");
         $config["plugin.Sitemap.channels"] = array_combine($data["channels"], $data["channels"]);
         $config["plugin.Sitemap.priority1"] = $form->getValue("prio1");
         $config["plugin.Sitemap.priority2"] = $form->getValue("prio2");
         $config["plugin.Sitemap.priority3"] = $form->getValue("prio3");
         $config["plugin.Sitemap.frequency1"] = $form->getValue("freq1");
         $config["plugin.Sitemap.frequency2"] = $form->getValue("freq2");
         $config["plugin.Sitemap.frequency3"] = $form->getValue("freq3");
         $config["plugin.Sitemap.google"] = $form->getValue("auto1");
         $config["plugin.Sitemap.bing"] = $form->getValue("auto2");
         // Write the config file.
         ET::writeConfig($config);
         $this->action_create();
         $sender->message(T("The sitemap has been regenerated!"), "success autoDismiss");
         if (!C("plugin.Sitemap.google") && !C("plugin.Sitemap.bing")) {
             $sender->message(T("Please submit <strong><i>" . C("esoTalk.baseURL") . "sitemap-index.xml</i></strong> to <a href='https://support.google.com/sites/answer/100283?hl=en' target='_blank'>Google Webmaster Tools</a> and <a href='http://www.bing.com/webmaster/help/how-to-submit-sitemaps-82a15bd4' target='_blank'>Bing Webmaster Tools</a>."), "success");
         }
         $this->autoSubmit();
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("SitemapSettingsForm", $form);
     return $this->view("settings");
 }
コード例 #8
0
ファイル: skin.php プロジェクト: ZerGabriel/Doragon-Skin
 /**
  * Construct and process the settings form for this skin, and return the path to the view that should be 
  * rendered.
  * 
  * @param ETController $sender The page controller.
  * @return string The path to the settings view to render.
  */
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/appearance");
     $form->setValue("primaryColor", C("skin.Doragon.primaryColor"));
     // If the form was submitted...
     if ($form->validPostBack("save")) {
         $this->writeColors($form->getValue("primaryColor"));
         $sender->message(T("message.changesSaved"), "success autoDismiss");
         $sender->redirect(URL("admin/appearance"));
     }
     $sender->data("skinSettingsForm", $form);
     $sender->addJSFile("core/js/lib/farbtastic.js");
     return $this->view("settings");
 }
コード例 #9
0
ファイル: plugin.php プロジェクト: m-mori/forum
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/GoogleAnalytics");
     $form->setValue("trackingId", C("GoogleAnalytics.trackingId"));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Construct an array of config options to write.
         $config = array();
         $config["GoogleAnalytics.trackingId"] = $form->getValue("trackingId");
         // Write the config file.
         ET::writeConfig($config);
         $sender->message(T("message.changesSaved"), "success autoDismiss");
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("googleAnalyticsSettingsForm", $form);
     return $this->view("settings");
 }
コード例 #10
0
ファイル: plugin.php プロジェクト: jpearman/Signature
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/Signature");
     // Set the values for the sitemap options.
     $form->setValue("characters", C("plugin.Signature.characters", "150"));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.Signature.characters"] = $form->getValue("characters");
         // Write the config file.
         ET::writeConfig($config);
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("SignatureSettingsForm", $form);
     return $this->view("settings");
 }
コード例 #11
0
ファイル: plugin.php プロジェクト: AlexandrST/esoTalk
 public function settings($sender)
 {
     // Expand the filters array into a string that will go in the textarea.
     $filters = C("plugin.WordFilter.filters", array());
     $filterText = "";
     foreach ($filters as $word => $replacement) {
         $filterText .= $word . ($replacement ? "|{$replacement}" : "") . "\n";
     }
     $filterText = trim($filterText);
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins");
     $form->setValue("filters", $filterText);
     // If the form was submitted...
     if ($form->validPostBack("wordFilterSave")) {
         // Create an array of word filters from the contents of the textarea.
         // Each line is a new element in the array; keys and values are separated by a | character.
         $filters = array();
         $lines = explode("\n", strtr($form->getValue("filters"), array("\r\n" => "\n", "\r" => "\n")));
         foreach ($lines as $line) {
             if (!$line) {
                 continue;
             }
             $parts = explode("|", $line, 2);
             if (!$parts[0]) {
                 continue;
             }
             $filters[$parts[0]] = @$parts[1];
         }
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.WordFilter.filters"] = $filters;
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("wordFilterSettingsForm", $form);
     return $this->getView("settings");
 }
コード例 #12
0
 /**
  * Initialize the admin controller. Construct a menu to show all admin panels.
  *
  * @return void
  */
 public function init()
 {
     // If the user isn't an administrator, kick them out.
     if (!ET::$session->isAdmin()) {
         $this->redirect(URL("user/login?return=" . urlencode($this->selfURL)));
     }
     parent::init();
     // Construct the menus for the side bar.
     $this->defaultMenu = ETFactory::make("menu");
     $this->menu = ETFactory::make("menu");
     $this->defaultMenu->add("dashboard", "<a href='" . URL("admin/dashboard") . "'>" . T("Dashboard") . "</a>");
     $this->defaultMenu->add("settings", "<a href='" . URL("admin/settings") . "'>" . T("Forum Settings") . "</a>");
     $this->defaultMenu->add("appearance", "<a href='" . URL("admin/appearance") . "'>" . T("Appearance") . "</a>");
     $this->defaultMenu->add("channels", "<a href='" . URL("admin/channels") . "'>" . T("Channels") . "</a>");
     $this->defaultMenu->add("plugins", "<a href='" . URL("admin/plugins") . "'>" . T("Plugins") . "</a>");
     $this->defaultMenu->highlight(ET::$controllerName);
     $this->menu->highlight(ET::$controllerName);
     $this->addJSFile("js/admin.js");
     $this->addCSSFile("skins/base/admin.css");
 }
コード例 #13
0
 /**
  * Show and process the settings form.
  *
  * @return void
  */
 public function index()
 {
     // Make an array of languages for the default forum language select.
     $languages = array();
     foreach (ET::getLanguages() as $v) {
         $languages[$v] = ET::$languageInfo[$v]["name"];
     }
     // Get a list of member groups.
     $groups = ET::groupModel()->getAll();
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/settings");
     // Set the default values for the forum inputs.
     $form->setValue("forumTitle", C("esoTalk.forumTitle"));
     $form->setValue("language", C("esoTalk.language"));
     $form->setValue("forumHeader", C("esoTalk.forumLogo") ? "image" : "title");
     $form->setValue("defaultRoute", C("esoTalk.defaultRoute"));
     $form->setValue("registrationOpen", C("esoTalk.registration.open"));
     $form->setValue("memberListVisibleToGuests", C("esoTalk.members.visibleToGuests"));
     $form->setValue("requireAdminApproval", C("esoTalk.registration.requireAdminApproval"));
     $form->setValue("requireEmailConfirmation", C("esoTalk.registration.requireEmailConfirmation"));
     // If the save button was clicked...
     if ($form->validPostBack("save")) {
         // Construct an array of config options to write.
         $config = array("esoTalk.forumTitle" => $form->getValue("forumTitle"), "esoTalk.language" => $form->getValue("language"), "esoTalk.forumLogo" => $form->getValue("forumHeader") == "image" ? $this->uploadHeaderImage($form) : false, "esoTalk.defaultRoute" => $form->getValue("defaultRoute"), "esoTalk.registration.open" => $form->getValue("registrationOpen"), "esoTalk.registration.requireEmailConfirmation" => $form->getValue("requireEmailConfirmation"), "esoTalk.members.visibleToGuests" => $form->getValue("memberListVisibleToGuests"));
         // Make sure a forum title is present.
         if (!strlen($config["esoTalk.forumTitle"])) {
             $form->error("forumTitle", T("message.empty"));
         }
         if (!$form->errorCount()) {
             ET::writeConfig($config);
             $this->message(T("message.changesSaved"), "success");
             $this->redirect(URL("admin/settings"));
         }
     }
     $this->data("form", $form);
     $this->data("languages", $languages);
     $this->data("groups", $groups);
     $this->title = T("Forum Settings");
     $this->render("admin/settings");
 }
コード例 #14
0
 public function create()
 {
     $form = ETFactory::make("form");
     $form->action = URL("admin/pages/create");
     if ($form->isPostBack("cancel")) {
         $this->redirect(URL("admin/pages"));
     }
     if ($form->validPostBack("save")) {
         $model = $this->model();
         $data = array("title" => $form->getValue("title"), "content" => $form->getValue("content"), "slug" => slug($form->getValue("slug")), "hideFromGuests" => (bool) $form->getValue("hideFromGuests"), "menu" => $form->getValue("menu"), "position" => $model->count());
         $model->create($data);
         if ($model->errorCount()) {
             $form->errors($model->errors());
         } else {
             $this->redirect(URL("admin/pages"));
         }
     }
     $this->data("form", $form);
     $this->data("page", null);
     $this->render($this->plugin()->getView("admin/editPage"));
 }
コード例 #15
0
ファイル: plugin.php プロジェクト: ZerGabriel/Reputation
 public function settings($sender)
 {
     // Set up the settings form. Set some default values for the first time.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/Reputation");
     $form->setValue("showReputationPublic", C("plugin.Reputation.showReputationPublic", "0"));
     $form->setValue("conversationStartRP", C("plugin.Reputation.conversationStartRP", "10"));
     $form->setValue("getReplyRP", C("plugin.Reputation.getReplyRP", "5"));
     $form->setValue("viewsRP", C("plugin.Reputation.viewsRP", "0"));
     $form->setValue("likesRP", C("plugin.Reputation.likesRP", "5"));
     $form->setValue("replyRP", C("plugin.Reputation.replyRP", "5"));
     $form->setValue("newReputationUpdate", C("plugin.Reputation.newReputationUpdate", "0"));
     // If the form was submitted...
     if ($form->validPostBack("reputationSave")) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.Reputation.showReputationPublic"] = $form->getValue("showReputationPublic");
         $config["plugin.Reputation.conversationStartRP"] = $form->getValue("conversationStartRP");
         $config["plugin.Reputation.getReplyRP"] = $form->getValue("getReplyRP");
         $config["plugin.Reputation.replyRP"] = $form->getValue("replyRP");
         $config["plugin.Reputation.viewsRP"] = $form->getValue("viewsRP");
         $config["plugin.Reputation.likesRP"] = $form->getValue("likesRP");
         $config["plugin.Reputation.newReputationUpdate"] = $form->getValue("newReputationUpdate");
         // Update reputatoin ponits in databse according to new formula
         if (C("plugin.Reputation.newReputationUpdate") == 1) {
             $this->updateNewReputation(C("plugin.Reputation.replyRP"), C("plugin.Reputation.conversationStartRP"), C("plugin.Reputation.viewsRP"), C("plugin.Reputation.likesRP"), C("plugin.Reputation.getReplyRP"));
             $config["plugin.Reputation.newReputationUpdate"] = 0;
         }
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success autoDismiss");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("reputationSettingsForm", $form);
     return $this->view("settings");
 }
コード例 #16
0
ファイル: plugin.php プロジェクト: ZerGabriel/MenuLinks
 /**
  * Setting form on admin panel
  */
 public function settings($sender)
 {
     $form = ETFactory::make('form');
     $form->action = URL('admin/plugins');
     $form->setValue('linksBottomMenu', $this->c['linksBottomMenu']);
     $form->setValue('linksTopMenu', $this->c['linksTopMenu']);
     $form->setValue('beforeBody', $this->c['beforeBody']);
     $form->setValue('headSection', $this->c['headSection']);
     if ($form->validPostBack("MenuLinksSave")) {
         $config = array();
         $config['plugin.MenuLinks.linksBottomMenu'] = $form->getValue('linksBottomMenu');
         $config['plugin.MenuLinks.linksTopMenu'] = $form->getValue('linksTopMenu');
         $config['plugin.MenuLinks.beforeBody'] = $form->getValue('beforeBody');
         $config['plugin.MenuLinks.headSection'] = $form->getValue('headSection');
         if (!$form->errorCount()) {
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success autoDismiss");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("MenuLinks", $form);
     return $this->getView("settings");
 }
コード例 #17
0
 /**
  * Show a sheet to create a new group.
  *
  * @return void
  */
 public function action_create()
 {
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/groups/create");
     // Was the cancel button pressed?
     if ($form->isPostBack("cancel")) {
         $this->redirect(URL("admin/groups"));
     }
     // Was the save button pressed?
     if ($form->validPostBack("save")) {
         $data = array("name" => $form->getValue("name"), "canSuspend" => (bool) $form->getValue("canSuspend"), "private" => (bool) $form->getValue("private"));
         $model = ET::groupModel();
         $groupId = $model->create($data);
         // If there were errors, pass them on to the form.
         if ($model->errorCount()) {
             $form->errors($model->errors());
         } else {
             // Do we want to give this group the moderate permission on all existing channels?
             if ($form->getValue("giveModeratePermission")) {
                 // Go through all the channels and construct an array of rows to insert into the channel_group table.
                 $channels = ET::channelModel()->getAll();
                 $inserts = array();
                 foreach ($channels as $id => $channel) {
                     $inserts[] = array($id, $groupId, 1, 1, 1, 1);
                 }
                 // Insert them!
                 ET::SQL()->insert("channel_group")->setMultiple(array("channelId", "groupId", "view", "reply", "start", "moderate"), $inserts)->setOnDuplicateKey("moderate", 1)->exec();
             }
             // Redirect back to the groups page.
             $this->redirect(URL("admin/groups"));
         }
     }
     $this->data("form", $form);
     $this->data("group", null);
     $this->render("admin/editGroup");
 }
コード例 #18
0
ファイル: plugin.php プロジェクト: jgknight/reCAPTCHA
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/reCAPTCHA");
     $form->setValue("secretkey", C("plugin.reCAPTCHA.secretkey"));
     $form->setValue("sitekey", C("plugin.reCAPTCHA.sitekey"));
     $form->setValue("language", C("plugin.reCAPTCHA.language"));
     $form->setValue("language", C("plugin.reCAPTCHA.language", "en"));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.reCAPTCHA.secretkey"] = $form->getValue("secretkey");
         $config["plugin.reCAPTCHA.sitekey"] = $form->getValue("sitekey");
         $config["plugin.reCAPTCHA.language"] = $form->getValue("language");
         // Write the config file.
         ET::writeConfig($config);
         $sender->message(T("message.changesSaved"), "success autoDismiss");
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("reCAPTCHASettingsForm", $form);
     return $this->view("settings");
 }
コード例 #19
0
ファイル: ET.class.php プロジェクト: m-mori/forum
 /**
  * Get an instance of the class specified by $factoryName. So that we don't constantly get new instances and
  * increase overhead, we store instances in ET::$instances and reuse them as needed.
  *
  * @return mixed An instance of the specified class.
  */
 public static function getInstance($factoryName)
 {
     if (!isset(self::$instances[$factoryName])) {
         self::$instances[$factoryName] = ETFactory::make($factoryName);
     }
     return self::$instances[$factoryName];
 }
コード例 #20
0
 /**
  * Add an item to one of the master view's menus.
  *
  * @param string $menu The name of the menu.
  * @param string $id The name of this menu item.
  * @param string $html The content of this menu item.
  * @param mixed $position Where to put this menu item relative to the others.
  * @see addToArray()
  * @return void
  */
 public function addToMenu($menu, $id, $html, $position = false)
 {
     if (empty($this->menus[$menu])) {
         $this->menus[$menu] = ETFactory::make("menu");
     }
     $this->menus[$menu]->add($id, $html, $position);
 }
コード例 #21
0
 /**
  * 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");
 }
コード例 #22
0
 /**
  * Edit a post.
  *
  * @param int $postId The post ID.
  * @return void
  */
 public function action_editPost($postId = false)
 {
     if (!($post = $this->getPostForEditing($postId))) {
         return;
     }
     // Set up a form.
     $form = ETFactory::make("form");
     $form->action = URL("conversation/editPost/" . $post["postId"]);
     $form->setValue("content", $post["content"]);
     if ($form->isPostBack("cancel")) {
         $this->redirect(URL(R("return", postURL($postId))));
     }
     // Are we saving the post?
     if ($form->validPostBack("save")) {
         $model = ET::postModel();
         $model->editPost($post, $form->getValue("content"));
         if ($model->errorCount()) {
             $this->messages($model->errors(), "warning");
         } else {
             $this->trigger("editPostAfter", array(&$post));
             // Normally, redirect back to the conversation.
             if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
                 redirect(URL(R("return", postURL($postId))));
             } elseif ($this->responseType === RESPONSE_TYPE_AJAX) {
                 $this->data("post", $this->formatPostForTemplate($post, $post["conversation"]));
                 $this->render("conversation/post");
                 return;
             } else {
                 // JSON?
             }
         }
     }
     $this->data("form", $form);
     $this->data("post", $post);
     $this->data("controls", $this->getEditControls("p" . $post["postId"]));
     $this->render("conversation/editPost");
 }
コード例 #23
0
 /**
  * Delete a channel.
  *
  * @param int $channelId The ID of the channel to delete.
  * @return void
  */
 public function action_delete($channelId)
 {
     // Get the channel.
     $channels = ET::channelModel()->getAll();
     if (!isset($channels[$channelId])) {
         return;
     }
     $channel = $channels[$channelId];
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/channels/delete/" . $channelId);
     $form->setValue("method", "move");
     // If the form was submitted...
     if ($form->validPostBack("delete")) {
         // If this is the last channel, we can't delete it.
         if (count($channels) == 1) {
             $this->message(T("message.cannotDeleteLastChannel"), "warning");
         } else {
             // Attempt to delete the channel.
             $model = ET::channelModel();
             $model->deleteById($channelId, $form->getValue("method") == "move" ? (int) $form->getValue("moveToChannelId") : false);
             // If there were errors, pass them on to the form.
             if ($model->errorCount()) {
                 $form->errors($model->errors());
             } else {
                 $this->message(T("message.changesSaved"), "success autoDismiss");
                 $this->redirect(URL("admin/channels"));
             }
         }
     }
     $this->data("channels", $channels);
     $this->data("channel", $channel);
     $this->data("form", $form);
     $this->render("admin/deleteChannel");
 }
コード例 #24
0
 /**
  * Show and process the settings form.
  *
  * @return void
  */
 public function action_index()
 {
     // Make an array of languages for the default forum language select.
     $languages = array();
     foreach (ET::getLanguages() as $v) {
         $languages[$v] = ET::$languageInfo[$v]["name"];
     }
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/settings");
     // Set the default values for the forum inputs.
     $form->setValue("forumTitle", C("esoTalk.forumTitle"));
     $form->setValue("language", C("esoTalk.language"));
     $form->setValue("forumHeader", C("esoTalk.forumLogo") ? "image" : "title");
     $form->setValue("defaultRoute", C("esoTalk.defaultRoute"));
     $form->setValue("forumVisibleToGuests", C("esoTalk.visibleToGuests"));
     $form->setValue("memberListVisibleToGuests", C("esoTalk.members.visibleToGuests"));
     $form->setValue("registrationOpen", C("esoTalk.registration.open"));
     $form->setValue("requireConfirmation", C("esoTalk.registration.requireConfirmation"));
     $c = C("esoTalk.conversation.editPostTimeLimit");
     if ($c === -1) {
         $form->setValue("editPostMode", "forever");
     } elseif ($c === "reply") {
         $form->setValue("editPostMode", "reply");
     } else {
         $form->setValue("editPostMode", "custom");
         $form->setValue("editPostTimeLimit", $c);
     }
     // If the save button was clicked...
     if ($form->validPostBack("save")) {
         $forumLogo = false;
         if ($form->getValue("forumHeader") == "image") {
             if ($form->getValue("forumHeaderOld") != "image") {
                 $forumLogo = $this->uploadHeaderImage($form);
             } else {
                 $forumLogo = !empty($_FILES["forumHeaderImage"]['tmp_name']) ? $this->uploadHeaderImage($form) : C("esoTalk.forumLogo");
             }
         }
         // Construct an array of config options to write.
         $config = array("esoTalk.forumTitle" => $form->getValue("forumTitle"), "esoTalk.language" => $form->getValue("language"), "esoTalk.forumLogo" => $forumLogo, "esoTalk.defaultRoute" => $form->getValue("defaultRoute"), "esoTalk.visibleToGuests" => $form->getValue("forumVisibleToGuests"), "esoTalk.members.visibleToGuests" => $form->getValue("forumVisibleToGuests") and $form->getValue("memberListVisibleToGuests"), "esoTalk.registration.open" => $form->getValue("registrationOpen"), "esoTalk.registration.requireConfirmation" => in_array($v = $form->getValue("requireConfirmation"), array(false, "email", "approval")) ? $v : false);
         switch ($form->getValue("editPostMode")) {
             case "forever":
                 $config["esoTalk.conversation.editPostTimeLimit"] = -1;
                 break;
             case "reply":
                 $config["esoTalk.conversation.editPostTimeLimit"] = "reply";
                 break;
             case "custom":
                 $config["esoTalk.conversation.editPostTimeLimit"] = (int) $form->getValue("editPostTimeLimit");
                 break;
         }
         // Make sure a forum title is present.
         if (!strlen($config["esoTalk.forumTitle"])) {
             $form->error("forumTitle", T("message.empty"));
         }
         if (!$form->errorCount()) {
             ET::writeConfig($config);
             $this->message(T("message.changesSaved"), "success autoDismiss");
             $this->redirect(URL("admin/settings"));
         }
     }
     $this->data("form", $form);
     $this->data("languages", $languages);
     $this->title = T("Forum Settings");
     $this->render("admin/settings");
 }
コード例 #25
0
ファイル: bootstrap.php プロジェクト: 19eighties/esoTalk
        if (!class_exists($className)) {
            continue;
        }
        ET::$plugins[$v] = new $className("addons/plugins/" . $v);
        ET::$plugins[$v]->boot();
    }
}
//***** 6. INITIALIZE SESSION AND DATABASE, AND CACHE
// Initialize the cache.
$cacheClass = C("esoTalk.cache");
ET::$cache = ETFactory::make($cacheClass ? $cacheClass : "cache");
// Connect to the database.
ET::$database = ETFactory::make("database");
ET::$database->init(C("esoTalk.database.host"), C("esoTalk.database.user"), C("esoTalk.database.password"), C("esoTalk.database.dbName"), C("esoTalk.database.prefix"), C("esoTalk.database.connectionOptions"), C("esoTalk.database.port"));
// Initialize the session.
ET::$session = ETFactory::make("session");
// Check if any plugins need upgrading by comparing the versions in ET::$pluginInfo with the versions in
// ET::$config.
foreach (ET::$plugins as $k => $v) {
    if (C("{$k}.version") != ET::$pluginInfo[$k]["version"]) {
        if ($v->setup(C("{$k}.version"))) {
            ET::writeConfig(array("{$k}.version" => ET::$pluginInfo[$k]["version"]));
        }
    }
}
//***** 7. PARSE REQUEST
// If $_GET["p"] was explicitly specified, use that.
if (!empty($_GET["p"])) {
    $request = $_GET["p"];
    unset($_GET["p"]);
} elseif (C("esoTalk.urls.friendly") and isset($_SERVER["REQUEST_URI"])) {
コード例 #26
0
/**
 * Parse an array of request parts (eg. $_GET["p"] exploded by "/"), work out what controller to set up,
 * instantiate it, and work out the method + arguments to dispatch to it.
 *
 * @param array $parts An array of parts of the request.
 * @param array $controllers An array of available controllers, with the keys as the controller names and the
 * 		values as the factory names.
 * @return array An array of information about the response:
 * 		0 => the controller name
 * 		1 => the controller instance
 * 		2 => the method to dispatch
 * 		3 => the arguments to pass when dispatching
 * 		4 => the response type to use
 *
 * @package esoTalk
 */
function parseRequest($parts, $controllers)
{
    $c = strtolower(@$parts[0]);
    $method = "index";
    $type = RESPONSE_TYPE_DEFAULT;
    // If the specified controller doesn't exist, 404.
    if (!isset($controllers[$c])) {
        ET::notFound();
    }
    // Make an instance of the controller.
    $controller = ETFactory::make($controllers[$c]);
    // Determine the controller method and response type to use. Default to index.
    $arguments = array_slice($parts, 2);
    if (!empty($parts[1])) {
        $method = strtolower($parts[1]);
        // If there's a period in the method string, use the first half as the method and the second half as the response type.
        if (strpos($method, ".") !== false) {
            list($method, $suffix) = explode(".", $method, 2);
            if (in_array($suffix, array(RESPONSE_TYPE_VIEW, RESPONSE_TYPE_JSON, RESPONSE_TYPE_AJAX, RESPONSE_TYPE_ATOM))) {
                $type = $suffix;
            }
        }
        // Get all of the action methods in the controller class.
        $methods = get_class_methods($controller);
        foreach ($methods as $k => $v) {
            if (strpos($v = strtolower($v), "action_") !== 0) {
                unset($methods[$k]);
                continue;
            }
            $methods[$k] = substr($v, 7);
        }
        // If the method we want to use doesn't exist in the controller...
        if (!$method or !in_array($method, $methods)) {
            // Search for a plugin with this method. If found, use that.
            $found = false;
            foreach (ET::$plugins as $plugin) {
                if (method_exists($plugin, "action_" . $c . "Controller_" . $method)) {
                    $found = true;
                    break;
                }
            }
            // If one wasn't found, default to the "action_index" method.
            if (!$found) {
                $method = "index";
                $arguments = array_slice($parts, 1);
            }
        }
    }
    return array($c, $controller, $method, $arguments, $type);
}
コード例 #27
0
 /**
  * Display a list of conversations, optionally filtered by channel(s) and a search string.
  *
  * @return void
  */
 public function action_index($channelSlug = false)
 {
     if (!$this->allowed()) {
         return;
     }
     list($channelInfo, $currentChannels, $channelIds, $includeDescendants) = $this->getSelectedChannels($channelSlug);
     // Now we need to construct some arrays to determine which channel "tabs" to show in the view.
     // $channels is a list of channels with the same parent as the current selected channel(s).
     // $path is a breadcrumb trail to the depth of the currently selected channel(s).
     $channels = array();
     $path = array();
     // Work out what channel we will use as the "parent" channel. This will be the last item in $path,
     // and its children will be in $channels.
     $curChannel = false;
     // If channels have been selected, use the first of them.
     if (count($currentChannels)) {
         $curChannel = $channelInfo[$currentChannels[0]];
     }
     // If the currently selected channel has no children, or if we're not including descendants, use
     // its parent as the parent channel.
     if ($curChannel and $curChannel["lft"] >= $curChannel["rgt"] - 1 or !$includeDescendants) {
         $curChannel = @$channelInfo[$curChannel["parentId"]];
     }
     // If no channel is selected, make a faux parent channel.
     if (!$curChannel) {
         $curChannel = array("lft" => 0, "rgt" => PHP_INT_MAX, "depth" => -1);
     }
     // Now, finally, go through all the channels and add ancestors of the "parent" channel to the $path,
     // and direct children to the list of $channels. Make sure we don't include any channels which
     // the user has unsubscribed to.
     foreach ($channelInfo as $channel) {
         if ($channel["lft"] > $curChannel["lft"] and $channel["rgt"] < $curChannel["rgt"] and $channel["depth"] == $curChannel["depth"] + 1 and empty($channel["unsubscribed"])) {
             $channels[] = $channel;
         } elseif ($channel["lft"] <= $curChannel["lft"] and $channel["rgt"] >= $curChannel["rgt"]) {
             $path[] = $channel;
         }
     }
     // Store the currently selected channel in the session, so that it can be automatically selected
     // if "New conversation" is clicked.
     if (!empty($currentChannels)) {
         ET::$session->store("searchChannelId", $currentChannels[0]);
     }
     // Get the search string request value.
     $searchString = R("search");
     // Last, but definitely not least... perform the search!
     $search = ET::searchModel();
     $conversationIDs = $search->getConversationIDs($channelIds, $searchString, count($currentChannels) or !ET::$session->userId);
     // If this page was originally accessed at conversations/markAsRead/all?search=whatever (the
     // markAsRead method simply calls the index method), then mark the results as read.
     if ($this->controllerMethod == "markasread" and ET::$session->userId) {
         ET::conversationModel()->markAsRead($conversationIDs, ET::$session->userId);
     }
     $results = $search->getResults($conversationIDs);
     // Were there any errors? Show them as messages.
     if ($search->errorCount()) {
         $this->messages($search->errors(), "warning dismissable");
     } else {
         $this->highlight($search->fulltext);
     }
     // Pass on a bunch of data to the view.
     $this->data("results", $results);
     $this->data("limit", $search->limit);
     $this->data("showViewMoreLink", $search->areMoreResults());
     $this->data("channelPath", $path);
     $this->data("channelTabs", $channels);
     $this->data("currentChannels", $currentChannels);
     $this->data("channelInfo", $channelInfo);
     $this->data("channelSlug", $channelSlug = $channelSlug ? $channelSlug : "all");
     $this->data("searchString", $searchString);
     $this->data("fulltextString", implode(" ", $search->fulltext));
     // Construct a canonical URL and add to the breadcrumb stack.
     $slugs = array();
     foreach ($currentChannels as $channel) {
         $slugs[] = $channelInfo[$channel]["slug"];
     }
     $url = "conversations/" . urlencode(($k = implode(" ", $slugs)) ? $k : "all") . ($searchString ? "?search=" . urlencode($searchString) : "");
     $this->pushNavigation("conversations", "search", URL($url));
     $this->canonicalURL = URL($url, true);
     // If we're loading the page in full...
     if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
         // Update the user's last action.
         ET::memberModel()->updateLastAction("search");
         // Add a link to the RSS feed in the bar.
         // $this->addToMenu("meta", "feed", "<a href='".URL(str_replace("conversations/", "conversations/index.atom/", $url))."' id='feed'>".T("Feed")."</a>");
         $controls = ETFactory::make("menu");
         // Mark as read controls
         if (ET::$session->user) {
             $controls->add("markAllAsRead", "<a href='" . URL("conversations/markAllAsRead/?token=" . ET::$session->token . "' id='control-markAllAsRead'><i class='icon-check'></i> " . T("Mark all as read") . "</a>"));
             $controls->add("markListedAsRead", "<a href='" . URL("conversations/{$channelSlug}/?search=" . urlencode($searchString) . "&markAsRead=1&token=" . ET::$session->token . "' id='control-markListedAsRead'><i class='icon-list'></i> " . T("Mark listed as read") . "</a>"));
         }
         // Add the default gambits to the gambit cloud: gambit text => css class to apply.
         $gambits = array("main" => array(T("gambit.sticky") => array("gambit-sticky", "icon-pushpin")), "time" => array(T("gambit.order by newest") => array("gambit-orderByNewest", "icon-list-ol"), T("gambit.active last ? hours") => array("gambit-activeLastHours", "icon-time"), T("gambit.active last ? days") => array("gambit-activeLastDays", "icon-calendar"), T("gambit.active today") => array("gambit-activeToday", "icon-asterisk"), T("gambit.dead") => array("gambit-dead", "icon-remove"), T("gambit.locked") => array("gambit-locked", "icon-lock")), "member" => array(T("gambit.author:") . T("gambit.member") => array("gambit-author", "icon-user"), T("gambit.contributor:") . T("gambit.member") => array("gambit-contributor", "icon-user")), "replies" => array(T("gambit.has replies") => array("gambit-hasReplies", "icon-comment"), T("gambit.has >10 replies") => array("gambit-replies", "icon-comments"), T("gambit.order by replies") => array("gambit-orderByReplies", "icon-list-ol")), "text" => array(T("gambit.title:") . " ?" => array("gambit-title", "icon-font")), "misc" => array(T("gambit.random") => array("gambit-random", "icon-random"), T("gambit.reverse") => array("gambit-reverse", "icon-exchange")));
         // Add some more personal gambits if there is a user logged in.
         if (ET::$session->user) {
             addToArrayString($gambits["main"], T("gambit.private"), array("gambit-private", "icon-envelope-alt"), 1);
             addToArrayString($gambits["main"], T("gambit.starred"), array("gambit-starred", "icon-star"), 2);
             addToArrayString($gambits["main"], T("gambit.draft"), array("gambit-draft", "icon-pencil"), 3);
             addToArrayString($gambits["main"], T("gambit.ignored"), array("gambit-ignored", "icon-eye-close"), 4);
             addToArrayString($gambits["time"], T("gambit.unread"), array("gambit-unread", "icon-inbox"), 0);
             addToArrayString($gambits["member"], T("gambit.author:") . T("gambit.myself"), array("gambit-authorMyself", "icon-smile"), 0);
             addToArrayString($gambits["member"], T("gambit.contributor:") . T("gambit.myself"), array("gambit-contributorMyself", "icon-smile"), 2);
         }
         $this->trigger("constructGambitsMenu", array(&$gambits));
         // Construct the gambits menu based on the above arrays.
         $gambitsMenu = ETFactory::make("menu");
         $linkPrefix = "conversations/" . $channelSlug . "/?search=" . urlencode(!empty($searchString) ? $searchString . " + " : "");
         foreach ($gambits as $section => $items) {
             foreach ($items as $gambit => $classes) {
                 $gambitsMenu->add($classes[0], "<a href='" . URL($linkPrefix . urlencode("#" . $gambit)) . "' class='{$classes[0]}' data-gambit='{$gambit}'>" . (!empty($classes[1]) ? "<i class='{$classes[1]}'></i> " : "") . "{$gambit}</a>");
             }
             end($gambits);
             if ($section !== key($gambits)) {
                 $gambitsMenu->separator();
             }
         }
         $this->data("controlsMenu", $controls);
         $this->data("gambitsMenu", $gambitsMenu);
         // Construct a list of keywords to use in the meta tags.
         $keywords = array();
         foreach ($channelInfo as $c) {
             if ($c["depth"] == 0) {
                 $keywords[] = strtolower($c["title"]);
             }
         }
         // Add meta tags to the header.
         $this->addToHead("<meta name='keywords' content='" . sanitizeHTML(($k = C("esoTalk.meta.keywords")) ? $k : implode(",", $keywords)) . "'>");
         $lastKeyword = reset(array_splice($keywords, count($keywords) - 1, 1));
         $this->addToHead("<meta name='description' content='" . sanitizeHTML(($d = C("esoTalk.meta.description")) ? $d : sprintf(T("forumDescription"), C("esoTalk.forumTitle"), implode(", ", $keywords), $lastKeyword)) . "'>");
         // If this is not technically the homepage (if it's a search page) the we don't want it to be indexed.
         if ($searchString) {
             $this->addToHead("<meta name='robots' content='noindex, noarchive'>");
         }
         // Add JavaScript language definitions and variables.
         $this->addJSLanguage("Starred", "Unstarred", "gambit.member", "gambit.more results", "Filter conversations", "Jump to last");
         $this->addJSVar("searchUpdateInterval", C("esoTalk.search.updateInterval"));
         $this->addJSVar("currentSearch", $searchString);
         $this->addJSVar("currentChannels", $currentChannels);
         $this->addJSFile("core/js/lib/jquery.cookie.js");
         $this->addJSFile("core/js/autocomplete.js");
         $this->addJSFile("core/js/search.js");
         // Add an array of channels in the form slug => id for the JavaScript to use.
         $channels = array();
         foreach ($channelInfo as $id => $c) {
             $channels[$id] = $c["slug"];
         }
         $this->addJSVar("channels", $channels);
         // Get a bunch of statistics...
         $queries = array("post" => ET::SQL()->select("COUNT(*)")->from("post")->get(), "conversation" => ET::SQL()->select("COUNT(*)")->from("conversation")->get(), "member" => ET::SQL()->select("COUNT(*)")->from("member")->get());
         $sql = ET::SQL();
         foreach ($queries as $k => $query) {
             $sql->select("({$query}) AS {$k}");
         }
         $stats = $sql->exec()->firstRow();
         // ...and show them in the footer.
         foreach ($stats as $k => $v) {
             $stat = Ts("statistic.{$k}", "statistic.{$k}.plural", number_format($v));
             if ($k == "member" and (C("esoTalk.members.visibleToGuests") or ET::$session->user)) {
                 $stat = "<a href='" . URL("members") . "'>{$stat}</a>";
             }
             $this->addToMenu("statistics", "statistic-{$k}", $stat, array("before" => "statistic-online"));
         }
         $this->render("conversations/index");
     } elseif ($this->responseType === RESPONSE_TYPE_VIEW) {
         $this->render("conversations/results");
     } elseif ($this->responseType === RESPONSE_TYPE_AJAX) {
         $this->json("channels", $this->getViewContents("channels/tabs", $this->data));
         $this->render("conversations/results");
     } elseif ($this->responseType === RESPONSE_TYPE_JSON) {
         $this->json("results", $results);
         $this->render();
     }
 }
コード例 #28
0
 /**
  * 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");
 }
コード例 #29
0
ファイル: plugin.php プロジェクト: ky0ncheng/esotalk-for-sae
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/AttachmentsSAE");
     $form->setValue("allowedFileTypes", implode(" ", (array) C("plugin.AttachmentsSAE.allowedFileTypes")));
     $form->setValue("maxFileSize", C("plugin.AttachmentsSAE.maxFileSize"));
     // If the form was submitted...
     if ($form->validPostBack("attachmentsSave")) {
         // Construct an array of config options to write.
         $config = array();
         $fileTypes = $form->getValue("allowedFileTypes");
         $config["plugin.AttachmentsSAE.allowedFileTypes"] = $fileTypes ? explode(" ", $fileTypes) : "";
         $config["plugin.AttachmentsSAE.maxFileSize"] = $form->getValue("maxFileSize");
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success autoDismiss");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("attachmentsSettingsForm", $form);
     return $this->view("settings");
 }
コード例 #30
0
 /**
  * Show the settings page with the change password or email pane.
  *
  * @return void
  */
 public function password()
 {
     $member = $this->profile("password");
     // Construct the form.
     $form = ETFactory::make("form");
     $form->action = URL("settings/password");
     // If the form was submitted...
     if ($form->validPostBack("save")) {
         $update = array();
         // Are we setting a new password?
         if ($password = $form->getValue("password")) {
             // Do the passwords entered match?
             if ($password != $form->getValue("confirm")) {
                 $form->error("confirm", T("message.passwordsDontMatch"));
             } else {
                 $update["password"] = $password;
             }
         }
         // Are we setting a new email?
         if ($email = $form->getValue("email")) {
             $update["email"] = $email;
         }
         // Did they enter the correct "current password"?
         if (!ET::memberModel()->checkPassword($form->getValue("currentPassword"), ET::$session->user["password"])) {
             $form->error("currentPassword", T("message.incorrectPassword"));
         }
         // If no preliminary errors occurred, and we have stuff to update, we can go ahead and call the model.
         if (!$form->errorCount() and count($update)) {
             // Update the stuff we need to with the model.
             $model = ET::memberModel();
             $model->updateById(ET::$session->userId, $update);
             // If the model encountered errors, pass them along to the form.
             if ($model->errorCount()) {
                 $form->errors($model->errors());
             } else {
                 $this->message(T("message.changesSaved"), "success");
                 $this->redirect(URL("settings"));
             }
         }
     }
     $this->data("form", $form);
     $this->renderProfile("settings/password");
 }