Exemplo n.º 1
0
 public function editAction()
 {
     SxCms_Acl::requireAcl('account', 'account.edit');
     $id = $this->_getParam('id');
     $gMapper = new SxCms_Group_DataMapper();
     $this->view->groups = $gMapper->getAll();
     $proxy = new SxCms_User_DataMapper();
     $user = $proxy->getById($id);
     if ($this->getRequest()->isPost()) {
         $user->setFirstName($this->_getParam('first_name'))->setLastName($this->_getParam('last_name'));
         if ($this->_getParam('password') || $this->_getParam('password_repeat')) {
             $user->setPassword($this->_getParam('password'));
         }
         foreach ($this->_getParam('group') as $groupId) {
             $group = new SxCms_Group();
             $group->setId($groupId);
             $user->addGroup($group);
         }
         $validator = new SxCms_User_UpdateValidator();
         $validator->setOldPassword($this->_getParam('old_password'));
         $validator->setPasswordRepeat($this->_getParam('password_repeat'));
         if ($validator->validate($user)) {
             $user->save();
             $this->_helper->redirector->gotoSimple('index', 'account');
         }
     }
     $this->view->user = $user;
     $this->view->messages = Sanmax_MessageStack::getInstance('SxCms_User');
 }
Exemplo n.º 2
0
 protected function _collectPermissions($pageObject)
 {
     $db = Zend_Registry::get('db');
     $select = $db->select()->from(array('p' => 'PageAcl'), array('*'))->join(array('g' => 'Group'), 'p.group_id = g.group_id');
     if ($pageObject instanceof SxCms_Page) {
         $select->where('page_id = ?', $pageObject->getId());
     } else {
         if (is_array($pageObject) && count($pageObject)) {
             $select->where('page_id IN (?)', array_keys($pageObject));
         } else {
             return $pageObject;
         }
     }
     $stmt = $db->query($select);
     $result = $stmt->fetchAll();
     foreach ($result as $row) {
         $group = new SxCms_Group();
         $group->setId($row['group_id'])->setIdentifier($row['identifier'])->setName($row['name']);
         if ($pageObject instanceof SxCms_Page) {
             $pageObject->addPermission($group);
         } else {
             $pageObject[$row['page_id']]->addPermission($group);
         }
     }
     return $pageObject;
 }
Exemplo n.º 3
0
 /**
  * Fetch a user by his identifier
  * 
  * @param  $id
  * @return SxCms_User
  */
 public function getById($id)
 {
     $db = Zend_Registry::get('db');
     $select = $db->select()->from(array('u' => 'User'), array('*'))->where('u.user_id = ' . (int) $id);
     $result = $db->fetchRow($select);
     $user = $this->toObject($result);
     $db = Zend_Registry::get('db');
     $select = $db->select()->from('UserGroup', array('group_id', 'Group.name'))->join('Group', 'UserGroup.group_id = Group.group_id')->where('user_id = ' . (int) $id);
     $result = $db->fetchAll($select);
     foreach ($result as $row) {
         $group = new SxCms_Group();
         $group->setId($row['group_id'])->setName($row['name']);
         $user->addGroup($group);
     }
     return $user;
 }
Exemplo n.º 4
0
 public function deleteAction()
 {
     SxCms_Acl::requireAcl('group', 'group.delete');
     $group = new SxCms_Group();
     $group->setId($this->_getParam('id'));
     $mapper = new SxCms_Group_DataMapper();
     $mapper->delete($group);
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $flashMessenger->addMessage($this->admin_tmx->_('usergroupdeleted'));
     $this->_helper->redirector->gotoSimple('index', 'group');
 }
Exemplo n.º 5
0
 protected function _getMetaTags()
 {
     if ($this->_metaLoaded) {
         return true;
     }
     $info = $this->openFile('r');
     $info->rewind();
     $end = false;
     $meta = '';
     if (strpos($info->current(), self::META_START) !== false) {
         if (strpos($info->current(), self::META_END) !== false) {
             $end = true;
         }
         while ($info->valid() && !$end) {
             $line = $info->fgets();
             if (strpos($line, self::META_END) !== false) {
                 $end = true;
             } else {
                 $meta .= $line;
             }
         }
     }
     if (!$meta) {
         return true;
     }
     $xml = simplexml_load_string($meta);
     foreach ($xml as $key => $node) {
         if ($key !== 'acl') {
             $kname = "_{$key}";
             $this->{$kname} = (string) $node;
         } else {
             foreach ($node as $perm) {
                 $group = new SxCms_Group();
                 $group->setId($perm);
                 $this->addPermission($group);
             }
         }
     }
     $this->_metaLoaded = true;
     return true;
 }
