Rename.php
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once(KT_LIB_DIR . '/actions/folderaction.inc.php');
require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php");
require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php");
require_once(KT_LIB_DIR . "/foldermanagement/folderutil.inc.php");
require_once(KT_LIB_DIR . "/documentmanagement/observers.inc.php");
require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php");
class KTFolderRenameAction extends KTFolderAction {
var $sName = 'ktcore.actions.folder.rename';
var $_sShowPermission = "ktcore.permissions.write";
function getDisplayName() {
return _('Rename');
}
function do_main() {
$this->oPage->setBreadcrumbDetails(_("rename"));
$this->oPage->setTitle(_('Rename folder'));
$oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/rename');
$fields = array();
$fields[] = new KTStringWidget(_('New folder name'), _('The name to which the current folder should be renamed.'), 'foldername', "", $this->oPage, true);
$oTemplate->setData(array(
'context' => &$this,
'fields' => $fields,
));
return $oTemplate->render();
}
function do_rename() {
$sName = KTUtil::arrayGet($_REQUEST, 'foldername');
$aOptions = array(
'redirect_to' => array('', sprintf('fFolderId=%d', $this->oFolder->getId())),
'message' => "No folder name given",
);
$this->oValidator->validateString($sName, $aOptions);
$res = KTFolderUtil::rename($this->oFolder, $sName, $this->oUser);
if (PEAR::isError($res)) {
$_SESSION['KTErrorMessage'][] = $res->getMessage();
redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
exit(0);
} else {
$_SESSION['KTInfoMessage'][] = sprintf(_('Folder "%s" renamed to "%s".'), $this->oFolder->getName(), $sName);
}
$this->commitTransaction();
redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
exit(0);
}
}
?>