示例#1
0
 /**
  */
 protected function _content()
 {
     if (!($query = $this->_getQuery())) {
         return '<p class="horde-content"><em>' . _("No query to run") . '</em></p>';
     }
     $vars = Horde_Variables::getDefaultVariables();
     $tickets = $GLOBALS['whups_driver']->executeQuery($query, $vars);
     return $this->_table($tickets, 'whups_block_query_' . $query->id);
 }
示例#2
0
文件: Metar.php 项目: horde/horde
 /**
  * Handle user initiated block refresh. Set a private member to avoid
  * BC issues with having to add a parameter to the _content method.
  *
  * @param Horde_Variables $vars
  *
  * @return string
  */
 public function refreshContent($vars = null)
 {
     if (empty($vars) || empty($vars->location)) {
         $this->_refreshParams = Horde_Variables::getDefaultVariables();
         $this->_refreshParams->set('location', $this->_params['location']);
     } else {
         $this->_refreshParams = $vars;
     }
     return $this->_content();
 }
示例#3
0
 public function __construct(&$object, $buttons)
 {
     $this->koward =& Koward::singleton();
     parent::__construct(Horde_Variables::getDefaultVariables());
     $this->setTitle(_("Object actions"));
     $this->object = $object;
     if (!empty($buttons)) {
         $this->setButtons($buttons);
     }
 }
示例#4
0
文件: Base.php 项目: jubinpatel/horde
 public function testTwoAssignees()
 {
     $share = array_shift($GLOBALS['nag_shares']->listShares('*****@*****.**'));
     $share = $GLOBALS['nag_shares']->getShare($share->getName());
     $share->addUserPermission('jane', Horde_Perms::READ);
     $vars = Horde_Variables::getDefaultVariables();
     $vars->set('tasklist_id', $share->getName());
     $form = new Nag_Form_Task($vars, _("New Task"));
     $this->assertEquals(array('jane' => 'jane', '*****@*****.**' => '*****@*****.**'), $this->_getAssignees($form));
 }
示例#5
0
文件: Test.php 项目: horde/horde
 /**
  */
 public function appTests()
 {
     $ret = '<h1>Mail Server Support Test</h1>';
     $vars = Horde_Variables::getDefaultVariables();
     if ($vars->user && $vars->passwd) {
         $ret .= $this->_doConnectionTest($vars);
     }
     $self_url = Horde::selfUrl()->add('app', 'imp');
     Horde::startBuffer();
     require IMP_TEMPLATES . '/test/mailserver.inc';
     return $ret . Horde::endBuffer();
 }
示例#6
0
文件: Api.php 项目: jubinpatel/horde
 /**
  * Display form
  *
  * @param integer $form_id      Form id dispaly
  * @param string $target_url    Target url to link form to
  */
 public function display($form_id, $target_url = null)
 {
     /* Get the stored form information from the backend. */
     try {
         $form_info = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getForm($form_id, Horde_Perms::READ);
     } catch (Horde_Exception $e) {
         throw new Ulaform_Exception($e->getMessage());
     }
     if (!empty($form_info['form_params']['language'])) {
         Horde_Nls::setLanguageEnvironment($form_info['form_params']['language']);
     }
     $vars = Horde_Variables::getDefaultVariables();
     $vars->set('form_id', $form_id);
     $form = new Horde_Form($vars);
     $form->addHidden('', 'form_id', 'int', false);
     $form->addHidden('', 'user_uid', 'text', false);
     $form->addHidden('', 'email', 'email', false);
     $vars->set('user_uid', $GLOBALS['registry']->getAuth());
     $vars->set('email', $GLOBALS['prefs']->getValue('from_addr'));
     try {
         $fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($form_id);
     } catch (Ulaform_Exception $e) {
         throw new Ulaform_Exception($e->getMessage());
     }
     foreach ($fields as $field) {
         /* In case of these types get array from stringlist. */
         if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'mlenum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') {
             $field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']);
         }
         /* Setup the field with all the parameters. */
         $form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']);
     }
     /* Check if submitted and validate. */
     $result = array('title' => $form_info['form_name']);
     if ($form->validate()) {
         $form->getInfo(null, $info);
         try {
             $GLOBALS['ulaform_driver']->submitForm($info);
             return true;
         } catch (Horde_Exception $e) {
             throw new Ulaform_Exception(sprintf(_("Error submitting form. %s."), $e->getMessage()));
         }
     }
     if (is_null($target_url)) {
         $target_url = Horde::selfUrl(true);
     }
     Horde::startBuffer();
     $form->renderActive(null, null, $target_url, 'post', 'multipart/form-data');
     return array('title' => $form_info['form_name'], 'form' => Horde::endBuffer());
 }
示例#7
0
文件: Form.php 项目: jubinpatel/horde
 protected function _content()
 {
     $vars = Horde_Variables::getDefaultVariables();
     $formname = $vars->get('formname');
     $done = false;
     $form = new Horde_Form($vars);
     $fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($this->_params['form_id']);
     foreach ($fields as $field) {
         /* In case of these types get array from stringlist. */
         if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') {
             $field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']);
         }
         /* Setup the field with all the parameters. */
         $form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']);
     }
     if ($formname) {
         $form->validate($vars);
         if ($form->isValid() && $formname) {
             $form->getInfo($vars, $info);
             $info['form_id'] = $this->_params['form_id'];
             try {
                 $submit = $GLOBALS['ulaform_driver']->submitForm($info);
                 $GLOBALS['notification']->push(_("Form submitted successfully."), 'horde.success');
                 $done = true;
             } catch (Horde_Exception $e) {
                 $GLOBALS['notification']->push(sprintf(_("Error submitting form. %s."), $e->getMessage()), 'horde.error');
             }
         }
     }
     /* Render active or inactive, depending if submitted or
      * not. */
     $render_type = $done ? 'renderInactive' : 'renderActive';
     /* Render the form. */
     $renderer = new Horde_Form_Renderer();
     $renderer->showHeader(false);
     Horde::startBuffer();
     $form->{$render_type}($renderer, $vars, Horde::selfUrl(true), 'post');
     return Horde::endBuffer();
 }
示例#8
0
        $vars->set('account', $curaccount);
        $Form = new ExtensionDeleteForm($vars);
        $FormValid = $Form->validate($vars, true);
        if ($Form->isSubmitted() && $FormValid) {
            try {
                $Form->execute();
                $notification->push(_("Extension Deleted."));
                $action = 'list';
            } catch (Exception $e) {
                $notification->push($e);
            }
        } elseif ($Form->isSubmitted()) {
            // Submitted but not valid
            $notification->push(_("Problem processing the form.  Please check below and try again."), 'horde.warning');
        }
        $vars = Horde_Variables::getDefaultVariables(array());
        $vars->set('account', $curaccount);
        $Form = new ExtensionDeleteForm($vars);
        break;
    case 'list':
    default:
        $action = 'list';
        $title .= _("List Numbers");
}
try {
    $accounts = $shout->storage->getAccounts();
    $numbers = $shout->storage->getNumbers();
} catch (Exception $e) {
    $notification->push($e);
}
$page_output->addScriptFile('stripe.js', 'horde');
示例#9
0
<?php

