* @license PHP License * @package WB * @subpackage content */ /** * Load classes */ WBClass::load('WBContent' , 'WBContent_ITS' , 'WBITS'); /** * Content component: ITS_Editor * * @version 1.1.0 * @package WB * @subpackage content */ class WBContent_ITS_Editor extends WBContent_ITS { /** * Parameter list * - action either "edit", "add", "list" * - requiredgroup (tableeditor) * - requiredgroupmanager (tableadmin) * - searchfields (array()) list of columns that are allowed to search in using LIKE * @var array */ protected $config = array( 'action' => 'list', 'requiredgroup' => 'its-staff', 'requiredgroupmanager' => 'its-master', 'namespace' => '', 'goto' => '1', 'searchfields' => array('title', 'blurb') ); /** * run * * run component * * @return array parameter list */ public function run() { if (!$this->isUserInGroup($this->config['requiredgroup'])) { $this->loadTemplates('anon'); return $this->config; } $this->its->initFilter($this->config['searchfields']); switch ($this->config['action']) { case 'edit': case 'add': if (!$this->editTicket()) { break; } default: case 'list': $this->listTickets(); break; } return $this->config; } /** * Show form to edit ticket * * @return bool true if ticket was saved, false to display form */ private function editTicket() { $save = $this->req->get('save', ''); $this->ticket = $this->its->loadByObscureId($this->req->get('obscureid', '')); // normal edit stuff $this->tmpl->addGlobalVar('obscureid', $this->ticket->getObscureId()); $this->tmpl->addGlobalVar('id', $this->ticket->getId()); $ret = $this->processForm('edit', $this->ticket->getData()); if (is_bool($ret)) { return $ret; } return false; } /** * Save ticket data * * Update ticket data * * @param patForms $form * @param array $values * @return bool always false */ public function onEditValid($form, $values) { if (!empty($this->config['namespace'])) { $values['namespace'] = $this->config['namespace']; } $this->ticket->save($values); return false; } /** * List tickets * * Get pager and fill template with list */ private function listTickets() { $pager = $this->its->getPager(); $this->tmpl->addGlobalVars($pager->browse($this->config['goto']), 'pager_'); $this->loadTemplates('list'); $this->tmpl->addRows('list_entry', $pager->get()); } }