Пример #1
0
 public function downloadAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $config = Knowledgeroot_Registry::get('config');
     // action body
     // normal download
     // with x-sendfile
     // @see: http://codeutopia.net/blog/2009/03/06/sending-files-better-apache-mod_xsendfile-and-php/
     // @see: http://redmine.lighttpd.net/projects/1/wiki/X-LIGHTTPD-send-file
     // @see: http://wiki.nginx.org/XSendfile
     $file = new Knowledgeroot_File($this->_getParam('id'));
     // check acl
     if (!Knowledgeroot_Acl::iAmAllowed('content_' . $file->getParent(), 'show')) {
         $this->_redirect('');
     }
     // check for sendfile option
     if ($config->files->xsendfile->enable) {
         header("Content-Disposition: attachment; filename=\"" . $file->getName() . "\";");
         header($config->files->xsendfile->name . ": " . $file->getDatastorePath());
     } else {
         header("Content-Type: " . $file->getType() . "; name=\"" . $file->getName() . "\"");
         header("Content-Disposition: attachment; filename=\"" . $file->getName() . "\";");
         header("Pragma: private");
         header("Expires: 0");
         header("Cache-Control: private, must-revalidate, post-check=0, pre-check=0");
         header("Content-Transfer-Encoding: binary");
         // put file content to screen
         echo $file->getContent();
     }
 }
Пример #2
0
 /**
  * init acl
  */
 protected function _initAcl()
 {
     try {
         // init config
         $this->bootstrap('config');
         // init acl
         $acl = new Knowledgeroot_Acl();
         // load acl from
         $acl->load();
         // save acl in registry
         Knowledgeroot_Registry::set('acl', $acl);
     } catch (Zend_Exception $e) {
         echo $e->getMessage();
         die('no acl');
     }
 }
Пример #3
0
 public function restoreAction()
 {
     // acl checks
     if (!Knowledgeroot_Acl::iAmAllowed('content_' . $this->_getParam('id'), 'edit')) {
         $this->_redirect('');
     }
     // get content and restore version
     $content = new Knowledgeroot_Content($this->_getParam('id'), $this->_getParam('version'));
     $content->restore();
     $parent = $content->getParent();
     // show success message
     Knowledgeroot_Message::success("Content restored", "Content was restored to version " . $this->_getParam('version'));
     // redirect to page
     $this->_redirect('page/' . $parent);
 }
Пример #4
0
 /**
  * move content down
  *
  * @return type
  */
 public function moveDown()
 {
     if ($this->readOnly) {
         return;
     }
     // check page rights
     if (!Knowledgeroot_Acl::iAmAllowed('page_' . $this->getParent(), 'edit')) {
         return;
     }
     $db = Knowledgeroot_Registry::get('db');
     if ($this->sorting == 0 || $this->sorting == null) {
         $res = $db->query("UPDATE content SET sorting=sorting+1 WHERE parent=? AND id<>? AND deleted=?", array($this->parent, $this->id, Knowledgeroot_Db::false()));
     } else {
         $res = $db->query("SELECT id, min(sorting) as sorting\n\t\t\t\tFROM content\n\t\t\t\tWHERE parent=? AND sorting>=? AND id<>? AND deleted=?\n\t\t\t\tGROUP BY id\n\t\t\t\tORDER BY sorting DESC\n\t\t\t\tLIMIT 1", array($this->parent, $this->sorting, $this->id, Knowledgeroot_Db::false()));
         $row = $res->fetchAll();
         $cnt = count($row);
         if ($cnt == 1) {
             if ($this->sorting == $row[0]['sorting']) {
                 $db->query("UPDATE content SET sorting=sorting+1 WHERE parent=? AND id<>? AND sorting>=? AND deleted=?", array($this->parent, $this->id, $this->sorting, Knowledgeroot_Db::false()));
             } else {
                 $db->query("UPDATE content SET sorting=? WHERE id=?", array($this->sorting, $row[0]['id']));
                 $db->query("UPDATE content SET sorting=? WHERE id=?", array($row[0]['sorting'], $this->id));
                 $this->sorting = $row[0]['sorting'];
             }
         }
     }
 }
Пример #5
0
 public function restoreAction()
 {
     // acl checks
     if (!Knowledgeroot_Acl::iAmAllowed('page_' . $this->_getParam('id'), 'edit')) {
         $this->_redirect('');
     }
     // get page and restore version
     $page = new Knowledgeroot_Page($this->_getParam('id'), $this->_getParam('version'));
     $page->restore();
     // show success message
     Knowledgeroot_Message::success("Page restored", "Page was restored to version " . $this->_getParam('version'));
     // redirect to page
     $this->_redirect('page/' . $page->getId());
 }