/** * Main method to process current row returned by getNextRow() method. * You may throw an exception if something goes wrong. It will be logged but won't break the import process * @param mixed $row Depending on your data format, can be DOMNode, SimpleXMLIterator, SimpleXMLElement, CSV row... */ public function process($row) { $contentOptions = new SQLIContentOptions(array('class_identifier' => 'user', 'remote_id' => (string) $row->login)); $content = SQLIContent::create($contentOptions); $content->fields->first_name = (string) $row->firstName; $content->fields->last_name = (string) $row->lastName; $userParts = array((string) $row->login, (string) $row->email); //password management : if empty, generate it, use custom default or fixed default $password = $row->password; if (!$password) { if (isset($this->options->generate_password) && $this->options->generate_password) { $password = eZUser::createPassword(6); } elseif (isset($this->options->default_password) && $this->options->default_password) { $password = $this->options->default_password; } else { $password = '******'; } } $userParts[] = $password; $userParts[] = eZUser::createHash((string) $row->login, $password, eZUser::site(), eZUser::hashType()); $userParts[] = eZUser::hashType(); $content->fields->user_account = implode('|', $userParts); // Now publish content $content->addLocation(SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID'])); $publisher = SQLIContentPublisher::getInstance(); $publisher->publish($content); // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called // @see SQLIContent::__destruct() unset($content); $this->csv->rows->next(); }
} else { $tpl->setVariable( 'wrong_key', true ); } } else if ( strlen( $hashKey ) > 4 ) { $tpl->setVariable( 'wrong_key', true ); } if ( $module->isCurrentAction( "Generate" ) ) { $ini = eZINI::instance(); $passwordLength = $ini->variable( "UserSettings", "GeneratePasswordLength" ); $password = eZUser::createPassword( $passwordLength ); $passwordConfirm = $password; // $http->setSessionVariable( "GeneratedPassword", $password ); if ( $module->hasActionParameter( "Email" ) ) { $email = $module->actionParameter( "Email" ); if ( trim( $email ) != "" ) { $users = eZPersistentObject::fetchObjectList( eZUser::definition(), null, array( 'email' => $email ), null, null, true );
protected function getUserAccountString($login, $email) { $password = eZUser::createPassword(8); $passwordHash = eZUser::createHash($login, $password, eZUser::site(), eZUser::hashType()); return $login . '|' . $email . '|' . $passwordHash . '|' . eZUser::passwordHashTypeName(eZUser::hashType()); }