public function updateUserGroupAccess($get, $post) { $user_group_id = $get['user_group_id'] ?: $post['user_group_id']; if (Router::isPost()) { $ex = Model::transaction(function () use($post, $user_group_id) { $con = "user_group_id = '" . addslashes($user_group_id) . "'"; UserGroupAuth::deleteWhere(0, $con); $data = array(); if ($post['act_bids']) { foreach ($post['act_bids'] as $act_id) { $data[] = array('user_group_id' => $user_group_id, 'action_id' => $act_id, 'type' => UserGroupAuth::TYPE_BLACK); } } if ($post['act_wids']) { foreach ($post['act_wids'] as $act_id) { $data[] = array('user_group_id' => $user_group_id, 'action_id' => $act_id, 'type' => UserGroupAuth::TYPE_BLACK); } } if ($data) { UserGroupAuth::insertMany($data); } }); return new Result(!$ex ? '操作成功' : $ex->getMessage(), !$ex, null, Router::getUrl('UserGroup')); } if (!$user_group_id) { $tmp = UserGroup::find()->one(); $user_group_id = $tmp->id; } $act_list = AccessAction::find()->all(true); $act_ids = array_column($act_list, 'id'); //user_group values $w_user_group_values = $b_user_group_values = array(); if ($act_ids) { $user_group_values = UserGroupAuth::find('action_id IN ? AND user_group_id = ?', $act_ids, $user_group_id)->all(true); foreach ($user_group_values as $val) { if ($val['type'] == UserGroupAuth::TYPE_WHITE) { $w_user_group_values[$val['action_id']] = $val; } else { $b_user_group_values[$val['action_id']] = $val; } } } array_orderby($act_list, 'desc', SORT_DESC); $white_list = $black_list = array(); foreach ($act_list as $act) { $a = $this->convertPathToArray('全部/' . $act['desc'], array($act['id'], $act['uri'], !!$w_user_group_values[$act['id']])); $white_list = array_merge_recursive($white_list, $a); $b = $this->convertPathToArray('全部/' . $act['desc'], array($act['id'], $act['uri'], !!$b_user_group_values[$act['id']])); $black_list = array_merge_recursive($black_list, $b); } return array('user_group_id' => $user_group_id, 'auth_list' => array($white_list, $black_list), 'user_group_list' => UserGroup::find()->all()); }
public function index() { $process_list = array(); $all_process = WorkProcess::find()->all(true); $all_process = array_group($all_process, 'work_stage_id'); foreach (WorkStage::$work_stage_list as $stage_id => $name) { $rs = array(); $ps = $all_process[$stage_id] ?: array(); array_orderby($ps, 'ord', SORT_DESC); foreach ($ps as $p) { $rs[] = new WorkProcess($p); } $process_list[$stage_id] = $rs; } return array('process_list' => $process_list); }