/** * Get all roles method * * @param string $sort * @param string $page * @return void */ public function getAll($sort = null, $page = null) { $order = $this->getSortOrder($sort, $page); $order['field'] = $order['field'] == 'id' ? DB_PREFIX . 'user_roles.id' : $order['field']; // Create SQL object to get role data $sql = Table\UserRoles::getSql(); $sql->select(array(DB_PREFIX . 'user_roles.id', DB_PREFIX . 'user_roles.type_id', DB_PREFIX . 'user_types.type', DB_PREFIX . 'user_roles.name'))->join(DB_PREFIX . 'user_types', array('type_id', 'id'), 'LEFT JOIN')->orderBy($order['field'], $order['order']); if (null !== $order['limit']) { $sql->select()->limit($order['limit'])->offset($order['offset']); } // Execute SQL query $roles = Table\UserRoles::execute($sql->render(true)); if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\User\\RolesController', 'remove')) { $removeCheckbox = '<input type="checkbox" name="remove_roles[]" id="remove_roles[{i}]" value="[{id}]" />'; $removeCheckAll = '<input type="checkbox" id="checkall" name="checkall" value="remove_roles" />'; $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove')); } else { $removeCheckbox = ' '; $removeCheckAll = ' '; $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'), 'style' => 'display: none;'); } $options = array('form' => array('id' => 'role-remove-form', 'action' => BASE_PATH . APP_URI . '/users/roles/remove', 'method' => 'post', 'process' => $removeCheckbox, 'submit' => $submit), 'table' => array('headers' => array('id' => '<a href="' . BASE_PATH . APP_URI . '/users/roles?sort=id">#</a>', 'edit' => '<span style="display: block; margin: 0 auto; width: 100%; text-align: center;">' . $this->i18n->__('Edit') . '</span>', 'type' => '<a href="' . BASE_PATH . APP_URI . '/users/roles?sort=type">' . $this->i18n->__('Type') . '</a>', 'name' => '<a href="' . BASE_PATH . APP_URI . '/users/roles?sort=name">' . $this->i18n->__('Role') . '</a>', 'process' => $removeCheckAll), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'exclude' => array('type_id', 'process' => array('id' => $this->data['user']->role_id)), 'indent' => ' '); if (isset($roles->rows[0])) { $rolesAry = array(); foreach ($roles->rows as $role) { if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\User\\RolesController', 'edit')) { $edit = '<a class="edit-link" title="' . $this->i18n->__('Edit') . '" href="' . BASE_PATH . APP_URI . '/users/roles/edit/' . $role->id . '">Edit</a>'; } else { $edit = null; } $rAry = array('id' => $role->id, 'name' => $role->name, 'type' => $role->type); if (null !== $edit) { $rAry['edit'] = $edit; } $rolesAry[] = $rAry; } $this->data['table'] = Html::encode($rolesAry, $options, $this->config->pagination_limit, $this->config->pagination_range, Table\UserRoles::getCount()); } }