protected function lazy_get_properties() { $properties = parent::lazy_get_properties(); if (!$this->key) { $properties['created'] = DateTime::now(); } return $properties; }
protected function lazy_get_properties() { $properties = parent::lazy_get_properties(); unset($properties['user_id']); if (!$this->key) { $properties['user_id'] = $this->app->user->id; $properties['created'] = DateTime::now(); } return $properties; }
/** * Overrides the method to handle the following properties: * * `uid`: Only users with the PERMISSION_ADMINISTER permission can choose the user of records. * If the user saving a record has no such permission, the Node::UID property is removed from * the properties created by the parent method. * * `siteid`: If the user is creating a new record or the user has no permission to choose the * record's site, the property is set to the value of the working site's id. * * Also, the following default values are used: * * - `uid`: 0 * - `nativeid`: 0 * - `language`: an empty string */ protected function lazy_get_properties() { global $core; $properties = parent::lazy_get_properties() + [Node::UID => 0, Node::NATIVEID => 0, Node::LANGUAGE => '']; $user = $core->user; if (!$user->has_permission(Module::PERMISSION_ADMINISTER, $this->module)) { unset($properties[Node::UID]); } if (!$this->key || !$user->has_permission(Module::PERMISSION_MODIFY_BELONGING_SITE)) { $properties[Node::SITEID] = $core->site_id; } $properties[Node::UPDATED_AT] = DateTime::now(); return $properties; }