/**
 * $Id: delete_event.php,v 1.1 2010/10/24 17:24:39 pety Exp pety $
 *
 * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Peter Sagi <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('cloudbank');
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_variables =& Horde_Variables::getDefaultVariables();
$g_account_id = $g_variables->get('account_id');
$g_event_id = $g_variables->get('event_id');
try {
    Book::Singleton()->deleteEvent($g_event_id);
    header('Location: ' . Horde::url('events.php', true)->add(array('ledger_account_id' => $g_account_id, 'ledger_account_type' => CloudBankConsts::LedgerAccountType_Account), NULL, false));
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $page_output->header();
    $notification->notify(array('listeners' => 'status'));
    $page_output->footer();
}
示例#10
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     global $nag_shares, $prefs;
     $vars = Horde_Variables::getDefaultVariables();
     $registry = $this->getInjector()->getInstance('Horde_Registry');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     $form = new Nag_Form_Task($vars, $vars->get('task_id') ? sprintf(_("Edit: %s"), $vars->get('name')) : _("New Task"));
     if (!$form->validate($vars)) {
         // Hideous
         $_REQUEST['actionID'] = 'task_form';
         require NAG_BASE . '/task.php';
         exit;
     }
     $form->getInfo($vars, $info);
     // Check if we are here due to a search_return push.
     if ($vars->search_return) {
         Horde::url('list.php', true)->add(array('actionID' => 'search_return', 'list' => $vars->list, 'tab_name' => $vars->tab_name))->redirect();
     }
     // Check if we are here due to a deletebutton push
     if ($vars->deletebutton) {
         try {
             $share = $nag_shares->getShare($info['old_tasklist']);
         } catch (Horde_Share_Exception $e) {
             $notification->push(sprintf(_("Access denied deleting task: %s"), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
             $notification->push(_("Access denied deleting task"), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['old_tasklist']);
         try {
             $storage->delete($info['task_id']);
         } catch (Nag_Exception $e) {
             $notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         $notification->push(_("Task successfully deleted"), 'horde.success');
         Horde::url('list.php', true)->redirect();
     }
     if ($prefs->isLocked('default_tasklist') || count(Nag::listTasklists(false, Horde_Perms::EDIT, false)) <= 1) {
         $info['tasklist_id'] = $info['old_tasklist'] = Nag::getDefaultTasklist(Horde_Perms::EDIT);
     }
     try {
         $share = $nag_shares->getShare($info['tasklist_id']);
     } catch (Horde_Share_Exception $e) {
         $notification->push(sprintf(_("Access denied saving task: %s"), $e->getMessage()), 'horde.error');
         Horde::url('list.php', true)->redirect();
     }
     if (!$share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(_("Access denied saving task to this task list."), 'horde.error');
         Horde::url('list.php', true)->redirect();
     }
     /* If a task id is set, we're modifying an existing task.  Otherwise,
      * we're adding a new task with the provided attributes. */
     if (!empty($info['task_id']) && !empty($info['old_tasklist'])) {
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['old_tasklist']);
         $info['tasklist'] = $info['tasklist_id'];
         $result = $storage->modify($info['task_id'], $info);
     } else {
         /* Check permissions. */
         $perms = $this->getInjector()->getInstance('Horde_Core_Perms');
         if ($perms->hasAppPermission('max_tasks') !== true && $perms->hasAppPermission('max_tasks') <= Nag::countTasks()) {
             Horde::url('list.php', true)->redirect();
         }
         /* Creating a new task. */
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['tasklist_id']);
         // These must be unset since the form sets them to NULL
         unset($info['owner']);
         unset($info['uid']);
         try {
             $newid = $storage->add($info);
         } catch (Nag_Exception $e) {
             $notification->push(sprintf(_("There was a problem saving the task: %s."), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
     }
     $notification->push(sprintf(_("Saved %s."), $info['name']), 'horde.success');
     /* Return to the last page or to the task list. */
     if ($vars->savenewbutton) {
         $url = Horde::url('task.php', true)->add(array('actionID' => 'add_task', 'tasklist_id' => $info['tasklist_id'], 'parent' => $info['parent']));
     } else {
         $url = Horde_Util::getFormData('url', (string) Horde::url('list.php', true));
         $url = Horde::url($url, true);
     }
     $response->setRedirectUrl($url);
 }
示例#11
0
 public static function getAdminTabs()
 {
     $tabname = Horde_Util::getFormData('view');
     $tabs = new Horde_Core_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
     $tabs->addTab(_("Telephone Numbers"), Horde::url('admin/numbers.php'), array('view' => 'numbers', id => 'tabnumbers'));
     $tabs->addTab(_("Accounts"), Horde::url('admin/accounts.php'), array('view' => 'accounts', id => 'tabaccounts'));
     if ($view === null) {
         $view = 'numbers';
     }
     echo $tabs->render($view);
 }
示例#12
0
文件: Ui.php 项目: horde/horde
 /**
  * Creates any form objects if they have not been initialised yet.
  */
 protected function _formInit()
 {
     if (is_null($this->_vars)) {
         /* No existing vars set, get them now. */
         $this->_vars = Horde_Variables::getDefaultVariables();
     }
     if (!$this->_form instanceof Horde_Form) {
         /* No existing valid form object set so set up a new one. */
         $this->_form = new Horde_Form($this->_vars);
     }
 }
示例#13
0
文件: Base.php 项目: horde/horde
 /**
  * Populate the Horde_View with the $pager object.
  *
  * @param Horde_View $view  The Horde_View object.
  */
 protected function _setupPager(Horde_View &$view)
 {
     $vars = Horde_Variables::getDefaultVariables();
     if (!empty($this->view->page)) {
         $vars->add('page', $this->view->page);
         $view->page = $this->view->page;
     } else {
         $view->page = 0;
     }
     $pagerurl = $this->_getPagerUrl();
     if (!empty($this->view->urlCallback)) {
         $callback = $this->view->urlCallback;
     } else {
         $callback = null;
     }
     $params = array('num' => $this->numTiles, 'url' => $pagerurl, 'perpage' => $this->perpage, 'url_callback' => $callback);
     $view->pager = new Horde_Core_Ui_Pager('page', $vars, $params);
 }
示例#14
0
 /**
  * Global variables defined:
  *   $chora_conf
  *   $sourceroots
  */
 protected function _init()
 {
     global $acts, $conf, $defaultActs, $where, $atdir, $fullname, $sourceroot, $page_output;
     // TODO: If chora isn't fully/properly setup, init() will throw fatal
     // errors. Don't want that if this class is being loaded simply to
     // obtain basic chora application information.
     $initial_app = $GLOBALS['registry']->initialApp == 'chora';
     try {
         $GLOBALS['sourceroots'] = Horde::loadConfiguration('backends.php', 'sourceroots');
     } catch (Horde_Exception $e) {
         $GLOBALS['sourceroots'] = array();
         if (!$initial_app) {
             return;
         }
         $GLOBALS['notification']->push($e);
     }
     $sourceroots = Chora::sourceroots();
     /**
      * Variables we wish to propagate across web pages
      *  ha  = Hide Attic Files
      *  ord = Sort order
      *  sbt = Sort By Type (name, age, author, etc)
      *
      * Obviously, defaults go into $defaultActs :)
      * TODO: defaults of 1 will not get propagated correctly - avsm
      * XXX: Rewrite this propagation code, since it sucks - avsm
      */
     $defaultActs = $acts = array('onb' => 0, 'ord' => Horde_Vcs::SORT_ASCENDING, 'rev' => 0, 'rt' => null, 'sa' => 0, 'sbt' => constant($conf['options']['defaultsort']), 'ws' => 1);
     /* See if any actions have been passed as form variables, and if so,
      * assign them into the acts array. */
     $vars = Horde_Variables::getDefaultVariables();
     foreach (array_keys($acts) as $key) {
         if (isset($vars->{$key})) {
             $acts[$key] = $vars->{$key};
         }
     }
     /* Use the value of the 'rt' form value for the sourceroot. If not
      * present, use the last sourceroot used as the default value if the
      * user has that preference. Otherwise, use default sourceroot. */
     $last_sourceroot = $GLOBALS['prefs']->getValue('last_sourceroot');
     if (is_null($acts['rt'])) {
         if (!empty($last_sourceroot) && !empty($sourceroots[$last_sourceroot]) && is_array($sourceroots[$last_sourceroot])) {
             $acts['rt'] = $last_sourceroot;
         } else {
             foreach ($sourceroots as $key => $val) {
                 if (!isset($acts['rt']) || isset($val['default'])) {
                     $acts['rt'] = $key;
                     break;
                 }
             }
             if (is_null($acts['rt'])) {
                 if ($initial_app) {
                     Chora::fatal(new Chora_Exception(_("No repositories found.")));
                 }
                 return;
             }
         }
     }
     if (!isset($sourceroots[$acts['rt']])) {
         if ($initial_app) {
             Chora::fatal(new Chora_Exception(sprintf(_("The repository with the slug '%s' was not found"), $acts['rt'])));
         }
         return;
     }
     $sourcerootopts = $sourceroots[$acts['rt']];
     $sourceroot = $acts['rt'];
     /* Store last repository viewed */
     if ($acts['rt'] != $last_sourceroot) {
         $GLOBALS['prefs']->setValue('last_sourceroot', $acts['rt']);
     }
     // Cache.
     $cache = empty($conf['caching']) ? null : $GLOBALS['injector']->getInstance('Horde_Cache');
     $GLOBALS['chora_conf'] = array('cvsusers' => $sourcerootopts['location'] . '/' . (isset($sourcerootopts['cvsusers']) ? $sourcerootopts['cvsusers'] : ''), 'introText' => CHORA_BASE . '/config/' . (isset($sourcerootopts['intro']) ? $sourcerootopts['intro'] : ''), 'introTitle' => isset($sourcerootopts['title']) ? $sourcerootopts['title'] : '', 'sourceRootName' => $sourcerootopts['name']);
     $chora_conf =& $GLOBALS['chora_conf'];
     $GLOBALS['VC'] = Horde_Vcs::factory(Horde_String::ucfirst($sourcerootopts['type']), array('cache' => $cache, 'sourceroot' => $sourcerootopts['location'], 'paths' => array_merge($conf['paths'], array('temp' => Horde::getTempDir())), 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '', 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : ''));
     if (!$initial_app) {
         return;
     }
     $where = Horde_Util::getFormData('f', '/');
     /* Location relative to the sourceroot. */
     $where = preg_replace(array('|^/|', '|\\.\\.|'), '', $where);
     $fullname = $sourcerootopts['location'] . (substr($sourcerootopts['location'], -1) == '/' ? '' : '/') . $where;
     if ($sourcerootopts['type'] == 'cvs') {
         $fullname = preg_replace('|/$|', '', $fullname);
         $atdir = @is_dir($fullname);
     } else {
         $atdir = !$where || substr($where, -1) == '/';
     }
     $where = preg_replace('|/$|', '', $where);
     if ($sourcerootopts['type'] == 'cvs' && !@is_dir($sourcerootopts['location'])) {
         Chora::fatal(new Chora_Exception(_("Sourceroot not found. This could be a misconfiguration by the server administrator, or the server could be having temporary problems. Please try again later.")));
     }
     if (Chora::isRestricted($where)) {
         Chora::fatal(new Chora_Exception(sprintf(_("%s: Forbidden by server configuration"), $where)));
     }
 }
示例#15
0
 /**
  * Check for, and handle, image editing actions.
  *
  * @param string $actionID  The action identifier.
  *
  * @return boolean  True if an action was handled, otherwise false.
  * @throws Ansel_Exception
  */
 public static function editActions($actionID)
 {
     global $notification, $page_output, $registry;
     $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
     $gallery_id = Horde_Util::getFormData('gallery');
     $image_id = Horde_Util::getFormData('image');
     $date = Ansel::getDateParameter();
     $page = Horde_Util::getFormData('page', 0);
     $watermark_font = Horde_Util::getFormData('font');
     $watermark_halign = Horde_Util::getFormData('whalign');
     $watermark_valign = Horde_Util::getFormData('wvalign');
     $watermark = Horde_Util::getFormData('watermark', $GLOBALS['prefs']->getValue('watermark_text'));
     // Get the gallery object and style information.
     try {
         $gallery = $ansel_storage->getGallery($gallery_id);
     } catch (Ansel_Exception $e) {
         $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error');
         Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
         exit;
     }
     switch ($actionID) {
         case 'modify':
             try {
                 $image = $ansel_storage->getImage($image_id);
                 $ret = Horde_Util::getFormData('ret', 'gallery');
             } catch (Ansel_Exception $e) {
                 $notification->push(_("Photo not found."), 'horde.error');
                 Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
                 exit;
             }
             $title = sprintf(_("Edit properties :: %s"), $image->filename);
             // Set up the form object.
             $vars = Horde_Variables::getDefaultVariables();
             if ($ret == 'gallery') {
                 $vars->set('actionID', 'saveclose');
             } else {
                 $vars->set('actionID', 'savecloseimage');
             }
             $form = new Ansel_Form_Image($vars, $title);
             $renderer = new Horde_Form_Renderer();
             // Set up the gallery attributes.
             $vars->set('image_default', $image->id == $gallery->get('default'));
             $vars->set('image_desc', $image->caption);
             $vars->set('image_tags', implode(', ', $image->getTags()));
             $vars->set('image_originalDate', $image->originalDate);
             $vars->set('image_uploaded', $image->uploaded);
             $page_output->header(array('title' => $title));
             $form->renderActive($renderer, $vars, Horde::url('image.php'), 'post', 'multipart/form-data');
             $page_output->footer();
             exit;
         case 'savecloseimage':
         case 'saveclose':
         case 'save':
             $title = _("Save Photo");
             if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $notification->push(_("Access denied saving photo to this gallery."), 'horde.error');
                 Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery', 'page' => $page), $date), true)->redirect();
                 exit;
             }
             // Validate the form object.
             $vars = Horde_Variables::getDefaultVariables();
             $vars->set('actionID', 'save');
             $renderer = new Horde_Form_Renderer();
             $form = new Ansel_Form_Image($vars, _("Edit a photo"));
             // Update existing image.
             if ($form->validate($vars)) {
                 $form->getInfo($vars, $info);
                 // Replacing photo
                 if (!empty($info['file0']['file'])) {
                     try {
                         $GLOBALS['browser']->wasFileUploaded('file0');
                         if (filesize($info['file0']['file'])) {
                             $data = file_get_contents($info['file0']['file']);
                             if (getimagesize($info['file0']['file']) === false) {
                                 $notification->push(_("The file you uploaded does not appear to be a valid photo."), 'horde.error');
                                 unset($data);
                             }
                         }
                     } catch (Horde_Browser_Exception $e) {
                     }
                 }
                 $image = $ansel_storage->getImage($image_id);
                 $image->caption = $vars->get('image_desc');
                 $image->setTags(explode(',', $vars->get('image_tags')));
                 $newDate = new Horde_Date($vars->get('image_originalDate'));
                 $image->originalDate = (int) $newDate->timestamp();
                 if (!empty($data)) {
                     try {
                         $image->replace($data);
                     } catch (Ansel_Exception $e) {
                         $notification->push(_("There was an error replacing the photo."), 'horde.error');
                     }
                 }
                 $image->save();
                 if ($vars->get('image_default')) {
                     if ($gallery->get('default') != $image_id) {
                         // Changing default - force refresh of stack
                         // If we have a default-pretty already, make sure we delete it
                         $ids = unserialize($gallery->get('default_prettythumb'));
                         if (is_array($ids)) {
                             foreach ($ids as $imageId) {
                                 $gallery->removeImage($imageId, true);
                             }
                         }
                         $gallery->set('default_prettythumb', '');
                     }
                     $gallery->set('default', $image_id);
                     $gallery->set('default_type', 'manual');
                 } elseif ($gallery->get('default') == $image_id) {
                     // Currently set as default, but we no longer wish it.
                     $gallery->set('default', 0);
                     $gallery->set('default_type', 'auto');
                     // If we have a default-pretty already, make sure we delete it
                     $ids = unserialize($gallery->get('default_prettythumb'));
                     if (is_array($ids)) {
                         foreach ($ids as $imageId) {
                             $gallery->removeImage($imageId);
                         }
                     }
                     $gallery->set('default_prettythumb', '');
                 }
                 $gallery->save();
                 $imageurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page), $date), true);
                 if ($actionID == 'save') {
                     $imageurl->redirect();
                 } elseif ($actionID == 'saveclose') {
                     $page_output->addInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();'));
                     $page_output->outputInlineScript();
                 } else {
                     $page_output->addInlineScript(array('window.opener.location.href = "' . $imageurl . '";', 'window.close();'));
                     $page_output->outputInlineScript();
                 }
                 exit;
             }
             break;
         case 'editimage':
         case 'cropedit':
         case 'resizeedit':
             $imageGenerator_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page), $date), true);
             $imageurl = Horde::url('image.php')->add(array_merge(array('gallery' => $gallery_id, 'slug' => $gallery->get('slug'), 'image' => $image_id, 'page' => $page), $date));
             $galleryurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'page' => $page, 'view' => 'Gallery', 'slug' => $gallery->get('slug')), $date));
             if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $notification->push(_("Access denied editing the photo."), 'horde.error');
                 // Return to the image view.
                 $imageGenerator_url->redirect();
                 exit;
             }
             // Retrieve image details.
             $image = $ansel_storage->getImage($image_id);
             $title = sprintf(_("Edit %s :: %s"), $gallery->get('name'), $image->filename);
             if ($actionID == 'cropedit') {
                 $geometry = $image->getDimensions('full');
                 $x1 = 0;
                 $y1 = 0;
                 $x2 = $geometry['width'];
                 $y2 = $geometry['height'];
                 // js and css files
                 $page_output->addScriptFile('scriptaculous/builder.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/effects.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/controls.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/dragdrop.js', 'horde');
                 $page_output->addScriptFile('cropper.js');
                 $page_output->addInlineScript('imageCropper.init();', true);
                 $page_output->addThemeStylesheet('cropper.css');
             } elseif ($actionID == 'resizeedit') {
                 // js and css files
                 $geometry = $image->getDimensions('full');
                 $page_output->addScriptFile('scriptaculous/builder.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/effects.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/controls.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/dragdrop.js', 'horde');
                 $page_output->addScriptFile('scriptaculous/slider.js', 'horde');
                 $page_output->addScriptFile('resizeimage.js');
                 $js = array('window.Ansel = window.Ansel || {}', 'Ansel.image_geometry = ' . Horde_Serialize::serialize($geometry, Horde_Serialize::JSON), "Ansel.slider = new Control.Slider(\n                        'handle1',\n                        'slider-track',\n                        {\n                            minimum: 1,\n                            maximum: Ansel.image_geometry['width'],\n                            sliderValue: Ansel.image_geometry['width'],\n                            handleImage: 'ansel_slider_img',\n                            axis: 'horizontal',\n                            onChange: function(e) { resizeImage(e * Ansel.image_geometry['width']); },\n                            onSlide: function(e) { resizeImage(e * Ansel.image_geometry['width']); }\n                        }\n                    );");
                 $page_output->addInlineScript($js, true);
             }
             $page_output->header(array('title' => $title));
             $notification->notify(array('listeners' => 'status'));
             if ($actionID == 'cropedit') {
                 require ANSEL_TEMPLATES . '/image/crop_image.inc';
             } elseif ($actionID == 'resizeedit') {
                 require ANSEL_TEMPLATES . '/image/resize_image.inc';
             } else {
                 require ANSEL_TEMPLATES . '/image/edit_image.inc';
             }
             $page_output->footer();
             exit;
         case 'watermark':
             if ($watermark) {
                 $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create();
                 $name = $identity->getValue('fullname');
                 if (empty($name)) {
                     $name = $registry->getAuth();
                 }
                 // Set up array of possible substitutions.
                 $watermark_array = array('%N' => $name, '%L' => $registry->getAuth());
                 $watermark = str_replace(array_keys($watermark_array), array_values($watermark_array), $watermark);
                 $watermark = strftime($watermark);
             }
             if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $notification->push(_("Access denied saving photo to this gallery."), 'horde.error');
                 // Return to the image view
                 Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page, 'slug' => $gallery->get('slug')), $date), true)->redirect();
                 exit;
             } else {
                 $image = $ansel_storage->getImage($image_id);
                 $image->watermark('screen', $watermark, $watermark_halign, $watermark_valign, $watermark_font);
                 $image->updateData($image->raw('screen'), 'screen');
                 Horde::url('image.php', true)->add(array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'actionID' => 'editimage', 'page' => $page), $date))->redirect();
                 exit;
             }
         case 'rotate90':
         case 'rotate180':
         case 'rotate270':
         case 'flip':
         case 'mirror':
         case 'grayscale':
         case 'crop':
         case 'resize':
             if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $notification->push(_("Access denied saving photo to this gallery."), 'horde.error');
             } else {
                 try {
                     $image = $ansel_storage->getImage($image_id);
                 } catch (Ansel_Exception $e) {
                     $notification->push($e->getMessage(), 'horde.error');
                     Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
                     exit;
                 }
                 switch ($actionID) {
                     case 'rotate90':
                     case 'rotate180':
                     case 'rotate270':
                         $angle = intval(substr($actionID, 6));
                         try {
                             $image->rotate('full', $angle);
                         } catch (Ansel_Exception $e) {
                             Horde::log($e->getMessage(), 'ERR');
                             $notification->push($e->getMessage(), 'horde.error');
                             $error = true;
                         }
                         break;
                     case 'flip':
                         try {
                             $image->flip('full');
                         } catch (Ansel_Exception $e) {
                             Horde::log($e->getMessage(), 'ERR');
                             $notification->push($e->getMessage(), 'horde.error');
                             $error = true;
                         }
                         break;
                     case 'mirror':
                         try {
                             $image->mirror('full');
                         } catch (Ansel_Exception $e) {
                             Horde::log($e->getMessage(), 'ERR');
                             $notification->push($e->getMessage(), 'horde.error');
                             $error = true;
                         }
                         break;
                     case 'grayscale':
                         try {
                             $image->grayscale('full');
                         } catch (Ansel_Exception $e) {
                             Horde::log($e->getMessage(), 'ERR');
                             $notification->push($e->getMessage(), 'horde.error');
                             $error = true;
                         }
                         break;
                     case 'crop':
                         $image->load('full');
                         $params = Horde_Util::getFormData('params');
                         list($x1, $y1, $x2, $y2) = explode('.', $params);
                         try {
                             $image->crop($x1, $y1, $x2, $y2);
                         } catch (Ansel_Exception $e) {
                             Horde::log($e->getMessage(), 'ERR');
                             $notification->push($e->getMessage(), 'horde.error');
                             $error = true;
                         }
                         break;
                     case 'resize':
                         $image->load('full');
                         $width = Horde_Util::getFormData('width');
                         $height = Horde_Util::getFormData('height');
                         try {
                             $image->resize($width, $height, true);
                         } catch (Ansel_Exception $e) {
                             Horde::log($e->getMessage(), 'ERR');
                             $notification->push($e->getMessage(), 'horde.error');
                             $error = true;
                         }
                         break;
                 }
                 if (empty($error)) {
                     $image->updateData($image->raw());
                 }
             }
             Horde::url('image.php', true)->add(array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'actionID' => 'editimage', 'page' => $page), $date))->redirect();
             exit;
         case 'setwatermark':
             $title = _("Watermark");
             try {
                 $image = $ansel_storage->getImage($image_id);
             } catch (Ansel_Exception $e) {
                 $notification->push($image->getMessage(), 'horde.error');
                 Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
                 exit;
             }
             $vars = Horde_Variables::getDefaultVariables();
             $vars->set('actionID', 'previewcustomwatermark');
             $form = new Ansel_Form_Watermark($vars, _("Watermark"));
             $renderer = new Horde_Form_Renderer();
             $page_output->header(array('title' => $title));
             $form->renderActive($renderer, $vars, Horde::url('image.php'), 'post');
             $page_output->footer();
             exit;
         case 'previewcustomwatermark':
             $imageurl = Horde::url('image.php', true)->add(array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'page' => $page, 'watermark' => $watermark, 'font' => $watermark_font, 'whalign' => $watermark_halign, 'wvalign' => $watermark_valign, 'actionID' => 'previewwatermark'), $date));
             $page_output->addInlineScript(array('window.opener.location.href = "' . $imageurl . '";', 'window.close();'));
             $page_output->outputInlineScript();
             exit;
         case 'previewgrayscale':
         case 'previewwatermark':
         case 'previewflip':
         case 'previewmirror':
         case 'previewrotate90':
         case 'previewrotate180':
         case 'previewrotate270':
             $title = _("Edit Photo");
             $action = substr($actionID, 7);
             $image = $ansel_storage->getImage($image_id);
             $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename);
             $page_output->header(array('title' => $title));
             require ANSEL_TEMPLATES . '/image/preview_image.inc';
             $page_output->footer();
             exit;
         case 'imagerotate90':
         case 'imagerotate180':
         case 'imagerotate270':
             $view = Horde_Util::getFormData('view');
             $angle = intval(substr($actionID, 11));
             $image = $ansel_storage->getImage($image_id);
             $image->rotate($view, $angle);
             $image->display($view);
             exit;
         case 'imageflip':
             $view = Horde_Util::getFormData('view');
             $image = $ansel_storage->getImage($image_id);
             $image->flip($view);
             $image->display($view);
             exit;
         case 'imagemirror':
             $view = Horde_Util::getFormData('view');
             $image = $ansel_storage->getImage($image_id);
             $image->mirror($view);
             $image->display($view);
             exit;
         case 'imagegrayscale':
             $view = Horde_Util::getFormData('view');
             $image = $ansel_storage->getImage($image_id);
             $image->grayscale($view);
             $image->display($view);
             exit;
         case 'imagewatermark':
             $view = Horde_Util::getFormData('view');
             $image = $ansel_storage->getImage($image_id);
             $image->watermark($view, $watermark, $watermark_halign, $watermark_valign, $watermark_font);
             $image->display($view);
             exit;
         case 'previewcrop':
             if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $notification->push(_("Access denied editing the photo."), 'horde.error');
                 Ansel::getUrlFor('view', array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page))->redirect();
             } else {
                 $x1 = (int) Horde_Util::getFormData('x1');
                 $y1 = (int) Horde_Util::getFormData('y1');
                 $x2 = (int) Horde_Util::getFormData('x2');
                 $y2 = (int) Horde_Util::getFormData('y2');
                 $title = _("Crop");
                 $action = substr($actionID, 7);
                 $image = $ansel_storage->getImage($image_id);
                 $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename);
                 $params = $x1 . '.' . $y1 . '.' . $x2 . '.' . $y2;
                 $page_output->header(array('title' => $title));
                 require ANSEL_TEMPLATES . '/image/preview_cropimage.inc';
                 $page_output->footer();
             }
             exit;
         case 'imagecrop':
             if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $params = Horde_Util::getFormData('params');
                 list($x1, $y1, $x2, $y2) = explode('.', $params);
                 $image = $ansel_storage->getImage($image_id);
                 $image->load('full');
                 $image->crop($x1, $y1, $x2, $y2);
                 $image->display();
             }
             exit;
     }
     return false;
 }
