/** * Add additional items to the sidebar. * * @param Horde_View_Sidebar $sidebar The sidebar object. */ public function sidebar($sidebar) { $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms'); if (Sesha::isAdmin(Horde_Perms::READ) || $perms->hasPermission('sesha:addStock', $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { $sidebar->addNewButton(_("_Add Stock"), Horde::url('stock.php')->add('actionId', 'add_stock')); } }
$topbar->searchAction = new Horde_Url('list.php'); $topbar->searchLabel = _("Stock ID"); $topbar->searchIcon = Horde_Themes::img('search-topbar.png'); $perms = $GLOBALS['injector']->getInstance('Horde_Perms'); $sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create(); $vars = Horde_Variables::getDefaultVariables(); $category_id = $vars->get('category_id'); $property_id = $vars->get('property_id'); $actionID = $vars->get('actionID'); // Admin actions. $baseUrl = $registry->get('webroot', 'sesha'); $adminurl = Horde::url('admin.php', true); $tabs = new Horde_Core_Ui_Tabs('actionID', $vars); $tabs->addTab(_("Manage Categories"), $adminurl, 'list_categories'); $tabs->addTab(_("Manage Properties"), $adminurl, 'list_properties'); if (!Sesha::isAdmin(Horde_Perms::DELETE)) { $notification->push(_("You are no administrator"), 'horde.warning'); header('Location: ' . Horde::url('list.php', true)); exit; } /* Run through the action handlers. */ switch ($actionID) { case 'add_category': $url = Horde::url('admin.php')->add('actionID', 'list_categories'); $title = _("Add a category"); $vars->set('actionID', $actionID); $renderer = new Horde_Form_Renderer(); $form = new Sesha_Form_Category($vars); if ($form->validate($vars)) { $form->getInfo($vars, $info); // Save category details.
/** * Returns the items which match the category or search criteria. */ protected function stock($filters = array()) { $driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create(); // Get the inventory $stock = $driver->findStock($filters); $isAdminEdit = Sesha::isAdmin(Horde_Perms::EDIT); $itemEditImg = Horde::img('edit.png', _("Edit Item")); $isAdminDelete = Sesha::isAdmin(Horde_Perms::DELETE); $adminDeleteImg = Horde::img('delete.png', _("Delete Item")); $stock_url = Horde::url('stock.php'); $items = array(); foreach ($stock as $item) { $url = $stock_url->add('stock_id', $item->stock_id); $columns = array(); // icons $icons = ''; if ($isAdminEdit) { $icons .= $url->copy()->add('actionId', 'update_stock')->link(array('title' => _("Edit Item"))) . $itemEditImg . '</a>'; } if ($isAdminDelete) { $icons .= $url->copy()->add('actionId', 'remove_stock')->link(array('title' => _("Delete Item"))) . $adminDeleteImg . '</a>'; } $columns[] = array('class' => ' class="nowrap"', 'column' => $icons); // stock_id $columns[] = array('class' => '', 'column' => $url->copy()->add('actionId', 'view_stock')->link(array('title' => _("View Item"))) . htmlspecialchars($item->stock_id) . '</a>'); // name $columns[] = array('class' => '', 'column' => $url->copy()->add('actionId', 'view_stock')->link(array('title' => _("View Item"))) . htmlspecialchars($item->stock_name) . '</a>'); // properties foreach ($this->shownProperties as $property) { $value = $item->getValue($property); $columns[] = array('class' => '', 'column' => $value ? htmlspecialchars($value->getDataValue()) : ' '); } // note $columns[] = array('class' => '', 'column' => $item->note ? htmlspecialchars($item->note) : ' '); $items[] = array('columns' => $columns); } return $items; }