public function init() { $this->addItem('add_list', _w('Can create new lists'), 'checkbox'); // existing lists $lm = new checklistsListModel(); $lists = array(); foreach ($lm->getAll() as $list) { $lists[$list['id']] = $list['name']; } $this->addItem('list', _w('Available lists'), 'selectlist', array('items' => $lists, 'options' => array(0 => _w('No access'), 1 => _w('Check items only'), 2 => _w('Full access')))); }
public function execute() { $lm = new checklistsListModel(); $lists = $lm->getAllowed(); foreach ($lists as $id => &$list) { if (strtolower(substr($list['icon'], 0, 7)) == 'http://') { $list['icon'] = '<i class="icon16" style="background-image:url(' . htmlspecialchars($list['icon']) . ')"></i>'; } else { $list['icon'] = '<i class="icon16 ' . $list['icon'] . '"></i>'; } } $id = waRequest::request('id'); if (($id = waRequest::request('id')) && isset($lists[$id])) { $lists[$id]['current'] = true; } $this->view->assign('lists', $lists); $this->view->assign('can_add_lists', $this->getRights('add_list')); }
/** Create new or edit existing list. */ public function EditorAction() { $id = waRequest::request('id', 0, 'int'); if ($id) { if ($this->getRights('list.' . $id) <= 1) { throw new waRightsException('Access denied.'); } $lm = new checklistsListModel(); if (!($list = $lm->getById($id))) { throw new waException('List does not exist.'); } $this->layout->setTitle($list['name']); } else { if (!$this->getRights('add_list')) { throw new waRightsException('Access denied.'); } $list = array('id' => '', 'name' => '', 'color_class' => 'c-white', 'icon' => 'notebook', 'count' => 0); } $this->view->assign('list', $list); $this->view->assign('icons', array('notebook', 'lock', 'lock-unlocked', 'broom', 'star', 'livejournal', 'contact', 'lightning', 'light-bulb', 'pictures', 'reports', 'books', 'marker', 'lens', 'alarm-clock', 'animal-monkey', 'anchor', 'bean', 'car', 'disk', 'cookie', 'burn', 'clapperboard', 'bug', 'clock', 'cup', 'home', 'fruit', 'luggage', 'guitar', 'smiley', 'sport-soccer', 'target', 'medal', 'phone', 'store')); $this->view->assign('colors', array('c-white', 'c-gray', 'c-yellow', 'c-green', 'c-blue', 'c-red', 'c-purple')); }
/** Delete list */ public function DeletelistAction() { if (!($id = waRequest::post('id', 0, 'int'))) { throw new waException('No id given.'); } // check access if ($this->getRights('list.' . $id) <= 1) { throw new waRightsException('Access denied.'); } $lm = new checklistsListModel(); $lm->deleteById($id); $lim = new checklistsListItemsModel(); $lim->deleteByField('list_id', $id); $this->log('list_delete', 1); $this->response = 'done'; }