示例#16
0
 /**
  */
 public function create(Horde_Injector $injector)
 {
     return Horde_Variables::getDefaultVariables();
 }
示例#17
0
 /**
  * @throws Turba_Exception
  * @throws Horde_Exception_NotFound
  */
 public function download(Horde_Variables $vars)
 {
     global $attributes, $cfgSources, $injector;
     switch ($vars->actionID) {
         case 'download_file':
             /* Get the object. */
             if (!isset($cfgSources[$vars->source])) {
                 throw new Turba_Exception(_("The contact you requested does not exist."));
             }
             $object = $injector->getInstance('Turba_Factory_Driver')->create($vars->source)->getObject($vars->key);
             /* Check permissions. */
             if (!$object->hasPermission(Horde_Perms::READ)) {
                 throw new Turba_Exception(_("You do not have permission to view this contact."));
             }
             try {
                 return array('data' => $object->vfsInit()->read(Turba::VFS_PATH . '/' . $object->getValue('__uid'), $vars->file), 'name' => $vars->file);
             } catch (Horde_Vfs_Exception $e) {
                 Horde::log($e, 'ERR');
                 throw new Turba_Exception(sprintf(_("Access denied to %s"), $vars->file));
             }
         case 'export':
             $sources = array();
             if ($vars->objectkeys) {
                 foreach ($vars->objectkeys as $objectkey) {
                     list($source, $key) = explode(':', $objectkey, 2);
                     if (!isset($sources[$source])) {
                         $sources[$source] = array();
                     }
                     $sources[$source][] = $key;
                 }
             } else {
                 if (!isset($vars->source) && !empty($cfgSources)) {
                     reset($cfgSources);
                     $vars->source = key($cfgSources);
                 }
                 $sources[$vars->source] = array();
             }
             if ($vcard = in_array($vars->exportID, array(Horde_Data::EXPORT_VCARD, 'vcard30'))) {
                 $version = $vars->exportID == 'vcard30' ? '3.0' : '2.1';
             }
             $all_fields = $data = array();
             $tfd = $injector->getInstance('Turba_Factory_Driver');
             foreach ($sources as $source => $objectkeys) {
                 /* Create a Turba storage instance. */
                 $driver = $tfd->create($source);
                 $blobs = $driver->getBlobs();
                 /* Get the full, sorted contact list. */
                 try {
                     $results = count($objectkeys) ? $driver->getObjects($objectkeys) : $driver->search(array())->objects;
                 } catch (Turba_Exception $e) {
                     throw new Turba_Exception(sprintf(_("Failed to search the directory: %s"), $e->getMessage()));
                 }
                 $fields = array_keys($driver->map);
                 $all_fields = array_merge($all_fields, $fields);
                 $params = $driver->getParams();
                 foreach ($results as $ob) {
                     if ($vcard) {
                         $data[] = $driver->tovCard($ob, $version, null, true);
                     } else {
                         $row = array();
                         foreach ($fields as $field) {
                             if (substr($field, 0, 2) == '__' || isset($blobs[$field])) {
                                 continue;
                             }
                             $attribute = $ob->getValue($field);
                             if ($attributes[$field]['type'] == 'date') {
                                 $row[$field] = strftime('%Y-%m-%d', $attribute);
                             } elseif ($attributes[$field]['type'] == 'time') {
                                 $row[$field] = strftime('%R', $attribute);
                             } elseif ($attributes[$field]['type'] == 'datetime') {
                                 $row[$field] = strftime('%Y-%m-%d %R', $attribute);
                             } else {
                                 $row[$field] = Horde_String::convertCharset($attribute, 'UTF-8', $params['charset']);
                             }
                         }
                         $data[] = $row;
                     }
                 }
             }
             /* Make sure that all rows have the same columns if exporting from
              * different sources. */
             if (!$vcard && count($sources) > 1) {
                 for ($i = 0; $i < count($data); $i++) {
                     foreach ($all_fields as $field) {
                         if (!isset($data[$i][$field])) {
                             $data[$i][$field] = '';
                         }
                     }
                 }
             }
             switch ($vars->exportID) {
                 case Horde_Data::EXPORT_CSV:
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("contacts.csv"), $data, true);
                     exit;
                 case Horde_Data::EXPORT_OUTLOOKCSV:
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Outlookcsv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("contacts.csv"), $data, true, array_flip($this->getOutlookMapping()));
                     exit;
                 case Horde_Data::EXPORT_TSV:
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Tsv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("contacts.tsv"), $data, true);
                     exit;
                 case Horde_Data::EXPORT_VCARD:
                 case 'vcard30':
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Vcard', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("contacts.vcf"), $data, true);
                     exit;
                 case 'ldif':
                     $ldif = new Turba_Data_Ldif(array('browser' => $injector->getInstance('Horde_Browser'), 'vars' => Horde_Variables::getDefaultVariables(), 'cleanup' => array($this, 'cleanupData')));
                     $ldif->exportFile(_("contacts.ldif"), $data, true);
                     exit;
             }
             break;
     }
 }