Exemplo n.º 6
0
 public function loadState($state = self::STATE_LIVE)
 {
     $db = Zend_Registry::get('db');
     if ($state === self::STATE_REVISION) {
         $select = $db->select()->from(array('p' => 'Page'), array('*'))->join(array('t' => 'PageRev'), 'p.page_id = t.page_id')->where('p.page_id = ?', $this->_id)->where('t.language = ?', $this->getLanguage())->order('t.revision_id ASC');
         $stmt = $db->query($select);
         $result = $stmt->fetchAll();
     }
     if ($state === self::STATE_LIVE or !$result) {
         $select = $db->select()->from(array('p' => 'Page'), array('*'))->joinLeft(array('t' => 'PageTsl'), 'p.page_id = t.page_id')->where('p.page_id = ?', $this->_id)->where('t.language = ?', $this->getLanguage());
         $stmt = $db->query($select);
         $result = $stmt->fetchAll();
     }
     $pageMapper = new SxCms_Page_DataMapper();
     foreach ($result as $page) {
         $pageMapper->map($page, $this);
     }
     $select = $db->select()->from('PageAcl', array('*'))->where('page_id = ?', $this->_id);
     $stmt = $db->query($select);
     $result = $stmt->fetchAll();
     foreach ($result as $row) {
         $group = new SxCms_Group();
         $group->setId($row['group_id']);
         $this->addPermission($group);
     }
     return $this;
 }
 public function editAction()
 {
     SxCms_Acl::requireAcl('filemanager', 'filemanager.edit');
     $mapper = new SxCms_Group_DataMapper();
     $this->view->groups = $mapper->getAll();
     $base = APPLICATION_PATH . '/../public_html/files/';
     if ($this->_getParam('file')) {
         $path = base64_decode($this->_getParam('file'));
         $file = new SxCms_File($base . $path);
     } else {
         $path = base64_decode($this->_getParam('dir'));
         $file = new SxCms_Dir($base . $path);
     }
     if ($this->getRequest()->isPost()) {
         $file->setFilename($this->_getParam('filename'));
         if ($this->_getParam('file')) {
             $file->setTitle($this->_getParam('title'))->setSource($this->_getParam('source'))->setSummary($this->_getParam('summary'))->setLink($this->_getParam('link'));
             $file->clearPermissions();
             foreach ((array) $this->_getParam('group') as $groupId) {
                 $group = new SxCms_Group();
                 $group->setId($groupId);
                 $file->addPermission($group);
             }
         }
         $file->save();
         $flashMessenger = $this->_helper->getHelper('FlashMessenger');
         $flashMessenger->addMessage('Bestand werd succesvol aangepast!');
         $this->_redirect('/admin/filemanager/index/path/' . $this->_getParam('path'));
     }
     $this->view->file = $file;
     $this->view->path = $this->_getParam('path');
 }
