CMS  Version 3.9
document_manager.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::usingFile("framework/directory_tree.inc");
40 
42 {
44  {
45  }
46 
47 
48  function export()
49  {
50  $xml = "\n<DocumentMap>";
51  $xml .= SerializationManager::serialize(DocumentLibrary, "ORDER BY document_library_id");
52  $xml .= SerializationManager::serialize(Document, "ORDER BY document_id");
53  $xml .= "</DocumentMap>";
54 
55  return $xml;
56  }
57 
58  function import($doc, $tx)
59  {
62  }
63 }
64 
71 {
72  var $library;
73  var $docs;
75  var $width = 700;
76  var $height = 400;
77 
83  {
84  $this->library = $library;
85  if ($this->library->document_library_id)
86  {
87  $this->documents = $library->Documents("ORDER BY title");
88  }
89  else
90  {
91  $this->documents = array();
92  }
93  }
94 
96  {
97  global $user;
98 
99  $permission = true;
100 
101  if (strpos($folder, "Board Members Only") !== FALSE && (!checkRole("board,admin,super") && !$this->library->allowManageFiles()))
102  {
103  $permission = false;
104  }
105 
106  trace("folderPermission: $folder ($permission)", 3);
107 
108  return $permission;
109  }
110 
111  function writeScript()
112  {
113  global $dialogs;
114 
115  ob_start();
116 ?>
117 <div class="dialog" id="documentManagerDlg" style="width: 760px">
118  <div class="dialog_header" id="documentManagerDlgHeader">
119  <div style="padding: 4px;">
120  <div style="float: right">&nbsp;<a id='closeDocumentManagerDlg' href="javascript:docManagerDlg.hide();">Close &times;</a></div>
121  <span style="font-weight: bold" id="documentManagerTitle">Document Manager</span>
122  </div>
123  </div>
124  <div id="documentManagerDlgBody" class="dialog_body">
125  </div>
126 </div>
127 <?
128  $dialogs .= ob_get_contents();
129  ob_end_clean();
130 
131  ob_start();
132 ?>
133 <script type="text/javascript">
134 
135 window.addEvent('domready', function()
136 {
137  docManagerDlg = new ModalDialog(document.id('documentManagerDlg'), {handle: document.id('documentManagerDlgHeader'), draggable: true, body: document.id('documentManagerDlgBody')});
138 });
139 
140 function downloadFile()
141 {
142  id = document.id('files_value').value;
143  go("/action/document/download?document_id=" + id);
144 }
145 
146 function editFile()
147 {
148  id = document.id('files_value').value;
149  docManagerDlg.show(function() {}, "/action/document/edit?document_id=" + id);
150 }
151 
152 function editResult(result)
153 {
154  if (result == "1")
155  {
156  docManagerDlg.hide();
157  }
158  else
159  {
160  document.id('Document_form__error').set({'text': result, 'display': 'table-cell'});
161  }
162 }
163 
164 
165 function uploadFile()
166 {
167  id = document.id('files_value').value;
168  docManagerDlg.show(function() {}, "/action/document/upload?document_library_id=<?echo $this->library->document_library_id?>");
169 }
170 
171 function uploadResult(responseText)
172 {
173  if (responseText == "1")
174  {
175  window.location.reload();
176  }
177  else
178  {
179  alert(responseText);
180  }
181 }
182 
183 function deleteFile()
184 {
185  if (confirm("Are you sure you want to delete this file?"))
186  {
187  id = document.id('files_value').value;
188 
189  var request = new Request({'url': '/action/document/delete?document_id=' + id,
190  'method': 'get',
191  'onSuccess': function(responseText)
192  {
193  if (responseText == "1")
194  {
195  window.location.reload();
196  }
197  else
198  {
199  alert(responseText);
200  }
201  },
202  'onFailure': function() { alert("Failed to communicate with server");}});
203 
204  request.send();
205  }
206 }
207 
208 function selectionChanged()
209 {
210  var id = document.id('files_value').value;
211 
212  if (id > 0)
213  {
214  document.id('download').removeProperty("disabled");
215  if(document.id('edit')) document.id('edit').removeProperty("disabled");
216  document.id('deleteButton').removeProperty("disabled");
217 
218  }
219  else
220  {
221  document.id('download').addProperty("disabled", "disabled");
222  if(document.id('edit')) document.id('edit').addProperty("disabled", "disabled");
223  document.id('deleteButton').addProperty("disabled", "disabled");
224  }
225 }
226 
227 function rescanLibrary()
228 {
229  result = httpRequest("/action/document/rescan?document_library_id=<?echo $this->library->document_library_id?>");
230  if (result == "OK")
231  {
232  window.location.reload();
233  }
234  else
235  {
236  alert(result);
237  }
238 }
239 
240 <?
241  if (checkRole($this->library->manage_folders) || $this->library->allowManageFiles())
242  {
243 ?>
244 function createFolder()
245 {
246  docManagerDlg.show(function() {}, "/action/document/create_folder?document_library_id=<?echo $this->library->document_library_id?>");
247 }
248 
249 function createFolderResult(result)
250 {
251  if (result == 1)
252  {
253  window.location.reload();
254  }
255  else
256  {
257  alert(result);
258  }
259 }
260 
261 function deleteFolder()
262 {
263  docManagerDlg.show(function() {}, "/action/document/delete_folder?document_library_id=<?echo $this->library->document_library_id?>");
264 }
265 
266 function deleteFolderResult(result)
267 {
268  if (result == 1)
269  {
270  window.location.reload();
271  }
272  else
273  {
274  alert(result);
275  }
276 }
277 
278 <?
279  }
280 ?>
281 </script>
282 <?
283  $script .= ob_get_contents();
284  ob_end_clean();
285  return $script;
286  }
287 
288  function drawView()
289  {
290  global $config;
291 
292  $tree = new DirectoryTreeControl("files");
293  $tree->width = $this->width;
294  $tree->height = $this->height;
295  $tree->onSelectionChanged = "selectionChanged";
296  $tree->onDoubleClick = "downloadFile";
297 
298  $tree->selectMode = "file";
299  $tree->permissionCallback = array($this, folderPermission);
300 
301  $root = $this->library->getLibraryDirectory();
302 
303  $tree->buildFolderTree($config["uploaddir"], $root);
304 
305  foreach($this->documents as $doc)
306  {
307  // Do not list files to which the user does not have access
308  if (!checkRole($doc->allow_access)) continue;
309 
310  $file = str_replace("/", DIRECTORY_SEPARATOR, $doc->file);
311  $file = str_replace("\\", DIRECTORY_SEPARATOR, $file);
312 
313  trace($file, 4);
314  $folderNode = $tree->findFolder(dirname($file));
315 
316  if ($folderNode != null)
317  {
318  trace("Found Folder {$folderNode->id}", 4);
319  $id = str_replace(DIRECTORY_SEPARATOR, "_", $file);
320 
321  $folderNode->add(new FileNode($id, basename($file), $doc->document_id));
322  }
323  else
324  {
325  trace("*** NODE NOT FOUND - $file", 3);
326  }
327  }
328 
329  $tree->children["documents"]->open = true;
330 
331  $page->page_title = "Documents";
332 
333  $tree->writeHTML();
334 
335  $this->drawButtons();
336  }
337 
338  function drawButtons()
339  {
340 ?>
341  <br/>
342  <button id="download" class="button" disabled="disabled" onclick="downloadFile()"> Download File </button>&nbsp;&nbsp;
343  <?
344  if (checkRole($this->library->upload_files))
345  {
346 ?>
347  <button id="edit" class="button" disabled="disabled" onclick="editFile()">Edit Details...</button>&nbsp;&nbsp;
348  <button id="upload" class="button" onclick="uploadFile()">Upload a File...</button>
349 <?
350  }
351 
352  if (checkRole($this->library->delete_files))
353  {
354 ?>
355  <button id="deleteButton" class="button" disabled="disabled" onclick="deleteFile()">Delete File</button>&nbsp;&nbsp;
356 <?
357  }
358 
359  if (checkRole($this->library->manage_folders))
360  {
361 ?>
362  &nbsp;&nbsp;<button id="createFolder" class="button" onclick="createFolder()">Create Folder...</button>&nbsp;&nbsp;
363  <button id="deleteFolder" class="button" onclick="deleteFolder()">Delete Folder</button>&nbsp;&nbsp;
364 <?php
365  }
366 
367  if (checkRole("admin"))
368  {
369 ?>
370  <button id="rescan" class="button" onclick="rescanLibrary()">Rescan</button>
371 <?
372  }
373  }
374 
382  static function deleteUser($user)
383  {
384  $pk = $user->getPrimaryKey();
385  $user_id = $user->$pk;
386 
387  trace("Component document is deleting objects dependent on user_id {$user_id}", 3);
388 
389  $tx = new DataTransaction();
390 
391  try
392  {
393  $libraries = Query::create(DocumentLibrary, "WHERE owner_id=:owner_id")
394  ->bind(":owner_id", $user_id)
395  ->execute();
396 
397  if(count($libraries))
398  {
399  foreach($libraries as $library)
400  {
401  $library->joinTransaction($tx);
403  $mgr->deleteDocumentLibrary();
404  }
405  }
406 
407  $document = new Document();
408  $document->joinTransaction($tx);
409  $document->delete("WHERE owner_id={$user_id}");
410 
411  $download = new DocumentDownload();
412  $download->joinTransaction($tx);
413  $download->delete("WHERE user_id={$user_id}");
414 
415  $tx->commit();
416  }
417  catch(Exception $e)
418  {
419  $tx->rollback();
420  throw $e;
421  }
422 
423  return $user;
424  }
425 
433  {
434 
435  if (!$_FILES[$field])
436  {
437  throw new FakoliException("No upload record found.");
438  }
439 
440  if ($_FILES[$field]["name"]=="")
441  {
442  throw new FakoliException("Upload name is empty");
443  }
444 
445  /* Copy across the uploaded file */
446  $folder = str_replace("/", DIRECTORY_SEPARATOR, $folder);
447  $folder = str_replace("\\", DIRECTORY_SEPARATOR, $folder);
448 
449  $name = $_FILES[$field]["name"];
450 
451  if (!$folder) $folder = "documents";
452 
453  $filepath = $folder . DIRECTORY_SEPARATOR . $name;
454  $base = $this->library->getLibraryDirectory();
455  $dir = $base . DIRECTORY_SEPARATOR . $folder;
456  $fullpath = $dir . DIRECTORY_SEPARATOR . $name;
457 
458  trace("Upload Directory: {$dir}", 3);
459 
460  trace("Uploading file to $fullpath", 3);
461 
462  if (!file_exists($dir))
463  {
464  // If the directory does not exist, create it
465  mkdir($dir);
466  }
467 
468  if (file_exists($fullpath))
469  {
470  // If a previous copy of the file already exists, remove it
471  unlink($fullpath);
472  }
473 
474  move_uploaded_file($_FILES[$field]["tmp_name"], $fullpath);
475  chmod($fullpath, 0755);
476 
477  return str_replace(DIRECTORY_SEPARATOR, "/", $filepath);
478  }
479 
486  {
487  $fullPath = $this->library->getLibraryDirectory() . DIRECTORY_SEPARATOR . $document->file;
488  if (file_exists($fullPath))
489  {
490  unlink($fullPath);
491  }
492 
493  $document->delete();
494  return true;
495  }
496 
497  /*
498  * Delete a folder record and its path in the file system.
499  */
501  {
502  $folder = sanitizePath($folder);
503  $path = $this->library->getLibraryDirectory() . DIRECTORY_SEPARATOR . $folder;
504 
505  if (file_exists($path))
506  rmdir($path);
507  $folder->delete();
508  }
509 
510  function drawSelectView($selectionChanged = "", $doubleClick = "", $width=700, $height = 400)
511  {
512  global $config;
513 
514  $tree = new DirectoryTreeControl("files");
515  $tree->width = $width;
516  $tree->height = $height;
517  $tree->onSelectionChanged = $selectionChanged;
518  $tree->onDoubleClick = $doubleClick;
519 
520  $tree->selectMode = "file";
521  $tree->permissionCallback = array($this, folderPermission);
522 
523  if ($this->documents)
524  {
525  $root = $this->library->getLibraryDirectory();
526 
527  $tree->buildFolderTree($config["uploaddir"], $root);
528 
529  foreach($this->documents as $doc)
530  {
531  $file = str_replace("/", DIRECTORY_SEPARATOR, $doc->file);
532  $file = str_replace("\\", DIRECTORY_SEPARATOR, $file);
533 
534  trace($file, 4);
535  $folderNode = $tree->findFolder(dirname($file));
536 
537  if ($folderNode != null)
538  {
539  trace("Found Folder {$folderNode->id} for document {$doc->document_id}", 4);
540  $id = str_replace(DIRECTORY_SEPARATOR, "_", $file);
541  $fileNode = new FileNode($id, basename($file), $doc->document_id);
542 
543  $folderNode->add($fileNode);
544  }
545  else
546  {
547  trace("*** NODE NOT FOUND - $file", 3);
548  }
549  }
550 
551  $tree->children["documents"]->open = true;
552  $tree->writeHTML();
553  }
554  else
555  {
556 ?>
557  <div style="width: <?echo $width?>px;height:<?echo $height?>px;border: solid 1px #000;">&nbsp;</div>
558 <?
559 
560  }
561  }
562 
563 
568  static function enumerateItems($items)
569  {
570  $documents = Query::create(DocumentLibrary, "ORDER BY name")->execute();
571 
572  $items["Document Libraries"] = $documents;
573  return $items;
574  }
575 
576  static function displayLibrary($identifier, &$continue)
577  {
578  try
579  {
581  $page = ComponentPage::findByIdentifier("document_library", "WHERE enabled=1");
582 
583  $_GET["library"] = $identifier;
584 
585  $pageView = new ComponentPageView($page, "{$page->template}.tpl");
586 
587  $page_role = $page->role;
588 
589  if (!checkRole($page->role))
590  {
592  redirect("/login");
593  }
594 
595  echo $pageView->drawView();
596 
597  $continue = false;
598  }
599  catch(DataNotFoundException $e)
600  {
601 
602  }
603 
604  return $identifier;
605  }
606 
607  // Used by document_library_form and fileshare_library_form
608  static function createLibraryObj()
609  {
610  global $user;
611 
612  $library = new DocumentLibrary();
613  $library->owner_id = $user->user_id;
614  $library->create_date = now();
615  $defaultRole = DocumentLibrary::getDefaultRole();
616  if($defaultRole)
617  {
618  $library->allow_access = $defaultRole;
619  $library->manage_folders = $defaultRole;
620  $library->upload_files = $defaultRole;
621  $library->delete_files = $defaultRole;
622  }
623 
624 
625  $library->filter = new InclusionFilter("document_library_id", "name",
626  "identifier", "description", "owner_id", "last_modified",
627  "allow_access", "manage_folders", "upload_files", "delete_files", "create_date");
628 
629  return $library;
630  }
631 
632  static function createLibrary($form)
633  {
634  $d = $form->data->getLibraryDirectory();
635  }
636 
638  {
639  $documents = $this->library->Documents();
640  if(count($documents) > 0)
641  {
642  foreach($documents as $document)
643  $this->deleteDocument($document);
644  }
645 
646  $folders = $this->library->Folders();
647  if(count($folders) > 0)
648  {
649  foreach($folders as $folder)
650  {
651  $this->deleteFolder($folder);
652  }
653  }
654 
655  $fileshareUsers = $this->library->FileshareUsers();
656  if(count($fileshareUsers) > 0)
657  {
658  foreach($fileshareUsers as $f_user)
659  $f_user->delete();
660  }
661 
662  $this->library->delete();
663  }
664 
665  // Not the most efficient but how often will we use it?
666  static function deleteRole($del_role)
667  {
668  $constraint = "WHERE role like '%$del_role%'";
669 
670  $roleFields = array("upload_files", "delete_files", "manage_folders", "allow_access");
671  foreach($roleFields as $field)
672  {
673  $libraries = Query::create(DocumentLibrary, "WHERE $field like '%$del_role%'")->execute();
675  }
676 
677  return $del_role;
678  }
679 
680  static function documentLibraryTabs($key)
681  {
682  $tabs = array(
683  "Details" => "document_library_form",
684  "Files" => "document_library_files"
685  );
686 
687  $qs = ($key) ? "document_library_id=$key" : "";
688  return new TabBar("tabs", $tabs, $qs);
689  }
690 
692  {
693  $form = new AutoForm($library);
694  $form->hide("owner_id", "allow_access", "manage_folders", "upload_files", "delete_files", "create_date");
695  $form->required("name", "identifier");
696  $form->annotate("allow_comments", "Allow users to comment on documents from the document details page (if commenting is enabled).");
697 
698  $form->allowDelete = true;
699  $form->onDelete = deleteDocumentLibary;
700 
701  return $form;
702  }
703 
705  {
706  $file = $document->file;
707 
708  $type = getDocType($file);
709  $icon = getDocIcon($file);
710 
711  $library = $document->DocumentLibrary();
712  $file_size = $library->getFileSize($document);
713  if($file_size)
714  {
715  $size = "($file_size)";
716  }
717 
718  return $document->format("<a style='display: inline' id='document_id_{document_id}' href='#' ondblclick=\"new LinkPicker().documentPickerInsertLink({document_id})\" onclick=\"new LinkPicker().toggleDocumentSelected(this, {document_id}); return false;\">{title}</a>&nbsp;<img style='display:inline; vertical-align: middle' src='$icon' alt='$type'/>&nbsp;$size");
719  }
720 
721  static function formatDocumentLink($document)
722  {
723  $library = $document->DocumentLibrary();
724  $size = $library->getFileSize($document);
725  $img = DocumentHandler::getDocIcon($document->file);
726 
727  return "<img src='$img' alt='' style='display: inline-block; vertical-align: middle'>&nbsp;".
728  "<a href='/action/document/download?document_id={$document->document_id}'>{$document->title}</a>&nbsp;$size";
729  }
730 
731  static function getStyles()
732  {
733  $styles .= "<link href=\"/fakoli/css/tabs.css\" rel=\"stylesheet\"/>\n";
734 
735  return $styles;
736  }
737 
738  function rescan()
739  {
740  $this->indexedDocuments = reindexList($this->documents, "file");
741  $this->indexedFolders = IndexedQuery::create(DocumentFolder, "WHERE document_library_id=:id", "path")
742  ->bind(":id", $this->library->document_library_id)
743  ->execute();
744 
745  $this->scanFiles("documents");
746  }
747 
748  function scanFiles($path)
749  {
750  global $user;
751 
752  $base = sanitizePath($this->library->getLibraryDirectory() . DIRECTORY_SEPARATOR . $path);
753 
754  $files = scandir($base);
755  foreach($files as $file)
756  {
757  if ($file == "." || $file == "..") continue;
758 
759  $f = $path . DIRECTORY_SEPARATOR . $file;
760 
761  if (is_dir($base . DIRECTORY_SEPARATOR . $file))
762  {
763  $this->scanFiles($f);
764  }
765  else
766  {
767  if ($this->indexedDocuments[$f]) continue;
768 
769  $doc = new Document();
770  $doc->title = $file;
771  $doc->file = $f;
772  $doc->keywords = "";
773  $doc->notes = "";
774  $doc->public = true;
775  $doc->document_library_id = $this->library->document_library_id;
776  $doc->owner_id = $user->get($user->getPrimaryKey());
777  $doc->save();
778  }
779  }
780  }
781 
783  {
784  $this->indexedDocuments = reindexList($this->documents, "file");
785 
786  $fp = fopen($file, "r");
787 
788  $fields = fgetcsv($fp);
789 
790  $fileIdx = -1;
791 
792  foreach($fields as $field)
793  {
794  if ($field == "file")
795  {
796  $fileIdx = $i;
797  break;
798  }
799 
800  $i++;
801  }
802 
803  if ($fileIdx < 0)
804  {
805  throw new FakoliException("'field' column not present");
806  }
807 
808  while($values = fgetcsv($fp))
809  {
810  $files = explode(";", $values[$fileIdx]);
811  foreach($files as $f)
812  {
813  $f = trim($f);
814 
815  trace($path, 3);
816 
817  foreach($this->indexedDocuments as $path => $doc)
818  {
819  if (basename($path) == $f)
820  {
821  $i = 0;
822 
823  foreach($fields as $field)
824  {
825  if ($field == "file")
826  {
827  $i++;
828  break;
829  }
830 
831  $doc->set($field, $values[$i]);
832  $i++;
833  }
834 
835  $doc->save();
836  }
837  }
838  }
839  }
840  }
841 
846  static function zipLibrary($library_id, $process = null)
847  {
848  global $config;
849 
850  Fakoli::assertRole("admin");
851  $library = new DocumentLibrary($library_id);
852 
853  if ($process)
854  {
855  $process->setProgress("Running", "Scanning files", 0);
856  }
857 
858  $files = $library->Documents("ORDER BY file");
859 
860  $libraryFileName = $library->format("library_{document_library_id}.zip");
861  $libraryDir = $library->getLibraryDirectory();
862  $libraryZipFile = $config['uploadbase'] . DIRECTORY_SEPARATOR . $libraryFileName;
863  if (file_exists($libraryZipFile))
864  {
865  unlink($libraryZipFile);
866  }
867 
868 
869  $zip = new ZipArchive();
870 
871  // open archive
872  if ($zip->open($libraryZipFile, ZIPARCHIVE::CREATE) !== TRUE)
873  {
874  if ($process)
875  {
876  $process->setProgress("Error", "Could not create ZIP archive");
877  throw new FakoliException("Could not create ZIP archive");
878  }
879  }
880 
881  $max = count($files);
882  $c = 0;
883 
884  foreach($files as $file)
885  {
886  $fullPath = $libraryDir . DIRECTORY_SEPARATOR . $file->file;
887  $zip->addFile($fullPath, $file->file);
888 
889  if ($process)
890  {
891  $process->setProgress("Running", "Added $c of $max ".pluralize("file", $max), number_format(100 * $c / $max, 0));
892  }
893  }
894 
895  $zip->close();
896 
897  if ($process)
898  {
899  $process->setProgress("Completed", "Zip archive created", 100);
900  }
901  }
902 
903  /*
904  * Read or allow_access roles, include
905  * visitor (nonuser) option.
906  */
907  static function getRoleOptions()
908  {
910  $roles["visitor"] = "Visitor";
911  return $roles;
912  }
913 
914  static function getRoleList()
915  {
917  return implode(",", array_keys($roles));
918  }
919 
923  static function getMaxUploadBytes()
924  {
925  $max = ini_get("upload_max_filesize");
926 
927  if (endsWith($max, "M"))
928  {
929  $max *= 1024 * 1024;
930  }
931  else if (endsWith($max, "K"))
932  {
933  $max *= 1024;
934  }
935  else if (endsWidth($max, "G"))
936  {
937  $max *= 1024 * 1024 * 1024;
938  }
939 
940  $postMax = ini_get("post_max_size");
941 
942  if (endsWith($postMax, "M"))
943  {
944  $postMax *= 1024 * 1024;
945  }
946  else if (endsWith($postMax, "K"))
947  {
948  $postMax *= 1024;
949  }
950  else if (endsWidth($postMax, "G"))
951  {
952  $postMax *= 1024 * 1024 * 1024;
953  }
954 
955  return min($max, $postMax);
956  }
957 
961  static function getMaxUploadSize()
962  {
963  return getScaledSize(DocumentManager::getMaxUploadBytes(), 0);
964  }
965 
966  static function registerSearchables($searchables)
967  {
968  trace("DocumentManager registerSearchables", 3);
969  if (!Settings::getValue("solr", "enabled"))
970  {
971  $searchables["document"] = array(Document);
972  }
973  return $searchables;
974  }
975 
976  static function registerSolrAdapter()
977  {
978  SolrManager::registerSolrAdapter(Document, new DocumentSolrAdapter());
979  }
980 
981  static function upgradeComponent($version)
982  {
984  $mgr->upgrade($version);
985  }
986 
987  static function registerCommentAdapter()
988  {
990  }
991 
993  {
994  $classes[] = Document;
995  return $classes;
996  }
997 
999  {
1000  SerializationManager::registerHandler("document_libraries", "Document Libraries &amp; Document Records (files need to be transferred manually)", new DocumentSerializationHandler());
1001  return true;
1002  }
1003 
1004  static function setDefaults()
1005  {
1006  Settings::setDefaultValue("document", "show_upload_details", true, Boolean, "Include upload details on the document library view");
1007  Settings::setDefaultValue("document", "link_to_details", false, Boolean, "Link to the document details page for each document from the library view");
1008  Settings::setDefaultValue("document", "show_table_filter", false, Boolean, "Show the generic column filter controls for the document table view");
1009  Settings::setDefaultValue("document", "always_display_PDFs_in_browser", false, Boolean, "When downloading PDF documents, have them display in the browser in a new tab, rather than as a file download");
1010  }
1011 }
1012 ?>
$constraint
$user_id
& nbsp
Definition: index.inc:49
$form
$tabs
deleteDocumentLibary($library)
$page
Definition: help.inc:39
if(! $page) $path
Definition: page.inc:57
$helpTree style
Definition: tree.inc:46
$folder
Definition: templates.inc:41
$dir
Definition: delete.inc:44
$file
Definition: delete.inc:47
$base
Definition: delete.inc:45
$f
Definition: download.inc:46
$filepath
Definition: download.inc:42
$size
Definition: download.inc:47
$name
Definition: upload.inc:54
$icon
Definition: upload.inc:92
static registerAdapter($component, $parentClass, $xrefClass)
static findByIdentifier($identifier, $constraint="")
ComponentPageView generates the page content for a component page, substituting page fields,...
This class maps the publication table.
Definition: document.inc:43
static findByIdentifier($identifier)
static getDefaultRole($fileshare=false)
The DocumentManager class provides the core API and management functions for uploading documents and ...
static upgradeComponent($version)
static registerSerializationHandler()
static registerCommentAdapter()
static enumerateItems($items)
Enumerate the Document objects.
static documentLibraryTabs($key)
static registerTaxonomyClasses($classes)
static registerSearchables($searchables)
static registerSolrAdapter()
DocumentManager($library)
Creates a new DocumentManager for the specified library.
deleteDocument($document)
Delete the specified document (assuming the user has permission).
uploadFile($field, $folder)
Upload a file from the specified form field to the specified folder within the current document libra...
folderPermission($folder)
static formatDocumentLink($document)
formatLinkPickerTitle($document)
static getMaxUploadBytes()
Calculate the maximum allowed file upload size in bytes.
static buildDocumentLibraryForm($library)
static deleteRole($del_role)
static createLibrary($form)
static zipLibrary($library_id, $process=null)
Generate a ZIP archive of all the documents in the specified library.
static displayLibrary($identifier, &$continue)
static deleteUser($user)
Respond to fired event DeleteUser.
drawSelectView($selectionChanged="", $doubleClick="", $width=700, $height=400)
static getMaxUploadSize()
Returns the maximum allowed file upload size in human-readable format.
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static usingFile()
Uses the specified framework file(s) from the framework directory.
Definition: core.inc:369
static assertRole($role, $redirect="", $message="")
Assert that the user has one of the specified roles.
Definition: core.inc:297
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
Definition: login.inc:493
static deleteRoleFromString(&$items, $del_role, $field="")
static serialize($class, $constraint="")
Serializes the specified DataItems to XML.
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.
static unserialize($class, $doc, $tx, $save=true)
Instantiates DataItems from the supplied XML document and stores them in the database.
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
static getRolesArray()
Retrieves the array of roles and their names for the current site for use in a CMS form.
Definition: role.inc:75
global $user
if(!checkRole("admin")) $c
$validator id
$root
if(! $document_id) $document
Definition: delete.inc:43
if(!checkRole($library->allow_access) &&! $library->allowAccess()) if(!checkRole($document->allow_access)) $d
Definition: download.inc:66
global $config
Definition: import.inc:4
$max
$styles
$identifier
Definition: rss.inc:37
$process
Definition: run.php:54