public function download(Horde_Variables $vars) { global $notification, $injector; switch ($vars->actionID) { case 'export': // 'export' used from Ajax view $ids = split(',', $vars->s); if (!is_array($ids)) { $notification->push(_("No time slices were submitted"), 'horde.error'); return false; } try { $hours = $injector->getInstance('Hermes_Driver')->getHours(array('id' => $ids)); } catch (Hermes_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); return false; } $exportHours = Hermes::makeExportHours($hours); $this->_doExport($vars->f, $exportHours); if ($vars->m) { $injector->getInstance('Hermes_Driver')->markAs('exported', $hours); } break; case 'search_export': // Called from Basic view. if (!($searchVars = $GLOBALS['session']->get('hermes', 'search_criteria'))) { $notification->push(_("No time slices were submitted"), 'horde.error'); return false; } $searchForm = new Hermes_Form_Search($searchVars); $criteria = $searchForm->getSearchCriteria($searchVars); if (is_null($criteria)) { $notification->push(_("No time slices were submitted"), 'horde.error'); return false; } $form = new Hermes_Form_Export($vars); $form->validate($vars); if (!$form->isValid()) { return false; } $form->getInfo($vars, $info); try { $hours = $injector->getInstance('Hermes_Driver')->getHours($criteria); } catch (Hermes_Exception $e) { $notification->push($e, 'horde.error'); return false; } $exportHours = Hermes::makeExportHours($hours); $this->_doExport($info['format'], $exportHours); if (!empty($info['mark_exported']) && $info['mark_exported'] == 'yes' && $GLOBALS['perms']->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $injector->getInstance('Hermes_Driver')->markAs('exported', $hours); } } $GLOBALS['notification']->push(_("Export complete."), 'horde.success'); return true; }