26 $this->Name =
"upload_properties";
27 $this->Title = _(
"Edit Uploaded File Properties");
28 $this->MenuList =
"Organize::Uploads::Edit Properties";
30 parent::__construct();
31 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
32 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
33 $this->folderDao = $GLOBALS[
'container']->get(
'dao.folder');
49 if (empty($newName) and empty($newDesc)) {
53 if (!empty($newName)) {
59 "SELECT pfile_fk FROM upload WHERE upload_pk=$1",array($uploadId),__METHOD__.
'.getPfileId');
63 $pfileFk = $row[
'pfile_fk'];
64 $trimNewName =
trim($newName);
68 "UPDATE uploadtree SET ufile_name=$3 WHERE upload_fk=$1 AND pfile_fk=$2",
69 array($uploadId, $pfileFk, $trimNewName),
70 __METHOD__ .
'.updateItem');
72 "UPDATE upload SET upload_filename=$3 WHERE upload_pk=$1 AND pfile_fk=$2",
73 array($uploadId, $pfileFk, $trimNewName),
74 __METHOD__ .
'.updateUpload.name');
77 if (! empty($newDesc)) {
78 $trimNewDesc =
trim($newDesc);
79 $this->
dbManager->getSingleRow(
"UPDATE upload SET upload_desc=$2 WHERE upload_pk=$1",
80 array($uploadId, $trimNewDesc), __METHOD__ .
'.updateUpload.desc');
87 $groupId = Auth::getGroupId();
88 $rootFolder = $this->folderDao->getRootFolder(Auth::getUserId());
89 $folderStructure = $this->folderDao->getFolderStructure($rootFolder->getId());
93 if (empty($folder_pk)) {
94 $folder_pk = $rootFolder->getId();
100 if (empty($upload_pk)) {
104 if (! empty($upload_pk) && !$this->uploadDao->isEditable($upload_pk, $groupId)) {
105 $text = _(
"Permission Denied");
106 return "<h2>$text</h2>";
110 $text = _(
"Nothing to Change");
111 $this->vars[
'message'] = $text;
112 }
else if ($rc == 1) {
113 $text = _(
"Upload Properties successfully changed");
114 $this->vars[
'message'] = $text;
117 $this->vars[
'folderStructure'] = $folderStructure;
118 $this->vars[
'folderId'] = $folder_pk;
119 $this->vars[
'baseUri'] = $Uri =
Traceback_uri() .
"?mod=" . $this->Name .
"&folder=";
121 $folderUploads = $this->folderDao->getFolderUploads($folder_pk, $groupId);
122 $uploadsById = array();
124 foreach ($folderUploads as $uploadProgress) {
125 if ($uploadProgress->getGroupId() != $groupId) {
128 if (! $this->uploadDao->isEditable($uploadProgress->getId(), $groupId)) {
131 $display = $uploadProgress->getFilename() . _(
" from ") .
Convert2BrowserTime(date(
"Y-m-d H:i:s",$uploadProgress->getTimestamp()));
132 $uploadsById[$uploadProgress->getId()] = $display;
134 $this->vars[
'uploadList'] = $uploadsById;
135 if (empty($upload_pk)) {
137 $upload_pk = key($uploadsById);
139 $this->vars[
'uploadId'] = $upload_pk;
142 $upload = $this->uploadDao->getUpload($upload_pk);
143 if (empty($upload)) {
144 $this->vars[
'message'] = _(
"Missing upload.");
151 $baseFolderUri = $this->vars[
'baseUri'].
"$folder_pk&upload=";
152 $this->vars[
'uploadAction'] =
"onchange=\"js_url(this.value, '$baseFolderUri')\"";
154 $this->vars[
'uploadFilename'] = $upload ? $upload->getFilename() :
'';
155 $this->vars[
'uploadDesc'] = $upload ? $upload->getDescription() :
'';
156 $this->vars[
'content'] = $V;
158 return $this->
render(
'admin_upload_edit.html.twig');
This is the Plugin class. All plugins should:
render($templateName, $vars=null)
Contains the constants and helpers for authentication of user.
Output()
This function is called when user output is requested. This function is responsible for content....
UpdateUploadProperties($uploadId, $newName, $newDesc)
Update upload properties (name, description)
__construct()
base constructor. Most plugins will just use this
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
GetArrayVal($Key, $Arr)
Get the value from a array(map)
Convert2BrowserTime($server_time)
Convert the server time to browser time.
char * trim(char *ptext)
Trimming whitespace.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
fo_dbManager * dbManager
fo_dbManager object