public function setOwnership($p) { $ids = Util\toNumericArray($p['ids']); $rez = array('success' => true, 'data' => $ids); if (empty($ids)) { return $rez; } $userId = empty($p['userId']) || !is_numeric($p['userId']) ? User::getId() : $p['userId']; //check if user has rights to take ownership on each object foreach ($ids as $id) { if (!Security::canTakeOwnership($id)) { throw new \Exception(L\get('Access_denied')); } } DM\Tree::updateOwner($ids, $userId); //TODO: view if needed to mark all childs as updated, for security to be changed .... Solr\Client::runCron(); return $rez; }
public function takeOwnership($ids) { $ids = Util\toNumericArray($ids); $rez = array('success' => true, 'data' => $ids); if (empty($ids)) { return $rez; } //check if user has rights to take ownership on each object foreach ($ids as $id) { if (!Security::canTakeOwnership($id)) { throw new \Exception(L\get('Access_denied')); } } //set the owner DB\dbQuery('UPDATE tree SET oid = $1 ,uid = $1 WHERE id IN (' . implode(',', $ids) . ') AND `system` = 0', $_SESSION['user']['id']) or die(DB\dbQueryError()); //TODO: view if needed to mark all childs as updated, for security to be changed .... Solr\Client::runCron(); return $rez; }