/** * 管理 角色 */ function actionRole() { $this->_pathway->addStep('管理角色'); if ($this->_context->isPOST()) { foreach ($_POST['id'] as $key => $value) { if (!isset($_POST['chk']) || !in_array($value, $_POST['chk'])) { $arr = array('id' => $value, 'name' => $_POST['name'][$key], 'description' => $_POST['description'][$key], 'weight' => $_POST['weight'][$key], 'enabled' => $_POST['enabled'][$key]); try { $role = Roles::find()->getById($_POST['id'][$key]); $role->changeProps($arr); $role->save(); } catch (QDB_ActiveRecord_ValidateFailedException $ex) { } } } if (isset($_POST['chk'])) { //Roles::meta()->destroyWhere("id in (?) and id > 6",$_POST['chk']); Roles::meta()->deleteWhere("id in (?) and id > 6", $_POST['chk']); GroupsHasRoles::meta()->deleteWhere("role_id in (?) and role_id > 6", $_POST['chk']); } } // 分页查询内容列表 $page = intval($this->_context->page); if ($page < 1) { $page = 1; } $select = Roles::find()->order('weight desc'); $select->limitPage($page, 10); // 将分页信息和查询到的数据传递到视图 $this->_view['pagination'] = $select->getPagination(); $this->_view['roles'] = $select->getAll(); }