Exemplo n.º 8
0
 public function addAction()
 {
     SxCms_Acl::requireAcl('page', 'page.add');
     $system = new Zend_Session_Namespace('System');
     $wizard = new Zend_Session_Namespace('Cms_PageWizard');
     if ($this->_getParam('reset')) {
         $wizard->page = new SxCms_Page();
         $wizard->page->setLanguage($system->lng);
         $this->_helper->redirector->gotoSimple('wizard-type', 'page');
     }
     $mapper = new SxCms_Group_DataMapper();
     $this->view->groups = $mapper->getAll();
     $revision = new SxCms_Page_Revision();
     $revision->setApproved(true);
     $revision->setNotes($this->admin_tmx->_('newpagecreated'));
     if ($wizard->page->getId() !== false) {
         $revision->setApproved(false);
         $revision->setNotes($this->admin_tmx->_('pageedited'));
     }
     if ($this->getRequest()->isPost()) {
         $path = APPLICATION_ROOT . '/public_html/images/thumbs/1200x160/';
         $path1 = APPLICATION_ROOT . '/public_html/images/thumbs/400x180/';
         if (!is_dir($path)) {
             mkdir($path, 0777, true);
         }
         if (!is_dir($path1)) {
             mkdir($path1, 0777, true);
         }
         $system->lng = $this->_getParam('lang');
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination($path);
         $adapter->setOptions(array('ignoreNoFile' => true));
         if (!$adapter->receive()) {
             $msgr = Sanmax_MessageStack::getInstance('SxCms_Page');
             $msgr->addMessage('file', $adapter->getMessages(), 'title');
         }
         $wizard->page->setThumb(null);
         $files = $adapter->getFileInfo();
         foreach ($files as $file) {
             if (!$file['tmp_name']) {
                 continue;
             }
             $filename = uniqid() . '.jpg';
             $image = new Imagick($file['tmp_name']);
             $image->cropThumbnailImage(1200, 190);
             $image->setCompressionQuality(100);
             $image->setCompression(Imagick::COMPRESSION_JPEG);
             $image->setImageFormat('jpeg');
             $image->writeImage($path . $filename);
             $image->clear();
             $image->destroy();
             $image = new Imagick($file['tmp_name']);
             $image->cropThumbnailImage(400, 180);
             $image->setCompressionQuality(100);
             $image->setCompression(Imagick::COMPRESSION_JPEG);
             $image->setImageFormat('jpeg');
             $image->writeImage($path1 . $filename);
             $image->clear();
             $image->destroy();
             unlink($file['tmp_name']);
             $wizard->page->setThumb($filename);
         }
         $wizard->page->clearPermissions();
         foreach ((array) $this->_getParam('group') as $groupId) {
             $group = new SxCms_Group();
             $group->setId($groupId);
             $wizard->page->addPermission($group);
         }
         $wizard->page->setTitle($this->_getParam('title'))->setTitleFallback($this->_getParam('title_fb'))->setSummary($this->_getParam('summary'))->setSummaryFallback($this->_getParam('summary_fb'))->setContent($this->_getParam('contenti'))->setContentFallback($this->_getParam('content_fb'))->setSource($this->_getParam('source'))->setSourceFallback($this->_getParam('source_fb'))->setLayout($this->_getParam('layout', 'default'))->addTag(explode("\n", $this->_getParam('tags')))->setLink($this->_getParam('link'))->setNavigation($this->_getParam('menu'), false)->setSitemap($this->_getParam('sitemap'), false)->setAllowComments($this->_getParam('comments'), false)->setInvisible($this->_getParam('invisible'))->setSeoTitle($this->_getParam('seotitle'))->setSeoTags($this->_getParam('seotags'))->setSeoDescription($this->_getParam('seodescription'));
         $revision->setNotes($this->_getParam('notes'));
         $datePublished = $this->_getParam('date_published') . ' ' . $this->_getParam('publish_h') . ':' . $this->_getParam('publish_i') . ':00';
         $dateExpired = null;
         if ($this->_getParam('date_expired')) {
             $dateExpired = $this->_getParam('date_expired') . ' ' . $this->_getParam('expire_h') . ':' . $this->_getParam('expire_i') . ':00';
         }
         $wizard->page->setDatePublished($datePublished)->setDateExpired($dateExpired);
         if ($this->_getParam('translation')) {
             $wizard->page->markTranslationInvalid();
         }
         if ($wizard->page->isValid()) {
             $config = Zend_Registry::get('config');
             if ($wizard->page->getId() === false) {
                 $lngs = $config->system->language;
             } else {
                 $lngs[$wizard->page->getLanguage()] = null;
             }
             $wizard->page->save();
             foreach ($lngs as $lng => $slng) {
                 $revision->setNotes($this->_getParam('notes'))->setLanguage($lng)->setTitle($wizard->page->getTitle())->setTitleFallback($wizard->page->hasTitleFallback())->setSummary($wizard->page->getSummary())->setSummaryFallback($wizard->page->hasSummaryFallback())->setContent($wizard->page->getContent())->setContentFallback($wizard->page->hasContentFallback())->setSource($wizard->page->getSource())->setSourceFallback($wizard->page->hasSourceFallback())->setLink($wizard->page->getLink())->setLinkFallback($wizard->page->hasLinkFallback())->setPageId($wizard->page->getId())->setInvisible($wizard->page->getInvisible());
                 $revision->setSeoTitle($wizard->page->getSeoTitle())->setSeoTags($wizard->page->getSeoTags())->setSeoDescription($wizard->page->getSeoDescription());
                 $revision->save();
                 if (!$this->_getParam('revision')) {
                     $revision->approve();
                 }
             }
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage($this->admin_tmx->_('pagesavesuccess'));
             if ($wizard->page->getType() == SxCms_Page::ARTICLE) {
                 $this->_helper->redirector->gotoSimple('news', 'page');
             } else {
                 $this->_helper->redirector->gotoSimple('index', 'page');
             }
             $wizard->unsetAll();
         }
         $wizard->page->setDatePublished($this->_getParam('date_published'))->setDateExpired($this->_getParam('date_expired'));
     }
     $this->view->page = $wizard->page;
     $this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Page');
     $this->view->revision = $revision;
 }
Exemplo n.º 9
0
 /**
  * Add a group that the user belongs to. A user can be assigned to multiple groups
  * 
  * @param SxCms_Group $group
  * @return SxCms_User
  */
 public function addGroup(SxCms_Group $group)
 {
     $this->groups[$group->getId()] = $group;
     return $this;
 }
Exemplo n.º 10
0
 public function delete(SxCms_Group $group)
 {
     $db = Zend_Registry::get('db');
     return $db->delete('Group', 'group_id = ' . $group->getId());
 }