"project_admin", "name" => __("관리자", "ajtodo"), "users" => array($uid)),
array("key" => "project_manager", "name" => __("매니저", "ajtodo"), "users" => array($uid)),
array("key" => "project_user", "name" => __("사용자", "ajtodo"), "users" => array($uid)),
);
return $ret;
}
public static function getMembers(){
$ret = array();
foreach($this->project->roles as $role){
$ret = array_unique(array_merge($$ret, $role["users"]));
}
$ret = apply_filters('ajtodo_get_allprojectuserIDs', $ret, $this->project->id);
return $ret;
}
private function setMessage(){
$ret = "
";
$ret .= __("역할은 '프로젝트 멤버' 탭에서 생성할 수 있습니다.","ajtodo");
$ret .= "
";
return $ret;
}
public function memberListView(){
//$user = wp_get_current_user();
//$this->project->updateCol("roleperm", json_encode($this->setInitRoles($user->ID), JSON_UNESCAPED_UNICODE));
$ret = "";
$ret .= "";
return $ret;
}
public static function getUserSmallCard($id){
$ret = "";
if($id){
$user = get_userdata($id);
$ret = "";
$ret .= "| ".get_avatar($user->ID, 18)." | ";
$ret .= "".$user->display_name." | ";
$ret .= "
";
}
return $ret;
}
public function createFormPart($title){
$ret = "";
$ret .= "".$title."
";
$ret .= "";
$ret .= "";
$ret .= " ";
$ret .= " | ".__("역할","ajtodo")." | ";
$ret .= " ".__("멤버","ajtodo")." | ";
if(!$this->project->donedate){
$ret .= " ".__("관리","ajtodo")." | ";
}
$ret .= "
";
$ret .= "";
$ret .= "";
foreach($this->project->roles as $role){
$ret .= "";
$ret .= " | ".$role["name"]." | ";
$ret .= " ";
foreach($this->getUsersByRole($role["key"]) as $mem){
$ret .= $this->getUserSmallCard($mem);
}
$ret .= " ";
$ret .= " | ";
if(!$this->project->donedate){
$ret .= " ";
if($this->project->hasPerm("tp_invite")){
$ret .= " ".__('사용자 추가', 'ajtodo' )."";
}
if($this->project->hasPerm("tp_role_member")){
$ret .= " ".__('역할 관리', 'ajtodo' )."";
}
$ret .= " | ";
}
$ret .= "
";
}
$ret .= "
";
$ret .= "
";
return $ret;
}
public function getUsersByRole($role){
foreach($this->project->roles as $r){
if($r["key"] == $role){
return $r["users"];
}
}
return array();
}
public function delRole($rolekey){
$delindex = -1;
for($i = 0; $i < count($this->project->roles) ; $i++){
if($this->project->roles[$i]["key"] == $rolekey){
$delindex = $i;
}
}
for($i = 0; $i < count($this->project->statuses) ; $i++){
for($j = 0; $j < count($this->project->statuses[$i]["rules"]) ; $j++){
if (($key = array_search($rolekey,
$this->project->statuses[$i]["rules"][$j]["roles"])) !== false) {
unset($this->project->statuses[$i]["rules"][$j]["roles"][$key]);
}
}
}
if($delindex != -1){
unset($this->project->roles[$delindex]);
}
unset($this->project->roleperm[$rolekey]);
$ret = $this->project->updateCols(
array(
"roles" => json_encode($this->project->roles, JSON_UNESCAPED_UNICODE),
"roleperm" => json_encode($this->project->roleperm, JSON_UNESCAPED_UNICODE),
"statuses" => json_encode($this->project->statuses, JSON_UNESCAPED_UNICODE),
)
);
if($ret)
do_action('ajtodo_del_role', $this->project->id);
return $ret;
}
public function addRole($dotype, $rolekey, $rolename){
if($dotype == "add"){
$has = false;
foreach($this->project->roles as $r){
if($r["key"] == $rolekey){
$has = true;
}
}
if($has){
$this->msg = __("역할 키가 중복됩니다. ","ajtodo");
return false;
}
$this->project->roles[] = array(
"key" => $rolekey,
"name" => $rolename,
"users" => array());
}else{
foreach($this->project->roles as &$r){
if($r["key"] == $rolekey){
$r["name"] = $rolename;
}
}
}
$ret = $this->project->updateCol("roles", json_encode($this->project->roles, JSON_UNESCAPED_UNICODE));
if($ret){
if($dotype == "add"){
do_action('ajtodo_add_role', $this->project->id, $rolekey, $rolename);
}else{
do_action('ajtodo_modify_role', $this->project->id, $rolekey, $rolename);
}
}
return $ret;
}
public function addMemberRole($role, $users){
$re = $this->project->roles ? $this->project->roles : array();
$set = false;
foreach($re as &$r){
if($r["key"] == $role){
$r["users"] = explode(",", $users);
$set = true;
}
}
$ret = $this->project->updateCol("roles", json_encode($re, JSON_UNESCAPED_UNICODE));
if($ret){
do_action('ajtodo_add_memberinrole', $this->project->id, $role, $users);
}
return $ret;
}
private function getUserCardForEdit($id){
$user = get_userdata($id);
$userbox = "";
$userbox .= "";
$userbox .= "";
$userbox .= "
";
return $userbox;
}
private function getRoleNameByKey($rolekey){
$ret = "";
if($rolekey){
foreach($this->project->roles as $r){
if($r["key"] == $rolekey){
$ret = $r["name"];
}
}
}
return $ret;
}
public function addRoleView($rolekey){
$rolename = $this->getRoleNameByKey($rolekey);
$users = get_users( array('fields' => array('ID', 'display_name')));
$ret = "";
$ret .= "";
if($rolekey){
$ret .= __("프로젝트 역할 수정","ajtodo");
}else{
$ret .= __("프로젝트 역할 추가","ajtodo");
}
$ret .= "
";
$ret .= "";
return $ret;
}
private function IsBuiltIn($rolekey){
foreach(json_decode(AJTODO_ProjectDefault::DefaultRoles(""), true) as $role){
if($role["key"] == $rolekey)
return true;
}
return false;
}
public function addMemberView($rolekey){
$rolename = $this->getRoleNameByKey($rolekey);
$users = get_users( array('fields' => array('ID', 'display_name')));
$ret = "";
$ret .= "".__("프로젝트 사용자 역할 관리","ajtodo")."
";
$ret .= "";
return $ret;
}
public function update(){
return "role";
}
}