ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserProfile Class Reference

Class ilUserProfile. More...

+ Collaboration diagram for ilUserProfile:

Public Member Functions

 __construct ()
 Constructor.
 getStandardFields ()
 Get standard user fields array.
 getLocalUserAdministrationFields ()
 Get visible fields in local user administration.
 skipGroup ($a_group)
 Skip a group.
 skipField ($a_field)
 Skip a field.
 addStandardFieldsToForm ($a_form, $a_user=NULL, array $custom_fields=NULL)
 Add standard fields to form.

Static Public Member Functions

static userSettingVisible ($a_setting)
 Checks whether user setting is visible.
static setMode ($mode)
static isProfileIncomplete ($a_user, $a_include_udf=true, $a_personal_data_only=true)
 Check if all required personal data fields are set.
static getIgnorableRequiredSettings ()
 Returns an array of all ignorable profiel fields.

Data Fields

const MODE_DESKTOP = 1
const MODE_REGISTRATION = 2

Static Protected Member Functions

static isEditableByUser ($setting)
 Returns whether a profile setting is editable by an user in the profile gui.

Static Private Attributes

static $mode = self::MODE_DESKTOP
static $user_field

Detailed Description

Class ilUserProfile.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilUserProfile.php.

Constructor & Destructor Documentation

ilUserProfile::__construct ( )

Constructor.

Definition at line 305 of file class.ilUserProfile.php.

{
$this->skip_groups = array();
$this->skip_fields = array();
}

Member Function Documentation

ilUserProfile::addStandardFieldsToForm (   $a_form,
  $a_user = NULL,
array  $custom_fields = NULL 
)

Add standard fields to form.

Definition at line 375 of file class.ilUserProfile.php.

