Skip to content

Commit

Permalink
Add createdon date field to modUser
Browse files Browse the repository at this point in the history
* origin/pr/12581:
  Check current "created" value as suggested by @Mark-H
  Add `createdon` date field to modUser (cf. #11472)
  • Loading branch information
theboxer committed Jan 18, 2016
2 parents 0163e97 + 46e31a9 commit 89c79f7
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 8 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog.txt
Expand Up @@ -4,6 +4,7 @@ development release, and is only shown to give an idea of what's currently in th

MODX Revolution 2.5.0-dev
====================================
- Add `createdon` date field to modUser [#12581]
- Ensure $restarted in templates/language.tpl always exists [#12847]
- Update LinkedIn link description on Help page [#12851]
- Fix undefined index in modOutputFilter->filter [#12856]
Expand Down
2 changes: 2 additions & 0 deletions core/lexicon/en/user.inc.php
Expand Up @@ -200,3 +200,5 @@
$_lang['user_zip'] = 'Zip';
$_lang['username'] = 'Username';
$_lang['users'] = 'Users';
$_lang['user_createdon'] = 'Created On';
$_lang['user_createdon_desc'] = 'The date the user was created.';
5 changes: 5 additions & 0 deletions core/model/modx/moduser.class.php
Expand Up @@ -15,6 +15,10 @@
* @property json $remote_data Used for storing remote data for authentication for a User
* @property string $hash_class The hashing class used to create this User's password
* @property string $salt A salt that might have been used to create this User's password
* @property int $primary_group The user primary Group
* @property array $session_stale
* @property int $sudo If checked, this user will have full access to all the site and will bypass any Access Permissions checks
* @property int $createdon The user creation date
*
* @property modUserProfile $Profile
* @property modUserGroup $PrimaryGroup
Expand Down Expand Up @@ -81,6 +85,7 @@ public function setSudo($sudo) {
*/
public function save($cacheFlag = false) {
$isNew = $this->isNew();
if ($isNew && ($this->get('createdon') < 1)) $this->set('createdon', time());

if ($this->xpdo instanceof modX) {
$this->xpdo->invokeEvent('OnUserBeforeSave',array(
Expand Down
17 changes: 13 additions & 4 deletions core/model/modx/mysql/moduser.map.inc.php
@@ -1,7 +1,7 @@
<?php
/**
* @package modx
* @subpackage mysql
<?php
/**
* @package modx
* @subpackage mysql
*/
$xpdo_meta_map['modUser']= array (
'package' => 'modx',
Expand All @@ -22,6 +22,7 @@
'primary_group' => 0,
'session_stale' => NULL,
'sudo' => 0,
'createdon' => 0,
),
'fieldMeta' =>
array (
Expand Down Expand Up @@ -123,6 +124,14 @@
'null' => false,
'default' => 0,
),
'createdon' =>
array (
'dbtype' => 'int',
'precision' => '20',
'phptype' => 'timestamp',
'null' => false,
'default' => 0,
),
),
'indexes' =>
array (
Expand Down
16 changes: 12 additions & 4 deletions core/model/modx/sqlsrv/moduser.map.inc.php
@@ -1,7 +1,7 @@
<?php
/**
* @package modx
* @subpackage sqlsrv
<?php
/**
* @package modx
* @subpackage sqlsrv
*/
$xpdo_meta_map['modUser']= array (
'package' => 'modx',
Expand All @@ -22,6 +22,7 @@
'primary_group' => 0,
'session_stale' => NULL,
'sudo' => 0,
'createdon' => 0,
),
'fieldMeta' =>
array (
Expand Down Expand Up @@ -119,6 +120,13 @@
'null' => false,
'default' => 0,
),
'createdon' =>
array (
'dbtype' => 'bigint',
'phptype' => 'timestamp',
'null' => false,
'default' => 0,
),
),
'indexes' =>
array (
Expand Down
1 change: 1 addition & 0 deletions core/model/schema/modx.mysql.schema.xml
Expand Up @@ -1253,6 +1253,7 @@
<field key="primary_group" dbtype="int" precision="10" phptype="integer" attributes="unsigned" null="false" default="0" index="index" />
<field key="session_stale" dbtype="text" phptype="array" null="true" />
<field key="sudo" dbtype="tinyint" precision="1" phptype="boolean" attributes="unsigned" null="false" default="0" />
<field key="createdon" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />

<index alias="username" name="username" primary="false" unique="true" type="BTREE">
<column key="username" length="" collation="A" null="false" />
Expand Down
1 change: 1 addition & 0 deletions core/model/schema/modx.sqlsrv.schema.xml
Expand Up @@ -1192,6 +1192,7 @@
<field key="primary_group" dbtype="int" phptype="integer" null="false" default="0" index="index" />
<field key="session_stale" dbtype="nvarchar" precision="max" phptype="array" null="true" />
<field key="sudo" dbtype="bit" phptype="boolean" null="false" default="0" />
<field key="createdon" dbtype="bigint" phptype="timestamp" null="false" default="0" />

<index alias="username" name="username" primary="false" unique="true" type="BTREE">
<column key="username" length="" collation="A" null="false" />
Expand Down
6 changes: 6 additions & 0 deletions manager/assets/modext/widgets/security/modx.panel.user.js
Expand Up @@ -463,6 +463,12 @@ Ext.extend(MODx.panel.User,MODx.FormPanel,{
,fieldLabel: _('user_failedlogincount')
,description: _('user_failedlogincount_desc')
,xtype: 'textfield'
},{
id: 'modx-user-createdon'
,name: 'createdon'
,fieldLabel: _('user_createdon')
,description: _('user_createdon_desc')
,xtype: 'statictextfield'
},{
id: 'modx-user-class-key'
,name: 'class_key'
Expand Down
14 changes: 14 additions & 0 deletions setup/includes/upgrades/common/2.5-user-createdon.php
@@ -0,0 +1,14 @@
<?php
/**
* Common upgrade script for 2.5 modUser
*
* @var modX $modx
* @package setup
*/

/* add modUser.createdon field */
$class = 'modUser';
$table = $modx->getTableName($class);

$description = $this->install->lexicon('add_column',array('column' => 'createdon','table' => $table));
$this->processResults($class, $description, array($modx->manager, 'addField'), array($class, 'createdon'));
11 changes: 11 additions & 0 deletions setup/includes/upgrades/mysql/2.5.0-pl.php
@@ -0,0 +1,11 @@
<?php
/*1
* Specific upgrades for Revolution 2.5.0-pl
*
* @var modX $modx
* @package setup
* @subpackage upgrades
*/

/* run upgrades common to all db platforms */
include dirname(dirname(__FILE__)) . '/common/2.5-user-createdon.php';
11 changes: 11 additions & 0 deletions setup/includes/upgrades/sqlsrv/2.5.0-pl.php
@@ -0,0 +1,11 @@
<?php
/*1
* Specific upgrades for Revolution 2.5.0-pl
*
* @var modX $modx
* @package setup
* @subpackage upgrades
*/

/* run upgrades common to all db platforms */
include dirname(dirname(__FILE__)) . '/common/2.5-user-createdon.php';

0 comments on commit 89c79f7

Please sign in to comment.