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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<?php
class DocumentsController extends ModulesController {
var $name = 'Documents';
var $helpers = array('BeTree', 'BeToolbar');
var $components = array('BeLangText', 'BeFileHandler', 'BeSecurity');
var $uses = array('BEObject', 'Document', 'Tree','Category') ;
protected $moduleName = 'documents';
protected $categorizableModels = array('Document');
public function index($id = null, $order = "", $dir = true, $page = 1, $dim = 20) {
$conf = Configure::getInstance() ;
$filter['object_type_id'] = $conf->objectTypes['document']['id'];
$filter['count_annotation'] = array('Comment', 'EditorNote');
$this->paginatedList($id, $filter, $order, $dir, $page, $dim);
$this->loadCategories($filter['object_type_id']);
}
public function view($id = null) {
$this->viewObject($this->Document, $id);
$this->set('autosave', true);
}
public function save() {
$this->checkWriteModulePermission();
$this->Transaction->begin();
$this->saveObject($this->Document);
$this->Transaction->commit() ;
$this->userInfoMessage(__("Document saved", true)." - ".$this->data["title"]);
$this->eventInfo("document [". $this->data["title"]."] saved");
}
public function autosave() {
$this->layout = 'ajax';
$this->Transaction->begin();
$this->autoSaveObject($this->Document);
$this->Transaction->commit();
$time = strftime(Configure::read("dateTimePattern"), time());
$this->userInfoMessage(__("Document Saved on", true)."<br/>".$time);
$this->eventInfo("document [". $this->data["title"]."] saved");
$this->render(null, null, "/elements/flash_messages");
}
public function delete() {
$this->checkWriteModulePermission();
$objectsListDeleted = $this->deleteObjects("Document");
$this->userInfoMessage(__("Documents deleted", true) . " - " . $objectsListDeleted);
$this->eventInfo("documents $objectsListDeleted deleted");
}
public function deleteSelected() {
$this->checkWriteModulePermission();
$objectsListDeleted = $this->deleteObjects("Document");
$this->userInfoMessage(__("Documents deleted", true) . " - " . $objectsListDeleted);
$this->eventInfo("documents $objectsListDeleted deleted");
}
public function categories() {
$this->showCategories($this->Document);
}
}
?>