Skip to content

Commit

Permalink
tweak(Tinebase/FileSystem): use SystemGeneric exception on node name …
Browse files Browse the repository at this point in the history
…update fail

... because js client currently allows renaming record attachments

TODO: this also needs to be fixed in the client
  • Loading branch information
pschuele committed Jan 8, 2025
1 parent 06b3a8e commit f8373ff
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tine20/Tinebase/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2715,23 +2715,29 @@ protected function _splitPath($path)
{
return explode('/', trim($path, '/'));
}

/**
* update node
*
*
* @param Tinebase_Model_Tree_Node $_node
* @return Tinebase_Model_Tree_Node
* @throws Tinebase_Exception_InvalidArgument
* @throws Tinebase_Exception_NotFound
* @throws Tinebase_Exception_Record_NotAllowed
* @throws Tinebase_Exception_Record_Validation
* @throws Tinebase_Exception_SystemGeneric
*/
public function update(Tinebase_Model_Tree_Node $_node)
public function update(Tinebase_Model_Tree_Node $_node): Tinebase_Model_Tree_Node
{
$transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());

try {
$currentNodeObject = $this->get($_node->getId());

if ($_node->name !== $currentNodeObject->name) {
throw new Tinebase_Exception_Record_Validation('name may not be changed in update');

$translation = Tinebase_Translation::getTranslation();
throw new Tinebase_Exception_SystemGeneric(
$translation->_('Node name may not be changed in update'));
}
if (isset($_node->grants)) {
if ($currentNodeObject->getId() !== $currentNodeObject->acl_node) {
Expand Down Expand Up @@ -3937,7 +3943,7 @@ public function getPersonalContainer($_accountId, $_recordClass, $_owner, $_gran
? Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $_accountId)
: $_accountId;

$translation = Tinebase_Translation::getTranslation('Tinebase');
$translation = Tinebase_Translation::getTranslation();
$nodeName = sprintf($translation->_("%s's personal container"), $account->accountFullName);
$nodeName = preg_replace('/\//', '', $nodeName);
$path = $pathRecord->statpath . '/' . $nodeName;
Expand Down

0 comments on commit f8373ff

Please sign in to comment.