diff --git a/.travis/install-dependencies.sh b/.travis/install-dependencies.sh index 258b8e7884..9e74009341 100755 --- a/.travis/install-dependencies.sh +++ b/.travis/install-dependencies.sh @@ -4,6 +4,9 @@ set -ev # Install chomedriver -curl -s -L -o chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/84.0.4147.30/chromedriver_linux64.zip \ +CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'` +CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"` + +curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O \ && unzip -o -d $HOME chromedriver_linux64.zip \ && chmod +x $HOME/chromedriver diff --git a/CHANGELOG_DEV.md b/CHANGELOG_DEV.md index cef7e5a55b..f5732e4338 100644 --- a/CHANGELOG_DEV.md +++ b/CHANGELOG_DEV.md @@ -19,6 +19,7 @@ HumHub Changelog - Enh #4378: Implemented generic ContentContainerActiveRecord::is() function - Enh #4310: Add "Can Like" Permission - Fix #4111: Issues Cropping Images +- Enh #4283: Implemented UserMemberSince and UserLastLogin user's profile virtual fields - Fix #4385: Tour broken when profile start page is changed - Enh #3882: Rework of wall stream entry widget design and API - Enh #3882: Introduction of alternative `WallStreamModuleEntry` widget for collaborative content types @@ -37,6 +38,7 @@ HumHub Changelog - Fix #3566: Bug in models/filetype/CheckboxList.php - Enh #4401: Allow to use less variable name in value of another less variable - Fix #4434: Fix title quoting for space icons in widget “Member in these spaces” +- Fix #4428: Replace db Expression time now with func date('Y-m-d G:i:s') - Enh #4370: Add "summary" to `Space` model - Enh #4370: Add `humhub\modules\space\widgets\MyMembership` to manage render user state in a space - Enh #4370: Add `humhub\modules\space\widgets\AboutPageSidebar` to manage about page sidebar diff --git a/protected/humhub/components/ActiveRecord.php b/protected/humhub/components/ActiveRecord.php index 9838d6001e..6b20c3198e 100644 --- a/protected/humhub/components/ActiveRecord.php +++ b/protected/humhub/components/ActiveRecord.php @@ -36,7 +36,7 @@ class ActiveRecord extends \yii\db\ActiveRecord implements \Serializable { if ($insert) { if ($this->hasAttribute('created_at') && $this->created_at == "") { - $this->created_at = new \yii\db\Expression('NOW()'); + $this->created_at = date('Y-m-d G:i:s'); } if (isset(Yii::$app->user) && $this->hasAttribute('created_by') && $this->created_by == "") { @@ -45,7 +45,7 @@ class ActiveRecord extends \yii\db\ActiveRecord implements \Serializable } if ($this->hasAttribute('updated_at')) { - $this->updated_at = new \yii\db\Expression('NOW()'); + $this->updated_at = date('Y-m-d G:i:s'); } if (isset(Yii::$app->user) && $this->hasAttribute('updated_by')) { $this->updated_by = Yii::$app->user->id; diff --git a/protected/humhub/modules/content/models/Content.php b/protected/humhub/modules/content/models/Content.php index 0867d722ba..b0613a1782 100644 --- a/protected/humhub/modules/content/models/Content.php +++ b/protected/humhub/modules/content/models/Content.php @@ -206,7 +206,7 @@ class Content extends ActiveRecord implements Movable, ContentOwner } } - $this->stream_sort_date = new \yii\db\Expression('NOW()'); + $this->stream_sort_date = date('Y-m-d G:i:s'); if ($this->created_by == "") { throw new Exception("Could not save content without created_by!"); @@ -853,7 +853,7 @@ class Content extends ActiveRecord implements Movable, ContentOwner */ public function updateStreamSortTime() { - $this->updateAttributes(['stream_sort_date' => new \yii\db\Expression('NOW()')]); + $this->updateAttributes(['stream_sort_date' => date('Y-m-d G:i:s')]); } /** diff --git a/protected/humhub/modules/content/widgets/WallEntryControls.php b/protected/humhub/modules/content/widgets/WallEntryControls.php index 5ab9e3b936..22d6117066 100644 --- a/protected/humhub/modules/content/widgets/WallEntryControls.php +++ b/protected/humhub/modules/content/widgets/WallEntryControls.php @@ -47,7 +47,10 @@ class WallEntryControls extends Menu { if(!$this->renderOptions && $this->wallEntryWidget instanceof WallStreamEntryWidget) { $this->renderOptions = $this->wallEntryWidget->renderOptions; + } else if(!$this->renderOptions) { + $this->renderOptions = new WallStreamEntryOptions(); } + parent::init(); } diff --git a/protected/humhub/modules/space/models/Membership.php b/protected/humhub/modules/space/models/Membership.php index 6dcf183385..2a7a49f797 100644 --- a/protected/humhub/modules/space/models/Membership.php +++ b/protected/humhub/modules/space/models/Membership.php @@ -146,7 +146,7 @@ class Membership extends ActiveRecord */ public function updateLastVisit() { - $this->last_visit = new \yii\db\Expression('NOW()'); + $this->last_visit = date('Y-m-d G:i:s'); $this->update(false, ['last_visit']); } diff --git a/protected/humhub/modules/stream/actions/LegacyStreamTrait.php b/protected/humhub/modules/stream/actions/LegacyStreamTrait.php index f6e4038e81..9e939276e4 100644 --- a/protected/humhub/modules/stream/actions/LegacyStreamTrait.php +++ b/protected/humhub/modules/stream/actions/LegacyStreamTrait.php @@ -6,6 +6,7 @@ namespace humhub\modules\stream\actions; use humhub\modules\content\components\ContentActiveRecord; use humhub\modules\content\models\Content; +use humhub\modules\content\widgets\stream\StreamEntryWidget; use humhub\modules\content\widgets\stream\WallStreamEntryWidget; use Yii; use yii\base\Exception; @@ -115,7 +116,8 @@ trait LegacyStreamTrait if(is_subclass_of($record->wallEntryClass, WallStreamEntryWidget::class, true)) { - return $record->getWallOut($options); + // This was added just in case we somehow run this with a new wall entry widget + return StreamEntryWidget::renderStreamEntry($record); } return static::renderLegacyWallEntry( $record, $options, $partial); diff --git a/protected/humhub/modules/user/components/User.php b/protected/humhub/modules/user/components/User.php index 253655f8a4..57dc6f137f 100644 --- a/protected/humhub/modules/user/components/User.php +++ b/protected/humhub/modules/user/components/User.php @@ -15,7 +15,6 @@ use humhub\modules\user\events\UserEvent; use humhub\modules\user\helpers\AuthHelper; use Yii; use yii\authclient\ClientInterface; -use yii\db\Expression; /** * Description of User @@ -198,7 +197,7 @@ class User extends \yii\web\User */ public function afterLogin($identity, $cookieBased, $duration) { - $identity->updateAttributes(['last_login' => new Expression('NOW()')]); + $identity->updateAttributes(['last_login' => date('Y-m-d G:i:s')]); parent::afterLogin($identity, $cookieBased, $duration); } diff --git a/protected/humhub/modules/user/controllers/RegistrationController.php b/protected/humhub/modules/user/controllers/RegistrationController.php index dded7859ec..933a326543 100644 --- a/protected/humhub/modules/user/controllers/RegistrationController.php +++ b/protected/humhub/modules/user/controllers/RegistrationController.php @@ -84,7 +84,7 @@ class RegistrationController extends Controller // Autologin when user is enabled (no approval required) if ($registration->getUser()->status === User::STATUS_ENABLED) { Yii::$app->user->switchIdentity($registration->models['User']); - $registration->models['User']->updateAttributes(['last_login' => new \yii\db\Expression('NOW()')]); + $registration->models['User']->updateAttributes(['last_login' => date('Y-m-d G:i:s')]); if (Yii::$app->request->getIsAjax()) { return $this->htmlRedirect(Yii::$app->user->returnUrl); } diff --git a/protected/humhub/modules/user/migrations/m140303_125031_password.php b/protected/humhub/modules/user/migrations/m140303_125031_password.php index 258f3dfcee..f9f6c463a9 100644 --- a/protected/humhub/modules/user/migrations/m140303_125031_password.php +++ b/protected/humhub/modules/user/migrations/m140303_125031_password.php @@ -31,7 +31,7 @@ class m140303_125031_password extends Migration ->all(); foreach ($rows as $row) { $password = str_replace('___enc___', '', $row['password']); - $this->update('user_password', ['user_id' => $row['id'], 'password' => $password, 'algorithm' => $algorithm, 'salt' => Yii::$app->settings->get('secret'), 'created_at' => new \yii\db\Expression('NOW()')]); + $this->update('user_password', ['user_id' => $row['id'], 'password' => $password, 'algorithm' => $algorithm, 'salt' => Yii::$app->settings->get('secret'), 'created_at' => date('Y-m-d G:i:s')]); } $this->dropColumn('user', 'password'); } diff --git a/protected/humhub/modules/user/migrations/m160229_162959_multiusergroups.php b/protected/humhub/modules/user/migrations/m160229_162959_multiusergroups.php index 558bb1592f..e3d902aaa2 100644 --- a/protected/humhub/modules/user/migrations/m160229_162959_multiusergroups.php +++ b/protected/humhub/modules/user/migrations/m160229_162959_multiusergroups.php @@ -2,7 +2,6 @@ use yii\db\Schema; use yii\db\Query; -use yii\db\Expression; use humhub\components\Migration; class m160229_162959_multiusergroups extends Migration @@ -41,7 +40,7 @@ class m160229_162959_multiusergroups extends Migration 'is_admin_group' => '1', 'show_at_registration' => '0', 'show_at_directory' => '0', - 'created_at' => new Expression('NOW()') + 'created_at' => date('Y-m-d G:i:s') ]); // Determine administration group id diff --git a/protected/humhub/modules/user/models/Group.php b/protected/humhub/modules/user/models/Group.php index dc92547ba2..4b532c9c58 100644 --- a/protected/humhub/modules/user/models/Group.php +++ b/protected/humhub/modules/user/models/Group.php @@ -220,11 +220,12 @@ class Group extends ActiveRecord * @param User $user user id or user model * @param bool $isManager mark as group manager * @throws \yii\base\InvalidConfigException + * @return bool true - on success adding user, false - if already member or cannot be added by some reason */ public function addUser($user, $isManager = false) { if ($this->isMember($user)) { - return; + return false; } $userId = ($user instanceof User) ? $user->id : $user; @@ -232,7 +233,7 @@ class Group extends ActiveRecord $newGroupUser = new GroupUser(); $newGroupUser->user_id = $userId; $newGroupUser->group_id = $this->id; - $newGroupUser->created_at = new \yii\db\Expression('NOW()'); + $newGroupUser->created_at = date('Y-m-d G:i:s'); $newGroupUser->created_by = Yii::$app->user->id; $newGroupUser->is_group_manager = $isManager; if ($newGroupUser->save() && !Yii::$app->user->isGuest) { @@ -240,7 +241,10 @@ class Group extends ActiveRecord ->about($this) ->from(Yii::$app->user->identity) ->send(User::findOne(['id' => $userId])); + return true; } + + return false; } /** diff --git a/protected/humhub/modules/user/models/Password.php b/protected/humhub/modules/user/models/Password.php index e83b9c5f4b..c168097e77 100644 --- a/protected/humhub/modules/user/models/Password.php +++ b/protected/humhub/modules/user/models/Password.php @@ -12,7 +12,6 @@ use Yii; use yii\base\ErrorException; use yii\db\ActiveRecord; use yii\base\Exception; -use yii\db\Expression; use humhub\libs\UUID; use humhub\modules\user\components\CheckPasswordValidator; @@ -55,7 +54,7 @@ class Password extends ActiveRecord public function beforeSave($insert) { - $this->created_at = new Expression('NOW()'); + $this->created_at = date('Y-m-d G:i:s'); return parent::beforeSave($insert); } diff --git a/protected/humhub/modules/user/models/fieldtype/BaseType.php b/protected/humhub/modules/user/models/fieldtype/BaseType.php index dd730bb0c6..07b526815b 100644 --- a/protected/humhub/modules/user/models/fieldtype/BaseType.php +++ b/protected/humhub/modules/user/models/fieldtype/BaseType.php @@ -86,6 +86,8 @@ class BaseType extends Model CheckboxList::class => Yii::t('UserModule.profile', 'Checkbox List'), UserEmail::class => Yii::t('UserModule.profile', 'E-mail address of the user'), UserName::class => Yii::t('UserModule.profile', 'Username'), + UserMemberSince::class => Yii::t('UserModule.profile', 'Creation date of the user'), + UserLastLogin::class => Yii::t('UserModule.profile', 'Last login date of the user'), ], $this->fieldTypes); return $fieldTypes; diff --git a/protected/humhub/modules/user/models/fieldtype/UserLastLogin.php b/protected/humhub/modules/user/models/fieldtype/UserLastLogin.php new file mode 100644 index 0000000000..ce0a873ae5 --- /dev/null +++ b/protected/humhub/modules/user/models/fieldtype/UserLastLogin.php @@ -0,0 +1,35 @@ +last_login)) { + return '-'; + } + + return Yii::$app->formatter->asDate($user->last_login,'long'); + } +} diff --git a/protected/humhub/modules/user/models/fieldtype/UserMemberSince.php b/protected/humhub/modules/user/models/fieldtype/UserMemberSince.php new file mode 100644 index 0000000000..1d7a1596ee --- /dev/null +++ b/protected/humhub/modules/user/models/fieldtype/UserMemberSince.php @@ -0,0 +1,34 @@ +created_at)) { + return ''; + } + + return Yii::$app->formatter->asDate($user->created_at,'long'); + } +}