/** * Imports a user record from csv file * This is a admin specific function * * @param $pParamHash an array with user data * @return TRUE if import succeed **/ function importUser(&$pParamHash) { global $gBitUser; if (!$gBitUser->hasPermission('p_users_admin')) { return FALSE; } if ($this->verifyUserImport($pParamHash)) { $this->StartTrans(); $pParamHash['content_type_guid'] = BITUSER_CONTENT_TYPE_GUID; if (!empty($pParamHash['user_store']) && count($pParamHash['user_store'])) { // lookup and asign the default group for user $defaultGroups = BitPermUser::getDefaultGroup(); if (!empty($defaultGroups)) { $pParamHash['user_store']['default_group_id'] = key($defaultGroups); } if ($this->isValid()) { $userId = array("user_id" => $this->mUserId); $result = $this->mDb->associateUpdate(BIT_DB_PREFIX . 'users_users', $pParamHash['user_store'], $userId); } else { if (empty($pParamHash['user_store']['user_id'])) { $pParamHash['user_store']['user_id'] = $this->mDb->GenID('users_users_user_id_seq'); } $this->mUserId = $pParamHash['user_store']['user_id']; $result = $this->mDb->associateInsert(BIT_DB_PREFIX . 'users_users', $pParamHash['user_store']); } // make sure user is added into the default group map if (!empty($pParamHash['user_store']['default_group_id'])) { BitPermUser::addUserToGroup($pParamHash['user_store']['user_id'], $pParamHash['user_store']['default_group_id']); } } // Prevent liberty from assuming ANONYMOUS_USER_ID while storing $pParamHash['user_id'] = $this->mUserId; if (LibertyContent::store($pParamHash)) { if (empty($this->mInfo['content_id']) || $pParamHash['content_id'] != $this->mInfo['content_id']) { $query = "UPDATE `" . BIT_DB_PREFIX . "users_users` SET `content_id`=? WHERE `user_id`=?"; $result = $this->mDb->query($query, array($pParamHash['content_id'], $this->mUserId)); $this->mInfo['content_id'] = $pParamHash['content_id']; } } $this->CompleteTrans(); // store any uploaded images $this->storeImages($pParamHash); $this->load(TRUE); } return count($this->mErrors) == 0; }