当前位置: 首页>>代码示例>>PHP>>正文


PHP eZUser::store方法代码示例

本文整理汇总了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);
    }
}
开发者ID:informaticatrentina,项目名称:batchtool,代码行数:97,代码来源:lib.php

示例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;
 }
开发者ID:netgen,项目名称:ngconnect,代码行数:40,代码来源:ngconnectfunctions.php


注:本文中的eZUser::store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。