示例#18
0
文件: browse.php 项目: horde/horde
<?php

/**
 * Turba browse.php.
 *
 * Copyright 2000-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL).  If you did
 * did not receive this file, see http://www.horde.org/licenses/apache.
 *
 * @author  Chuck Hagenbuch <*****@*****.**>
 * @package Turba
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('turba');
/* If default source is not browsable, try one from the addressbooks pref */
if (empty($cfgSources[Turba::$source]['browse'])) {
    $addressbooks = Turba::getAddressBooks();
    foreach ($addressbooks as $source) {
        if (!empty($cfgSources[$source]['browse'])) {
            Turba::$source = $source;
            break;
        }
    }
}
$params = array('addSources' => $addSources, 'attributes' => $attributes, 'browse_source_count' => $browse_source_count, 'browser' => $browser, 'cfgSources' => $cfgSources, 'copymoveSources' => $copymoveSources, 'conf' => $conf, 'factory' => $injector->getInstance('Turba_Factory_Driver'), 'history' => $injector->getInstance('Horde_History'), 'notification' => $notification, 'page_output' => $page_output, 'prefs' => $prefs, 'registry' => $registry, 'source' => Turba::$source, 'turba_shares' => $injector->getInstance('Turba_Shares'), 'vars' => Horde_Variables::getDefaultVariables());
$browse = new Turba_View_Browse($params);
$browse->run();
示例#19
0
文件: Attendees.php 项目: horde/horde
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $conf, $injector, $registry, $session;
     $config['templatePath'] = KRONOLITH_TEMPLATES . '/attendees';
     parent::__construct($config);
     $this->addHelper('Text');
     $this->formInput = Horde_Util::formInput();
     $this->view = Horde_Util::getFormData('view', 'Day');
     $this->date = $config['start']->dateString();
     $this->end = $config['end']->dateString();
     $this->freeBusy = $config['fbView']->render($config['start']);
     $auth = $injector->getInstance('Horde_Core_Factory_Auth')->create();
     if ($auth->hasCapability('list') && ($conf['auth']['list_users'] == 'list' || $conf['auth']['list_users'] == 'both')) {
         $this->userList = $auth->listNames();
     }
     $this->resourcesEnabled = !empty($conf['resources']['enabled']);
     if ($registry->hasMethod('contacts/search')) {
         $this->addressbookLink = Horde::url('#')->link(array('class' => 'widget', 'onclick' => 'window.open(\'' . Horde::url('contacts.php') . '\', \'contacts\', \'toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=550,height=270,left=100,top=100\'); return false;')) . Horde::img('addressbook_browse.png') . '<br />' . _("Address Book") . '</a>';
     }
     $vars = Horde_Variables::getDefaultVariables();
     $tabs = new Horde_Core_Ui_Tabs(null, $vars);
     $tabs->addTab(_("Day"), new Horde_Url('javascript:switchView(\'Day\')'), 'Day');
     $tabs->addTab(_("Work Week"), new Horde_Url('javascript:switchView(\'Workweek\')'), 'Workweek');
     $tabs->addTab(_("Week"), new Horde_Url('javascript:switchView(\'Week\')'), 'Week');
     $tabs->addTab(_("Month"), new Horde_Url('javascript:switchView(\'Month\')'), 'Month');
     $this->tabs = $tabs->render($this->view);
     $attendees = $session->get('kronolith', 'attendees');
     if ($attendees) {
         $roles = array(Kronolith::PART_REQUIRED, Kronolith::PART_OPTIONAL, Kronolith::PART_NONE);
         $responses = array(Kronolith::RESPONSE_ACCEPTED, Kronolith::RESPONSE_DECLINED, Kronolith::RESPONSE_TENTATIVE, Kronolith::RESPONSE_NONE);
         $this->attendees = array();
         foreach ($attendees as $attendee) {
             $viewAttendee = array('id' => $attendee->id, 'name' => strval($attendee), 'deleteLink' => Horde::url('#')->link(array('title' => sprintf(_("Remove %s"), $attendee->displayName), 'onclick' => "performAction('remove', decodeURIComponent('" . rawurlencode($attendee->id) . "')); return false;")) . Horde::img('delete.png') . '</a>');
             if ($attendee->user) {
                 unset($this->userList[$attendee->user]);
             } else {
                 $viewAttendee['editLink'] = Horde::url('#')->link(array('title' => sprintf(_("Edit %s"), $attendee->displayName), 'onclick' => "performAction('edit', decodeURIComponent('" . rawurlencode($attendee->id) . "')); return false;")) . Horde::img('edit.png') . '</a>';
             }
             foreach ($roles as $role) {
                 $viewAttendee['roles'][$role] = array('selected' => $attendee->role == $role, 'label' => Kronolith::partToString($role));
             }
             foreach ($responses as $response) {
                 $viewAttendee['responses'][$response] = array('selected' => $attendee->response == $response, 'label' => Kronolith::responseToString($response));
             }
             $this->attendees[] = $viewAttendee;
         }
     }
     $this->resources = $session->get('kronolith', 'resources', Horde_Session::TYPE_ARRAY);
     foreach ($this->resources as $id => &$resource) {
         $resource['id'] = $id;
         $resource['deleteLink'] = Horde::url('#')->link(array('title' => sprintf(_("Remove %s"), $resource['name']), 'onclick' => "performAction('removeResource', decodeURIComponent('" . $id . "')); return false;")) . Horde::img('delete.png') . '</a>';
         foreach ($roles as $role) {
             $resource['roles'][$role] = array('selected' => $resource['attendance'] == $role, 'label' => Kronolith::partToString($role));
         }
         foreach ($responses as $response) {
             $resource['responses'][$response] = array('selected' => $resource['response'] == $response, 'label' => Kronolith::responseToString($response));
         }
     }
     /* Get list of resources for select list, and remove those we already
      * added. */
     if ($this->resourcesEnabled) {
         $this->allResources = array_diff_key(Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array(), 'name'), $this->resources);
     }
 }
