/** * Perform search * * @throws Mnemo_Exception */ protected function _doSearch() { $search_pattern = $this->_vars->get('search_pattern'); $search_type = $this->_vars->get('search_type'); $search_desc = $search_type == 'desc'; $search_body = $search_type == 'body'; if (!empty($search_pattern) && ($search_body || $search_desc)) { $search_pattern = '/' . preg_quote($search_pattern, '/') . '/i'; $search_result = array(); foreach ($this->_notes as $memo_id => $memo) { if ($search_desc && preg_match($search_pattern, $memo['desc']) || $search_body && preg_match($search_pattern, $memo['body'])) { $search_result[$memo_id] = $memo; } } $this->_notes = $search_result; } elseif ($search_type == 'tags') { // Tag search, use the browser. $this->_browser->clearSearch(); $tags = $GLOBALS['injector']->getInstance('Mnemo_Tagger')->split($this->_vars->get('search_pattern')); foreach ($tags as $tag) { $this->_browser->addTag($tag); } $this->_notes = $this->_browser->getSlice(); $this->_handleActions(false); return; } $this->_baseurl->add(array('actionID' => 'search_memos', 'search_pattern' => $search_pattern, 'search_type' => $search_type)); }
/** */ protected function _handle(Horde_Variables $vars) { // Avoid errors if 'input' isn't set and short-circuit empty searches. if (!isset($vars->input)) { $result = array(); } else { $input = $vars->get($vars->input); $result = strlen($input) ? $this->_handleAutoCompleter($input) : array(); } return new Horde_Core_Ajax_Response_Prototypejs($result); }
/** * Function to validate any delete form input. * * @param TODO $info TODO * * @return mixed If the delete button confirmation has been pressed return * true, if any other submit button has been pressed return * false. If form did not validate return null. */ public function validateDeleteForm(&$info) { $form_submit = $this->_vars->get('submitbutton'); if ($form_submit == Horde_Core_Translation::t("Delete")) { if ($this->_form->validate($this->_vars)) { $this->_form->getInfo($this->_vars, $info); return true; } } elseif (!empty($form_submit)) { return false; } return null; }
/** * Expects: * $vars * $registry * $notification */ public function run() { extract($this->_params, EXTR_REFS); /* Set up the form variables and the form. */ $form_submit = $vars->get('submitbutton'); $channel_id = $vars->get('channel_id'); try { $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id); } catch (Exception $e) { Horde::log($e, 'ERR'); $notification->push(_("Invalid channel specified for deletion."), 'horde.message'); Horde::url('channels')->redirect(); exit; } /* If not yet submitted set up the form vars from the fetched channel. */ if (empty($form_submit)) { $vars = new Horde_Variables($channel); } /* Check permissions and deny if not allowed. */ if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::DELETE, $channel_id)) { $notification->push(_("You are not authorised for this action."), 'horde.warning'); throw new Horde_Exception_AuthenticationFailure(); } $title = sprintf(_("Delete News Channel \"%s\"?"), $vars->get('channel_name')); $form = new Horde_Form($vars, $title); $form->setButtons(array(_("Delete"), _("Do not delete"))); $form->addHidden('', 'channel_id', 'int', true, true); $msg = _("Really delete this News Channel? All stories created in this channel will be lost!"); $form->addVariable($msg, 'confirm', 'description', false); if ($form_submit == _("Delete")) { if ($form->validate($vars)) { $form->getInfo($vars, $info); try { $delete = $GLOBALS['injector']->getInstance('Jonah_Driver')->deleteChannel($info); $notification->push(_("The channel has been deleted."), 'horde.success'); Horde::url('channels')->redirect(); exit; } catch (Exception $e) { $notification->push(sprintf(_("There was an error deleting the channel: %s"), $e->getMessage()), 'horde.error'); } } } elseif (!empty($form_submit)) { $notification->push(_("Channel has not been deleted."), 'horde.message'); Horde::url('channels')->redirect(); exit; } $GLOBALS['page_output']->header(array('title' => $title)); $notification->notify(array('listeners' => 'status')); $form->renderActive(null, $vars, Horde::selfUrl(), 'post'); $GLOBALS['page_output']->footer(); }
/** * Form variables used: * - input */ protected function _handle(Horde_Variables $vars) { global $injector; $args = array('html' => !empty($vars->html)); if (isset($vars->locale)) { $args['locale'] = $vars->locale; } $input = $vars->get($vars->input); try { return new Horde_Core_Ajax_Response_Prototypejs($injector->getInstance('Horde_Core_Factory_SpellChecker')->create($args, $input)->spellCheck($input)); } catch (Horde_Exception $e) { Horde::log($e, 'ERR'); return array('bad' => array(), 'suggestions' => array()); } }
/** * Check token. * * @param array $actions The list of actions that require token checking. * * @return string The verified action ID. */ protected function _checkToken($actions) { global $notification, $session; $actionID = $this->vars->actionID; /* Run through the action handlers */ if (!empty($actions) && strlen($actionID) && in_array($actionID, $actions)) { try { $session->checkToken($this->vars->get(self::INGO_TOKEN)); } catch (Horde_Exception $e) { $notification->push($e); $actionID = null; } } return $actionID; }
/** */ public function __construct(Horde_Variables $vars) { global $conf, $injector, $registry; $this->_userid = $registry->getAuth(); if ($conf['user']['change'] === true) { $this->_userid = $vars->get('userid', $this->_userid); } else { try { $this->_userid = Horde::callHook('default_username', array(), 'passwd'); } catch (Horde_Exception_HookNotSet $e) { } } $this->_backends = $injector->getInstance('Passwd_Factory_Driver')->backends; $this->_vars = $vars; $this->_init(); }
/** * expects * $notification * $registry * $vars */ public function run() { extract($this->_params, EXTR_REFS); $form = new Jonah_Form_Feed($vars); /* Set up some variables. */ $formname = $vars->get('formname'); $channel_id = $vars->get('channel_id'); /* Form not yet submitted and is being edited. */ if (!$formname && $channel_id) { $vars = new Horde_Variables($GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id)); } /* Get the vars for channel type. */ $channel_type = $vars->get('channel_type'); /* Check permissions and deny if not allowed. */ if (!Jonah::checkPermissions(Jonah::typeToPermName($channel_type), Horde_Perms::EDIT, $channel_id)) { $notification->push(_("You are not authorised for this action."), 'horde.warning'); throw new Horde_Exception_AuthenticationFailure(); } /* Output the extra fields required for this channel type. */ $form->setExtraFields($channel_id); if ($formname && empty($changed_type)) { if ($form->validate($vars)) { $form->getInfo($vars, $info); try { $save = $GLOBALS['injector']->getInstance('Jonah_Driver')->saveChannel($info); $notification->push(sprintf(_("The feed \"%s\" has been saved."), $info['channel_name']), 'horde.success'); Horde::url('channels')->redirect(); exit; } catch (Exception $e) { $notification->push(sprintf(_("There was an error saving the feed: %s"), $e->getMessage()), 'horde.error'); } } } $GLOBALS['page_output']->header(array('title' => $form->getTitle())); $notification->notify(array('listeners' => 'status')); $form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('channels/edit.php'), 'post'); $GLOBALS['page_output']->footer(); }
*/ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('ulaform', array('admin' => true)); /* Get some variables. */ $changed_action = false; $vars = Horde_Variables::getDefaultVariables(); $form_id = $vars->get('form_id'); $old_form_action = $vars->get('old_form_action'); $formname = $vars->get('formname'); $ulaform_driver = $injector->getInstance('Ulaform_Factory_Driver')->create(); /* Check if a form is being edited. */ if ($form_id && !$formname) { $vars = new Horde_Variables($ulaform_driver->getForm($form_id)); } /* Get the form action var, whether from edit or new. */ $form_action = $vars->get('form_action'); /* Get details for this action. */ $actions = Ulaform_Action::getDrivers(); /* Check if user changed action. */ if ($form_action != $old_form_action && $formname) { $changed_action = true; $notification->push(_("Changed action driver."), 'horde.message'); } /* Selected a action so get the info and parameters for this action. */ if ($form_action) { $action_info = Ulaform::getActionInfo($form_action); $action_params = Ulaform::getActionParams($form_action); } /* Set up the form. */ $form = new Horde_Form($vars, _("Form Details")); $form->setButtons(empty($form_id) ? _("Create") : _("Modify"), true);
/** * @throws Kronolith_Exception */ public function download(Horde_Variables $vars) { global $display_calendars, $injector; switch ($vars->actionID) { case 'download_file': $source = Horde_Util::getFormData('source'); $key = Horde_Util::getFormData('key'); $filename = Horde_Util::getFormData('file'); $type = Horde_Util::getFormData('type'); list($driver_type, $calendar) = explode('|', $source); if ($driver_type == 'internal' && !Kronolith::hasPermission($calendar, Horde_Perms::SHOW)) { $GLOBALS['notification']->push(_("Permission Denied"), 'horde.error'); return false; } try { $driver = Kronolith::getDriver($driver_type, $calendar); } catch (Exception $e) { $GLOBALS['notification']->push($e, 'horde.error'); return false; } $event = $driver->getEvent($key); /* Check permissions. */ if (!$event->hasPermission(Horde_Perms::READ)) { throw new Kronolith_Exception(_("You do not have permission to view this event.")); } try { $data = $event->vfsInit()->read(Kronolith::VFS_PATH . '/' . $event->getVfsUid(), $filename); } catch (Horde_Vfs_Exception $e) { Horde::log($e, 'ERR'); throw new Kronolith_Exception(sprintf(_("Access denied to %s"), $filename)); } try { return array('data' => $data, 'name' => $vars->file, 'type' => $type); } catch (Horde_Vfs_Exception $e) { Horde::log($e, 'ERR'); throw new Kronolith_Exception(sprintf(_("Access denied to %s"), $vars->file)); } case 'export': if ($vars->all_events) { $end = $start = null; } else { $start = new Horde_Date($vars->start_year, $vars->start_month, $vars->start_day); $end = new Horde_Date($vars->end_year, $vars->end_month, $vars->end_day); } $calendars = $vars->get('exportCal', $display_calendars); if (!is_array($calendars)) { $calendars = array($calendars); } $events = array(); foreach ($calendars as $calendar) { list($type, $cal) = explode('_', $calendar, 2); $kronolith_driver = Kronolith::getDriver($type, $cal); $calendarObject = Kronolith::getCalendar($kronolith_driver); if (!$calendarObject || !$calendarObject->hasPermission(Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(); } $events[$calendar] = $kronolith_driver->listEvents($start, $end, array('cover_dates' => false, 'hide_exceptions' => $vars->exportID == Horde_Data::EXPORT_ICALENDAR)); } switch ($vars->exportID) { case Horde_Data::EXPORT_CSV: $data = array(); foreach ($events as $calevents) { foreach ($calevents as $dayevents) { foreach ($dayevents as $event) { $row = array('alarm' => $event->alarm, 'description' => $event->description, 'end_date' => $event->end->format('Y-m-d'), 'end_time' => $event->end->format('H:i:s'), 'location' => $event->location, 'private' => intval($event->private), 'recur_type' => null, 'recur_end_date' => null, 'recur_interval' => null, 'recur_data' => null, 'start_date' => $event->start->format('Y-m-d'), 'start_time' => $event->start->format('H:i:s'), 'tags' => implode(', ', $event->tags), 'title' => $event->getTitle()); if ($event->recurs()) { $row['recur_type'] = $event->recurrence->getRecurType(); if ($event->recurrence->hasRecurEnd()) { $row['recur_end_date'] = $event->recurrence->recurEnd->format('Y-m-d'); } $row['recur_interval'] = $event->recurrence->getRecurInterval(); $row['recur_data'] = $event->recurrence->recurData; } $data[] = $row; } } } $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("events.csv"), $data, true); exit; case Horde_Data::EXPORT_ICALENDAR: $calNames = array(); $iCal = new Horde_Icalendar(); foreach ($events as $calevents) { foreach ($calevents as $dayevents) { foreach ($dayevents as $event) { $calNames[Kronolith::getCalendar($event->getDriver())->name()] = true; $iCal->addComponent($event->toiCalendar($iCal)); } } } $iCal->setAttribute('X-WR-CALNAME', implode(', ', array_keys($calNames))); return array('data' => $iCal->exportvCalendar(), 'name' => _("events.ics"), 'type' => 'text/calendar'); } } }
public function run() { extract($this->_params, EXTR_REFS); $form_submit = $vars->get('submitbutton'); $channel_id = $vars->get('channel_id'); $story_id = $vars->get('id'); /* Driver */ $driver = $GLOBALS['injector']->getInstance('Jonah_Driver'); /* Fetch the channel details, needed for later and to check if valid * channel has been requested. */ try { $channel = $driver->getChannel($channel_id); } catch (Exception $e) { $notification->push(sprintf(_("Story editing failed: %s"), $e->getMessage()), 'horde.error'); Horde::url('channels/index.php', true)->redirect(); exit; } /* Check permissions. */ if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::DELETE, $channel_id)) { $notification->push(_("You are not authorised for this action."), 'horde.warning'); throw new Horde_Exception_AuthenticationFailure(); } try { $story = $driver->getStory($channel_id, $story_id); } catch (Exception $e) { $notification->push(_("No valid story requested for deletion."), 'horde.message'); Horde::url('channels/index.php', true)->redirect(); exit; } /* If not yet submitted set up the form vars from the fetched story. */ if (empty($form_submit)) { $vars = new Horde_Variables($story); } $title = sprintf(_("Delete News Story \"%s\"?"), $vars->get('title')); $form = new Horde_Form($vars, $title); $form->setButtons(array(_("Delete"), _("Do not delete"))); $form->addHidden('', 'channel_id', 'int', true, true); $form->addHidden('', 'id', 'int', true, true); $form->addVariable(_("Really delete this News Story?"), 'confirm', 'description', false); if ($form_submit == _("Delete")) { if ($form->validate($vars)) { $form->getInfo($vars, $info); try { $delete = $driver->deleteStory($info['channel_id'], $info['id']); $notification->push(_("The story has been deleted."), 'horde.success'); Horde::url('stories/index.php', true)->add('channel_id', $channel_id)->setRaw(true)->redirect(); exit; } catch (Exception $e) { $notification->push(sprintf(_("There was an error deleting the story: %s"), $e->getMessage()), 'horde.error'); } } } elseif (!empty($form_submit)) { $notification->push(_("Story has not been deleted."), 'horde.message'); $url = Horde::url('stories/index.php', true)->add('channel_id', $channel_id)->setRaw(true); Horde::url('stories/index.php', true)->add('channel_id', $channel_id)->setRaw(true)->redirect(); exit; } $GLOBALS['page_output']->header(array('title' => $title)); $notification->notify(array('listeners' => 'status')); $form->renderActive(null, $vars, Horde::url('stories/delete.php'), 'post'); $GLOBALS['page_output']->footer(); }
} else { $form1->renderActive($renderer, $vars, $adminurl, 'post'); } } break; case 'whups_form_admin_editreplysteptwo': $form = new Whups_Form_Admin_EditReplyStepTwo($vars); $vars->set('action', 'type'); if ($vars->get('formname') == 'whups_form_admin_editreplysteptwo' && $form->validate($vars)) { try { $whups_driver->updateReply($vars->get('reply'), $vars->get('reply_name'), $vars->get('reply_text')); $notification->push(_("The form reply has been modified."), 'horde.success'); _open(); $form->renderInactive($renderer, $vars); echo '<br />'; $vars = new Horde_Variables(array('type' => $vars->get('type'))); } catch (Whups_Exception $e) { $notification->push(_("There was an error editing the form reply:") . ' ' . $e->getMessage(), 'horde.error'); } _open(); $form1 = new Whups_Form_Admin_EditReplyStepOne($vars); $form1->renderActive($renderer, $vars, $adminurl, 'post'); echo '<br />'; $form2 = new Whups_Form_Admin_AddReply($vars); $form2->renderActive($renderer, $vars, $adminurl, 'post'); } else { _open(); $form->renderActive($renderer, $vars, $adminurl, 'post'); } break; case 'whups_form_admin_deletereply':
/** * Saves the sort order to the preferences backend. * * @param Horde_Variables $vars Variables object. * @param string $source Source. */ public static function setPreferredSortOrder(Horde_Variables $vars, $source) { if (!strlen($sortby = $vars->get('sortby'))) { return; } $sources = self::getColumns(); $columns = isset($sources[$source]) ? $sources[$source] : array(); $column_name = self::getColumnName($sortby, $columns); $append = true; $ascending = $vars->get('sortdir') == 0; if ($vars->get('sortadd')) { $sortorder = self::getPreferredSortOrder(); foreach ($sortorder as $i => $elt) { if ($elt['field'] == $column_name) { $sortorder[$i]['ascending'] = $ascending; $append = false; } } } else { $sortorder = array(); } if ($append) { $sortorder[] = array('ascending' => $ascending, 'field' => $column_name); } $GLOBALS['prefs']->setValue('sortorder', serialize($sortorder)); }
/** * Allows other Horde apps to remove 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. * * @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 delete * </pre> * @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 removeMessage($scope, $forum_name, $callback, $params = array(), $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('agoraRemoveMessage'); $queue->attach('status'); /* Set up the forums object. */ $forums = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope); $params['forum_id'] = $forums->getForumId($forum_name); if (empty($params['forum_id'])) { return PEAR::raiseError(sprintf(_("Forum %s does not exist."), $forum_name)); } /* Set up the messages control object. */ $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope, $params['forum_id']); if ($messages instanceof PEAR_Error) { PEAR::raiseError(sprintf(_("Could not delete the message. %s"), $messages->getMessage())); } /* Check delete permissions. */ if (!$messages->hasPermission(Horde_Perms::DELETE)) { return PEAR::raiseError(sprintf(_("You don't have permission to delete messages in forum %s."), $params['forum_id'])); } /* Get the message to be deleted. */ $message = $messages->getMessage($params['message_id']); if ($message instanceof PEAR_Error) { return PEAR::raiseError(sprintf(_("Could not delete the message. %s"), $message->getMessage())); } /* Set up the form. */ $vars = new Horde_Variables($variables); $form = new Horde_Form($vars, sprintf(_("Delete \"%s\" and all replies?"), $message['message_subject']), 'delete_agora_message'); $form->setButtons(array(_("Delete"), _("Cancel"))); $form->addHidden('', 'forum_id', 'int', true); $form->addHidden('', 'message_id', 'int', true); if ($form->validate()) { if ($vars->get('submitbutton') == _("Delete")) { $result = $messages->deleteMessage($params['message_id']); if ($result instanceof PEAR_Error) { $queue->push(sprintf(_("Could not delete the message. %s"), $result->getMessage()), 'horde.error'); } else { $queue->push(_("Message deleted."), 'horde.success'); $count = $messages->countMessages(); $registry->callByPackage($scope, $callback, array($forum_name, 'messages', $count)); } } else { $queue->push(_("Message not deleted."), 'horde.message'); } Horde::startBuffer(); $queue->notify(array('listeners' => 'status')); return Horde::endBuffer(); } Horde::startBuffer(); $form->renderActive(null, null, null, 'post', null, false); return Horde::endBuffer(); }
/** * Sends reminders, one email per user. * * @param Horde_Variables $vars The selection criteria: * - 'id' (integer) for individual tickets * - 'queue' (integer) for tickets of a queue. * - 'category' (array) for ticket * categories, defaults to unresolved * tickets. * - 'unassigned' (boolean) for unassigned * tickets. * * @throws Whups_Exception */ public static function sendReminders($vars) { global $whups_driver; if ($vars->get('id')) { $info = array('id' => $vars->get('id')); } elseif ($vars->get('queue')) { $info['queue'] = $vars->get('queue'); if ($vars->get('category')) { $info['category'] = $vars->get('category'); } else { // Make sure that resolved tickets aren't returned. $info['category'] = array('unconfirmed', 'new', 'assigned'); } } else { throw new Whups_Exception(_("You must select at least one queue to send reminders for.")); } $tickets = $whups_driver->getTicketsByProperties($info); self::sortTickets($tickets); if (!count($tickets)) { throw new Whups_Exception(_("No tickets matched your search criteria.")); } $unassigned = $vars->get('unassigned'); $remind = array(); foreach ($tickets as $info) { $info['link'] = self::urlFor('ticket', $info['id'], true, -1); $owners = $whups_driver->getOwners($info['id']); if (!empty($owners)) { foreach (reset($owners) as $owner) { $remind[$owner][] = $info; } } elseif (!empty($unassigned)) { $remind['**' . $unassigned][] = $info; } } /* Build message template. */ $view = new Horde_View(array('templatePath' => WHUPS_BASE . '/config')); $view->date = strftime($GLOBALS['prefs']->getValue('date_format')); /* Get queue specific notification message text, if available. */ $message_file = WHUPS_BASE . '/config/reminder_email.plain'; if (file_exists($message_file . '.local.php')) { $message_file .= '.local.php'; } else { $message_file .= '.php'; } $message_file = basename($message_file); foreach ($remind as $user => $utickets) { if (empty($user) || !count($utickets)) { continue; } $view->tickets = $utickets; $subject = _("Reminder: Your open tickets"); $whups_driver->mail(array('recipients' => array($user => 'owner'), 'subject' => $subject, 'view' => $view, 'template' => $message_file, 'from' => $user)); } }
/** * @throws Kronolith_Exception */ public function download(Horde_Variables $vars) { global $display_calendars, $injector; switch ($vars->actionID) { case 'export': if ($vars->all_events) { $end = $start = null; } else { $start = new Horde_Date($vars->start_year, $vars->start_month, $vars->start_day); $end = new Horde_Date($vars->end_year, $vars->end_month, $vars->end_day); } $calendars = $vars->get('exportCal', $display_calendars); if (!is_array($calendars)) { $calendars = array($calendars); } $events = array(); foreach ($calendars as $calendar) { list($type, $cal) = explode('_', $calendar, 2); $kronolith_driver = Kronolith::getDriver($type, $cal); $calendarObject = Kronolith::getCalendar($kronolith_driver); if (!$calendarObject || !$calendarObject->hasPermission(Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(); } $events[$calendar] = $kronolith_driver->listEvents($start, $end, array('cover_dates' => false, 'hide_exceptions' => $vars->exportID == Horde_Data::EXPORT_ICALENDAR)); } switch ($vars->exportID) { case Horde_Data::EXPORT_CSV: $data = array(); foreach ($events as $calevents) { foreach ($calevents as $dayevents) { foreach ($dayevents as $event) { $row = array('alarm' => $event->alarm, 'description' => $event->description, 'end_date' => $event->end->format('Y-m-d'), 'end_time' => $event->end->format('H:i:s'), 'location' => $event->location, 'private' => intval($event->private), 'recur_type' => null, 'recur_end_date' => null, 'recur_interval' => null, 'recur_data' => null, 'start_date' => $event->start->format('Y-m-d'), 'start_time' => $event->start->format('H:i:s'), 'tags' => implode(', ', $event->tags), 'title' => $event->getTitle()); if ($event->recurs()) { $row['recur_type'] = $event->recurrence->getRecurType(); if ($event->recurrence->hasRecurEnd()) { $row['recur_end_date'] = $event->recurrence->recurEnd->format('Y-m-d'); } $row['recur_interval'] = $event->recurrence->getRecurInterval(); $row['recur_data'] = $event->recurrence->recurData; } $data[] = $row; } } } $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("events.csv"), $data, true); exit; case Horde_Data::EXPORT_ICALENDAR: $calNames = array(); $iCal = new Horde_Icalendar(); foreach ($events as $calevents) { foreach ($calevents as $dayevents) { foreach ($dayevents as $event) { $calNames[Kronolith::getCalendar($event->getDriver())->name()] = true; $iCal->addComponent($event->toiCalendar($iCal)); } } } $iCal->setAttribute('X-WR-CALNAME', implode(', ', array_keys($calNames))); return array('data' => $iCal->exportvCalendar(), 'name' => _("events.ics"), 'type' => 'text/calendar'); } } }
* did not receive this file, see http://www.horde.org/licenses/gpl. * * @author Marko Djukic <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('ulaform', array('admin' => true)); /* Get some variables. */ $vars = Horde_Variables::getDefaultVariables(); $formname = $vars->get('formname'); if (is_null($formname)) { if ($vars->exists('field_id')) { $vars = $ulaform_driver->getField($vars->get('form_id'), $vars->get('field_id')); $vars = new Horde_Variables($vars); } else { $notification->push(_("No field specified."), 'horde.warning'); Horde::url('fields.php', true)->add('form_id', $vars->get('form_id'))->redirect(); } } /* Set up the form. */ $fieldform = new Horde_Form($vars, _("Delete Field")); $fieldform->setButtons(array(_("Delete"), _("Do not delete"))); $fieldform->addHidden('', 'field_id', 'int', true); $fieldform->addHidden('', 'form_id', 'int', true); $fieldform->addHidden('', 'field_name', 'text', false); $fieldform->addVariable(_("Delete this field?"), 'field_name', 'text', false, true); if ($vars->get('submitbutton') == _("Delete")) { $fieldform->validate($vars); if ($fieldform->isValid()) { $fieldform->getInfo($vars, $info); try { $del_field = $injector->getInstance('Ulaform_Factory_Driver')->create()->deleteField($info['field_id']);
/** * @throws Nag_Exception */ public function download(Horde_Variables $vars) { global $display_tasklists, $injector, $registry; switch ($vars->actionID) { case 'export': $tasklists = $vars->get('exportList', $display_tasklists); if (!is_array($tasklists)) { $tasklists = array($tasklists); } /* Get the full, sorted task list. */ $tasks = Nag::listTasks(array('tasklists' => $tasklists, 'completed' => $vars->exportTasks, 'include_tags' => true, 'include_history' => false)); $tasks->reset(); switch ($vars->exportID) { case Horde_Data::EXPORT_CSV: $data = array(); while ($task = $tasks->each()) { $task = $task->toHash(); $task['desc'] = str_replace(',', '', $task['desc']); $task['tags'] = implode(',', $task['tags']); unset($task['complete_link'], $task['delete_link'], $task['edit_link'], $task['parent'], $task['task_id'], $task['tasklist_id'], $task['view_link'], $task['recurrence'], $task['methods']); foreach (array('start', 'due', 'completed_date') as $field) { if (!empty($task[$field])) { $date = new Horde_Date($task[$field]); $task[$field] = $date->format('c'); } } $data[] = $task; } $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("tasks.csv"), $data, true); exit; case Horde_Data::EXPORT_ICALENDAR: $iCal = new Horde_Icalendar(); $iCal->setAttribute('PRODID', '-//The Horde Project//Nag ' . $registry->getVersion() . '//EN'); while ($task = $tasks->each()) { $iCal->addComponent($task->toiCalendar($iCal)); } return array('data' => $iCal->exportvCalendar(), 'name' => _("tasks.ics"), 'type' => 'text/calendar'); } } }
$fieldform->addHidden('', 'field_id', 'int', false); $fieldform->addHidden('', 'form_id', 'int', false); $fieldform->addHidden('', 'field_order', 'int', false); $fieldform->addHidden('', 'old_field_type', 'text', false); $fieldform->addVariable(_("Label"), 'field_label', 'text', true); $fieldform->addVariable(_("Internal name"), 'field_name', 'text', false, false, _("Set this name if you have a particular reason to override the automatic internal naming of fields.")); /* Set up the field type selection, with a submit action. */ $fields = Ulaform::getFieldTypes(); $v = $fieldform->addVariable(_("Type"), 'field_type', 'enum', true, false, null, array($fields, true)); $v->setAction(Horde_Form_Action::factory('submit')); $v->setOption('trackchange', true); $fieldform->addVariable(_("Required"), 'field_required', 'boolean', false); $fieldform->addVariable(_("Read only"), 'field_readonly', 'boolean', false); $fieldform->addVariable(_("Description"), 'field_desc', 'longtext', false, false, '', array(3, 40)); /* Check if the submitted field type has extra parameters and set them up. */ $field_type = $vars->get('field_type'); $available_params = Ulaform::getFieldParams($field_type); if (!is_null($vars->get('formname')) && $vars->get($v->getVarName()) != $vars->get('__old_' . $v->getVarName()) && !empty($available_params)) { $notification->push(_("This field type has extra parameters."), 'horde.message'); } foreach ($available_params as $name => $param) { $field_id = 'field_params[' . $name . ']'; $param['required'] = isset($param['required']) ? $param['required'] : null; $param['readonly'] = isset($param['readonly']) ? $param['readonly'] : null; $param['desc'] = isset($param['desc']) ? $param['desc'] : null; $fieldform->addVariable($param['label'], $field_id, $param['type'], $param['required'], $param['readonly'], $param['desc']); } /* Set the current field type to the old field type var. */ $vars->set('old_field_type', $field_type); if ($fieldform->validate($vars)) { /* Save field if valid and the current and old field type match. */
/** * Performs a Task search. self::_tasks is populated with the results. * * @throws Nag_Exception */ protected function _doSearch() { // Clear the tag browser in case we have an active browse set. $this->_browser->clearSearch(); // Don't show the tag browser. $this->_showTagBrowser = false; $form = new Nag_Form_Search($this->_vars); if ($form->validate($this->_vars, true)) { $form->getInfo($this->_vars, $info); } else { throw new Nag_Exception(current($form->getErrors())); } // Text filter $search_pattern = $this->_vars->search_pattern; $search_in = empty($this->_vars->search_in) ? array() : $this->_vars->search_in; $search_name = in_array('search_name', $search_in) ? Nag_Search::MASK_NAME : 0; $search_desc = in_array('search_desc', $search_in) ? Nag_Search::MASK_DESC : 0; $search_tags = !empty($this->_vars->search_tags) ? Nag_Search::MASK_TAGS : 0; $search_completed = $this->_vars->search_completed; $this->_vars->set('show_completed', $search_completed); $mask = $search_name | $search_desc | $search_tags; // Date filter $date = $info['due_date']; if (empty($date)) { $date = array(); } // Prepare the search $search = new Nag_Search($search_pattern, $mask, array('completed' => $search_completed, 'due' => $date, 'tags' => empty($this->_vars->search_tags) ? array() : $GLOBALS['injector']->getInstance('Nag_Tagger')->split($this->_vars->search_tags))); try { $tasks = $search->getSlice(); } catch (Nag_Exception $e) { $GLOBALS['notification']->push($tasks, 'horde.error'); $tasks = new Nag_Task(); } // Save as a smart list? if ($id = $this->_vars->get('smart_id')) { // Existing list. $smartlist = $GLOBALS['nag_shares']->getShare($id); Nag::updateTasklist($smartlist, array('name' => $this->_vars->get('smartlist_name'), 'search' => serialize($search))); $this->_title = $smartlist->get('name'); $this->_smartShare = $smartlist; } elseif ($this->_vars->get('save_smartlist')) { $this->_smartShare = Nag::addTasklist(array('name' => $this->_vars->get('smartlist_name'), 'search' => serialize($search)), false); $this->_title = $this->_vars->get('smartlist_name'); } else { // Build a page title based on criteria. $this->_title = sprintf(_("Search: Results for")); $have_title = false; if (!empty($search_pattern)) { $have_title = true; $this->_title .= ' "' . $search_pattern . '" '; } else { $this->_title .= ' ' . _("tasks") . ' '; } if (!empty($date)) { if ($have_title) { $this->_title .= _("and") . ' '; } else { $this->_title .= _("with") . ' '; $have_title = true; } $this->_title .= sprintf(_("due date within %d days of %s"), $date[0], $date[1]) . ' '; } if (!empty($search_tags)) { if ($have_title) { $this->_title .= _("and") . ' '; } else { $this->_title .= _("with") . ' '; } $this->_title .= sprintf(_("and tagged with %s"), $this->_vars->search_tags); } } $GLOBALS['session']->set('nag', 'search', $search, Horde_Session::TYPE_OBJECT); $this->_haveSearch = true; $this->_tasks = $tasks; }
/** * Check for a download token. * * @param Horde_Variables $vars Form variables. * * @throws Horde_Exception Exception on incorrect token. */ public function checkToken(Horde_Variables $vars) { $GLOBALS['session']->checkToken($vars->get(self::VIEW_TOKEN_PARAM)); }
} $vars = Horde_Variables::getDefaultVariables(); $address = $vars->address; $section = $vars->get('section', 'all'); $domain = Vilma::stripDomain($address); /* Check if a form is being edited. */ if (!isset($vars->mode)) { if ($address) { try { $address = $vilma->driver->getAddressInfo($address, $section); } catch (Exception $e) { $notification->push(sprintf(_("Error reading address information from backend: %s"), $e->getMessage()), 'horde.error'); Horde::url('users/index.php', true)->redirect(); } $vars = new Horde_Variables($address); $user_name = $vars->get('user_name'); $vars->user_name = Vilma::stripUser($user_name); $domain = Vilma::stripDomain($user_name); $vars->domain = $domain; $vars->type = $address['type']; $vars->target = 'test'; //$address['target']); $vars->mode = 'edit'; } else { $vars->mode = 'new'; $domain_info = $session->get('vilma', 'domain'); $domain = $domain_info['domain_name']; $domain_id = $domain_info['domain_id']; $vars->domain = $domain; $vars->id = $domain_id; $vars->add('user_name', Horde_Util::getFormData('user_name', ''));
case 'hermes_form_deliverable': $form = new Hermes_Form_Deliverable($vars); $form->validate($vars); if ($form->isValid()) { try { $form->getInfo($vars, $info); if (!empty($info['deliverable_id'])) { $info['id'] = $info['deliverable_id']; if (empty($info['parent'])) { $origdeliv = $GLOBALS['injector']->getInstance('Hermes_Driver')->getDeliverableByID($info['id']); $info['parent'] = $origdeliv['parent']; } } $res = $GLOBALS['injector']->getInstance('Hermes_Driver')->updateDeliverable($info); $notification->push(_("Deliverable saved successfully."), 'horde.success'); $vars = new Horde_Variables(array('client_id' => $vars->get('client_id'))); } catch (Exception $e) { $notification->push(sprintf(_("Error saving deliverable: %s"), $res->getMessage()), 'horde.error'); } } break; case 'deletedeliverable': try { $res = $GLOBALS['injector']->getInstance('Hermes_Driver')->deleteDeliverable($vars->get('delete')); $notification->push(_("Deliverable successfully deleted."), 'horde.success'); } catch (Exception $e) { $notification->push(sprintf(_("Error deleting deliverable: %s"), $res->getMessage()), 'horde.error'); } break; } $page_output->header(array('title' => _("Deliverables")));
/** * Path to form * * @param Horde_Variables $vars * * @return string * @throws Whups_Exception */ public function pathToForm(&$vars) { $path = Whups_Query::stringToPath($vars->get('path')); $parent = null; $qobj = $this->query; for ($i = 0, $c = count($path); $i < $c; $i++) { $parent = $qobj; $qobj = $qobj['children'][$path[$i]]; } if ($qobj['type'] != Whups_Query::TYPE_CRITERION) { // Search for any criteria that have been combined automatically // with an AND or OR. switch ($qobj['type']) { case Whups_Query::TYPE_OR: // Search for multiple ids. $criteria = array(); foreach ($qobj['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_ID) { $criteria = false; break; } $criteria[] = $child['value']; } if ($criteria) { $vars->set('id', implode(',', $criteria)); return 'props'; } // Search for user criteria. $criteria = array(); $operator = $value = null; foreach ($qobj['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_OWNERS && $child['criterion'] != Whups_Query::CRITERION_REQUESTER && $child['criterion'] != Whups_Query::CRITERION_ADDED_COMMENT || isset($operator) && $operator != $child['operator'] || isset($value) && $value != $child['value']) { $criteria = false; break; } $criteria[] = $child['criterion']; $operator = $child['operator']; $value = $child['value']; } if ($criteria) { $vars->set('user', $value); $vars->set('operator', $operator); foreach ($criteria as $criterion) { switch ($criterion) { case Whups_Query::CRITERION_OWNERS: $vars->set('owners', true); break; case Whups_Query::CRITERION_REQUESTER: $vars->set('requester', true); break; case Whups_Query::CRITERION_ADDED_COMMENT: $vars->set('comments', true); break; } } return 'user'; } // Search for text criteria. $criteria = array(); $operator = $value = null; foreach ($qobj['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_COMMENT && $child['criterion'] != Whups_Query::CRITERION_SUMMARY || isset($operator) && $operator != $child['operator'] || isset($value) && $value != $child['value']) { $criteria = false; break; } $criteria[] = $child['criterion']; $operator = $child['operator']; $value = $child['value']; } if ($criteria) { $vars->set('text', $value); $vars->set('operator', $operator); foreach ($criteria as $criterion) { if ($criterion == Whups_Query::CRITERION_COMMENT) { $vars->set('comments', true); } elseif ($criterion == Whups_Query::CRITERION_SUMMARY) { $vars->set('summary', true); } } return 'text'; } // Search for attributes. $attribs = array_keys($GLOBALS['whups_driver']->getAttributesForType()); $criteria = array(); $operator = $value = null; foreach ($qobj['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_ATTRIBUTE || isset($operator) && $operator != $child['operator'] || isset($value) && $value != $child['value'] || !in_array($child['cvalue'], $attribs)) { $criteria = false; break; } $criteria[] = $child['cvalue']; $operator = $child['operator']; $value = $child['value']; } if ($criteria) { $vars->set('text', $value); $vars->set('operator', $operator); foreach ($criteria as $criterion) { $vars->set('a' . $criterion, true); } return 'attribs'; } break; case Whups_Query::TYPE_AND: // Search for date criteria. $criteria = false; foreach ($qobj['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_TIMESTAMP && $child['criterion'] != Whups_Query::CRITERION_UPDATED && $child['criterion'] != Whups_Query::CRITERION_RESOLVED && $child['criterion'] != Whups_Query::CRITERION_ASSIGNED && $child['criterion'] != Whups_Query::CRITERION_DUE) { $criteria = false; break; } $criteria = true; } if ($criteria) { foreach ($qobj['children'] as $child) { switch ($child['criterion'] . $child['operator']) { case Whups_Query::CRITERION_TIMESTAMP . Whups_Query::OPERATOR_GREATER: $vars->set('ticket_timestamp[from]', $child['value']); break; case Whups_Query::CRITERION_TIMESTAMP . Whups_Query::OPERATOR_LESS: $vars->set('ticket_timestamp[to]', $child['value']); break; case Whups_Query::CRITERION_UPDATED . Whups_Query::OPERATOR_GREATER: $vars->set('date_updated[from]', $child['value']); break; case Whups_Query::CRITERION_UPDATED . Whups_Query::OPERATOR_LESS: $vars->set('date_updated[to]', $child['value']); break; case Whups_Query::CRITERION_RESOLVED . Whups_Query::OPERATOR_GREATER: $vars->set('date_resolved[from]', $child['value']); break; case Whups_Query::CRITERION_RESOLVED . Whups_Query::OPERATOR_LESS: $vars->set('date_resolved[to]', $child['value']); break; case Whups_Query::CRITERION_ASSIGNED . Whups_Query::OPERATOR_GREATER: $vars->set('date_assigned[from]', $child['value']); break; case Whups_Query::CRITERION_ASSIGNED . Whups_Query::OPERATOR_LESS: $vars->set('date_assigned[to]', $child['value']); break; case Whups_Query::CRITERION_DUE . Whups_Query::OPERATOR_GREATER: $vars->set('ticket_due[from]', $child['value']); break; case Whups_Query::CRITERION_DUE . Whups_Query::OPERATOR_LESS: $vars->set('ticket_due[to]', $child['value']); break; } } return 'date'; } // Search for version criterion. if (count($qobj['children']) == 2 && $qobj['children'][0]['type'] == Whups_Query::TYPE_CRITERION && $qobj['children'][0]['criterion'] == Whups_Query::CRITERION_QUEUE && $qobj['children'][1]['type'] == Whups_Query::TYPE_CRITERION && $qobj['children'][1]['criterion'] == Whups_Query::CRITERION_VERSION) { $vars->set('queue', $qobj['children'][0]['value']); $vars->set('version', $qobj['children'][1]['value']); return 'props'; } break; } throw new Whups_Exception(_("This query element cannot be edited.")); } switch ($qobj['criterion']) { case Whups_Query::CRITERION_ID: $multiple = false; if ($parent && $parent['type'] == Whups_Query::TYPE_OR) { $multiple = array(); foreach ($parent['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_ID) { $multiple = false; break; } $multiple[] = $child['value']; } } if ($multiple) { array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); $vars->set('id', implode(',', $multiple)); } else { $vars->set('id', $qobj['value']); } return 'props'; case Whups_Query::CRITERION_QUEUE: if ($parent && $parent['type'] == Whups_Query::TYPE_AND && count($parent['children']) == 2 && $parent['children'][1]['type'] == Whups_Query::TYPE_CRITERION && $parent['children'][1]['criterion'] == Whups_Query::CRITERION_VERSION) { array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); $vars->set('version', $parent['children'][1]['value']); } $vars->set('queue', $qobj['value']); return 'props'; case Whups_Query::CRITERION_VERSION: array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); $vars->set('queue', $parent['children'][0]['value']); $vars->set('version', $qobj['value']); return 'props'; case Whups_Query::CRITERION_TYPE: $vars->set('ttype', $qobj['value']); return 'props'; case Whups_Query::CRITERION_STATE: $vars->set('state', $qobj['value']); return 'props'; case Whups_Query::CRITERION_PRIORITY: $vars->set('priority', $qobj['value']); return 'props'; case Whups_Query::CRITERION_TIMESTAMP: case Whups_Query::CRITERION_UPDATED: case Whups_Query::CRITERION_RESOLVED: case Whups_Query::CRITERION_ASSIGNED: case Whups_Query::CRITERION_DUE: $criteria = false; if ($parent && $parent['type'] == Whups_Query::TYPE_AND) { foreach ($parent['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_TIMESTAMP && $child['criterion'] != Whups_Query::CRITERION_UPDATED && $child['criterion'] != Whups_Query::CRITERION_RESOLVED && $child['criterion'] != Whups_Query::CRITERION_ASSIGNED && $child['criterion'] != Whups_Query::CRITERION_DUE) { $criteria = false; break; } $criteria = true; } } if ($criteria) { array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); foreach ($parent['children'] as $child) { switch ($child['criterion'] . $child['operator']) { case Whups_Query::CRITERION_TIMESTAMP . Whups_Query::OPERATOR_GREATER: $vars->set('ticket_timestamp[from]', $child['value']); break; case Whups_Query::CRITERION_TIMESTAMP . Whups_Query::OPERATOR_LESS: $vars->set('ticket_timestamp[to]', $child['value']); break; case Whups_Query::CRITERION_UPDATED . Whups_Query::OPERATOR_GREATER: $vars->set('date_updated[from]', $child['value']); break; case Whups_Query::CRITERION_UPDATED . Whups_Query::OPERATOR_LESS: $vars->set('date_updated[to]', $child['value']); break; case Whups_Query::CRITERION_RESOLVED . Whups_Query::OPERATOR_GREATER: $vars->set('date_resolved[from]', $child['value']); break; case Whups_Query::CRITERION_RESOLVED . Whups_Query::OPERATOR_LESS: $vars->set('date_resolved[to]', $child['value']); break; case Whups_Query::CRITERION_ASSIGNED . Whups_Query::OPERATOR_GREATER: $vars->set('date_assigned[from]', $child['value']); break; case Whups_Query::CRITERION_ASSIGNED . Whups_Query::OPERATOR_LESS: $vars->set('date_assigned[to]', $child['value']); break; case Whups_Query::CRITERION_DUE . Whups_Query::OPERATOR_GREATER: $vars->set('ticket_due[from]', $child['value']); break; case Whups_Query::CRITERION_DUE . Whups_Query::OPERATOR_LESS: $vars->set('ticket_due[to]', $child['value']); break; } } } return 'date'; case Whups_Query::CRITERION_OWNERS: case Whups_Query::CRITERION_REQUESTER: case Whups_Query::CRITERION_ADDED_COMMENT: $criteria = false; if ($parent && $parent['type'] == Whups_Query::TYPE_OR) { $criteria = array(); foreach ($parent['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || !in_array($child['criterion'], array(Whups_Query::CRITERION_OWNERS, Whups_Query::CRITERION_REQUESTER, Whups_Query::CRITERION_ADDED_COMMENT))) { $criteria = false; break; } $criteria[] = $child['criterion']; } if ($criteria) { array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); } } if (!$criteria) { $criteria = array($qobj['criterion']); } $vars->set('user', $qobj['value']); $vars->set('operator', $qobj['operator']); foreach ($criteria as $criterion) { switch ($criterion) { case Whups_Query::CRITERION_OWNERS: $vars->set('owners', true); break; case Whups_Query::CRITERION_REQUESTER: $vars->set('requester', true); break; case Whups_Query::CRITERION_ADDED_COMMENT: $vars->set('comments', true); break; } } return 'user'; case Whups_Query::CRITERION_GROUPS: $vars->set('groups', $qobj['value']); return 'group'; case Whups_Query::CRITERION_COMMENT: case Whups_Query::CRITERION_SUMMARY: $criteria = false; if ($parent && $parent['type'] == Whups_Query::TYPE_OR) { $criteria = array(); $operator = $value = null; foreach ($parent['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_COMMENT && $child['criterion'] != Whups_Query::CRITERION_SUMMARY || isset($operator) && $operator != $child['operator'] || isset($value) && $value != $child['value']) { $criteria = false; break; } $criteria[] = $child['criterion']; $operator = $child['operator']; $value = $child['value']; } if ($criteria) { array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); } } else { $operator = $qobj['operator']; $value = $qobj['value']; } if (!$criteria) { $criteria = array($qobj['criterion']); } $vars->set('text', $value); $vars->set('operator', $operator); foreach ($criteria as $criterion) { if ($criterion == Whups_Query::CRITERION_COMMENT) { $vars->set('comments', true); } elseif ($criterion == Whups_Query::CRITERION_SUMMARY) { $vars->set('summary', true); } } return 'text'; case Whups_Query::CRITERION_ATTRIBUTE: $attribs = array_keys($GLOBALS['whups_driver']->getAttributesForType()); $criteria = false; if ($parent && $parent['type'] == Whups_Query::TYPE_OR) { $criteria = array(); $operator = $value = null; foreach ($parent['children'] as $child) { if ($child['type'] != Whups_Query::TYPE_CRITERION || $child['criterion'] != Whups_Query::CRITERION_ATTRIBUTE || isset($operator) && $operator != $child['operator'] || isset($value) && $value != $child['value'] || !in_array($child['cvalue'], $attribs)) { $criteria = false; break; } $criteria[] = $child['cvalue']; $operator = $child['operator']; $value = $child['value']; } if ($criteria) { array_pop($path); $vars->set('path', Whups_Query::pathToString($path)); } } else { $operator = $qobj['operator']; $value = $qobj['value']; } if (!$criteria) { $criteria = array($qobj['cvalue']); } $vars->set('text', $value); $vars->set('operator', $operator); foreach ($criteria as $criterion) { $vars->set('a' . $criterion, true); } return 'attribs'; } throw new Whups_Exception(_("This query element cannot be edited.")); }
/** * Gets the upload and sets up the upload data array. Either * fetches an upload done with this submit or retrieves stored * upload info. * @param Horde_Variables $vars The form state to check this field for * @param Horde_Form_Variable $var The Form field object to check * */ function _getUpload(&$vars, &$var) { global $session; /* Don't bother with this function if already called and set * up vars. */ if (!empty($this->_img)) { return true; } /* Check if file has been uploaded. */ $varname = $var->getVarName(); try { $GLOBALS['browser']->wasFileUploaded($varname . '[new]'); $this->_uploaded = true; /* A file has been uploaded on this submit. Save to temp dir for * preview work. */ $this->_img['img']['type'] = $this->getUploadedFileType($varname . '[new]'); /* Get the other parts of the upload. */ Horde_Array::getArrayParts($varname . '[new]', $base, $keys); /* Get the temporary file name. */ $keys_path = array_merge(array($base, 'tmp_name'), $keys); $this->_img['img']['file'] = Horde_Array::getElement($_FILES, $keys_path); /* Get the actual file name. */ $keys_path = array_merge(array($base, 'name'), $keys); $this->_img['img']['name'] = Horde_Array::getElement($_FILES, $keys_path); /* Get the file size. */ $keys_path = array_merge(array($base, 'size'), $keys); $this->_img['img']['size'] = Horde_Array::getElement($_FILES, $keys_path); /* Get any existing values for the image upload field. */ $upload = $vars->get($var->getVarName()); if (!empty($upload['hash'])) { $upload['img'] = $session->get('horde', 'form/' . $upload['hash']); $session->remove('horde', 'form/' . $upload['hash']); } /* Get the temp file if already one uploaded, otherwise create a * new temporary file. */ if (!empty($upload['img']['file'])) { $tmp_file = Horde::getTempDir() . '/' . $upload['img']['file']; } else { $tmp_file = Horde::getTempFile('Horde', false); } /* Move the browser created temp file to the new temp file. */ move_uploaded_file($this->_img['img']['file'], $tmp_file); $this->_img['img']['file'] = basename($tmp_file); } catch (Horde_Browser_Exception $e) { $this->_uploaded = $e; /* File has not been uploaded. */ $upload = $vars->get($var->getVarName()); /* File is explicitly removed */ if ($vars->get('remove_' . $var->getVarName())) { $this->_img = null; $session->remove('horde', 'form/' . $upload['hash']); return; } if ($this->_uploaded->getCode() == 4 && !empty($upload['hash']) && $session->exists('horde', 'form/' . $upload['hash'])) { $this->_img['img'] = $session->get('horde', 'form/' . $upload['hash']); $session->remove('horde', 'form/' . $upload['hash']); if (isset($this->_img['error'])) { $this->_uploaded = PEAR::raiseError($this->_img['error']); } } } if (isset($this->_img['img'])) { $session->set('horde', 'form/' . $this->getRandomId(), $this->_img['img']); } }
/** */ public function download(Horde_Variables $vars) { global $wicked; $page = $vars->get('page', 'Wiki/Home'); $page_id = ($id = $wicked->getPageId($page)) === false ? $page : $id; $version = $vars->version; if (empty($version)) { try { $attachments = $wicked->getAttachedFiles($page_id); foreach ($attachments as $attachment) { if ($attachment['attachment_name'] == $vars->file) { $version = $attachment['attachment_version']; } } } catch (Wicked_Exception $e) { } if (empty($version)) { // If we redirect here, we cause an infinite loop with inline // attachments. header('HTTP/1.1 404 Not Found'); exit; } } try { $data = $wicked->getAttachmentContents($page_id, $vars->file, $version); $wicked->logAttachmentDownload($page_id, $vars->file); } catch (Wicked_Exception $e) { // If we redirect here, we cause an infinite loop with inline // attachments. header('HTTP/1.1 404 Not Found'); echo $e->getMessage(); exit; } $type = Horde_Mime_Magic::analyzeData($data, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null); if ($type === false) { $type = Horde_Mime_Magic::filenameToMime($vars->file, false); } return array('data' => $data, 'file' => $vars->file, 'type' => $type); }