- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/baseobject.php
- Класс: BitrixDiskBaseObject
- Вызов: BaseObject::renameInternal
public function renameInternal($newName, $generateUniqueName = false)
{
$this->errorCollection->clear();
if(!$newName)
{
$this->errorCollection->addOne(new Error('Empty name.'));
return false;
}
if($this->name === $newName)
{
return true;
}
if($generateUniqueName)
{
$newName = static::generateUniqueName($newName, $this->getParentId());
}
$opponentId = null;
if(!static::isUniqueName($newName, $this->parentId, null, $opponentId))
{
if($opponentId != $this->id)
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_OBJECT_MODEL_ERROR_NON_UNIQUE_NAME'), self::ERROR_NON_UNIQUE_NAME)));
return false;
}
}
$oldName = $this->name;
$success = $this->update(array('NAME' => $newName, 'SYNC_UPDATE_TIME' => new DateTime()));
if(!$success)
{
return false;
}
$this->label = null;
Driver::getInstance()->getIndexManager()->changeName($this);
Driver::getInstance()->sendChangeStatusToSubscribers($this, 'quick');
$event = new Event(Driver::INTERNAL_MODULE_ID, "onAfterRenameObject", array($this, $oldName, $newName));
$event->send();
return true;
}