本文整理汇总了PHP中eZUser::store方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::store方法的具体用法?PHP eZUser::store怎么用?PHP eZUser::store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::store方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importAttribute
/**
* Imports a value to an attribute adapting it to the proper type.
* Not written by me, downloaded from ez.no! Extended it only!
* @param data The value (string/int/float).
* @param contentObjectAttribute The attribute to modify.
*/
function importAttribute($data, &$contentObjectAttribute)
{
$contentClassAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
$dataTypeString = $contentClassAttribute->attribute('data_type_string');
ezDebug::writeDebug("Converting " . $data . " to expected " . $dataTypeString);
switch ($dataTypeString) {
case 'ezfloat':
case 'ezprice':
$contentObjectAttribute->setAttribute('data_float', $data);
$contentObjectAttribute->store();
break;
case 'ezboolean':
case 'ezdate':
case 'ezdatetime':
case 'ezinteger':
case 'ezsubtreesubscription':
case 'eztime':
$contentObjectAttribute->setAttribute('data_int', $data);
$contentObjectAttribute->store();
break;
case 'ezobjectrelation':
// $data is contentobject_id to relate to
// $oldData = $contentObjectAttribute->attribute( 'data_int' );
$contentObjectAttribute->setAttribute('data_int', $data);
$contentObjectAttribute->store();
$object = $contentObjectAttribute->object();
$contentObjectVersion = $contentObjectAttribute->attribute('version');
$contentClassAttributeID = $contentObjectAttribute->attribute('contentclassattribute_id');
// Problem with translations if removing old relations ?!
// $object->removeContentObjectRelation( $oldData, $contentObjectVersion, $contentClassAttributeID, eZContentObject::RELATION_ATTRIBUTE );
$object->addContentObjectRelation($data, $contentObjectVersion, $contentClassAttributeID, RELATION_ATTRIBUTE);
break;
case 'ezurl':
$urlID = eZURL::registerURL($data);
$contentObjectAttribute->setAttribute('data_int', $urlID);
// Fall through to set data_text
// Fall through to set data_text
case 'ezemail':
case 'ezisbn':
case 'ezstring':
case 'eztext':
$contentObjectAttribute->setAttribute('data_text', $data);
$contentObjectAttribute->store();
break;
case 'ezxmltext':
/* $parser = new eZXMLInputParser();
$document = $parser->process( $data );
$data = eZXMLTextType::domString( $document );
$contentObjectAttribute->fromString( $data );*/
$contentObjectAttribute->setAttribute('data_text', $data);
$contentObjectAttribute->store();
break;
// case 'ezimage':
// $this->saveImage( $data, $contentObjectAttribute );
// break;
// case 'ezbinaryfile':
// $this->saveFile( $data, $contentObjectAttribute );
// break;
// case 'ezenum':
//removed enum - function can be found at ez.no
// break;
// case 'ezimage':
// $this->saveImage( $data, $contentObjectAttribute );
// break;
// case 'ezbinaryfile':
// $this->saveFile( $data, $contentObjectAttribute );
// break;
// case 'ezenum':
//removed enum - function can be found at ez.no
// break;
case 'ezuser':
// $data is assumed to be an associative array( login, password, email );
$user = new eZUser($contentObjectAttribute->attribute('contentobject_id'));
if (isset($data['login'])) {
$user->setAttribute('login', $data['login']);
}
if (isset($data['email'])) {
$user->setAttribute('email', $data['email']);
}
if (isset($data['password'])) {
$hashType = eZUser::hashType() . '';
$newHash = $user->createHash($data['login'], $data['password'], eZUser::site(), $hashType);
$user->setAttribute('password_hash_type', $hashType);
$user->setAttribute('password_hash', $newHash);
}
$user->store();
break;
default:
die('Can not store ' . $data . ' as datatype: ' . $dataTypeString);
}
}
示例2: updateUser
/**
* Updates user with provided auth data
*
* @param eZUser $user
* @param array $authResult
*
* @return bool
*/
public static function updateUser($user, $authResult)
{
$currentTimeStamp = eZDateTime::currentTimeStamp();
$contentObject = $user->contentObject();
if (!$contentObject instanceof eZContentObject) {
return false;
}
/** @var eZContentObjectVersion $version */
$version = $contentObject->currentVersion();
$db = eZDB::instance();
$db->begin();
$version->setAttribute('modified', $currentTimeStamp);
$version->store();
self::fillUserObject($version->dataMap(), $authResult);
if ($authResult['email'] != $user->Email) {
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (empty($authResult['email']) || $userExists) {
$email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
} else {
$email = $authResult['email'];
}
$user->setAttribute('email', $email);
$user->store();
}
$contentObject->setName($contentObject->contentClass()->contentObjectName($contentObject));
$contentObject->store();
$db->commit();
return $user;
}