Public Member Functions | Data Fields

ilSoapUserAdministration Class Reference

Public Member Functions

 ilSoapUserAdministration ($use_nusoap=true)
 login ($client, $username, $password)
 logout ($sid)
 lookupUser ($sid, $user_name)
 getUser ($sid, $user_id)
 updateUser ($sid, $user_data)
 addUser ($sid, $user_data, $global_role_id)
 deleteUser ($sid, $user_id)
 __explodeSid ($sid)
 __setMessage ($a_str)
 __getMessage ()
 __appendMessage ($a_str)
 __validateUserData (&$user_data, $check_complete=true)
 __setUserData (&$user_obj, &$user_data)
 __initAuthenticationObject ()
 __raiseError ($a_message, $a_code)
 __readUserData (&$usr_obj)
 __substituteUserData ($user_old, $user_new)

Data Fields

 $sauth = null
 $error_method = null

Detailed Description

Definition at line 82 of file class.ilSoapUserAdministration.php.


Member Function Documentation

ilSoapUserAdministration::__appendMessage ( a_str  ) 

Definition at line 398 of file class.ilSoapUserAdministration.php.

Referenced by __validateUserData().

        {
                $this->message .= isset($this->message) ? ' ' : '';
                $this->message .= $a_str;
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__explodeSid ( sid  ) 

Definition at line 382 of file class.ilSoapUserAdministration.php.

Referenced by addUser(), deleteUser(), getUser(), logout(), lookupUser(), and updateUser().

        {
                $exploded = explode('::',$sid);

                return is_array($exploded) ? $exploded : array('sid' => '','client' => '');
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__getMessage (  ) 

Definition at line 394 of file class.ilSoapUserAdministration.php.

Referenced by __validateUserData(), addUser(), and updateUser().

        {
                return $this->message;
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__initAuthenticationObject (  ) 

Definition at line 561 of file class.ilSoapUserAdministration.php.

Referenced by addUser(), deleteUser(), getUser(), login(), logout(), lookupUser(), and updateUser().

        {
                include_once './webservice/soap/classes/class.ilSoapAuthentication.php';
                
                return $this->sauth = new ilSoapAuthentication();
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__raiseError ( a_message,
a_code 
)

Definition at line 569 of file class.ilSoapUserAdministration.php.

Referenced by addUser(), deleteUser(), getUser(), login(), logout(), lookupUser(), and updateUser().

        {
                switch($this->error_method)
                {
                        case NUSOAP:

                                return new soap_fault($a_code,'',$a_message);
                }
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__readUserData ( &$  usr_obj  ) 

Definition at line 580 of file class.ilSoapUserAdministration.php.

Referenced by getUser(), and updateUser().

        {
                $usr_data['usr_id'] = $usr_obj->getId();
                $usr_data['login'] = $usr_obj->getLogin();
                $usr_data['passwd'] = $usr_obj->getPasswd();
                $usr_data['passwd_type'] = $usr_obj->getPasswdType();
                $usr_data['firstname'] = $usr_obj->getFirstname();
                $usr_data['lastname'] = $usr_obj->getLastname();
                $usr_data['title'] = $usr_obj->getUTitle();
                $usr_data['gender'] = $usr_obj->getGender();
                $usr_data['email'] = $usr_obj->getEmail();
                $usr_data['institution'] = $usr_obj->getInstitution();
                $usr_data['street'] = $usr_obj->getStreet();
                $usr_data['city'] = $usr_obj->getCity();
                $usr_data['zipcode'] = $usr_obj->getZipcode();
                $usr_data['country'] = $usr_obj->getCountry();
                $usr_data['phone_office'] = $usr_obj->getPhoneOffice();
                $usr_data['last_login'] = $usr_obj->getLastLogin();
                $usr_data['last_update'] = $usr_obj->getLastUpdate();
                $usr_data['create_date'] = $usr_obj->getCreateDate();
                $usr_data['hobby'] = $usr_obj->getHobby();
                $usr_data['department'] = $usr_obj->getDepartment();
                $usr_data['phone_home'] = $usr_obj->getPhoneHome();
                $usr_data['phone_mobile'] = $usr_obj->getPhoneMobile();
                $usr_data['fax'] = $usr_obj->getFax();
                $usr_data['time_limit_owner'] = $usr_obj->getTimeLimitOwner();
                $usr_data['time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
                $usr_data['time_limit_from'] = $usr_obj->getTimeLimitFrom();
                $usr_data['time_limit_until'] = $usr_obj->getTimeLimitUntil();
                $usr_data['time_limit_message'] = $usr_obj->getTimeLimitMessage();
                $usr_data['referral_commment'] = $usr_obj->getComment();
                $usr_data['matriculation'] = $usr_obj->getMatriculation();
                $usr_data['active'] = $usr_obj->getActive();
                $usr_data['approve_date'] = $usr_obj->getApproveDate();
                $usr_data['user_skin'] = $usr_obj->getPref('skin');
                $usr_data['user_style'] = $usr_obj->getPref('style');
                $usr_data['user_language'] = $usr_obj->getLanguage();
                
                return $usr_data;
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__setMessage ( a_str  ) 

Definition at line 390 of file class.ilSoapUserAdministration.php.

Referenced by __validateUserData().

        {
                $this->message = $a_str;
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__setUserData ( &$  user_obj,
&$  user_data 
)

Definition at line 531 of file class.ilSoapUserAdministration.php.

Referenced by addUser(), and updateUser().

        {
                // Default to unlimited if no access period is given
                if(!$user_data['time_limit_from'] and 
                   !$user_data['time_limit_until'] and
                   !$user_data['time_limit_unlimited'])
                {
                        $user_data['time_limit_unlimited'] = 1;
                }
                if(!$user_data['time_limit_owner'])
                {
                        $user_data['time_limit_owner'] = USER_FOLDER_ID;
                }

                $user_obj->assignData($user_data);

                if(isset($user_data['user_language']))
                {
                        $user_obj->setLanguage($user_data['user_language']);
                }
                if(isset($user_data['user_skin']) and isset($user_data['user_style']))
                {
                        $user_obj->setPref('skin',$user_data['skin']);
                        $user_obj->setPref('style',$user_data['style']);
                }
                return true;
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__substituteUserData ( user_old,
user_new 
)

Definition at line 621 of file class.ilSoapUserAdministration.php.

Referenced by updateUser().

        {
                foreach($user_new as $key => $value)
                {
                        $user_old[$key] = $value;
                }
                return $user_old ? $user_old : array();
        }

Here is the caller graph for this function:

ilSoapUserAdministration::__validateUserData ( &$  user_data,
check_complete = true 
)

Definition at line 404 of file class.ilSoapUserAdministration.php.

References $lng, $styleDefinition, $type, __appendMessage(), __getMessage(), __setMessage(), ilObject::_lookupType(), ilUtil::is_email(), ilUtil::isLogin(), ilUtil::isPassword(), and loginExists().

Referenced by addUser(), and updateUser().

        {
                global $lng,$styleDefinition;

                $this->__setMessage('');
                
                if($check_complete)
                {
                        if(!isset($user_data['login']))
                        {
                                $this->__appendMessage('No login given.');
                        }
                        if(!isset($user_data['passwd']))
                        {
                                $this->__appendMessage('No password given.');
                        }
                        if(!isset($user_data['email']))
                        {
                                $this->__appendMessage('No email given');
                        }
                        if(!isset($user_data['user_language']))
                        {
                                $user_data['user_language'] = 'en';
                        }
                }
                foreach($user_data as $field => $value)
                {
                        switch($field)
                        {
                                case 'login':
                                        if (!ilUtil::isLogin($value))
                                        {
                                                $this->__appendMessage('Login invalid.');
                                        }

                                        // check loginname
                                        if($check_complete)
                                        {
                                                if (loginExists($value))
                                                {
                                                        $this->__appendMessage('Login already exists.');
                                                }
                                        }
                                        break;

                                case 'passwd':
                                        if (!ilUtil::isPassword($value))
                                        {
                                                $this->__appendMessage('Password invalid.');
                                        }
                                        break;

                                case 'email':
                                        if(!ilUtil::is_email($value))
                                        {
                                                $this->__appendMessage('Email invalid.');
                                        }
                                        break;

                                case 'time_limit_unlimited':
                                        if($value != 1)
                                        {
                                                if($user_data['time_limit_from'] >= $user_data['time_limit_until'])
                                                {
                                                        $this->__appendMessage('Time limit invalid');
                                                }
                                        }
                                        break;

                                case 'user_language':
                                        $lang_inst = $lng->getInstalledLanguages();

                                        if(!in_array($user_data['user_language'],$lang_inst))
                                        {
                                                $this->__appendMessage('Language: '.$user_data['user_language'].' is not installed');
                                        }
                                        break;


                                case 'user_skin':
                                case 'user_style':
                                        if(($user_data['user_skin'] and !$user_data['user_style']) or
                                           (!$user_data['user_skin'] and $user_data['user_style']))
                                        {
                                                $this->__appendMessage('user_skin, user_style not valid.');
                                        }
                                        elseif($user_data['user_skin'] and $user_data['user_style'])
                                        {
                                                $ok = false;
                                                foreach($styleDefinition->getAllTemplates() as $template)
                                                {
                                                        $styleDef =& new ilStyleDefinition($template["id"]);
                                                        $styleDef->startParsing();
                                                        $styles = $styleDef->getStyles();
                                                        foreach ($styles as $style)
                                                        {
                                                                if ($user_data['user_skin'] == $template["id"] &&
                                                                        $user_data['user_style'] == $style["id"])
                                                                {
                                                                        $ok = true;
                                                                }
                                                        }
                                                }
                                                if(!$ok)
                                                {
                                                        $this->__appendMessage('user_skin, user_style not valid.');
                                                }
                                        }
                                        break;

                                case 'time_limit_owner':
                                        $type = ilObject::_lookupType($user_data['time_limit_owner'],true);
                                        if($type != 'cat' and $type != 'usrf')
                                        {
                                                $this->__appendMessage('time_limit_owner must be ref_id of category or user folder'.$type);
                                        }
                                        break;

                                        

                                default:
                                        continue;
                        }
                }
                return strlen($this->__getMessage()) ? false : true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilSoapUserAdministration::addUser ( sid,
user_data,
global_role_id 
)

Definition at line 263 of file class.ilSoapUserAdministration.php.

References $global_roles, $log, $rbacadmin, $rbacreview, $rbacsystem, __explodeSid(), __getMessage(), __initAuthenticationObject(), __raiseError(), __setUserData(), and __validateUserData().

        {
                list($sid,$client) = $this->__explodeSid($sid);

                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setSid($sid);
                if(!$this->sauth->validateSession())
                {
                        return $this->__raiseError($this->sauth->getMessage(),'Client');
                }

                // Include main header
                include_once './include/inc.header.php';

                if(!$rbacsystem->checkAccess('create_user',USER_FOLDER_ID))
                {
                        return $this->__raiseError('Check access failed.','Server');
                }

                // Validate user_data
                if(!$this->__validateUserData($user_data))
                {
                        return $this->__raiseError($this->__getMessage(),'Client');
                }
                // Validate global role
                if(!$global_role_id)
                {
                        return $this->__raiseError('No role id given','Client');
                }

                // Validate global role
                global $rbacreview;
                
                $global_roles = $rbacreview->getGlobalRoles();

                if(!in_array($global_role_id,$global_roles))
                {
                        return $this->__raiseError('Role with id: '.$global_role_id.' is not a valid global role','Client');
                }

                $new_user =& new ilObjUser();

                $user_data['passwd_type'] =  IL_PASSWD_PLAIN;
                $this->__setUserData($new_user,$user_data);


                $log->write('SOAP: addUser()');

                // Need this for entry in object_data
                $new_user->setTitle($new_user->getFullname());
                $new_user->setDescription($new_user->getEmail());

                $new_user->create();
                $new_user->saveAsNew();

                // Assign role
                $rbacadmin->assignUser($global_role_id,$new_user->getId());

                // Assign user prefs
                $new_user->setLanguage($user_data['user_language']);
                $new_user->setPref('style',$user_data['style']);
                $new_user->setPref('skin',$user_data['skin']);
                $new_user->writePrefs();

                return $new_user->getId();
        }

Here is the call graph for this function:

ilSoapUserAdministration::deleteUser ( sid,
user_id 
)

Definition at line 332 of file class.ilSoapUserAdministration.php.

References $ilUser, $log, $rbacsystem, $user_id, __explodeSid(), __initAuthenticationObject(), __raiseError(), and ilObjectFactory::getInstanceByObjId().

        {
                list($sid,$client) = $this->__explodeSid($sid);

                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setSid($sid);
                if(!$this->sauth->validateSession())
                {
                        return $this->__raiseError($this->sauth->getMessage(),'Client');
                }
                
                if(!isset($user_id))
                {
                        return $this->__raiseError('No user_id given. Aborting','Client');
                }

                // Include main header
                include_once './include/inc.header.php';

                if(!$rbacsystem->checkAccess('delete',USER_FOLDER_ID))
                {
                        return $this->__raiseError('Check access failed.','Server');
                }

                global $ilUser;

                if(!$ilUser->getLoginByUserId($user_id))
                {
                        return $this->__raiseError('User id: '.$user_id.' is not a valid identifier. Aborting','Client');
                }
                if($ilUser->getId() == $user_id)
                {
                        return $this->__raiseError('Cannot delete myself. Aborting','Client');
                }
                if($user_id == SYSTEM_USER_ID)
                {
                        return $this->__raiseError('Cannot delete root account. Aborting','Client');
                }
                // Delete him
                $log->write('SOAP: deleteUser()');
                $delete_user =& ilObjectFactory::getInstanceByObjId($user_id,false);
                $delete_user->delete();

                return true;
        }

Here is the call graph for this function:

ilSoapUserAdministration::getUser ( sid,
user_id 
)

Definition at line 174 of file class.ilSoapUserAdministration.php.

References $ilUser, $rbacsystem, $tmp_user, $user_id, __explodeSid(), __initAuthenticationObject(), __raiseError(), __readUserData(), and ilObjectFactory::getInstanceByObjId().

        {
                list($sid,$client) = $this->__explodeSid($sid);

                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setSid($sid);

                if(!$this->sauth->validateSession())
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       
                
                // Include main header
                include_once './include/inc.header.php';

                if(!$rbacsystem->checkAccess('read',USER_FOLDER_ID))
                {
                        return $this->__raiseError('Check access failed.','Server');
                }

                global $ilUser;

                if($ilUser->getLoginByUserId($user_id))
                {
                        $tmp_user =& ilObjectFactory::getInstanceByObjId($user_id);
                        $usr_data = $this->__readUserData($tmp_user);

                        return $usr_data;
                }
                return $this->__raiseError('User does not exist','Client');
        }               

Here is the call graph for this function:

ilSoapUserAdministration::ilSoapUserAdministration ( use_nusoap = true  ) 

Definition at line 97 of file class.ilSoapUserAdministration.php.

        {
                define('USER_FOLDER_ID',7);
                define('NUSOAP',1);
                define('PHP5',2);

                if($use_nusoap)
                {
                        $this->error_method = NUSOAP;
                }
        }

ilSoapUserAdministration::login ( client,
username,
password 
)

Definition at line 111 of file class.ilSoapUserAdministration.php.

References __initAuthenticationObject(), and __raiseError().

        {
                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setUsername($username);
                $this->sauth->setPassword($password);

                if(!$this->sauth->authenticate())
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }
                return $this->sauth->getSid().'::'.$client;
        }

Here is the call graph for this function:

ilSoapUserAdministration::logout ( sid  ) 

Definition at line 126 of file class.ilSoapUserAdministration.php.

References __explodeSid(), __initAuthenticationObject(), and __raiseError().

        {
                list($sid,$client) = $this->__explodeSid($sid);

                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setSid($sid);


                if(!$this->sauth->logout())
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }
                
                return true;
        }

Here is the call graph for this function:

ilSoapUserAdministration::lookupUser ( sid,
user_name 
)

Definition at line 144 of file class.ilSoapUserAdministration.php.

References $rbacsystem, __explodeSid(), __initAuthenticationObject(), __raiseError(), and ilObjUser::getUserIdByLogin().

        {
                list($sid,$client) = $this->__explodeSid($sid);

                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setSid($sid);

                if(!$this->sauth->validateSession())
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       

                if(!strlen($user_name))
                {
                        return $this->__raiseError('No username given. Aborting','Client');
                }

                // Include main header
                include_once './include/inc.header.php';

                if(!$rbacsystem->checkAccess('read',USER_FOLDER_ID))
                {
                        return $this->__raiseError('Check access failed.'.USER_FOLDER_ID,'Server');
                }

                return (int) ilObjUser::getUserIdByLogin($user_name);
        }

Here is the call graph for this function:

ilSoapUserAdministration::updateUser ( sid,
user_data 
)

Definition at line 208 of file class.ilSoapUserAdministration.php.

References $ilUser, $log, $rbacsystem, __explodeSid(), __getMessage(), __initAuthenticationObject(), __raiseError(), __readUserData(), __setUserData(), __substituteUserData(), __validateUserData(), and ilObjectFactory::getInstanceByObjId().

        {
                list($sid,$client) = $this->__explodeSid($sid);


                $this->__initAuthenticationObject();

                $this->sauth->setClient($client);
                $this->sauth->setSid($sid);

                if(!$this->sauth->validateSession())
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       
                
                // Include main header
                include_once './include/inc.header.php';

                if(!$rbacsystem->checkAccess('write',USER_FOLDER_ID))
                {
                        return $this->__raiseError('Check access failed.','Server');
                }

                global $ilUser;

                if(!$user_obj =& ilObjectFactory::getInstanceByObjId($user_data['usr_id'],false))
                {
                        return $this->__raiseError('User with id '.$user_data['usr_id'].' does not exist.','Client');
                }

                $user_old = $this->__readUserData($user_obj);
                $user_new = $this->__substituteUserData($user_old,$user_data);

                if(!$this->__validateUserData($user_data,false))
                {
                        return $this->__raiseError($this->__getMessage(),'Client');
                }

                if(strlen($user_data['passwd']) != 32)
                {
                        $user_new['passwd_type'] = IL_PASSWD_PLAIN;
                }
                else
                {
                        $user_new['passwd_type'] = IL_PASSWD_MD5;
                }
                $this->__setUserData($user_obj,$user_new);

                $log->write('SOAP: updateUser()');
                $user_obj->update();

                return true;
        }               

Here is the call graph for this function:


Field Documentation

ilSoapUserAdministration::$error_method = null

Definition at line 94 of file class.ilSoapUserAdministration.php.

ilSoapUserAdministration::$sauth = null

Definition at line 88 of file class.ilSoapUserAdministration.php.


The documentation for this class was generated from the following file: