当前位置: 首页>>代码示例>>PHP>>正文


PHP Engine_Form::addNotice方法代码示例

本文整理汇总了PHP中Engine_Form::addNotice方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Form::addNotice方法的具体用法?PHP Engine_Form::addNotice怎么用?PHP Engine_Form::addNotice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Engine_Form的用法示例。


在下文中一共展示了Engine_Form::addNotice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: notificationsAction

 public function notificationsAction()
 {
     $user = Engine_Api::_()->core()->getSubject();
     // Build the different notification types
     $modules = Engine_Api::_()->getDbtable('modules', 'core')->getModulesAssoc();
     $notificationTypes = Engine_Api::_()->getDbtable('notificationTypes', 'activity')->getNotificationTypes();
     $notificationSettings = Engine_Api::_()->getDbtable('notificationSettings', 'activity')->getEnabledNotifications($user);
     $notificationTypesAssoc = array();
     $notificationSettingsAssoc = array();
     foreach ($notificationTypes as $type) {
         if (in_array($type->module, array('core', 'activity', 'fields', 'authorization', 'messages', 'user'))) {
             $elementName = 'general';
             $category = 'General';
         } else {
             if (isset($modules[$type->module])) {
                 $elementName = preg_replace('/[^a-zA-Z0-9]+/', '-', $type->module);
                 $category = $modules[$type->module]->title;
             } else {
                 $elementName = 'misc';
                 $category = 'Misc';
             }
         }
         $notificationTypesAssoc[$elementName]['category'] = $category;
         $notificationTypesAssoc[$elementName]['types'][$type->type] = 'ACTIVITY_TYPE_' . strtoupper($type->type);
         if (in_array($type->type, $notificationSettings)) {
             $notificationSettingsAssoc[$elementName][] = $type->type;
         }
     }
     ksort($notificationTypesAssoc);
     $notificationTypesAssoc = array_filter(array_merge(array('general' => array(), 'misc' => array()), $notificationTypesAssoc));
     // Make form
     $this->view->form = $form = new Engine_Form(array('title' => 'Notification Settings', 'description' => 'Which of the these do you want to receive email alerts about?'));
     foreach ($notificationTypesAssoc as $elementName => $info) {
         $form->addElement('MultiCheckbox', $elementName, array('label' => $info['category'], 'multiOptions' => $info['types'], 'value' => (array) @$notificationSettingsAssoc[$elementName]));
     }
     $form->addElement('Button', 'execute', array('label' => 'Save Changes', 'type' => 'submit'));
     // Check method
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Process
     $values = array();
     foreach ($form->getValues() as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         foreach ($value as $skey => $svalue) {
             if (!isset($notificationTypesAssoc[$key]['types'][$svalue])) {
                 continue;
             }
             $values[] = $svalue;
         }
     }
     // Set notification setting
     Engine_Api::_()->getDbtable('notificationSettings', 'activity')->setEnabledNotifications($user, $values);
     $form->addNotice('Your changes have been saved.');
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:60,代码来源:SettingsController.php

示例2: notificationsAction

 public function notificationsAction()
 {
     error_reporting(E_ALL);
     ini_set('display_errors', TRUE);
     // Build the different notification types
     $modules = Engine_Api::_()->getDbtable('modules', 'core')->getModulesAssoc();
     $notificationTypes = Engine_Api::_()->getDbtable('notificationTypes', 'activity')->getNotificationTypes();
     $notificationSettings = Engine_Api::_()->getDbtable('notificationTypes', 'activity')->getDefaultNotifications();
     $notificationTypesAssoc = array();
     $notificationSettingsAssoc = array();
     foreach ($notificationTypes as $type) {
         if (in_array($type->module, array('core', 'activity', 'fields', 'authorization', 'messages', 'user'))) {
             $elementName = 'general';
             $category = 'General';
         } else {
             if (isset($modules[$type->module])) {
                 $elementName = preg_replace('/[^a-zA-Z0-9]+/', '-', $type->module);
                 $category = $modules[$type->module]->title;
             } else {
                 $elementName = 'misc';
                 $category = 'Misc';
             }
         }
         $notificationTypesAssoc[$elementName]['category'] = $category;
         $notificationTypesAssoc[$elementName]['types'][$type->type] = 'ACTIVITY_TYPE_' . strtoupper($type->type);
         if (in_array($type->type, $notificationSettings)) {
             $notificationSettingsAssoc[$elementName][] = $type->type;
         }
     }
     ksort($notificationTypesAssoc);
     $notificationTypesAssoc = array_filter(array_merge(array('general' => array(), 'misc' => array()), $notificationTypesAssoc));
     $this->view->form = $form = new Engine_Form(array('title' => 'Default Email Notifications', 'description' => 'This page allows you to specify the default email notifications for new users.'));
     foreach ($notificationTypesAssoc as $elementName => $info) {
         $form->addElement('MultiCheckbox', $elementName, array('label' => $info['category'], 'multiOptions' => $info['types'], 'value' => (array) @$notificationSettingsAssoc[$elementName]));
     }
     // init submit
     $form->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
     // Check method
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $values = array();
     foreach ($form->getValues() as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         foreach ($value as $skey => $svalue) {
             if (!isset($notificationTypesAssoc[$key]['types'][$svalue])) {
                 continue;
             }
             $values[] = $svalue;
         }
     }
     Engine_Api::_()->getDbtable('notificationTypes', 'activity')->setDefaultNotifications($values);
     $form->addNotice('Your changes have been saved.');
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:59,代码来源:AdminSettingsController.php


注:本文中的Engine_Form::addNotice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。