Exemple #1
0
 /**
  * List roles
  *
  * @return  void
  */
 public function displayTask()
 {
     // Incoming
     $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'));
     // Instantiate an object
     $model = new Tables\Role($this->database);
     // Get a record count
     $this->view->total = $model->count($this->view->filters);
     // Get records
     $this->view->rows = $model->find($this->view->filters);
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->display();
 }
 /**
  * Get a list of units for an offering
  *   Accepts either a numeric array index or a string [id, name]
  *   If index, it'll return the entry matching that index in the list
  *   If string, it'll return either a list of IDs or names
  *
  * @param      array   $filters Filters to build query from
  * @param      boolean $clear   Force a new dataset?
  * @return     mixed
  */
 public function roles($filters = array(), $clear = false)
 {
     if (!isset($filters['offering_id'])) {
         $filters['offering_id'] = array(0, (int) $this->get('id'));
         // 0 = default roles
     }
     if (isset($filters['count']) && $filters['count']) {
         $tbl = new Tables\Role($this->_db);
         return $tbl->count($filters);
     }
     if (!isset($this->_roles) || !is_array($this->_roles) || $clear) {
         $tbl = new Tables\Role($this->_db);
         if (!($results = $tbl->find($filters))) {
             $results = array();
         }
         $this->_roles = $results;
     }
     return $this->_roles;
 }