本文整理汇总了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.');
}
示例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.');
}