References $ilSetting, $lng, $options, ilObjUser\_getPersonalPicturePath(), ilObjRole\_lookupRegisterAllowed(), getStandardFields(), IL_CAL_DATE, MODE_REGISTRATION, ilDateTime\setDate(), ilRadioOption\setDisabled(), ilFormPropertyGUI\setDisabled(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setValue(), ilSelectInputGUI\setValue(), ilEMailInputGUI\setValue(), ilRadioGroupInputGUI\setValue(), ilNonEditableValueGUI\setValue(), ilTextAreaInputGUI\setValue(), and userSettingVisible().

{
global $ilSetting, $lng, $rbacreview, $ilias;
// custom registration settings
if(self::$mode == self::MODE_REGISTRATION)
{
include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
$registration_settings = new ilRegistrationSettings();
self::$user_field["username"]["group"] = "login_data";
self::$user_field["password"]["group"] = "login_data";
self::$user_field["language"]["default"] = $lng->lang_key;
// different position for role
$roles = self::$user_field["roles"];
unset(self::$user_field["roles"]);
self::$user_field["roles"] = $roles;
self::$user_field["roles"]["group"] = "settings";
}
$fields = $this->getStandardFields();
$current_group = "";
$custom_fields_done = false;
foreach ($fields as $f => $p)
{
// next group? -> diplay subheader
if (($p["group"] != $current_group) &&
{
if (is_array($custom_fields) && !$custom_fields_done)
{
// should be appended to "other" or at least before "settings"
if($current_group == "other" || $p["group"] == "settings")
{
// add "other" subheader
if($current_group != "other")
{
$sh->setTitle($lng->txt("other"));
$a_form->addItem($sh);
}
foreach($custom_fields as $custom_field)
{
$a_form->addItem($custom_field);
}
$custom_fields_done = true;
}
}
$sh->setTitle($lng->txt($p["group"]));
$a_form->addItem($sh);
$current_group = $p["group"];
}
$m = "";
if (isset($p["method"]))
{
$m = $p["method"];
}
$lv = (isset($p["lang_var"]) && $p["lang_var"] != "")
? $p["lang_var"]
: $f;
switch ($p["input"])
{
case "login":
if ((int)$ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION)
{
$val = new ilTextInputGUI($lng->txt('username'),'username');
if($a_user)
{
$val->setValue($a_user->getLogin());
}
$val->setMaxLength(32);
$val->setSize(40);
$val->setRequired(true);
}
else
{
// user account name
$val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
if($a_user)
{
$val->setValue($a_user->getLogin());
}
}
$a_form->addItem($val);
break;
case "text":
{
$ti = new ilTextInputGUI($lng->txt($lv), "usr_".$f);
if($a_user)
{
$ti->setValue($a_user->$m());
}
$ti->setMaxLength($p["maxlength"]);
$ti->setSize($p["size"]);
$ti->setRequired($ilSetting->get("require_".$f));
if(!$ti->getRequired() || $ti->getValue())
{
$ti->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
$a_form->addItem($ti);
}
break;
case "sel_country":
{
include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
$ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_".$f);
if($a_user)
{
$ci->setValue($a_user->$m());
}
$ci->setRequired($ilSetting->get("require_".$f));
if(!$ci->getRequired() || $ci->getValue())
{
$ci->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
$a_form->addItem($ci);
}
break;
case "birthday":
{
$bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_".$f);
include_once "./Services/Calendar/classes/class.ilDateTime.php";
$date = null;
if ($a_user && strlen($a_user->$m()))
{
$date = new ilDateTime($a_user->$m(), IL_CAL_DATE);
$bi->setDate($date);
}
$bi->setShowEmpty(true);
$bi->setStartYear(1900);
$bi->setRequired($ilSetting->get("require_".$f));
if(!$bi->getRequired() || $date)
{
$bi->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
$a_form->addItem($bi);
}
break;
case "radio":
{
$rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_".$f);
if($a_user)
{
$rg->setValue($a_user->$m());
}
foreach ($p["values"] as $k => $v)
{
$op = new ilRadioOption($lng->txt($v), $k);
$rg->addOption($op);
}
$rg->setRequired($ilSetting->get("require_".$f));
if(!$rg->getRequired() || $rg->getValue())
{
$rg->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
$a_form->addItem($rg);
}
break;
case "picture":
if (ilUserProfile::userSettingVisible("upload") && $a_user)
{
$ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
$ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
$upload = $a_form->getFileUpload("userfile");
if($upload["name"])
{
$ii->setPending($upload["name"]);
}
else
{
$im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true,
true);
if ($im != "")
{
$ii->setImage($im);
$ii->setAlt($lng->txt("personal_picture"));
}
}
// ilinc link as info
$ilSetting->get("ilinc_active"))
{
include_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
$ilinc_user = new ilObjiLincUser($a_user);
if ($ilinc_user->id)
{
include_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
$ilincAPI = new ilnetucateXMLAPI();
$ilincAPI->uploadPicture($ilinc_user);
$response = $ilincAPI->sendRequest("uploadPicture");
// return URL to user's personal page
$url = trim($response->data['url']['cdata']);
$desc =
$lng->txt("ilinc_upload_pic_text")." ".
'<a href="'.$url.'">'.$lng->txt("ilinc_upload_pic_linktext").'</a>';
$ii->setInfo($desc);
}
}
$a_form->addItem($ii);
}
break;
case "roles":
if(self::$mode == self::MODE_DESKTOP)
{
{
$global_roles = $rbacreview->getGlobalRoles();
foreach($global_roles as $role_id)
{
if (in_array($role_id,$rbacreview->assignedRoles($a_user->getId())))
{
$roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
$role_names .= $roleObj->getTitle().", ";
unset($roleObj);
}
}
$dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
$dr->setValue(substr($role_names,0,-2));
$a_form->addItem($dr);
}
}
else if(self::$mode == self::MODE_REGISTRATION)
{
if($registration_settings->roleSelectionEnabled())
{
include_once("./Services/AccessControl/classes/class.ilObjRole.php");
$options = array();
foreach (ilObjRole::_lookupRegisterAllowed() as $role)
{
$options[$role["id"]] = $role["title"];
}
// registration form validation will take care of missing field / value
{
if(sizeof($options) > 1)
{
$ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_".$f);
$ta->setRequired($ilSetting->get("require_".$f));
if(!$ta->getRequired())
{
$ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
}
// no need for select if only 1 option
else
{
$ta = new ilHiddenInputGUI("usr_".$f);
$ta->setValue(array_shift(array_keys($options)));
}
$a_form->addItem($ta);
}
}
}
break;
case "email":
{
$em = new ilEMailInputGUI($lng->txt($lv), "usr_".$f);
if($a_user)
{
$em->setValue($a_user->$m());
}
$em->setRequired($ilSetting->get("require_".$f));
if(!$em->getRequired() || $em->getValue())
{
$em->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
if(self::MODE_REGISTRATION == self::$mode)
{
$em->setRetype(true);
}
$a_form->addItem($em);
}
break;
case "textarea":
{
$ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_".$f);
if($a_user)
{
$ta->setValue($a_user->$m());
}
$ta->setRows($p["rows"]);
$ta->setCols($p["cols"]);
$ta->setRequired($ilSetting->get("require_".$f));
if(!$ta->getRequired() || $ta->getValue())
{
$ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
$a_form->addItem($ta);
}
break;
case "messenger":
if (ilUserProfile::userSettingVisible("instant_messengers"))
{
$im_arr = $p["types"];
foreach ($im_arr as $im_name)
{
$im = new ilTextInputGUI($lng->txt("im_".$im_name), "usr_im_".$im_name);
if($a_user)
{
$im->setValue($a_user->getInstantMessengerId($im_name));
}
$im->setMaxLength($p["maxlength"]);
$im->setSize($p["size"]);
$im->setRequired($ilSetting->get("require_"."instant_messengers"));
if(!$im->getRequired() || $im->getValue())
{
$im->setDisabled($ilSetting->get("usr_settings_disable_"."instant_messengers"));
}
$a_form->addItem($im);
}
}
break;
case "password":
if (self::$mode == self::MODE_REGISTRATION)
{
if(!$registration_settings->passwordGenerationEnabled())
{
$ta = new ilPasswordInputGUI($lng->txt($lv), "usr_".$f);
$ta->setRequired(true);
// $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
else
{
$ta = new ilNonEditableValueGUI($lng->txt($lv));
$ta->setValue($lng->txt("reg_passwd_via_mail"));
}
$a_form->addItem($ta);
}
break;
case "language":
{
$ta = new ilSelectInputGUI($lng->txt($lv), "usr_".$f);
if($a_user)
{
$ta->setValue($a_user->$m());
}
$options = array();
$lng->loadLanguageModule("meta");
foreach ($lng->getInstalledLanguages() as $lang_key)
{
$options[$lang_key] = $lng->txt("meta_l_".$lang_key);
}
asort($options); // #9728
$ta->setOptions($options);
$ta->setRequired($ilSetting->get("require_".$f));
if(!$ta->getRequired() || $ta->getValue())
{
$ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
}
$a_form->addItem($ta);
}
break;
}
}
// append custom fields as "other"
if(is_array($custom_fields) && !$custom_fields_done)
{
// add "other" subheader
if($current_group != "other")
{
$sh->setTitle($lng->txt("other"));
$a_form->addItem($sh);
}
foreach($custom_fields as $custom_field)
{
$a_form->addItem($custom_field);
}
}
}

+ Here is the call graph for this function:

static ilUserProfile::getIgnorableRequiredSettings ( )
static

Returns an array of all ignorable profiel fields.

Returns
array public

ilSetting

Definition at line 906 of file class.ilUserProfile.php.

References $ilSetting.

Referenced by ilObjUserGUI\handleIgnoredRequiredFields().

{
global $ilSetting;
$ignorableSettings = array();
foreach(self::$user_field as $field => $definition)
{
// !!!username and password must not be ignored!!!
if( 'username' == $field ||
'password' == $field )
{
continue;
}
// Field is not required -> continue
if( !$ilSetting->get('require_'.$field) )
{
continue;
}
if( self::isEditableByUser($field) )
{
$ignorableSettings[] = $field;
}
}
return $ignorableSettings;
}

+ Here is the caller graph for this function:

ilUserProfile::getLocalUserAdministrationFields ( )

Get visible fields in local user administration.

Returns

Definition at line 334 of file class.ilUserProfile.php.

References $ilSetting, and getStandardFields().

{
global $ilSetting;
$settings = $ilSetting->getAll();
$fields = array();
foreach($this->getStandardFields() as $field => $info)
{
if($ilSetting->get('usr_settings_visib_lua_'.$field,1))
{
$fields[$field] = $info;
}
elseif($info['visib_lua_fix_value'])
{
$fields[$field] = $info;
}
}
return $fields;
}

+ Here is the call graph for this function:

ilUserProfile::getStandardFields ( )

Get standard user fields array.

Definition at line 314 of file class.ilUserProfile.php.

Referenced by addStandardFieldsToForm(), and getLocalUserAdministrationFields().

{
$fields = array();
foreach (self::$user_field as $f => $p)
{
// skip hidden groups
if (in_array($p["group"], $this->skip_groups) ||
in_array($f, $this->skip_fields))
{
continue;
}
$fields[$f] = $p;
}
return $fields;
}

+ Here is the caller graph for this function:

static ilUserProfile::isEditableByUser (   $setting)
staticprotected

Returns whether a profile setting is editable by an user in the profile gui.

Parameters
stringA key of a profile setting
Returns
boolean Determines whether the passed setting can be edited by the user itself protected

ilSetting

Definition at line 877 of file class.ilUserProfile.php.

References $ilSetting.

{
global $ilSetting;
// Not visible in personal data or not changeable
if( $ilSetting->get('usr_settings_hide_'.$setting) == 1 ||
$ilSetting->get('usr_settings_disable_'.$setting) == 1 )
{
// User has no chance to edit this field
return false;
}
return true;
}
static ilUserProfile::isProfileIncomplete (   $a_user,
  $a_include_udf = true,
  $a_personal_data_only = true 
)
static

Check if all required personal data fields are set.

Parameters
ilObjUser$a_user
bool$a_include_udfcheck custom fields, too
bool$a_personal_data_onlyonly check fields which are visible in personal data
Returns
bool

Definition at line 819 of file class.ilUserProfile.php.

References $ilSetting.

Referenced by ilUserImportParser\checkProfileIncomplete(), ilAuthBase\loginObserver(), ilObjUserGUI\saveObject(), and ilObjUserGUI\updateObject().

{
global $ilSetting;
// standard fields
foreach(self::$user_field as $field => $definition)
{
// only if visible in personal data
if($a_personal_data_only && $ilSetting->get("usr_settings_hide_".$field))
{
continue;
}
if($ilSetting->get("require_".$field) && $definition["method"])
{
$value = $a_user->{$definition["method"]}();
if($value == "")
{
return true;
}
}
}
// custom fields
if($a_include_udf)
{
$user_defined_data = $a_user->getUserDefinedData();
include_once './Services/User/classes/class.ilUserDefinedFields.php';
$user_defined_fields = ilUserDefinedFields::_getInstance();
foreach($user_defined_fields->getRequiredDefinitions() as $field => $definition)
{
// only if visible in personal data
if($a_personal_data_only && !$definition["visible"])
{
continue;
}
if(!$user_defined_data["f_".$field])
{
return true;
}
}
}
return false;
}

+ Here is the caller graph for this function:

static ilUserProfile::setMode (   $mode)
static

Definition at line 799 of file class.ilUserProfile.php.

References $lng, and $mode.

{
global $lng;
if(in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION)))
{
self::$mode = $mode;
return true;
}
return false;
}
ilUserProfile::skipField (   $a_field)

Skip a field.

Definition at line 367 of file class.ilUserProfile.php.

{
$this->skip_fields[] = $a_field;
}
ilUserProfile::skipGroup (   $a_group)

Skip a group.

Definition at line 359 of file class.ilUserProfile.php.

{
$this->skip_groups[] = $a_group;
}
static ilUserProfile::userSettingVisible (   $a_setting)
static

Checks whether user setting is visible.

Definition at line 781 of file class.ilUserProfile.php.

References $ilSetting.

Referenced by addStandardFieldsToForm(), and ilUserDataSet\importRecord().

{
global $ilSetting;
if(self::$mode == self::MODE_DESKTOP)
{
return ($ilSetting->get("usr_settings_hide_".$a_setting) != 1);
}
else
{
if(isset(self::$user_field[$a_setting]["visib_reg_hide"]) && self::$user_field[$a_setting]["visib_reg_hide"] === true)
{
return true;
}
return ($ilSetting->get("usr_settings_visib_reg_".$a_setting, "1") || $ilSetting->get("require_".$a_setting, "0"));
}
}

+ Here is the caller graph for this function:

Field Documentation

ilUserProfile::$mode = self::MODE_DESKTOP
staticprivate

Definition at line 20 of file class.ilUserProfile.php.

Referenced by setMode().

ilUserProfile::$user_field
staticprivate

Definition at line 46 of file class.ilUserProfile.php.

const ilUserProfile::MODE_DESKTOP = 1

Definition at line 17 of file class.ilUserProfile.php.

const ilUserProfile::MODE_REGISTRATION = 2

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