示例#20
0
文件: Api.php 项目: horde/horde
 /**
  * Allows other Horde apps to post messages.
  *
  * The forum name is constructed by just the $forum_name variable under the
  * data root 'agora.forums.<app>'. It is up to the apps themselves to make
  * sure that the forum name is unique.
  *
  * If the forum does not exist, it will be automatically created by Agora.
  *
  * @access private
  *
  * @param string $scope       The application which is posting this message.
  * @param string $forum_name  The unique name for the forum.
  * @param string $callback    A callback method of the specified application
  *                            that gets called to make sure that posting to
  *                            this forum is allowed.
  * @param array $params       Any parameters for the forum message posting.
  * <pre>
  * message_id        - An existing message to edit
  * message_parent_id - The ID of the parent message
  * title             - Posting title
  * </pre>
  * @param string $url         If specified, the form gets submitted to this URL
  *                            instead of the current page.
  * @param array $variables    A hash with all variables of a submitted form
  *                            generated by this method.
  *
  * @return mixed  Returns either the rendered Horde_Form for posting a message
  *                or PEAR_Error object on error, or true in case of a
  *                successful post.
  */
 public function postMessage($scope, $forum_name, $callback, $params = array(), $url = null, $variables = null)
 {
     global $registry;
     /* Check if posting messages is allowed. */
     $check = $registry->callByPackage($scope, $callback, array($forum_name));
     if ($check instanceof PEAR_Error || !$check) {
         return '';
     }
     /* Create a separate notification queue. */
     $queue = Horde_Notification::singleton('agoraPostMessage');
     $queue->attach('status');
     /* Set up the forums object. */
     $forums = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope);
     /* Set up form variables. */
     $vars = Horde_Variables::getDefaultVariables();
     if (is_array($variables)) {
         foreach ($variables as $varname => $value) {
             $vars->add($varname, $value);
         }
     }
     $formname = $vars->get('formname');
     /* Check if the forum exists and fetch the ID. */
     $params['forum_id'] = $forums->getForumId($forum_name);
     if ($params['forum_id'] === null) {
         $vars->set('new_forum', $forum_name);
     } else {
         $vars->set('forum_id', $params['forum_id']);
     }
     /* Set up the messages control object. */
     $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope, $params['forum_id']);
     if ($messages instanceof PEAR_Error) {
         $queue->push(_("Could not post the message: ") . $messages->getMessage(), 'horde.error');
         Horde::startBuffer();
         $queue->notify(array('listeners' => 'status'));
         return Horde::endBuffer();
     }
     /* Check post permissions. */
     if (!$messages->hasPermission(Horde_Perms::EDIT)) {
         Horde::permissionDeniedError('agora', null);
         return PEAR::raiseError(sprintf(_("You don't have permission to post messages in forum %s."), $params['forum_id']));
     }
     if (isset($params['message_id'])) {
         $message = $messages->getMessage($params['message_id']);
         if (!$formname) {
             $vars = new Horde_Variables($message);
             $vars->set('message_subject', $message['message_subject']);
             $vars->set('message_body', $message['body']);
         }
         $editing = true;
     } else {
         $editing = false;
         $params['message_id'] = null;
     }
     /* Set a default title if one not specified. */
     if (!isset($params['title'])) {
         $params['title'] = $editing ? _("Edit Message") : _("Post a New Message");
     }
     /* Get the form object. */
     $form = $messages->getForm($vars, $params['title'], $editing, is_null($params['forum_id']));
     /* Validate the form. */
     if ($form->validate($vars)) {
         $form->getInfo($vars, $info);
         if (isset($info['new_forum'])) {
             $forum_info = $this->prepareFormData($scope, false, array('forum_name' => $info['new_forum']), $callback);
             if ($forum_info instanceof PEAR_Error) {
                 return $forum_info;
             }
             $info['forum_id'] = $m_params['forum_id'] = $forums->saveForum($forum_info);
             $result = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope, $info['forum_id']);
             if ($result instanceof PEAR_Error) {
                 return $result;
             }
         }
         /* Try and store this message and get back a new message_id */
         $message_id = $messages->saveMessage($info);
         if ($message_id instanceof PEAR_Error) {
             $queue->push(_("Could not post the message: ") . $message_id->getMessage(), 'horde.error');
         } else {
             $queue->push(_("Message posted."), 'horde.success');
             $count = $messages->countMessages();
             $registry->callByPackage($scope, $callback, array($forum_name, 'messages', $count));
             Horde::startBuffer();
             $queue->notify(array('listeners' => 'status'));
             return Horde::endBuffer();
         }
     }
     /* Replying to a previous post? */
     if (isset($params['message_parent_id']) && !$form->isSubmitted()) {
         $message = $messages->replyMessage($params['message_parent_id']);
         if (!$message instanceof PEAR_Error) {
             $vars->set('message_parent_id', $params['message_parent_id']);
             $vars->set('message_subject', $message['message_subject']);
             $vars->set('message_body', $message['body']);
         } else {
             /* Bad parent message id, offer to do a regular post. */
             $vars->set('message_parent_id', '');
         }
     }
     if (!$url) {
         $url = Horde::selfUrl(true, false, true);
     }
     Horde::startBuffer();
     $form->renderActive(null, $vars, $url, 'post', null, false);
     return Horde::endBuffer();
 }
示例#21
0
文件: List.php 项目: DSNS-LAB/Dmail
 /**
  * @param integer $numDisplayed  Set to the number of displayed contacts.
  * @param object $filter         A Turba_View_List filter object.
  * @param string $page           The currently displayed page.
  *
  * @return string
  */
 protected function _get(&$numDisplayed, $filter, $page)
 {
     ob_start();
     $width = floor(90 / (count($this->columns) + 1));
     $own = $GLOBALS['prefs']->getValue('own_contact');
     if (strpos($own, ';')) {
         list($own_source, $own_id) = explode(';', $own);
     } else {
         $own_source = $own_id = null;
     }
     $vars = Horde_Variables::getDefaultVariables();
     include TURBA_TEMPLATES . '/browse/column_headers.inc';
     $numDisplayed = 0;
     $this->list->reset();
     while ($ob = $this->list->next()) {
         if ($filter->skip($ob)) {
             continue;
         }
         include TURBA_TEMPLATES . '/browse/row.inc';
         $numDisplayed++;
     }
     include TURBA_TEMPLATES . '/browse/column_footers.inc';
     return ob_get_clean();
 }
示例#22
0
<?php

/**
 * Copyright 2001-2002 Robert E. Coyle <*****@*****.**>
 * Copyright 2001-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('whups');
$empty = '';
$beendone = 0;
$wereerrors = 0;
$vars = Horde_Variables::getDefaultVariables($empty);
$formname = $vars->get('formname');
Whups::addTopbarSearch();
$form1 = new Whups_Form_Ticket_CreateStepOne($vars);
$form2 = new Whups_Form_Ticket_CreateStepTwo($vars);
$form3 = new Whups_Form_Ticket_CreateStepThree($vars);
$form4 = new Whups_Form_Ticket_CreateStepFour($vars);
$r = new Horde_Form_Renderer(array('varrenderer_driver' => array('whups', 'whups')));
$valid4 = $form4->validate($vars) && $formname == 'whups_form_ticket_createstepfour';
$valid3 = $form3->validate($vars, true);
$valid2 = $form2->validate($vars, !$form1->isSubmitted());
$valid1 = $form1->validate($vars, true);
$doAssignForm = $GLOBALS['registry']->getAuth() && $whups_driver->isCategory('assigned', $vars->get('state'));
if ($valid1 && $valid2 && $valid3 && (!$doAssignForm || $valid4)) {
    $form1->getInfo($vars, $info);
    $form2->getInfo($vars, $info);
    $form3->getInfo($vars, $info);
示例#23
0
文件: List.php 项目: horde/horde
 /**
  * Return the HTML representing this view.
  *
  * @return string  The HTML.
  *
  */
 public function html()
 {
     global $conf, $prefs, $registry;
     $vars = Horde_Variables::getDefaultVariables();
     if (!empty($this->_params['page'])) {
         $vars->add('page', $this->_params['page']);
     }
     if (!empty($this->_params['pager_url'])) {
         $this->_pagerurl = $this->_params['pager_url'];
         $override = true;
     } else {
         $override = false;
         $this->_pagerurl = Ansel::getUrlFor('view', array('owner' => $this->_owner, 'special' => $this->_special, 'groupby' => $this->_view->groupby, 'view' => 'List'));
     }
     $p_params = array('num' => $this->_view->numGalleries, 'url' => $this->_pagerurl, 'perpage' => $this->_view->gPerPage);
     if ($override) {
         $p_params['url_callback'] = null;
     }
     $this->_pager = new Horde_Core_Ui_Pager('page', $vars, $p_params);
     $preserve = array('sort_dir' => $this->_view->sortDir);
     if (!empty($this->_view->sortBy)) {
         $preserve['sort'] = $this->_view->sortBy;
     }
     $this->_pager->preserve($preserve);
     if ($this->_view->numGalleries) {
         $min = $this->_page * $this->_view->gPerPage;
         $max = $min + $this->_view->gPerPage;
         if ($max > $this->_view->numGalleries) {
             $max = $this->_view->numGalleries - $min;
         }
         $this->_view->start = $min + 1;
         $this->_view->end = min($this->_view->numGalleries, $min + $this->_view->gPerPage);
         if ($this->_owner) {
             $this->_view->refresh_link = Ansel::getUrlFor('view', array('groupby' => $this->_view->groupby, 'owner' => $this->_owner, 'page' => $this->_page, 'view' => 'List'));
         } else {
             $this->_view->refresh_link = Ansel::getUrlFor('view', array('view' => 'List', 'groupby' => $this->_view->groupby, 'page' => $this->_page));
         }
         // Get top-level / default gallery style.
         if (empty($this->_params['style'])) {
             $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
         } else {
             $style = Ansel::getStyleDefinition($this->_params['style']);
         }
         // Final touches.
         if (empty($this->_params['api'])) {
             $this->_view->breadcrumbs = Ansel::getBreadcrumbs();
             $this->_view->groupbyUrl = strval(Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'owner')));
         }
         $this->_view->pager = $this->_pager->render();
         $this->_view->style = $style;
         $this->_view->tilesperrow = $prefs->getValue('tilesperrow');
         $this->_view->cellwidth = round(100 / $this->_view->tilesperrow);
         $this->_view->params = $this->_params;
         $GLOBALS['page_output']->addScriptFile('views/common.js');
         return $this->_view->render('list');
     }
     return '&nbsp;';
 }
