Exemplo n.º 1
0
 /**
  * TODO: drop fields last_update & create_date. redundant data in object_data!
  * saves a new record "user" to database
  * @access	public
  * @param	boolean	user data from formular (addSlashes) or not (prepareDBString)
  */
 function saveAsNew($a_from_formular = true)
 {
     global $ilErr, $ilDB, $ilSetting, $ilUser;
     switch ($this->passwd_type) {
         case IL_PASSWD_PLAIN:
             $pw_field = "passwd";
             if (strlen($this->passwd)) {
                 $pw_value = md5($this->passwd);
             } else {
                 $pw_value = $this->passwd;
             }
             break;
         case IL_PASSWD_MD5:
             $pw_field = "passwd";
             $pw_value = $this->passwd;
             break;
         case IL_PASSWD_CRYPT:
             $pw_field = "i2passwd";
             $pw_value = $this->passwd;
             break;
         default:
             $ilErr->raiseError("<b>Error: passwd_type missing in function saveAsNew. " . $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
     }
     if (!$this->active) {
         $this->setInactivationDate(ilUtil::now());
     }
     $insert_array = array("usr_id" => array("integer", $this->id), "login" => array("text", $this->login), $pw_field => array("text", $pw_value), "firstname" => array("text", $this->firstname), "lastname" => array("text", $this->lastname), "title" => array("text", $this->utitle), "gender" => array("text", $this->gender), "email" => array("text", trim($this->email)), "hobby" => array("text", (string) $this->hobby), "institution" => array("text", $this->institution), "department" => array("text", $this->department), "street" => array("text", $this->street), "city" => array("text", $this->city), "zipcode" => array("text", $this->zipcode), "country" => array("text", $this->country), "sel_country" => array("text", $this->sel_country), "phone_office" => array("text", $this->phone_office), "phone_home" => array("text", $this->phone_home), "phone_mobile" => array("text", $this->phone_mobile), "fax" => array("text", $this->fax), "birthday" => array('date', $this->getBirthday()), "last_login" => array("timestamp", null), "last_update" => array("timestamp", ilUtil::now()), "create_date" => array("timestamp", ilUtil::now()), "referral_comment" => array("text", $this->referral_comment), "matriculation" => array("text", $this->matriculation), "client_ip" => array("text", $this->client_ip), "approve_date" => array("timestamp", $this->approve_date), "agree_date" => array("timestamp", $this->agree_date), "active" => array("integer", (int) $this->active), "time_limit_unlimited" => array("integer", $this->getTimeLimitUnlimited()), "time_limit_until" => array("integer", $this->getTimeLimitUntil()), "time_limit_from" => array("integer", $this->getTimeLimitFrom()), "time_limit_owner" => array("integer", $this->getTimeLimitOwner()), "auth_mode" => array("text", $this->getAuthMode()), "ext_account" => array("text", $this->getExternalAccount()), "profile_incomplete" => array("integer", $this->getProfileIncomplete()), "im_icq" => array("text", $this->im_icq), "im_yahoo" => array("text", $this->im_yahoo), "im_msn" => array("text", $this->im_msn), "im_aim" => array("text", $this->im_aim), "im_skype" => array("text", $this->im_skype), "delicious" => array("text", $this->delicious), "latitude" => array("text", $this->latitude), "longitude" => array("text", $this->longitude), "loc_zoom" => array("integer", (int) $this->loc_zoom), "last_password_change" => array("integer", (int) $this->last_password_change_ts), "im_jabber" => array("text", $this->im_jabber), "im_voip" => array("text", $this->im_voip), 'inactivation_date' => array('timestamp', $this->inactivation_date), 'is_self_registered' => array('integer', (int) $this->is_self_registered));
     $ilDB->insert("usr_data", $insert_array);
     // add new entry in usr_defined_data
     $this->addUserDefinedFieldEntry();
     // ... and update
     $this->updateUserDefinedFields();
     // CREATE ENTRIES FOR MAIL BOX
     include_once "Services/Mail/classes/class.ilMailbox.php";
     $mbox = new ilMailbox($this->id);
     $mbox->createDefaultFolder();
     include_once "Services/Mail/classes/class.ilMailOptions.php";
     $mail_options = new ilMailOptions($this->id);
     $mail_options->createMailOptionsEntry();
     // create personal bookmark folder tree
     include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
     $bmf = new ilBookmarkFolder(0, $this->id);
     $bmf->createNewBookmarkTree();
 }