public function indexAction() { //Add toolbar button $this->_toolbar->addNewButton(); $this->_toolbar->addEditButton(); $this->_toolbar->addDeleteButton(); $this->updateRules(); UserRoles::updateModuleMenu(); $this->updateACLCache(); //Add filter $this->addFilter("filter_order", "role_id", "string"); $this->addFilter("filter_order_dir", "ASC", "string"); $conditions = []; $conditions[] = 'ar.is_super_admin != 1'; //Get all filter $filter = $this->getFilter(); $items = $this->modelsManager->createBuilder()->columns('ar.role_id AS id, ar.name AS name, ar.is_default, ar.location, ar.updated_at AS updated_at, ar.updated_by AS updated_by, ar.created_at AS created_at')->addFrom('ZCMS\\Core\\Models\\UserRoles', "ar")->where(implode(' AND ', $conditions))->orderBy($filter['filter_order'] . ' ' . $filter['filter_order_dir']); $currentPage = $this->request->getQuery("page", "int", 1); $paginationLimit = $this->config->pagination->limit; //Create pagination $this->view->setVar('_page', ZPagination::getPaginationQueryBuilder($items, $paginationLimit, $currentPage)); //Set search value $this->view->setVar('_filter', $filter); //Set column name, value $this->view->setVar('_pageLayout', [['type' => 'check_all'], ['type' => 'index', 'title' => '#'], ['type' => 'link', 'title' => 'm_system_role_form_name', 'column' => 'name', 'link' => '/admin/system/role/edit/', 'access' => $this->acl->isAllowed('system|role|edit')], ['type' => 'text', 'title' => 'gb_is_default', 'column' => 'is_default', 'class' => 'text-center col-location', 'label' => [['condition' => '==', 'condition_value' => '1', 'class' => 'glyphicon glyphicon-star orange', 'text' => ''], ['condition' => '==', 'condition_value' => '0', 'class' => 'glyphicon glyphicon-star grey', 'text' => '']]], ['type' => 'text', 'title' => 'gb_location', 'class' => 'text-center col-location', 'column' => 'location', 'label' => [['condition' => '==', 'condition_value' => 'backend', 'class' => 'label label-sm label-success', 'text' => 'gb_backend'], ['condition' => '!=', 'condition_value' => 'backend', 'class' => 'label label-sm label-warning', 'text' => 'gb_frontend']], 'translation' => true], ['type' => 'date', 'title' => 'gb_created_at', 'column' => 'created_at'], ['type' => 'date', 'title' => 'gb_updated_at', 'column' => 'updated_at'], ['type' => 'id', 'title' => 'gb_id', 'column' => 'id']]); }
/** * Unpublished item action * * @param int $id * @param string $redirect * @param bool $log */ public function unPublishAction($id = null, $redirect = null, $log = true) { if (class_exists($this->_model) && $this->_modelBaseName) { if ($log) { $extraQuery = ', updated_by = ' . $this->_user['id'] . ", updated_at = '" . date("Y-m-d H:i:s") . "'"; } else { $extraQuery = null; } $ids = []; if ($id) { $id = intval($id); $ids[] = $id; } else { $ids = $this->request->getPost('ids'); ZArrayHelper::toInteger($ids); } if (is_array($ids)) { ZArrayHelper::toInteger($ids); $query = "UPDATE {$this->_modelBaseName} SET published = 0 " . $extraQuery . " WHERE is_core = 0 AND module_id IN (" . implode(',', $ids) . ")"; $this->db->execute($query); $this->flashSession->success(__('m_' . $this->_module . '_' . $this->_controller . '_message_items_successfully_unpublished', ["1" => $this->db->affectedRows()])); UserRoles::updateModuleMenu(); } } else { $this->flashSession->error('gb_message_you_are_must_set_model_in_child_controller'); } if ($redirect) { $this->response->redirect($redirect); } else { $this->response->redirect('/admin/' . $this->_module . '/' . $this->_controller . '/'); } }