示例#24
0
文件: Cli.php 项目: jubinpatel/horde
 /**
  */
 public function __construct($options = array())
 {
     global $registry, $conf;
     parent::__construct($options);
     $options = array(new Horde_Argv_Option('-b', '--base', array('type' => 'string')), new Horde_Argv_Option('-u', '--user', array('type' => 'string')), new Horde_Argv_Option('-p', '--pass', array('type' => 'string')));
     $parser = new Horde_Argv_Parser(array('allowUnknownArgs' => true, 'optionList' => $options, 'addHelpOption' => false));
     list($this->_argv, $args) = $parser->parseArgs();
     if (!count($args)) {
         throw new Koward_Exception('unknown command: ' . implode(' ', $args));
     }
     /**
      * FIXME: Workaround to fix the path so that the command line call
      * really only needs the route.
      */
     $this->_path = $registry->get('webroot', 'koward') . '/' . $args[0];
     try {
         $registry->pushApp('koward', false);
     } catch (Horde_Exception $e) {
         if ($e->getCode() == 'permission_denied') {
             echo 'Perission denied!';
             exit;
         }
     }
     $this->_cmd_argv = array();
     /* Authenticate the user if possible. */
     if ($this->_argv->user) {
         $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
         if (!$auth->authenticate($this->_argv->user, array('password' => $this->_argv->pass))) {
             throw new InvalidArgumentException('Failed to log in!');
         }
     }
     try {
         $registry->pushApp('koward', empty($this->auth_handler) || $this->auth_handler != $this->params[':action']);
     } catch (Horde_Exception $e) {
         if ($e->getCode() == 'permission_denied') {
             $this->urlFor(array('controller' => 'index', 'action' => 'login'))->redirect();
         }
     }
     /**
      * A rough command line handler that allows us to map CLI requests into
      * the web view of the system.
      */
     switch ($args[0]) {
         case 'object/add':
             $this->_cmd_argv['formname'] = 'koward_form_object';
             /** Has the object type been set? */
             if ($this->_argv->type && is_array($this->_argv->type) && count($this->_argv->type) == 1) {
                 $type = $this->_argv->type[0];
                 /**
                  * FIXME: Editing on the command line does not work if we don't
                  * specify the full set of form attributes. Yet another reason
                  * for not using the Form.
                  */
                 if ($this->_argv->id && is_array($this->_argv->id) && count($this->_argv->id) == 1) {
                     $this->_cmd_argv['id'] = $this->_argv->id[0];
                 } else {
                     $this->_cmd_argv['id'] = $this->_argv->id;
                 }
                 /**
                  * Fake the selected type for the form handler and short circuit the
                  * type selection machinery.
                  */
                 $this->_cmd_argv['__old_type'] = $type;
                 /**
                  * Fake the form token. Hm, it does not really make much sense
                  * to use the standard form mechanisms via CLI. Think of some
                  * alternatives here.
                  */
                 $token = $GLOBALS['injector']->getInstance('Horde_Token')->get('cli');
                 $this->_cmd_argv['koward_form_object_formToken'] = $token;
                 /**
                  * FIXME: Allow retrieving the form fields without specifying $vars.
                  */
                 $object = null;
                 $form = new Koward_Form_Object(Horde_Variables::getDefaultVariables(), $object);
                 $fields = array_keys($form->getTypeFields($type));
                 /**
                  * Now that we know the type of object that should be edited we
                  * can restrict the amount of options we allow.
                  */
                 $options = array(new Horde_Argv_Option('-b', '--base', array('type' => 'string')), new Horde_Argv_Option('-u', '--user', array('type' => 'string')), new Horde_Argv_Option('-p', '--pass', array('type' => 'string')), new Horde_Argv_Option('-t', '--type', array('type' => 'string')), new Horde_Argv_Option('-i', '--id', array('type' => 'string')));
                 foreach ($fields as $field) {
                     $options[] = new Horde_Argv_Option(null, '--' . $field, array('type' => 'string'));
                 }
                 $parser = new Horde_Argv_Parser(array('allowUnknownArgs' => false, 'optionList' => $options, 'addHelpOption' => true));
                 list($cmd_argv, $cmd) = $parser->parseArgs();
                 foreach ($cmd_argv as $field => $value) {
                     if ($field == 'userPassword') {
                         /**
                          * FIXME: Obvious hack and probably another reason why
                          * mixing forms and CLI does not make that much
                          * sense.
                          */
                         $this->_cmd_argv['object']['userPassword']['original'] = $value;
                         $this->_cmd_argv['object']['userPassword']['confirm'] = $value;
                     } else {
                         if (in_array($field, $fields) && $value !== null) {
                             $this->_cmd_argv['object'][$field] = $value;
                         }
                     }
                 }
             }
             break;
         case 'object/delete':
             if ($this->_argv->id && is_array($this->_argv->id) && count($this->_argv->id) == 1) {
                 $this->_cmd_argv['id'] = $this->_argv->id[0];
             } else {
                 $this->_cmd_argv['id'] = $this->_argv->id;
             }
             /**
              * Provide a token for immediate deletion.
              */
             $this->_cmd_argv['token'] = $GLOBALS['injector']->getInstance('Horde_Token')->get('object.delete');
             break;
     }
 }
示例#25
0
文件: Base.php 项目: horde/horde
 /**
  * Constructor.
  *
  * @param Horde_Data_Storage  A storage object.
  * @param array $params       Optional parameters:
  *   - browser: (Horde_Browser) A browser object.
  *   - http: (Horde_Http_Client) A HTTP client object.
  *   - cleanup: (callback) A callback to call at cleanup time.
  *   - vars: (Horde_Variables) Form data.
  */
 public function __construct(Horde_Data_Storage $storage, array $params = array())
 {
     $this->storage = $storage;
     if (isset($params['browser'])) {
         $this->_browser = $params['browser'];
     }
     if (isset($params['http'])) {
         $this->_http = $params['http'];
     }
     if (isset($params['cleanup']) && is_callable($params['cleanup'])) {
         $this->_cleanupCallback = $params['cleanup'];
     }
     $this->_vars = isset($params['vars']) ? $params['vars'] : Horde_Variables::getDefaultVariables();
 }
