本文整理汇总了PHP中Horde::permissionDeniedError方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde::permissionDeniedError方法的具体用法?PHP Horde::permissionDeniedError怎么用?PHP Horde::permissionDeniedError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde
的用法示例。
在下文中一共展示了Horde::permissionDeniedError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _check_max
function _check_max()
{
$perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
return false;
}
return true;
}
示例2: _
if (!$prefs->isLocked('thread_view_bodies')) {
$actions[] = Horde::link($url->add('bodies', 1), _("View bodies")) . _("View bodies") . '</a>';
}
$threads = $messages->getThreadsUi($threads_list, $col_headers, $view_bodies, $threads_template);
break;
}
/* Set up the main template tags. */
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$view->notify = Horde::endBuffer();
$view->actions = $actions;
$view->threads = $threads;
$view->rss = Horde::url('rss/messages.php', true, -1)->add(array('scope' => $scope, 'message_id' => $message_id, 'forum_id' => $forum_id));
/* Display an edit-dialogue if the thread is not locked and we can edit messages in them. */
if (!$messages->hasPermission(Horde_Perms::EDIT)) {
Horde::permissionDeniedError('agora', null);
$view->form = sprintf(_("You don't have permission to post messages in forum %s."), $forum['forum_name']);
} elseif ($message['locked']) {
$view->form = _("Thread locked.");
} else {
$reply = $messages->replyMessage($message);
$vars = Horde_Variables::getDefaultVariables();
$vars->set('forum_id', $forum_id);
$vars->set('message_parent_id', $message_id);
$vars->set('message_subject', $reply['message_subject']);
$vars->set('message_body_old', $reply['body']);
$form = $messages->getForm($vars, sprintf(_("Post a Reply to \"%s\""), $reply['message_subject']));
Horde::startBuffer();
$form->renderActive(null, null, Horde::url('messages/edit.php'), 'post', null, false);
$view->form = Horde::endBuffer();
}
示例3: hasMaxContacts
/**
* Checks the max_contacts permission.
*
* @param Turba_Driver $driver The address book to check.
* @param boolean $notify If true, outputs error to notification.
*
* @return string Error message if maximum contacts have been reached.
* False otherwise.
*/
public static function hasMaxContacts(Turba_Driver $driver, $notify = true)
{
$error = false;
$max_contacts = Turba::getExtendedPermission($driver, 'max_contacts');
if ($max_contacts !== true && $max_contacts <= count($driver)) {
$error = sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title);
Horde::permissionDeniedError('turba', 'max_contacts', $notify ? $error : null);
}
return $error;
}
示例4: _init
/**
*/
protected function _init()
{
global $injector, $notification, $page_output, $prefs, $session;
/* Get the list of filter rules. */
$ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
/* Load the Ingo_Script factory. */
$factory = $injector->getInstance('Ingo_Factory_Script');
/* Get permissions. */
$edit_allowed = Ingo::hasSharePermission(Horde_Perms::EDIT);
$delete_allowed = Ingo::hasSharePermission(Horde_Perms::DELETE);
/* Token checking. */
$actionID = $this->_checkToken(array('rule_copy', 'rule_delete', 'rule_disable', 'rule_enable'));
/* Default to no mailbox filtering. */
$mbox_search = null;
/* Perform requested actions. */
switch ($actionID) {
case 'mbox_search':
if (isset($this->vars->searchfield)) {
$mbox_search = array('exact' => $this->vars->get('searchexact', 1), 'query' => $this->vars->searchfield);
}
break;
case 'rule_copy':
case 'rule_delete':
case 'rule_disable':
case 'rule_enable':
if (!$edit_allowed) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
self::url()->redirect();
}
$success = false;
switch ($actionID) {
case 'rule_delete':
if (!$delete_allowed) {
$notification->push(_("You do not have permission to delete filter rules."), 'horde.error');
self::url()->redirect();
}
if (($tmp = $ingo_storage->getRuleByUid($this->vars->uid)) && $ingo_storage->deleteRule($tmp)) {
$notification->push(sprintf(_("Rule \"%s\" deleted."), $tmp->name), 'horde.success');
$success = true;
}
break;
case 'rule_copy':
switch ($ingo_storage->maxRules()) {
case Ingo_Storage::MAX_NONE:
Horde::permissionDeniedError('ingo', 'max_rules', _("You are not allowed to create or edit custom rules."));
break 2;
case Ingo_Storage::MAX_OVER:
Horde::permissionDeniedError('ingo', 'max_rules', sprintf(_("You are not allowed to create more than %d rules."), $ingo_storage->max_rules));
break 2;
}
if (($tmp = $ingo_storage->getRuleByUid($this->vars->uid)) && $ingo_storage->copyRule($tmp)) {
$notification->push(sprintf(_("Rule \"%s\" copied."), $tmp->name), 'horde.success');
$success = true;
}
break;
case 'rule_disable':
case 'rule_enable':
if ($tmp = $ingo_storage->getRuleByUid($this->vars->uid)) {
$tmp->disable = $actionID === 'rule_disable';
$ingo_storage->updateRule($tmp);
$notification->push(sprintf($actionID === 'rule_disable' ? _("Rule \"%s\" disabled.") : _("Rule \"%s\" enabled."), $tmp->name), 'horde.success');
$success = true;
}
break;
}
/* Save changes */
if ($success) {
try {
$factory->activateAll();
} catch (Ingo_Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
}
}
break;
case 'settings_save':
if (!$edit_allowed) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
self::url()->redirect();
}
$prefs->setValue('show_filter_msg', $this->vars->show_filter_msg);
$prefs->setValue('filter_seen', $this->vars->filter_seen);
$notification->push(_("Settings successfully updated."), 'horde.success');
break;
case 'apply_filters':
$factory->perform();
break;
}
/* Common URLs. */
$filters_url = $this->_addToken(self::url());
$rule_url = Ingo_Basic_Rule::url();
$view = new Horde_View(array('templatePath' => INGO_TEMPLATES . '/basic/filters'));
$view->addHelper('Horde_Core_View_Helper_Help');
$view->addHelper('Horde_Core_View_Helper_Image');
$view->addHelper('Horde_Core_View_Helper_Label');
$view->addHelper('FormTag');
$view->addHelper('Tag');
$view->canapply = $factory->canPerform();
$view->deleteallowed = $delete_allowed;
//.........这里部分代码省略.........
示例5: _assertMaxRules
/**
* @param mixed $max
* @param Ingo_Storage_Filters $filters
*/
protected function _assertMaxRules($max, $filters)
{
if ($max !== true && $max <= count($filters->getFilterList())) {
Horde::permissionDeniedError('ingo', 'max_rules', sprintf(_("You are not allowed to create more than %d rules."), $max));
return true;
}
return false;
}
示例6: switch
* Copyright 2002-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you did not
* did not receive this file, see http://www.horde.org/licenses/bsdl.php.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('trean');
/* Deal with any action task. */
$actionID = Horde_Util::getFormData('actionID');
switch ($actionID) {
case 'add_bookmark':
/* Check permissions. */
if (Trean::hasPermission('max_bookmarks') !== true && Trean::hasPermission('max_bookmarks') <= $trean_gateway->countBookmarks()) {
Horde::permissionDeniedError('trean', 'max_bookmarks', sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')));
Horde::url('browse.php', true)->redirect();
}
/* Create a new bookmark. */
$properties = array('bookmark_url' => Horde_Util::getFormData('url'), 'bookmark_title' => Horde_Util::getFormData('title'), 'bookmark_description' => Horde_Util::getFormData('description'), 'bookmark_tags' => Horde_Util::getFormData('treanBookmarkTags'));
try {
$bookmark = $trean_gateway->newBookmark($properties, !empty($conf['content_index']['enabled']));
} catch (Exception $e) {
$notification->push(sprintf(_("There was an error adding the bookmark: %s"), $e->getMessage()), 'horde.error');
}
if (Horde_Util::getFormData('popup')) {
echo Horde::wrapInlineScript(array('window.close();'));
} elseif (Horde_Util::getFormData('iframe')) {
$notification->push(_("Bookmark Added"), 'horde.success');
$page_output->header();
$notification->notify();
示例7: sprintf
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Chuck Hagenbuch <chuck@horde.org>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith');
if (Kronolith::showAjaxView()) {
Horde::url('', true)->setAnchor('event')->redirect();
}
/* Check permissions. */
$url = Horde::url($prefs->getValue('defaultview') . '.php', true)->add(array('month' => Horde_Util::getFormData('month'), 'year' => Horde_Util::getFormData('year')));
$perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
$url->redirect();
}
$display_resource = $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_RESOURCE_CALENDARS);
$calendar_id = Horde_Util::getFormData('calendar', empty($display_resource) ? 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT) : 'resource_' . $display_resource[0]);
if ($calendar_id == 'internal_' || $calendar_id == 'resource_') {
$url->redirect();
}
$event = Kronolith::getDriver()->getEvent();
$session->set('kronolith', 'attendees', $event->attendees);
$session->set('kronolith', 'resources', $event->getResources());
$date = Horde_Util::getFormData('datetime');
if ($date) {
$event->start = new Horde_Date($date);
} else {
$date = Horde_Util::getFormData('date', date('Ymd')) . '000600';
示例8: _init
/**
*/
protected function _init()
{
global $conf, $injector, $notification, $page_output;
$ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
switch ($ingo_storage->maxRules()) {
case Ingo_Storage::MAX_NONE:
Horde::permissionDeniedError('ingo', 'allow_rules', _("You are not allowed to create or edit custom rules."));
Ingo_Basic_Filters::url()->redirect();
case Ingo_Storage::MAX_OVER:
Horde::permissionDeniedError('ingo', 'max_rules', sprintf(_("You are not allowed to create more than %d rules."), $ingo_storage->max_rules));
Ingo_Basic_Filters::url()->redirect();
}
if (!Ingo::hasSharePermission(Horde_Perms::EDIT)) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
Ingo_Basic_Filters::url()->redirect();
}
/* Load the Ingo_Script:: driver. */
$ingo_script_factory = $injector->getInstance('Ingo_Factory_Script');
$ingo_script = $ingo_script_factory->create(Ingo::RULE_FILTER);
/* Redirect if no rules are available. */
$availActions = $ingo_script->availableActions();
if (empty($availActions)) {
$notification->push(_("Individual rules are not supported in the current filtering driver."), 'horde.error');
Ingo_Basic_Filters::url()->redirect();
}
/* This provides the $ingo_fields array. */
$config = new Horde_Registry_LoadConfig('ingo', 'fields.php', 'ingo_fields');
$ingo_fields = $config->config['ingo_fields'];
/* Token checking. */
$actionID = $this->_checkToken(array('rule_save', 'rule_delete'));
/* Update the current rules before performing any action. */
switch ($this->vars->action) {
case 'Ingo_Rule_User_Discard':
case 'Ingo_Rule_User_FlagOnly':
case 'Ingo_Rule_User_Keep':
case 'Ingo_Rule_User_Move':
case 'Ingo_Rule_User_MoveKeep':
case 'Ingo_Rule_User_Notify':
case 'Ingo_Rule_User_Redirect':
case 'Ingo_Rule_User_RedirectKeep':
case 'Ingo_Rule_User_Reject':
$rule = new $this->vars->action();
$rule->combine = $this->vars->combine;
$rule->name = $this->vars->name;
$rule->stop = $this->vars->stop;
$rule->uid = $this->vars->edit;
break;
default:
$rule = isset($this->vars->edit) ? $ingo_storage->getRuleByUid($this->vars->edit) : new Ingo_Rule_User();
break;
}
if (!$rule) {
$notification->push(_("Filter not found."), 'horde.error');
Ingo_Basic_Filters::url()->redirect();
}
if ($ingo_script->hasFeature('case_sensitive')) {
$casesensitive = $this->vars->case;
}
foreach (array_filter(isset($this->vars->field) ? $this->vars->field : array()) as $key => $val) {
$condition = array();
$f_label = null;
if ($val == Ingo::USER_HEADER) {
$condition['field'] = empty($this->vars->userheader[$key]) ? '' : $this->vars->userheader[$key];
$condition['type'] = Ingo_Rule_User::TEST_HEADER;
} elseif (!isset($ingo_fields[$val])) {
$condition['field'] = $val;
$condition['type'] = Ingo_Rule_User::TEST_HEADER;
} else {
$condition['field'] = $val;
$f_label = $ingo_fields[$val]['label'];
$condition['type'] = $ingo_fields[$val]['type'];
}
$condition['match'] = isset($this->vars->match[$key]) ? $this->vars->match[$key] : '';
if ($actionID == 'rule_save' && empty($this->vars->value[$key]) && !in_array($condition['match'], array('exists', 'not exist'))) {
$notification->push(sprintf(_("You cannot create empty conditions. Please fill in a value for \"%s\"."), is_null($f_label) ? $condition['field'] : $f_label), 'horde.error');
$actionID = null;
}
$condition['value'] = isset($this->vars->value[$key]) ? $this->vars->value[$key] : '';
if (isset($casesensitive)) {
$condition['case'] = isset($casesensitive[$key]) ? $casesensitive[$key] : '';
}
$tmp = $rule->conditions;
$tmp[] = $condition;
$rule->conditions = $tmp;
}
if ($this->vars->action) {
switch ($rule->type) {
case Ingo_Rule_User::TYPE_MAILBOX:
switch ($actionID) {
case 'rule_save':
try {
$rule->value = $this->validateMbox('actionvalue');
} catch (Ingo_Exception $e) {
$notification->push($e, 'horde.error');
$actionID = null;
}
break;
default:
//.........这里部分代码省略.........
示例9: handle
/**
* Process a modification to the current layout.
*
* @param string $action TODO
* @param integer $row TODO
* @param integer $col TODO
* @param string $url TODO
*
* @throws Horde_Exception
*/
public function handle($action, $row, $col, $url = null)
{
switch ($action) {
case 'moveUp':
case 'moveDown':
case 'moveLeft':
case 'moveRight':
case 'expandUp':
case 'expandDown':
case 'expandLeft':
case 'expandRight':
case 'shrinkLeft':
case 'shrinkRight':
case 'shrinkUp':
case 'shrinkDown':
case 'removeBlock':
try {
call_user_func(array($this, $action), $row, $col);
$this->_updated = true;
} catch (Horde_Exception $e) {
$GLOBALS['notification']->push($e);
}
break;
// Save the changes made to a block.
// Save the changes made to a block.
case 'save':
// Save the changes made to a block and continue editing.
// Save the changes made to a block and continue editing.
case 'save-resume':
// Get requested block type.
list($newapp, $newtype) = explode(':', Horde_Util::getFormData('app'));
// Is this a new block?
$new = false;
if ($this->isEmpty($row, $col) || !$this->rowExists($row) || !$this->colExists($col)) {
// Check permissions.
$max_blocks = $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_blocks');
if ($max_blocks !== true && $max_blocks <= count($this)) {
Horde::permissionDeniedError('horde', 'max_blocks', sprintf(Horde_Core_Translation::ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks));
break;
}
$new = true;
// Make sure there is somewhere to put it.
$this->addBlock($row, $col);
}
// Or an existing one?
$exists = false;
$changed = false;
if (!$new) {
// Get target block info.
$info = $this->getBlockInfo($row, $col);
$exists = $this->isBlock($row, $col);
// Has a different block been selected?
if ($exists && ($info['app'] != $newapp || $info['block'] != $newtype)) {
$changed = true;
}
}
if ($new || $changed) {
// Change app or type.
$info = array('app' => $newapp, 'block' => $newtype);
$params = $this->_collection->getParams($newapp, $newtype);
foreach ($params as $newparam) {
$info['params'][$newparam] = $this->_collection->getDefaultValue($newapp, $newtype, $newparam);
}
$this->setBlockInfo($row, $col, $info);
} elseif ($exists) {
// Change values.
$this->setBlockInfo($row, $col, array('params' => Horde_Util::getFormData('params', array())));
}
$this->_updated = true;
if ($action == 'save') {
break;
}
// Make a block the current block for editing.
// Make a block the current block for editing.
case 'edit':
$this->_currentBlock = array($row, $col);
$url = null;
break;
}
if (!empty($url)) {
$url = new Horde_Url($url);
$url->unique()->redirect();
}
}
示例10: run
public function run()
{
extract($this->_params, EXTR_REFS);
$this->updateSortOrderFromVars();
$title = _("Address Book Listing");
if (!$browse_source_count && $vars->get('key') != '**search') {
$notification->push(_("There are no browseable address books."), 'horde.warning');
} else {
try {
$driver = $factory->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
unset($driver);
}
}
if (isset($driver)) {
$actionID = $vars->get('actionID');
switch ($actionID) {
case 'delete':
$keys = $vars->get('objectkeys');
if (!is_array($keys)) {
break;
}
$key = false;
if ($vars->exists('key')) {
$key = $vars->get('key');
}
if ($key && $key != '**search') {
// We are removing a contact from a list.
$errorCount = 0;
$list = $driver->getObject($key);
foreach ($keys as $sourceKey) {
list($objectSource, $objectKey) = explode(':', $sourceKey, 2);
if (!$list->removeMember($objectKey, $objectSource)) {
$errorCount++;
}
}
if (!$errorCount) {
$notification->push(sprintf(_("Successfully removed %d contact(s) from list."), count($keys)), 'horde.success');
} elseif (count($keys) == $errorCount) {
$notification->push(sprintf(_("Error removing %d contact(s) from list."), count($keys)), 'horde.error');
} else {
$notification->push(sprintf(_("Error removing %d of %d requested contact(s) from list."), $errorCount, count($keys)), 'horde.error');
}
$list->store();
} else {
// We are deleting an object.
$errorCount = 0;
foreach ($keys as $sourceKey) {
list($objectSource, $objectKey) = explode(':', $sourceKey, 2);
try {
$driver->delete($objectKey);
} catch (Turba_Exception $e) {
++$errorCount;
}
}
if (!$errorCount) {
$notification->push(sprintf(ngettext("Successfully deleted %d contact.", "Successfully deleted %d contacts.", count($keys)), count($keys)), 'horde.success');
} elseif (count($keys) == $errorCount) {
$notification->push(sprintf(ngettext("Error deleting %d contact.", "Error deleting %d contacts.", count($keys)), count($keys)), 'horde.error');
} else {
$notification->push(sprintf(ngettext("Error deleting %d of %d requested contact.", "Error deleting %d of %d requested contacts.", count($keys)), $errorCount, count($keys)), 'horde.error');
}
}
break;
case 'move':
case 'copy':
$keys = $vars->get('objectkeys');
if (!(is_array($keys) && $keys)) {
break;
}
// If we have data, try loading the target address book driver.
$targetSource = $vars->get('targetAddressbook');
try {
$targetDriver = $factory->create($targetSource);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
break;
}
$max_contacts = Turba::getExtendedPermission($targetDriver, 'max_contacts');
if ($max_contacts !== true && $max_contacts <= count($targetDriver)) {
Horde::permissionDeniedError('turba', 'max_contacts', sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$targetSource]['title']));
break;
}
foreach ($keys as $sourceKey) {
// Split up the key into source and object ids.
list($objectSource, $objectKey) = explode(':', $sourceKey, 2);
// Ignore this entry if the target is the same as the
// source.
if ($objectSource == $targetDriver->getName()) {
continue;
}
// Try and load the driver for the source.
try {
$sourceDriver = $factory->create($objectSource);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
continue;
}
try {
//.........这里部分代码省略.........
示例11: switch
}
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('nag');
$vars = Horde_Variables::getDefaultVariables();
/* Redirect to the task list if no action has been requested. */
$actionID = $vars->get('actionID');
if (is_null($actionID)) {
Horde::url('list.php', true)->redirect();
}
/* Run through the action handlers. */
switch ($actionID) {
case 'add_task':
/* Check permissions. */
$perms = $injector->getInstance('Horde_Core_Perms');
if ($perms->hasAppPermission('max_tasks') !== true && $perms->hasAppPermission('max_tasks') <= Nag::countTasks()) {
Horde::permissionDeniedError('nag', 'max_tasks', sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')));
Horde::url('list.php', true)->redirect();
}
if (!$vars->exists('tasklist_id')) {
$vars->set('tasklist_id', Nag::getDefaultTasklist(Horde_Perms::EDIT));
}
if ($parent = Horde_Util::getFormData('parent_task')) {
$vars->set('parent', $parent);
}
$form = new Nag_Form_Task($vars, _("New Task"));
break;
case 'modify_task':
$task_id = $vars->get('task');
$tasklist_id = $vars->get('tasklist');
try {
$share = $nag_shares->getShare($tasklist_id);
示例12: _prepSendMessageAssert
/**
* Recipiet checks to do if this is a user-generated compose message.
*
* @param Horde_Mail_Rfc822_List $email The e-mail list to send to.
*
* @throws IMP_Compose_Exception
*/
protected function _prepSendMessageAssert(Horde_Mail_Rfc822_List $email)
{
global $injector;
$email_count = count($email);
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!$imp_imap->accessCompose(IMP_Imap::ACCESS_COMPOSE_TIMELIMIT, $email_count)) {
Horde::permissionDeniedError('imp', 'max_timelimit');
throw new IMP_Compose_Exception(sprintf(ngettext("You are not allowed to send messages to more than %d recipient within %d hours.", "You are not allowed to send messages to more than %d recipients within %d hours.", $imp_imap->max_compose_timelimit), $imp_imap->max_compose_timelimit, $injector->getInstance('IMP_Sentmail')->limit_period));
}
/* Count recipients if necessary. We need to split email groups
* because the group members count as separate recipients. */
if (!$imp_imap->accessCompose(IMP_Imap::ACCESS_COMPOSE_RECIPIENTS, $email_count)) {
Horde::permissionDeniedError('imp', 'max_recipients');
throw new IMP_Compose_Exception(sprintf(ngettext("You are not allowed to send messages to more than %d recipient.", "You are not allowed to send messages to more than %d recipients.", $imp_imap->max_compose_recipients), $imp_imap->max_compose_recipients));
}
}
示例13: _init
/**
*/
protected function _init()
{
global $injector, $notification, $page_output, $prefs, $session;
/* Get the list of filter rules. */
$ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
$filters = $ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
/* Load the Ingo_Script factory. */
$factory = $injector->getInstance('Ingo_Factory_Script');
/* Get permissions. */
$edit_allowed = Ingo::hasSharePermission(Horde_Perms::EDIT);
$delete_allowed = Ingo::hasSharePermission(Horde_Perms::DELETE);
/* Permissions. */
$perms = $injector->getInstance('Horde_Core_Perms');
/* Token checking. */
$actionID = $this->_checkToken(array('rule_copy', 'rule_delete', 'rule_disable', 'rule_enable'));
/* Default to no mailbox filtering. */
$mbox_search = null;
/* Perform requested actions. */
switch ($actionID) {
case 'mbox_search':
if (isset($this->vars->searchfield)) {
$mbox_search = array('exact' => $this->vars->get('searchexact', 1), 'query' => $this->vars->searchfield);
}
break;
case 'rule_copy':
case 'rule_delete':
case 'rule_disable':
case 'rule_enable':
if (!$edit_allowed) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
self::url()->redirect();
}
switch ($actionID) {
case 'rule_delete':
if (!$delete_allowed) {
$notification->push(_("You do not have permission to delete filter rules."), 'horde.error');
self::url()->redirect();
}
$tmp = $filters->getFilter($this->vars->rulenumber);
if ($filters->deleteRule($this->vars->rulenumber)) {
$notification->push(sprintf(_("Rule \"%s\" deleted."), $tmp['name']), 'horde.success');
}
break;
case 'rule_copy':
$max = $perms->hasAppPermission(Ingo_Perms::getPerm('max_rules'));
if ($max === 0) {
Horde::permissionDeniedError('ingo', 'max_rules', _("You are not allowed to create or edit custom rules."));
break 2;
} elseif ($max !== true && $max <= count($filters->getFilterList())) {
Horde::permissionDeniedError('ingo', 'max_rules', sprintf(_("You are not allowed to create more than %d rules."), $max));
break 2;
}
$tmp = $filters->getFilter($this->vars->rulenumber);
if ($filters->copyRule($this->vars->rulenumber)) {
$notification->push(sprintf(_("Rule \"%s\" copied."), $tmp['name']), 'horde.success');
}
break;
case 'rule_disable':
$tmp = $filters->getFilter($this->vars->rulenumber);
$filters->ruleDisable($this->vars->rulenumber);
$notification->push(sprintf(_("Rule \"%s\" disabled."), $tmp['name']), 'horde.success');
break;
case 'rule_enable':
$tmp = $filters->getFilter($this->vars->rulenumber);
$filters->ruleEnable($this->vars->rulenumber);
$notification->push(sprintf(_("Rule \"%s\" enabled."), $tmp['name']), 'horde.success');
break;
}
/* Save changes */
$ingo_storage->store($filters);
try {
Ingo_Script_Util::update();
} catch (Ingo_Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
}
break;
case 'settings_save':
if (!$edit_allowed) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
self::url()->redirect();
}
$prefs->setValue('show_filter_msg', $this->vars->show_filter_msg);
$prefs->setValue('filter_seen', $this->vars->filter_seen);
$notification->push(_("Settings successfully updated."), 'horde.success');
break;
case 'apply_filters':
$factory->perform();
break;
}
/* Get the list of rules now. */
$filter_list = $filters->getFilterList();
/* Common URLs. */
$filters_url = $this->_addToken(self::url());
$rule_url = Ingo_Basic_Rule::url();
$view = new Horde_View(array('templatePath' => INGO_TEMPLATES . '/basic/filters'));
$view->addHelper('Horde_Core_View_Helper_Help');
$view->addHelper('Horde_Core_View_Helper_Image');
$view->addHelper('Horde_Core_View_Helper_Label');
//.........这里部分代码省略.........
示例14: _prepSendMessageAssert
/**
* Additonal checks to do if this is a user-generated compose message.
*
* @param Horde_Mail_Rfc822_List $email The e-mail list to send to.
* @param Horde_Mime_Headers $headers The object holding this message's
* headers.
* @param Horde_Mime_Part $message The object that contains the text
* to send.
*
* @throws IMP_Compose_Exception
*/
protected function _prepSendMessageAssert(Horde_Mail_Rfc822_List $email, Horde_Mime_Headers $headers = null, Horde_Mime_Part $message = null)
{
global $injector;
$email_count = count($email);
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!$imp_imap->accessCompose(IMP_Imap::ACCESS_COMPOSE_TIMELIMIT, $email_count)) {
Horde::permissionDeniedError('imp', 'max_timelimit');
throw new IMP_Compose_Exception(sprintf(ngettext("You are not allowed to send messages to more than %d recipient within %d hours.", "You are not allowed to send messages to more than %d recipients within %d hours.", $imp_imap->max_compose_timelimit), $imp_imap->max_compose_timelimit, $injector->getInstance('IMP_Sentmail')->limit_period));
}
/* Count recipients if necessary. We need to split email groups
* because the group members count as separate recipients. */
if (!$imp_imap->accessCompose(IMP_Imap::ACCESS_COMPOSE_RECIPIENTS, $email_count)) {
Horde::permissionDeniedError('imp', 'max_recipients');
throw new IMP_Compose_Exception(sprintf(ngettext("You are not allowed to send messages to more than %d recipient.", "You are not allowed to send messages to more than %d recipients.", $imp_imap->max_compose_recipients), $imp_imap->max_compose_recipients));
}
/* Pass to hook to allow alteration of message details. */
if (!is_null($message)) {
try {
$injector->getInstance('Horde_Core_Hooks')->callHook('pre_sent', 'imp', array($message, $headers, $this));
} catch (Horde_Exception_HookNotSet $e) {
}
}
}
示例15: foreach
$next_step = $data->cleanup();
} else {
$notification->push(_("This file format is not supported."), 'horde.error');
$next_step = Horde_Data::IMPORT_FILE;
}
}
}
/* We have a final result set. */
if (is_array($next_step)) {
/* Create a Mnemo storage instance. */
$memo_storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create($storage->get('target'));
$max_memos = $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_notes');
$num_memos = Mnemo::countMemos();
foreach ($next_step as $row) {
if ($max_memos !== true && $num_memos >= $max_memos) {
Horde::permissionDeniedError('mnemo', 'max_notes', sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_notes')));
break;
}
/* Check if we need to convert from iCalendar data into an array. */
if ($row instanceof Horde_Icalendar_vnote) {
$row = $storage->fromiCalendar($row);
}
foreach ($app_fields as $field => $null) {
if (!isset($row[$field])) {
$row[$field] = '';
}
}
/* Default the tags if there isn't one. */
if (empty($row['tags'])) {
$row['tags'] = '';
}