public function editAction()
 {
     SxCms_Acl::requireAcl('members', 'members.edit');
     $proxy = new SxModule_Securedocs_Group_Proxy();
     $groups = $proxy->getAll();
     $this->view->groups = $groups;
     $proxy = new SxModule_Members_Proxy();
     $item = $proxy->getById((int) $this->_getParam('id'), $_SESSION['System']['lng']);
     $item->setTmx($this->tmx);
     if ($this->getRequest()->isPost()) {
         $mapper = new SxModule_Members_Mapper();
         $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields());
         $data = $mapper->toObject($fields, $item);
         $validator = new SxModule_Members_Validator();
         if ($validator->validate($data)) {
             $item->save();
             $cache = Zend_Registry::get('cache');
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Members'));
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage($this->admin_tmx->_('itemedited'));
             $this->_helper->redirector->gotoSimple('index', 'member');
         }
         $item = $data;
     }
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Members');
     $this->view->item = $item;
 }
 public function deletegroupAction()
 {
     SxCms_Acl::requireAcl('securedocs', 'securedocs.delete');
     $id = $this->_getParam('id');
     $proxy = new SxModule_Securedocs_Group_Proxy();
     $item = $proxy->getById($id);
     $item->delete();
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $flashMessenger->addMessage($this->admin_tmx->_('groupdeleted'));
     $this->_helper->redirector->gotoSimple('groupoverview', 'securedocs');
 }
 public function indexAction()
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $this->_helper->redirector->gotoSimple('login', 'member');
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     //set base + path
     $base = APPLICATION_PATH . '/../public_html/securedocs/';
     $base = realpath($base);
     $path = base64_decode($this->_getParam('path'));
     if ($this->getRequest()->isPost()) {
         if ($this->_getParam('folder')) {
             if (!file_exists($base . $path . '/' . $this->_getParam('folder'))) {
                 mkdir($base . $path . '/' . $this->_getParam('folder'));
                 if ($path == '') {
                     //if path = '' add map in database
                     $newmap = new SxModule_Securedocs_Folder();
                     $newmap->setFoldername($this->_getParam('folder'));
                     $newmap->save();
                 }
                 $messages = 'Directory created !';
                 $this->view->messages = $messages;
             }
         } else {
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $adapter->setDestination(realpath($base) . $path);
             $adapter->setOptions(array('ignoreNoFile' => true));
             $adapter->receive();
             if ($adapter->getFileName('filename')) {
                 $filename = realpath($adapter->getFileName('filename'));
                 $filename = str_replace(" ", "", array_pop(explode("/", $filename)));
                 $file = $adapter->getFileName('filename');
                 $newfile = $base . $path . '/' . $filename;
                 rename($file, $newfile);
                 $mail = $this->_getParam('mail');
                 if ($mail) {
                     $mail = 1;
                 } else {
                     $mail = 0;
                 }
                 $file = new SxModule_Securedocs_File($newfile);
                 $file->setMail($mail);
                 $file->setSummary($this->_getParam('samenvatting'));
                 $file->setPath($path);
                 $file->save();
                 $messages = 'File uploaded !';
                 $this->view->messages = $messages;
                 //als mail mag gest worden
                 if ($mail == '1') {
                     $groups = explode('/', $path);
                     //get folder id to find group
                     $proxy = new SxModule_Securedocs_Folder_Proxy();
                     $folder = $proxy->getByFolder($groups[1]);
                     $folderId = $folder->getFolderId();
                     //get group id's that allows the folder to find the members
                     $proxy = new SxModule_Securedocs_Group_Proxy();
                     $groups = $proxy->getAllByMap($folderId);
                     //Zend_Debug::dump($groups);die();
                     $aantal = count($groups);
                     $q = 0;
                     $groupids = '(';
                     foreach ($groups as $group) {
                         $q++;
                         if ($q != $aantal) {
                             $groupids .= $group->getGroupId() . ",";
                         } else {
                             $groupids .= $group->getGroupId();
                         }
                     }
                     $groupids .= ')';
                     $proxy = new SxModule_Members_Proxy();
                     $members = $proxy->getAllByGroups($groupids);
                     foreach ($members as $member) {
                         $member->sendDocument($file);
                     }
                 }
             }
         }
     }
     try {
         $it = new SxModule_Securedocs_Filesystem(realpath($base . $path));
     } catch (Exception $e) {
         $it = new SxModule_Securedocs_Filesystem($base);
         $path = '';
         $e;
     }
     /*maps waar lid toegang tot heeft*/
     $aantal = count($identity->getGroups());
     $groups = $identity->getGroups();
     $testempty = count($identity->getGroups()) == 1 && $groups[0] == '' ? true : false;
     if ($aantal != '0' && $testempty == false) {
         $q = 0;
         $groupids = '(';
         foreach ($identity->getGroups() as $group) {
             $q++;
             if ($q != $aantal) {
                 $groupids .= $group . ",";
             } else {
                 $groupids .= $group;
             }
         }
         $groupids .= ')';
         $proxy = new SxModule_Securedocs_Group_Proxy();
         $groepen = $proxy->getAllMapsByGroupIds($groupids);
         //uiteindelijk de mappen waar het lid toegang tot heeft
         $accessGroups = array();
         foreach ($groepen as $groep) {
             $accessGroups[] = $groep['foldername'];
         }
     } else {
         $accessGroups = array();
     }
     //check if member has fullacces
     if ($identity->getBoardMember() == '1') {
         $fullacces = true;
     } else {
         $fullacces = false;
     }
     /*get parentmap*/
     if ($this->_getParam('path')) {
         $parentmap = base64_decode($this->_getParam('path'));
         $parentmap = explode("/", $parentmap);
         $parentmap = $parentmap[1];
     } else {
         $parentmap = '';
     }
     /* sort the files */
     foreach ($it as $file) {
         if (isset($fullacces)) {
             $files[strtolower($file->getFilename())] = $file->key();
         } elseif (in_array($file, $accessGroups) || in_array($parentmap, $accessGroups)) {
             $files[strtolower($file->getFilename())] = $file->key();
         }
     }
     ksort($files);
     $showPath = explode('/', $path);
     for ($i = 1; $i < count($showPath); $i++) {
         $tmpPath = isset($showPath[$i - 1]['path']) ? $showPath[$i - 1]['path'] : '';
         $showPath[$i] = array('path' => $tmpPath . '/' . $showPath[$i], 'name' => $showPath[$i]);
     }
     array_shift($showPath);
     $this->view->accessgroups = $accessGroups;
     $this->view->fullAccess = $fullacces;
     $this->view->files = $files;
     $this->view->it = $it;
     $this->view->path = $path;
     $this->view->showpath = $showPath;
     $this->view->member = $identity;
 }