Permalink
Browse files

Added an alternative way of adding the current User ID to \Gems_Model…

…, for instances where GemsEscort is not available
  • Loading branch information...
jvangestel committed Oct 5, 2018
1 parent 5b12e0b commit bbd71c8f4821e7092753285dd5961355956af7ce
Showing with 19 additions and 0 deletions.
  1. +19 −0 classes/Gems/Model.php
View
@@ -69,6 +69,11 @@ class Gems_Model extends \Gems_Loader_TargetLoaderAbstract
*/
protected $cascade = 'Model';
/**
* @var int Current user ID
*/
protected static $currentUserId;
/**
*
* @var \Zend_Db_Adapter_Abstract
@@ -390,6 +395,10 @@ public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstrac
$model->setOnSave($created_field, new \MUtil_Db_Expr_CurrentTimestamp());
$model->setSaveWhenNew($created_field);
if (! $userid && self::$currentUserId) {
$userid = self::$currentUserId;
}
if (! $userid) {
$escort = \GemsEscort::getInstance();
@@ -412,4 +421,14 @@ public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstrac
$model->setSaveWhenNew($created_by_field);
}
}
/**
* Set the current User ID
*
* @param $userId
*/
public static function setCurrentUserId($userId)
{
self::$currentUserId = $userId;
}
}

0 comments on commit bbd71c8

Please sign in to comment.