IceHrm v18.0
This commit is contained in:
@@ -53,5 +53,30 @@ if (!class_exists('CustomField')) {
|
||||
public function getAnonymousAccess(){
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
public function validateSave($obj){
|
||||
$type = $obj->type;
|
||||
$baseObject = new $type();
|
||||
$fields = $baseObject->getObjectKeys();
|
||||
if(isset($fields[$obj->name])){
|
||||
return new IceResponse(IceResponse::ERROR,"Column name already exists by default");
|
||||
}
|
||||
|
||||
$cf = new CustomField();
|
||||
if(empty($obj->id)){
|
||||
$cf->Load("type = ? and name = ?",array($obj->type, $obj->name));
|
||||
if($cf->name == $obj->name){
|
||||
return new IceResponse(IceResponse::ERROR,"Another custom field with same name has already been added");
|
||||
}
|
||||
}else{
|
||||
$cf->Load("type = ? and name = ? and id <> ?",array($obj->type, $obj->name, $obj->id));
|
||||
if($cf->name == $obj->name){
|
||||
return new IceResponse(IceResponse::ERROR,"Another custom field with same name has already been added");
|
||||
}
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS,"");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user