當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Settings::getSubscriptionsSettings方法代碼示例

本文整理匯總了PHP中thebuggenie\core\framework\Settings::getSubscriptionsSettings方法的典型用法代碼示例。如果您正苦於以下問題:PHP Settings::getSubscriptionsSettings方法的具體用法?PHP Settings::getSubscriptionsSettings怎麽用?PHP Settings::getSubscriptionsSettings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在thebuggenie\core\framework\Settings的用法示例。


在下文中一共展示了Settings::getSubscriptionsSettings方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: runMyAccount

 /**
  * "My account" page
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runMyAccount(framework\Request $request)
 {
     $this->forward403unless($this->getUser()->hasPageAccess('account'));
     $categories = \thebuggenie\core\entities\Category::getAll();
     $projects = [];
     $project_subscription_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS;
     $category_subscription_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY;
     $category_notification_key = \thebuggenie\core\framework\Settings::SETTINGS_USER_NOTIFY_NEW_ISSUES_MY_PROJECTS_CATEGORY;
     $subscriptionssettings = framework\Settings::getSubscriptionsSettings();
     $notificationsettings = framework\Settings::getNotificationSettings();
     $selected_project_subscriptions = [];
     $selected_category_subscriptions = [];
     $selected_category_notifications = [];
     $this->all_projects_subscription = $this->getUser()->getNotificationSetting($project_subscription_key, false)->isOn();
     foreach (\thebuggenie\core\entities\Project::getAll() as $project_id => $project) {
         if ($project->hasAccess()) {
             $projects[$project_id] = $project;
             if ($this->getUser()->getNotificationSetting($project_subscription_key . '_' . $project_id, false)->isOn()) {
                 $selected_project_subscriptions[] = $project_id;
             }
         }
     }
     foreach ($categories as $category_id => $category) {
         if ($this->getUser()->getNotificationSetting($category_subscription_key . '_' . $category_id, false)->isOn()) {
             $selected_category_subscriptions[] = $category_id;
         }
         if ($this->getUser()->getNotificationSetting($category_notification_key . '_' . $category_id, false)->isOn()) {
             $selected_category_notifications[] = $category_id;
         }
     }
     $this->selected_project_subscriptions = $this->all_projects_subscription ? [] : $selected_project_subscriptions;
     $this->projects = $projects;
     $this->selected_category_subscriptions = $selected_category_subscriptions;
     $this->selected_category_notifications = $selected_category_notifications;
     $this->categories = $categories;
     $this->subscriptionssettings = $subscriptionssettings;
     $this->notificationsettings = $notificationsettings;
     $this->has_autopassword = framework\Context::hasMessage('auto_password');
     if ($this->has_autopassword) {
         $this->autopassword = framework\Context::getMessage('auto_password');
     }
     if ($request->isPost() && $request->hasParameter('mode')) {
         switch ($request['mode']) {
             case 'information':
                 if (!$request['buddyname'] || !$request['email']) {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Please fill out all the required fields')));
                 }
                 $this->getUser()->setBuddyname($request['buddyname']);
                 $this->getUser()->setRealname($request['realname']);
                 $this->getUser()->setHomepage($request['homepage']);
                 $this->getUser()->setEmailPrivate((bool) $request['email_private']);
                 $this->getUser()->setUsesGravatar((bool) $request['use_gravatar']);
                 $this->getUser()->setTimezone($request->getRawParameter('timezone'));
                 $this->getUser()->setLanguage($request['profile_language']);
                 if ($this->getUser()->getEmail() != $request['email']) {
                     if (\thebuggenie\core\framework\Event::createNew('core', 'changeEmail', $this->getUser(), array('email' => $request['email']))->triggerUntilProcessed()->isProcessed() == false) {
                         $this->getUser()->setEmail($request['email']);
                     }
                 }
                 $this->getUser()->save();
                 return $this->renderJSON(array('title' => framework\Context::getI18n()->__('Profile information saved')));
                 break;
             case 'settings':
                 $this->getUser()->setPreferredWikiSyntax($request['syntax_articles']);
                 $this->getUser()->setPreferredIssuesSyntax($request['syntax_issues']);
                 $this->getUser()->setPreferredCommentsSyntax($request['syntax_comments']);
                 $this->getUser()->setKeyboardNavigationEnabled($request['enable_keyboard_navigation']);
                 $this->getUser()->save();
                 return $this->renderJSON(array('title' => framework\Context::getI18n()->__('Profile settings saved')));
                 break;
             case 'notificationsettings':
                 $this->getUser()->setDesktopNotificationsNewTabEnabled($request['enable_desktop_notifications_new_tab']);
                 foreach ($subscriptionssettings as $setting => $description) {
                     if ($setting == framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS_CATEGORY) {
                         foreach ($categories as $category_id => $category) {
                             if ($request->hasParameter('core_' . $setting . '_' . $category_id)) {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $category_id, true)->save();
                             } else {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $category_id, false)->save();
                             }
                         }
                     } elseif ($setting == framework\Settings::SETTINGS_USER_SUBSCRIBE_NEW_ISSUES_MY_PROJECTS) {
                         if ($request->hasParameter('core_' . $setting . '_all')) {
                             $this->getUser()->setNotificationSetting($setting, true)->save();
                             foreach (\thebuggenie\core\entities\Project::getAll() as $project_id => $project) {
                                 $this->getUser()->setNotificationSetting($setting . '_' . $project_id, false)->save();
                             }
                         } else {
                             $this->getUser()->setNotificationSetting($setting, false)->save();
                             foreach (\thebuggenie\core\entities\Project::getAll() as $project_id => $project) {
                                 if ($request->hasParameter('core_' . $setting . '_' . $project_id)) {
                                     $this->getUser()->setNotificationSetting($setting . '_' . $project_id, true)->save();
                                 } else {
                                     $this->getUser()->setNotificationSetting($setting . '_' . $project_id, false)->save();
//.........這裏部分代碼省略.........
開發者ID:nrensen,項目名稱:thebuggenie,代碼行數:101,代碼來源:Main.php


注:本文中的thebuggenie\core\framework\Settings::getSubscriptionsSettings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。