diff --git a/core/includes/common.inc b/core/includes/common.inc diff --git a/core/modules/entity/entity.controller.inc b/core/modules/entity/entity.controller.inc index cca1845..3c24169 100644 --- a/core/modules/entity/entity.controller.inc +++ b/core/modules/entity/entity.controller.inc @@ -497,6 +497,8 @@ class EntityDatabaseStorageController extends DrupalDefaultEntityController impl $this->invokeHook('update', $entity); } else { + dpm($entity); + unset($entity->uid); $return = drupal_write_record($this->entityInfo['base table'], $entity); $this->postSave($entity); $this->invokeHook('insert', $entity); diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index 2eda87c..2e68de9 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -290,6 +290,7 @@ function entity_create($entity_type, array $values) { * Gets the entity controller class for an entity type. */ function entity_get_controller($entity_type) { +dpm($entity_type); $controllers = &drupal_static(__FUNCTION__, array()); if (!isset($controllers[$entity_type])) { $type_info = entity_get_info($entity_type); diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php index 5c711fb..bba89b5 100644 --- a/core/modules/simpletest/drupal_web_test_case.php +++ b/core/modules/simpletest/drupal_web_test_case.php @@ -1116,7 +1116,9 @@ class DrupalWebTestCase extends DrupalTestCase { $edit['pass'] = user_password(); $edit['status'] = 1; - $account = user_save(drupal_anonymous_user(), $edit); + $User = entity_create('user', $edit); + + $account = $User->save(); $this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login')); if (empty($account->uid)) { diff --git a/core/modules/user/user.entity.inc b/core/modules/user/user.entity.inc index 5549c77..92a2f4b 100644 --- a/core/modules/user/user.entity.inc +++ b/core/modules/user/user.entity.inc @@ -5,12 +5,131 @@ */ /** + * Defines the user entity class + */ +class User extends Entity { + + /** + * The user ID. + * + * @var integer + */ + public $uid; + + /** + * The unique user name. + * + * @var string + */ + public $name = ''; + + /** + * The user's password (hashed). + * + * @var string + */ + public $pass; + + /** + * The user's email address. + * + * @var string + */ + public $mail = ''; + + /** + * The user's default theme. + * + * @var string + */ + public $theme; + + /** + * The user's signature. + * + * @var string + */ + public $signature; + + /** + * The user's signature format. + * + * @var string + */ + public $signature_format = NULL; + + /** + * The timestamp when the user was created. + * + * @var integer + */ + public $created = 0; + + /** + * The timestamp when the user last accessed the site. + * + * @var integer + */ + public $access = 0; + + /** + * The timestamp when the user lasted logged in. + * + * @var integer + */ + public $login = 0; + + /** + * Whether the user is active(1) or blocked(0). + * + * @var integer + */ + public $status = 0; + + /** + * The user's timezone. + * + * @var string + */ + public $timezone = NULL; + + /** + * The user's default language. + * + * @var string + */ + public $language = ''; + + /** + * The fid of the user's picture. + * + * @var integer + */ + public $picture = 0; + + /** + * The email address used for initial account creation. + * + * @var string + */ + public $init = ''; + + /** + * The user's roles. + * + * @var array + */ + public $roles = array(); + +} + +/** * Controller class for users. * * This extends the DrupalDefaultEntityController class, adding required * special handling for user objects. */ -class UserController extends DrupalDefaultEntityController { +class UserController extends EntityDatabaseStorageController { function attachLoad(&$queried_users, $revision_id = FALSE) { // Build an array of user picture IDs so that these can be fetched later. @@ -49,4 +168,11 @@ class UserController extends DrupalDefaultEntityController { // hook_user_load(). parent::attachLoad($queried_users, $revision_id); } + + function save(EntityInterface $entity) { + if (empty($entity->uid)) { + $entity->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField()); + } + parent::save($entity); + } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 2dded35..7905fab 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -143,7 +143,7 @@ function user_theme() { * Implements hook_entity_info(). */ function user_entity_info() { - $return = array( + return array( 'user' => array( 'label' => t('User'), 'controller class' => 'UserController', @@ -151,6 +151,7 @@ function user_entity_info() { 'uri callback' => 'user_uri', 'label callback' => 'user_label', 'fieldable' => TRUE, + 'entity class' => 'User', 'entity keys' => array( 'id' => 'uid', ), @@ -171,7 +172,6 @@ function user_entity_info() { ), ), ); - return $return; } /**