35 function __construct()
37 $this->Name =
"upload_properties";
38 $this->Title = _(
"Edit Uploaded File Properties");
39 $this->MenuList =
"Organize::Uploads::Edit Properties";
41 parent::__construct();
42 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
43 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
44 $this->folderDao = $GLOBALS[
'container']->get(
'dao.folder');
60 if (empty($newName) and empty($newDesc)) {
64 if (!empty($newName)) {
70 "SELECT pfile_fk FROM upload WHERE upload_pk=$1",array($uploadId),__METHOD__.
'.getPfileId');
74 $pfileFk = $row[
'pfile_fk'];
75 $trimNewName =
trim($newName);
79 "UPDATE uploadtree SET ufile_name=$3 WHERE upload_fk=$1 AND pfile_fk=$2",
80 array($uploadId, $pfileFk, $trimNewName),
81 __METHOD__ .
'.updateItem');
83 "UPDATE upload SET upload_filename=$3 WHERE upload_pk=$1 AND pfile_fk=$2",
84 array($uploadId, $pfileFk, $trimNewName),
85 __METHOD__ .
'.updateUpload.name');
88 if (! empty($newDesc)) {
89 $trimNewDesc =
trim($newDesc);
90 $this->
dbManager->getSingleRow(
"UPDATE upload SET upload_desc=$2 WHERE upload_pk=$1",
91 array($uploadId, $trimNewDesc), __METHOD__ .
'.updateUpload.desc');
96 public function Output()
98 $groupId = Auth::getGroupId();
99 $rootFolder = $this->folderDao->getRootFolder(Auth::getUserId());
100 $folderStructure = $this->folderDao->getFolderStructure($rootFolder->getId());
104 if (empty($folder_pk)) {
105 $folder_pk = $rootFolder->getId();
111 if (empty($upload_pk)) {
115 if (! empty($upload_pk) && !$this->uploadDao->isEditable($upload_pk, $groupId)) {
116 $text = _(
"Permission Denied");
117 return "<h2>$text</h2>";
121 $text = _(
"Nothing to Change");
122 $this->vars[
'message'] = $text;
123 }
else if ($rc == 1) {
124 $text = _(
"Upload Properties successfully changed");
125 $this->vars[
'message'] = $text;
128 $this->vars[
'folderStructure'] = $folderStructure;
129 $this->vars[
'folderId'] = $folder_pk;
130 $this->vars[
'baseUri'] = $Uri =
Traceback_uri() .
"?mod=" . $this->Name .
"&folder=";
132 $folderUploads = $this->folderDao->getFolderUploads($folder_pk, $groupId);
133 $uploadsById = array();
135 foreach ($folderUploads as $uploadProgress) {
136 if ($uploadProgress->getGroupId() != $groupId) {
139 if (! $this->uploadDao->isEditable($uploadProgress->getId(), $groupId)) {
142 $display = $uploadProgress->getFilename() . _(
" from ") .
Convert2BrowserTime(date(
"Y-m-d H:i:s",$uploadProgress->getTimestamp()));
143 $uploadsById[$uploadProgress->getId()] = $display;
145 $this->vars[
'uploadList'] = $uploadsById;
146 if (empty($upload_pk)) {
148 $upload_pk = key($uploadsById);
150 $this->vars[
'uploadId'] = $upload_pk;
153 $upload = $this->uploadDao->getUpload($upload_pk);
154 if (empty($upload)) {
155 $this->vars[
'message'] = _(
"Missing upload.");
162 $baseFolderUri = $this->vars[
'baseUri'].
"$folder_pk&upload=";
163 $this->vars[
'uploadAction'] =
"onchange=\"js_url(this.value, '$baseFolderUri')\"";
165 $this->vars[
'uploadFilename'] = $upload ? $upload->getFilename() :
'';
166 $this->vars[
'uploadDesc'] = $upload ? $upload->getDescription() :
'';
167 $this->vars[
'content'] = $V;
169 return $this->
render(
'admin_upload_edit.html.twig');
Traceback_uri()
Get the URI without query to this location.
Convert2BrowserTime($server_time)
Convert the server time to browser time.
UpdateUploadProperties($uploadId, $newName, $newDesc)
Update upload properties (name, description)
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
GetArrayVal($Key, $Arr)
Get the value from a array(map)
char * trim(char *ptext)
Trimming whitespace.
render($templateName, $vars=null)