diff --git a/module/action/model.php b/module/action/model.php index ed26d364e4..c3e7612dab 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -93,7 +93,7 @@ class actionModel extends model } if($hasRecentTable) $this->dao->insert(TABLE_ACTIONRECENT)->data($action)->autoCheck()->exec(); - foreach($uid as $value) $this->file->updateObjectID($value, $objectID, $objectType); + $this->file->updateObjectID($uid, $objectID, $objectType); $this->loadModel('message')->send(strtolower($objectType), $objectID, $actionType, $actionID, $actor, $extra); diff --git a/module/file/model.php b/module/file/model.php index a9a224ecb6..03cdd1d3b2 100755 --- a/module/file/model.php +++ b/module/file/model.php @@ -853,23 +853,30 @@ class fileModel extends model /** * Update objectID. * - * @param string $uid - * @param int $objectID - * @param string $objectType + * @param array|string|bool $uid + * @param int $objectID + * @param string $objectType * @access public * @return bool */ - public function updateObjectID(string|bool $uid, int $objectID, string $objectType): bool + public function updateObjectID(array|string|bool $uid, int $objectID, string $objectType): bool { if(empty($uid)) return true; - if(empty($_SESSION['album']['used'][$uid])) return true; - $data = new stdclass(); - $data->objectID = $objectID; - $data->objectType = $objectType; - if(!defined('RUN_MODE') || RUN_MODE != 'api') $data->extra = 'editor'; + if(is_string($uid)) $uid = array($uid); + if(!is_array($uid)) return true; - $this->dao->update(TABLE_FILE)->data($data)->where('id')->in($_SESSION['album']['used'][$uid])->exec(); + foreach($uid as $value) + { + if(empty($_SESSION['album']['used'][$value])) continue; + + $data = new stdclass(); + $data->objectID = $objectID; + $data->objectType = $objectType; + if(!defined('RUN_MODE') || RUN_MODE != 'api') $data->extra = 'editor'; + + $this->dao->update(TABLE_FILE)->data($data)->where('id')->in($_SESSION['album']['used'][$value])->exec(); + } return !dao::isError(); }