/**
  * Configure soap settings
  * 
  * @access	public
  */
 function editSOAPObject()
 {
     global $rbacsystem, $rbacreview, $ilSetting, $ilCtrl, $lng;
     if (!$rbacsystem->checkAccess("read", $this->object->getRefId())) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     $this->tabs_gui->setTabActive('auth_soap');
     //set Template
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.auth_soap.html', 'Services/Authentication');
     // compose role list
     $role_list = $rbacreview->getRolesByFilter(2, $this->object->getId());
     $roles = array();
     foreach ($role_list as $role) {
         $roles[$role['obj_id']] = $role['title'];
     }
     //set property form gui
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $soap_config = new ilPropertyFormGUI();
     $soap_config->setTitle($this->lng->txt("auth_soap_auth"));
     $soap_config->setDescription($this->lng->txt("auth_soap_auth_desc"));
     $soap_config->setFormAction($this->ctrl->getFormAction($this, "editSOAP"));
     $soap_config->addCommandButton("saveSOAP", $this->lng->txt("save"));
     $soap_config->addCommandButton("editSOAP", $this->lng->txt("cancel"));
     //set activ
     $active = new ilCheckboxInputGUI();
     $active->setTitle($this->lng->txt("active"));
     $active->setPostVar("soap[active]");
     //set server
     $server = new ilTextInputGUI();
     $server->setTitle($this->lng->txt("server"));
     $server->setInfo($this->lng->txt("auth_soap_server_desc"));
     $server->setPostVar("soap[server]");
     $server->setSize(50);
     $server->setMaxLength(256);
     $server->setRequired(true);
     //set port
     $port = new ilTextInputGUI();
     $port->setTitle($this->lng->txt("port"));
     $port->setInfo($this->lng->txt("auth_soap_port_desc"));
     $port->setPostVar("soap[port]");
     $port->setSize(7);
     $port->setMaxLength(5);
     //set https
     $https = new ilCheckboxInputGUI();
     $https->setTitle($this->lng->txt("auth_soap_use_https"));
     $https->setPostVar("soap[use_https]");
     //set uri
     $uri = new ilTextInputGUI();
     $uri->setTitle($this->lng->txt("uri"));
     $uri->setInfo($this->lng->txt("auth_soap_uri_desc"));
     $uri->setPostVar("soap[uri]");
     $uri->setSize(50);
     $uri->setMaxLength(256);
     //set namespace
     $namespace = new ilTextInputGUI();
     $namespace->setTitle($this->lng->txt("auth_soap_namespace"));
     $namespace->setInfo($this->lng->txt("auth_soap_namespace_desc"));
     $namespace->setPostVar("soap[namespace]");
     $namespace->setSize(50);
     $namespace->setMaxLength(256);
     //set dotnet
     $dotnet = new ilCheckboxInputGUI();
     $dotnet->setTitle($this->lng->txt("auth_soap_use_dotnet"));
     $dotnet->setPostVar("soap[use_dotnet]");
     //set create users
     $createuser = new ilCheckboxInputGUI();
     $createuser->setTitle($this->lng->txt("auth_create_users"));
     $createuser->setInfo($this->lng->txt("auth_soap_create_users_desc"));
     $createuser->setPostVar("soap[create_users]");
     //set account mail
     $sendmail = new ilCheckboxInputGUI();
     $sendmail->setTitle($this->lng->txt("user_send_new_account_mail"));
     $sendmail->setInfo($this->lng->txt("auth_new_account_mail_desc"));
     $sendmail->setPostVar("soap[account_mail]");
     //set user default role
     $defaultrole = new ilSelectInputGUI();
     $defaultrole->setTitle($this->lng->txt("auth_user_default_role"));
     $defaultrole->setInfo($this->lng->txt("auth_soap_user_default_role_desc"));
     $defaultrole->setPostVar("soap[user_default_role]");
     $defaultrole->setOptions($roles);
     //set allow local authentication
     $allowlocal = new ilCheckboxInputGUI();
     $allowlocal->setTitle($this->lng->txt("auth_allow_local"));
     $allowlocal->setInfo($this->lng->txt("auth_soap_allow_local_desc"));
     $allowlocal->setPostVar("soap[allow_local]");
     // get all settings
     $settings = $ilSetting->getAll();
     // get values in error case
     if ($_SESSION["error_post_vars"]) {
         $active->setChecked($_SESSION["error_post_vars"]["soap"]["active"]);
         $server->setValue($_SESSION["error_post_vars"]["soap"]["server"]);
         $port->setValue($_SESSION["error_post_vars"]["soap"]["port"]);
         $https->setChecked($_SESSION["error_post_vars"]["soap"]["use_https"]);
         $uri->setValue($_SESSION["error_post_vars"]["soap"]["uri"]);
         $namespace->setValue($_SESSION["error_post_vars"]["soap"]["namespace"]);
         $dotnet->setChecked($_SESSION["error_post_vars"]["soap"]["use_dotnet"]);
         $createuser->setChecked($_SESSION["error_post_vars"]["soap"]["create_users"]);
         $allowlocal->setChecked($_SESSION["error_post_vars"]["soap"]["allow_local"]);
         $defaultrole->setValue($_SESSION["error_post_vars"]["soap"]["user_default_role"]);
         $sendmail->setChecked($_SESSION["error_post_vars"]["soap"]["account_mail"]);
     } else {
         $active->setChecked($settings["soap_auth_active"]);
         $server->setValue($settings["soap_auth_server"]);
         $port->setValue($settings["soap_auth_port"]);
         $https->setChecked($settings["soap_auth_use_https"]);
         $uri->setValue($settings["soap_auth_uri"]);
         $namespace->setValue($settings["soap_auth_namespace"]);
         $dotnet->setChecked($settings["soap_auth_use_dotnet"]);
         $createuser->setChecked($settings["soap_auth_create_users"]);
         $allowlocal->setChecked($settings["soap_auth_allow_local"]);
         $defaultrole->setValue($settings["soap_auth_user_default_role"]);
         $sendmail->setChecked($settings["soap_auth_account_mail"]);
     }
     if (!$defaultrole->getValue()) {
         $defaultrole->setValue(4);
     }
     //add Items to property gui
     $soap_config->addItem($active);
     $soap_config->addItem($server);
     $soap_config->addItem($port);
     $soap_config->addItem($https);
     $soap_config->addItem($uri);
     $soap_config->addItem($namespace);
     $soap_config->addItem($dotnet);
     $soap_config->addItem($createuser);
     $soap_config->addItem($sendmail);
     $soap_config->addItem($defaultrole);
     $soap_config->addItem($allowlocal);
     $this->tpl->setVariable("CONFIG_FORM", $soap_config->getHTML());
     // test form
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this));
     $form->setTitle("Test Request");
     $text_prop = new ilTextInputGUI("ext_uid", "ext_uid");
     $form->addItem($text_prop);
     $text_prop2 = new ilTextInputGUI("soap_pw", "soap_pw");
     $form->addItem($text_prop2);
     $cb = new ilCheckboxInputGUI("new_user", "new_user");
     $form->addItem($cb);
     $form->addCommandButton("testSoapAuthConnection", "Send");
     if ($ilCtrl->getCmd() == "testSoapAuthConnection") {
         include_once "./Services/SOAPAuth/classes/class.ilSOAPAuth.php";
         $ret = "<br />" . ilSOAPAuth::testConnection(ilUtil::stripSlashes($_POST["ext_uid"]), ilUtil::stripSlashes($_POST["soap_pw"]), (bool) $_POST["new_user"]);
     }
     $this->tpl->setVariable("TEST_FORM", $form->getHTML() . $ret);
 }
 /**
  * Add standard fields to form
  */
 function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
 {
     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 && ilUserProfile::userSettingVisible($f)) {
             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 = new ilFormSectionHeaderGUI();
                         $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 = new ilFormSectionHeaderGUI();
             $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":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $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":
                 if (ilUserProfile::userSettingVisible($f)) {
                     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":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $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":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $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
                     if (ilUserProfile::userSettingVisible("upload") and $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) {
                     if (ilUserProfile::userSettingVisible("roles")) {
                         $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 ($options) {
                                 if (sizeof($options) > 1) {
                                     $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_" . $f);
                                     $ta->setOptions($options);
                                     $ta->setRequired($ilSetting->get("require_" . $f));
                                     if (!$ta->getRequired()) {
                                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                                     }
                                 } else {
                                     $ta = new ilHiddenInputGUI("usr_" . $f);
                                     $ta->setValue(array_shift(array_keys($options)));
                                 }
                                 $a_form->addItem($ta);
                             }
                         }
                     }
                 }
                 break;
             case "email":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $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":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $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":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $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;
             case "multitext":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     $ti->setMulti(true);
                     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));
                     }
                     if ($this->ajax_href) {
                         // add field to ajax call
                         $ti->setDataSource($this->ajax_href . "&f=" . $f);
                     }
                     $a_form->addItem($ti);
                 }
                 break;
         }
     }
     // append custom fields as "other"
     if (is_array($custom_fields) && !$custom_fields_done) {
         // add "other" subheader
         if ($current_group != "other") {
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt("other"));
             $a_form->addItem($sh);
         }
         foreach ($custom_fields as $custom_field) {
             $a_form->addItem($custom_field);
         }
     }
 }