setData(); } private function setData(){ $this->init_globalroles = array( array( "key" => "ajtodo_project_team_create", "name" => __("팀 프로젝트 생성","ajtodo"), "desc" => __("팀 프로젝트를 생성할 수 있습니다.","ajtodo") ), array( "key" => "ajtodo_project_team_remove", "name" => __("팀 프로젝트 삭제","ajtodo"), "desc" => __("팀 프로젝트를 삭제할 수 있습니다.","ajtodo") ), array( "key" => "ajtodo_project_team_close", "name" => __("팀 프로젝트 종료","ajtodo"), "desc" => __("팀 프로젝트를 종료할 수 있습니다.","ajtodo") ), array( "key" => "ajtodo_project_team_viewlist", "name" => __("팀 프로젝트 목록 보기","ajtodo"), "desc" => __("프로젝트 톡록을 열람할 수 있습니다.","ajtodo") ), array( "key" => "ajtodo_project_private", "name" => __("개인 프로젝트 사용","ajtodo"), "desc" => __("개인 프로젝트 기능을 사용할 수 있습니다.","ajtodo") ) ); } private function clearPerm(){ $this->clearRolePerm("administrator"); $this->clearRolePerm("editor"); $this->clearRolePerm("author"); $this->clearRolePerm("contributor"); $this->clearRolePerm("subscriber"); } private function clearRolePerm($role){ foreach($this->init_globalroles as $r){ $this->updatePerms($role, $r["key"], false); } } public function updateRolesPerms($postdata){ $this->clearPerm(); foreach($postdata as $key => $val){ $pv = isset($key) ? sanitize_text_field($key) : ""; if(strstr($pv, "|")){ $tmp = explode("|", $pv); $this->updatePerms($tmp[0], $tmp[1], true); } } } private function updatePerms($rolekey, $cap, $isadd){ $role = get_role($rolekey); $isadd ? $role->add_cap($cap) : $role->remove_cap($cap); } public function getFormRolesPerms(){ global $wp_roles; $wproles = $wp_roles->roles; $ret = ""; $ret .= $this->getFormRolePerm("administrator", "Administrator", $wproles); $ret .= $this->getFormRolePerm("editor", "Editor", $wproles); $ret .= $this->getFormRolePerm("author", "Author", $wproles); $ret .= $this->getFormRolePerm("contributor", "Contributor", $wproles); $ret .= $this->getFormRolePerm("subscriber", "Subscriber", $wproles); return $ret; } private function getFormRolePerm($role, $rolename, $wproles){ $ret = "