示例#26
0
 /**
  * Handle uploads from non-js browsers
  */
 public function handleLegacy()
 {
     global $conf, $notification, $page_output, $browser;
     $vars = Horde_Variables::getDefaultVariables();
     $form = new Ansel_Form_Upload($vars, _("Upload photos"));
     // Output the carousel JS in case we are here because the user
     // explicitly selected the old uploader.
     $js = $this->_doCarouselSetup();
     if (!empty($js)) {
         $page_output->addInlineScript($js, true);
     }
     if ($form->validate($vars)) {
         $valid = true;
         $uploaded = 0;
         $form->getInfo($vars, $info);
         // Remember the ids of the images we uploaded so we can autogen
         $image_ids = array();
         for ($i = 0; $i <= $conf['image']['num_uploads'] + 1; ++$i) {
             if (empty($info['file' . $i]['file'])) {
                 continue;
             }
             try {
                 $GLOBALS['browser']->wasFileUploaded('file' . $i);
             } catch (Horde_Browser_Exception $e) {
                 if (!empty($info['file' . $i]['error'])) {
                     $notification->push(sprintf(_("There was a problem uploading the photo: %s"), $info['file' . $i]['error']), 'horde.error');
                 } elseif (!filesize($info['file' . $i]['file'])) {
                     $notification->push(_("The uploaded file appears to be empty. It may not exist on your computer."), 'horde.error');
                 }
                 $valid = false;
                 continue;
             }
             // Check for a compressed file.
             if (in_array($info['file' . $i]['type'], array('x-extension/zip', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip')) || Horde_Mime_Magic::filenameToMime($info['file' . $i]['name']) == 'application/zip') {
                 $this->_handleZip($info['file' . $i]['name']);
             } else {
                 // Read in the uploaded data.
                 $data = file_get_contents($info['file' . $i]['file']);
                 // Try and make sure the image is in a recognizeable
                 // format.
                 if (getimagesize($info['file' . $i]['file']) === false) {
                     $notification->push(_("The file you uploaded does not appear to be a valid photo."), 'horde.error');
                     continue;
                 }
                 // Add the image to the gallery
                 $image_data = array('image_filename' => $info['file' . $i]['name'], 'image_caption' => $vars->get('image' . $i . '_desc'), 'image_type' => $info['file' . $i]['type'], 'data' => $data, 'tags' => isset($info['image' . $i . '_tags']) ? explode(',', $info['image' . $i . '_tags']) : array());
                 try {
                     $image_ids[] = $this->_gallery->addImage($image_data, (bool) $vars->get('image' . $i . '_default'));
                     ++$uploaded;
                 } catch (Ansel_Exception $e) {
                     $notification->push(sprintf(_("There was a problem saving the photo: %s"), $e->getMessage()), 'horde.error');
                     $valid = false;
                 }
             }
         }
         // Try to autogenerate some views and tell the user what happened.
         if ($uploaded) {
             $qtask = new Ansel_Queue_ProcessThumbs($image_ids);
             $queue = $GLOBALS['injector']->getInstance('Horde_Queue_Storage');
             $queue->add($qtask);
             // postupload hook if needed
             try {
                 Horde::callHook('postupload', array($image_ids), 'ansel');
             } catch (Horde_Exception_HookNotSet $e) {
             }
             $notification->push(sprintf(ngettext("%d photo was uploaded.", "%d photos were uploaded.", $uploaded), $uploaded), 'horde.success');
         } elseif ($vars->get('submitbutton') != _("Cancel")) {
             $notification->push(_("You did not select any photos to upload."), 'horde.error');
         }
         if ($valid) {
             // Return to the gallery view.
             Ansel::getUrlFor('view', array('gallery' => $this->_gallery->id, 'slug' => $this->_gallery->get('slug'), 'view' => 'Gallery', 'page' => $page), true)->redirect();
             exit;
         }
     }
     Horde::startBuffer();
     include ANSEL_TEMPLATES . '/image/upload.inc';
     return ($this->_forceNoScript ? '' : '<noscript>') . Horde::endBuffer() . ($this->_forceNoScript ? '' : '</noscript>');
 }
示例#27
0
文件: edit.php 项目: raz0rsdge/horde
<?php

/**
 * Copyright 2003-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
 *
 * @author Chuck Hagenbuch <*****@*****.**>
 * @author Marko Djukic <*****@*****.**>
 * @author Michael J. Rubinsky <*****@*****.**>
 * @package Jonah
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('jonah');
$params = array('vars' => Horde_Variables::getDefaultVariables(), 'registry' => &$registry, 'notification' => &$notification);
$view = new Jonah_View_ChannelEdit($params);
$view->run();
示例#28
0
 /**
  * @param string $tabname
  * @param Kronolith_Event $event
  */
 public static function eventTabs($tabname, $event)
 {
     if (!$event->initialized) {
         return;
     }
     $GLOBALS['page_output']->addScriptFile('views.js');
     $tabs = new Horde_Core_Ui_Tabs('event', Horde_Variables::getDefaultVariables());
     $date = self::currentDate();
     $tabs->preserve('datetime', $date->dateString());
     $tabs->addTab(htmlspecialchars($event->getTitle()), $event->getViewUrl(), array('tabname' => 'Event', 'id' => 'tabEvent', 'onclick' => 'return ShowTab(\'Event\');'));
     /* We check for read permissions, because we can always save a copy if
      * we can read the event. */
     if ((!$event->private || $event->creator == $GLOBALS['registry']->getAuth()) && $event->hasPermission(Horde_Perms::READ) && self::getDefaultCalendar(Horde_Perms::EDIT)) {
         $tabs->addTab($event->hasPermission(Horde_Perms::EDIT) ? _("_Edit") : _("Save As New"), $event->getEditUrl(), array('tabname' => 'EditEvent', 'id' => 'tabEditEvent', 'onclick' => 'return ShowTab(\'EditEvent\');'));
     }
     if ($event->hasPermission(Horde_Perms::DELETE)) {
         $tabs->addTab(_("De_lete"), $event->getDeleteUrl(array('confirm' => 1)), array('tabname' => 'DeleteEvent', 'id' => 'tabDeleteEvent', 'onclick' => 'return ShowTab(\'DeleteEvent\');'));
     }
     $tabs->addTab(_("Export"), $event->getExportUrl(), array('tabname' => 'ExportEvent', 'id' => 'tabExportEvent'));
     echo $tabs->render($tabname);
 }
示例#29
0
文件: delete.php 项目: horde/horde
/**
 * Copyright 2002-2016 Horde LLC (http://www.horde.org/)
 *
 * 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 <*****@*****.**>
 */
require_once __DIR__ . '/../../lib/Application.php';
Horde_Registry::appInit('kronolith');
// Exit if this isn't an authenticated administrative user.
$default = Horde::url($prefs->getValue('defaultview') . '.php', true);
if (!$registry->isAdmin()) {
    $default->redirect();
}
$vars = Horde_Variables::getDefaultVariables();
try {
    $resource = Kronolith::getDriver('Resource')->getResource($vars->get('c'));
    if (!$resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
        $notification->push(_("You are not allowed to delete this resource group."), 'horde.error');
        $default->redirect();
    }
} catch (Exception $e) {
    $notification->push($e);
    $default->redirect();
}
$form = new Kronolith_Form_DeleteResourceGroup($vars, $resource);
// Execute if the form is valid (must pass with POST variables only).
if ($form->validate(new Horde_Variables($_POST))) {
    try {
        $form->execute();
示例#30
0
 /**
  * Actually perform the export in the appropriate format.
  *
  * @param string $format  The format to export in.
  * @param array $hours     The data to export, as returned from
  *                        Hermes::makeExportHours()
  *
  */
 protected function _doExport($format, $hours)
 {
     switch ($format) {
         case Horde_Data::EXPORT_CSV:
             $class = 'Hermes_Data_Csv';
             $ext = 'csv';
             break;
         case Horde_Data::EXPORT_TSV:
             $class = 'Hermes_Data_Tsv';
             $ext = 'tsv';
             break;
         case 'xls':
             $class = 'Hermes_Data_Xls';
             $ext = 'xls';
             break;
         case 'iif':
             $class = 'Hermes_Data_Iif';
             $ext = 'iif';
             break;
     }
     $data = new $class($GLOBALS['injector']->getInstance('Horde_Core_Data_Storage'), array('browser' => $GLOBALS['injector']->getInstance('Horde_Browser'), 'vars' => Horde_Variables::getDefaultVariables()));
     $data->exportFile('time.' . $ext, $hours, true);
 }