/**
  * handleFileTransfer
  * @author Thomas Schedler <*****@*****.**>
  */
 private function handleFileTransfer()
 {
     $this->objUpload = new Zend_File_Transfer_Adapter_Http();
     $this->objUpload->setOptions(array('useByteString' => false));
     /**
      * validators for upload of media
      */
     $arrExcludedExtensions = $this->core->sysConfig->upload->excluded_extensions->extension->toArray();
     $this->objUpload->addValidator('Size', false, array('min' => 1, 'max' => $this->core->sysConfig->upload->max_filesize));
     $this->objUpload->addValidator('ExcludeExtension', false, $arrExcludedExtensions);
     /**
      * check if medium is uploaded
      */
     if (!$this->objUpload->isUploaded(self::UPLOAD_FIELD)) {
         $this->core->logger->warn('isUploaded: ' . implode('\\n', $this->objUpload->getMessages()));
         throw new Exception('File is not uploaded!');
     }
     /**
      * check if upload is valid
      */
     if (!$this->objUpload->isValid(self::UPLOAD_FIELD)) {
         $this->core->logger->warn('isValid: ' . implode('\\n', $this->objUpload->getMessages()));
         throw new Exception('Uploaded file is not valid!');
     }
 }
 public function uploadFile($object, $type, $subtype)
 {
     $sheets = new SxModule_Sheets();
     $base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
     $path = $type . '/' . $subtype;
     if (!is_dir($base . '/' . $path)) {
         echo $base . '/' . $path;
         mkdir($base . '/' . $type);
         mkdir($base . '/' . $path);
     }
     if ($object->getFile() == null) {
         $object->setFile('');
     }
     $uploadAdapter = new Zend_File_Transfer_Adapter_Http();
     $uploadAdapter->setDestination($base . '/' . $path);
     $uploadAdapter->setOptions(array('ignoreNoFile' => true));
     $uploadAdapter->receive();
     $files = $uploadAdapter->getFileName(null, true);
     foreach ($_FILES['file']['name'] as $key => $filename) {
         if (!$filename) {
             continue;
         }
         $file = $base . '/' . $path . '/' . $filename;
         $date = date('Y-m-d His');
         $path_info = pathinfo($filename);
         $myfilename = str_replace(' ', '_', $path_info['filename'] . '_' . $date . '.' . $path_info['extension']);
         $myfilename = $sheets->createFileName($myfilename);
         $newfile = $base . '/' . $path . '/' . $myfilename;
         rename($file, $newfile);
         $object->setFile($myfilename);
     }
 }
 public function addAction()
 {
     SxCms_Acl::requireAcl('securedocs', 'securedocs.add');
     $base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
     $path = base64_decode($this->_getParam('path'));
     if ($this->getRequest()->isPost()) {
         $uploadAdapter = new Zend_File_Transfer_Adapter_Http();
         $uploadAdapter->setDestination($base . $path);
         $uploadAdapter->setOptions(array('ignoreNoFile' => true));
         $uploadAdapter->receive();
         $files = $uploadAdapter->getFileName(null, true);
         foreach ($_FILES['file']['name'] as $key => $filename) {
             if (!$filename) {
                 continue;
             }
             $summary = $this->_getParam('samenvatting');
             $mail = $this->_getParam('mail', '');
             $file = $base . $path . '/' . $filename;
             $newfile = $base . $path . '/' . str_replace(" ", "", $filename);
             rename($file, $newfile);
             $file = new SxModule_Securedocs_File($newfile);
             $file->setPath($path);
             $file->setSummary($summary[$key]);
             $file->setMail(isset($mail[$key]) ? "1" : "0");
             $file->save();
             if ($mail[$key]) {
                 $groups = explode('/', $path);
                 $control = $path;
                 if ($control != "") {
                     $proxy = new SxModule_Securedocs_Folder_Proxy();
                     $folder = $proxy->getByFolder($groups[1]);
                     $folderId = $folder->getFolderId();
                     $proxy = new SxModule_Securedocs_Group_Proxy();
                     $groups = $proxy->getAllByMap($folderId);
                     $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);
                     }
                 }
             }
         }
         $this->_redirect('/admin/securedocs/index/path/' . base64_encode($path));
     }
     $this->view->path = $path;
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Securedocs_File');
 }
 protected function _imageResizeAndSave($object)
 {
     $path = APPLICATION_ROOT . '/public_html/images/topcontentblock/';
     $system->lng = $this->_getParam('lng');
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($path);
     $adapter->setOptions(array('ignoreNoFile' => true));
     if (!$adapter->receive()) {
         $msgr = Sanmax_MessageStack::getInstance('SxModule_Topcontentblock_Validator');
         $msgr->addMessage('file', $adapter->getMessages(), 'title');
     }
     if ($object->getPicture() == null) {
         $object->setPicture('');
     }
     $files = $adapter->getFileInfo();
     foreach ($files as $file) {
         if (!$file['tmp_name']) {
             continue;
         }
         $path0 = $path . "253X115/";
         $path1 = $path . "1263X575/";
         $path2 = $path . "1263X325/";
         $filename = $object->createThumbName($file['name']) . '_' . time() . '.jpg';
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(253, 115);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(100);
         $image->setImageFormat('jpeg');
         $image->writeImage($path0 . $filename);
         $image->clear();
         $image->destroy();
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(1263, 575);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(75);
         $image->setImageFormat('jpeg');
         $image->writeImage($path1 . $filename);
         $image->clear();
         $image->destroy();
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(1263, 325);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(75);
         $image->setImageFormat('jpeg');
         $image->writeImage($path2 . $filename);
         $image->clear();
         $image->destroy();
         unlink($file['tmp_name']);
         $object->setPicture($filename);
     }
 }
 protected function _imageResizeAndSave($object)
 {
     $path = APPLICATION_ROOT . '/public_html/images/eyecatchers/';
     $system->lng = $this->_getParam('lng');
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($path);
     $adapter->setOptions(array('ignoreNoFile' => true));
     if (!$adapter->receive()) {
         $msgr = Sanmax_MessageStack::getInstance('SxModule_Eyecatchers_Validator');
         $msgr->addMessage('file', $adapter->getMessages(), 'title');
     }
     if ($object->getPicture() == null) {
         $object->setPicture('');
     }
     $files = $adapter->getFileInfo();
     foreach ($files as $file) {
         if (!$file['tmp_name']) {
             continue;
         }
         $path0 = $path . "253x115/";
         $path1 = $path . "980x450/";
         if (!is_dir($path0)) {
             mkdir($path0, 0777, true);
         }
         if (!is_dir($path1)) {
             mkdir($path1, 0777, true);
         }
         $filename = $object->createThumbName($file['name']) . '_' . time() . '.png';
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(253, 115);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(100);
         $image->setBackgroundColor(new ImagickPixel('transparent'));
         $image->setImageFormat('png32');
         $image->writeImage($path0 . $filename);
         $image->clear();
         $image->destroy();
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(980, 450);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(75);
         $image->setBackgroundColor(new ImagickPixel('transparent'));
         $image->setImageFormat('png32');
         $image->writeImage($path1 . $filename);
         $image->clear();
         $image->destroy();
         unlink($file['tmp_name']);
         $object->setPicture($filename);
     }
 }
Example #6
0
 public function addAction()
 {
     $userNs = new Zend_Session_Namespace("members");
     $this->view->title = "City - Add";
     $this->view->headTitle(" -  " . $this->view->title);
     $form = new Admin_Form_City();
     $this->view->form = $form;
     $this->view->successMsg = "";
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $upload = new Zend_File_Transfer_Adapter_Http();
             //---main image
             if ($upload->isValid('logo')) {
                 $upload->setDestination("images/logo/");
                 try {
                     $upload->receive('logo');
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $id = time();
                 $file_name = $upload->getFileName('logo');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "logo_" . $id . ".{$ext}";
                 $targetPath = 'media/picture/city/logo/' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $formData['logo'] = $target_file_name;
                 /*--- Generate Thumbnail ---*/
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 100);
                 $thumb->save($targetPath = 'media/picture/city/logo/thumb_' . $target_file_name);
             }
             $usersNs = new Zend_Session_Namespace("members");
             $formData['userId'] = $usersNs->userId;
             $this->view->warningMsg = '';
             $model = new Application_Model_City($formData);
             $id = $model->save($model);
             $form->reset();
             $this->view->successMsg = "City added successfully. City Id : {$id}";
         } else {
             $form->populate($formData);
         }
     }
 }
Example #7
0
 public function uploadAttendanceSheet()
 {
     $targetPath = false;
     $upload = new Zend_File_Transfer_Adapter_Http();
     if ($upload->isValid('attendanceSheet')) {
         $upload->setDestination("media/attendance/");
         try {
             $upload->receive('attendanceSheet');
         } catch (Zend_File_Transfer_Exception $e) {
             $msg = $e->getMessage();
         }
         $upload->setOptions(array('useByteString' => false));
         $file_name = $upload->getFileName('attendanceSheet');
         $cardImageTypeArr = explode(".", $file_name);
         $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
         $target_file_name = "attendance_" . date("Y_m_d_H_i_s") . ".{$ext}";
         $targetPath = 'media/attendance/' . $target_file_name;
         $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
         $filterFileRename->filter($file_name);
     }
     return $targetPath;
 }
 public function resizeAndSave()
 {
     $path = APPLICATION_ROOT . '/public_html/images/doctors/';
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($path);
     $adapter->setOptions(array('ignoreNoFile' => true));
     if (!$adapter->receive()) {
         $msgr = Sanmax_MessageStack::getInstance('SxModule_Doctor');
         $msgr->addMessage('file', $adapter->getMessages(), 'file');
     }
     $files = $adapter->getFileInfo();
     foreach ($files as $file) {
         if ($file['tmp_name'] == '') {
             continue;
         }
         $filename = $this->_doc->createThumbName($file['name']) . '_' . time() . '.png';
         $path0 = $path . "100x100/";
         $path1 = $path . "230x230/color/";
         $path2 = $path . "230x230/fade/";
         $path3 = $path . "110x110/color/";
         $path4 = $path . "110x110/fade/";
         if (!is_dir($path0)) {
             mkdir($path0, 0777, true);
         }
         if (!is_dir($path1)) {
             mkdir($path1, 0777, true);
         }
         if (!is_dir($path2)) {
             mkdir($path2, 0777, true);
         }
         if (!is_dir($path3)) {
             mkdir($path3, 0777, true);
         }
         if (!is_dir($path4)) {
             mkdir($path4, 0777, true);
         }
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(100, 100);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(100);
         $image->setBackgroundColor(new ImagickPixel('transparent'));
         $image->setImageFormat('png32');
         $image->writeImage($path0 . $filename);
         $image->clear();
         $image->destroy();
         $image1 = new Imagick($file['tmp_name']);
         $image1->cropThumbnailImage(230, 230);
         $image1->setCompression(Imagick::COMPRESSION_JPEG);
         $image1->setImageCompressionQuality(100);
         $image1->setBackgroundColor(new ImagickPixel('transparent'));
         $image1->setImageFormat('png32');
         $image1->writeImage($path1 . $filename);
         $image1->setimagetype(Imagick::IMGTYPE_GRAYSCALE);
         $image1->writeImage($path2 . $filename);
         $image1->clear();
         $image1->destroy();
         $image1 = new Imagick($file['tmp_name']);
         $image1->cropThumbnailImage(110, 110);
         $image1->setCompression(Imagick::COMPRESSION_JPEG);
         $image1->setImageCompressionQuality(100);
         $image1->setBackgroundColor(new ImagickPixel('transparent'));
         $image1->setImageFormat('png32');
         $image1->writeImage($path3 . $filename);
         $image1->setimagetype(Imagick::IMGTYPE_GRAYSCALE);
         $image1->writeImage($path4 . $filename);
         $image1->clear();
         $image1->destroy();
         unlink($file['tmp_name']);
         $this->_doc->setPhoto($filename);
     }
 }
Example #9
0
 public function uploadCoverImage($id, $options)
 {
     $model = new Application_Model_Album();
     $model = $model->find($id);
     $upload = new Zend_File_Transfer_Adapter_Http();
     if ($upload->isValid('coverImage')) {
         $upload->setDestination("media/picture/album/");
         try {
             $upload->receive('coverImage');
         } catch (Zend_File_Transfer_Exception $e) {
             $msg = $e->getMessage();
         }
         $upload->setOptions(array('useByteString' => false));
         $file_name = $upload->getFileName('coverImage');
         $cardImageTypeArr = explode(".", $file_name);
         $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
         $target_file_name = "album_cover_" . $id . ".{$ext}";
         $targetPath = 'media/picture/album/' . $target_file_name;
         $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
         $filterFileRename->filter($file_name);
         $options['coverImage'] = $target_file_name;
         /*--- Generate Profile Picture ---*/
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize(150, 150);
         $thumb->save('media/picture/album/thumb_' . $target_file_name);
         $model->setCoverImage($options['coverImage']);
         return $model->save();
     }
 }
Example #10
0
 public function editAction()
 {
     $this->view->type = $type = $this->_getParam('type', "other");
     $this->view->title = ucfirst($type) . " Category - Edit";
     $this->view->headTitle(" -  " . $this->view->title);
     $id = $this->_getParam('id');
     $model1 = new Application_Model_Category();
     $model = $model1->find($id);
     $options['name'] = $model->getName();
     $options['urlText'] = $model->getUrlText();
     $options['urlLink'] = $model->getUrlLink();
     $options['description'] = $model->getDescription();
     $options['image'] = $model->getImage();
     $options['status'] = $model->getStatus();
     $options['weight'] = $model->getWeight();
     $this->view->imgName = $model->getImage();
     $request = $this->getRequest();
     $form = new Admin_Form_Category();
     $form->populate($options);
     //remove weight field for all type of categories except advice and wsv category
     if ($type == "album" || $type == "blog" || $type == "work" || $type == "study" || $type == "volunteer" || $type == "other") {
         $form->removeElement('weight');
     }
     //Url Link and Url Text fields should appear for WSV categories only
     if ($type != "wsv") {
         $form->removeElement('urlText');
         $form->removeElement('urlLink');
     }
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $category_id = $model->getId();
             $upload = new Zend_File_Transfer_Adapter_Http();
             //---main image
             if ($upload->isValid('image')) {
                 $upload->setDestination("images/uploads/");
                 try {
                     $upload->receive('image');
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 //delete existing files
                 if ($model->getImage() != "" && file_exists("media/picture/category/" . $type . "/" . $model->getImage())) {
                     unlink("media/picture/category/" . $type . "/" . $model->getImage());
                     unlink("media/picture/category/" . $type . "/thumb_" . $model->getImage());
                 }
                 $id = $category_id;
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "category_" . $id . ".{$ext}";
                 $targetPath = 'media/picture/category/' . $type . '/' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $options['image'] = $target_file_name;
                 /*--- Generate Thumbnail ---*/
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 100);
                 $thumb->save($targetPath = 'media/picture/category/' . $type . '/thumb_' . $target_file_name);
             }
             //-----------
             $model->setOptions($options);
             $model->save($model);
             $model->updateRelatedSeoUrls($id);
             $this->view->successMsg = "Category has been updated successfully!";
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
 public function addPrintAction()
 {
     parent::postDispatch();
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->redirect('/auth');
     }
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $dbTable = new Application_Model_DbTable_Block();
     $options = array('ignoreNoFile' => true);
     $adapter->setOptions($options);
     $lastText = $dbTable->getTextById($_GET['id']);
     $this->view->block = $lastText;
     if (isset($_POST['submit'])) {
         // Enviar a atualização para o banco.
         $adapter->setDestination('c:/teste');
         $link_file = $adapter->getFileName();
         $name_file = $adapter->getFileName(null, false);
         $dbTable->update(array('date' => date('Y-m-d H:i:s'), 'name_pdf' => "{$name_file}", 'link_pdf' => "{$link_file}"), array('id = ? ' => $_GET['id']));
         $adapter->receive();
         header('Location: ../');
     }
 }
Example #12
0
 public function uploadPicture($options)
 {
     $upload = new Zend_File_Transfer_Adapter_Http();
     $albumId = $options['album_id'];
     $targetFolder = PUBLIC_PATH . "/media/picture/album/{$albumId}";
     if (!is_dir($targetFolder)) {
         mkdir(str_replace('//', '/', $targetFolder), 0755, true);
     }
     if ($upload->isValid('Filedata')) {
         $upload->setDestination($targetFolder);
         try {
             $upload->receive('Filedata');
         } catch (Zend_File_Transfer_Exception $e) {
             $msg = $e->getMessage();
         }
         $upload->setOptions(array('useByteString' => false));
         $file_name = $upload->getFileName('Filedata');
         $model = new Application_Model_Pictures();
         $model->setAlbumId($albumId);
         $model->setImage($file_name);
         $id = $model->save();
         $cardImageTypeArr = explode(".", $file_name);
         $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
         $target_file_name = "album_picture_" . $id . ".{$ext}";
         $targetPath = $targetFolder . '/' . $target_file_name;
         $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
         $filterFileRename->filter($file_name);
         /*--- Generate Profile Picture ---*/
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize(600, 600);
         $thumb->save($targetFolder . '/small_' . $target_file_name);
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize(150, 150);
         $thumb->save($targetFolder . '/thumb_' . $target_file_name);
         $model = new Application_Model_Pictures();
         $model = $model->find($id);
         $model->setImage($target_file_name);
         $model->save();
         $str = "<div class='album_pic_thumb_box' id='pic_container_" . $model->getId() . "'>";
         $str .= '<a class="album_pic_slide"  href="' . $model->getPictureSmallUrl() . '"><img class="album_pic_thumb" src="' . $model->getPictureThumbUrl() . '"/></a>';
         $str .= '<br class="clear">';
         $str .= "<a href=\"javascript: deletePic('" . $model->getId() . "');\">";
         $str .= "<img src=\"/images/icons/cross_circle.png\" alt=\"Click here to delete!\">";
         $str .= "</a>";
         $str .= "</div>";
         return $str;
     }
 }
Example #13
0
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Admin_Form_User();
     $options = $request->getPost();
     if ($request->isPost()) {
         /*---- email validation ----*/
         $form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address.'))));
         /*-------------------------*/
         if ($form->isValid($options)) {
             $model = new Application_Model_User();
             $options['dob'] = $options['year'] . "-" . $options['month'] . "-" . $options['day'];
             $options['status'] = 'active';
             $options['password'] = md5($options['password']);
             $options['preferredLanguage'] = 'English';
             //$options['userLevelId']	=$options['userLevelId'];
             //$model->setOptions($options);
             // $id=$model->save();
             /*---------  Upload image START -------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid('image')) {
                 $upload->setDestination("media/picture/profile/");
                 try {
                     $upload->receive('image');
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "profile_" . $id . ".{$ext}";
                 $targetPath = 'media/picture/profile/' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $options['image'] = $target_file_name;
                 /*--- Generate Thumbnail ---*/
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 100);
                 $thumb->save($targetPath = 'media/picture/profile/thumb_' . $target_file_name);
                 $model->setOptions($options);
                 $model->setId($id);
                 $id = $model->save();
             }
             /*---------  Upload image END -------------------------*/
             //$options['dob'] = $options['year']."-".$options['month']."-".$options['day'];
             //$model->setOptions($options);
             //$model->save();
             $user = new Application_Model_User($options);
             $user_id = $user->save();
             if ($user_id > 0) {
                 /*---- default permission settings ----*/
                 $user->setDefaultPermissions($user_id);
                 $user->setDefaultJournal($user_id);
             }
             $this->view->msg = "'User has been inserted successfully!";
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Example #14
0
 public function editAction()
 {
     $id = $this->_getParam('id');
     $preview = false;
     $preview = $this->_getParam('preview');
     //echo "diana==>".base64_encode(85);
     $this->view->id = $id;
     $this->view->preview = $preview;
     $page = new Application_Model_Advice();
     $page = $page->find($id);
     $options = array('categoryId' => $page->getCategoryId(), 'title' => $page->getTitle(), 'identifire' => $page->getIdentifire(), 'name' => $page->getName(), 'content' => $page->getContent(), 'synopsis' => $page->getSynopsis(), 'metaTitle' => $page->getMetaTitle(), 'metaDescription' => $page->getMetaDescription(), 'metaKeyword' => $page->getMetaKeyword(), 'status' => $page->getStatus(), 'name' => $page->getName(), 'userId' => $page->getUserId());
     $request = $this->getRequest();
     $form = new Admin_Form_Advice();
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     //$this->view->type = $page->getType();
     $this->view->imgName = $page->getName();
     $form->populate($options);
     if ($request->isPost()) {
         $options = $request->getPost();
         if (trim($options['identifire']) == "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $options['title'];
         }
         if (trim($options['identifire']) != "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $sanitize->clearInputs($options['identifire']);
             $options['identifire'] = $sanitize->sanitize($options['identifire']);
             //update seo url table
             $seo_url_title = $options['identifire'];
             $adviceM = new Application_Model_Advice();
             $advice = $adviceM->find($id);
             $seo_url = "";
             $actual_url = "/advice/detail/id/{$id}";
             if (false !== $advice) {
                 $sanitizeM = new Base_Sanitize();
                 //$category_id	=	$advice->getCategoryId();
                 $category_id = $options['categoryId'];
                 $categoryM = new Application_Model_Category();
                 $category = $categoryM->find($category_id);
                 if (false !== $category) {
                     $seo_url = "/advice/" . $sanitizeM->sanitize($category->getName()) . "/" . $seo_url_title;
                 }
             }
             $seoUrlM = new Application_Model_SeoUrl();
             $soeUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
             if (false !== $soeUrl) {
                 if ($seo_url != "") {
                     $soeUrl->setSeoUrl($seo_url);
                     $soeUrl->save();
                 }
             } else {
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
         }
         //save data
         if ($form->isValid($options)) {
             //set previous image name if not uploaded new one
             $options['name'] = $page->getName();
             /*------------------------------ Image Upload START ---------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid()) {
                 $upload->setDestination("images/advice/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 //unlink previous uploaded image files
                 unlink("images/advice/" . $page->getName());
                 unlink("images/advice/thumb_" . $page->getName());
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('name');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "advice_" . time() . ".{$ext}";
                 $targetPath = 'images/advice/' . $target_file_name;
                 $targetPathThumb = 'images/advice/thumb_' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(128, 84);
                 $thumb->save($targetPathThumb);
                 // file name
                 $options['name'] = $target_file_name;
             }
             /*------------------------------ Image Upload END ---------------------------*/
             $options['status'] = $page->getStatus();
             if ($options["saveUnpublish"] == "Save and Unpublish") {
                 $options['status'] = 0;
             }
             if ($options["savePublish"] == "Save and Publish") {
                 $options['status'] = 1;
             }
             $page->setOptions($options);
             $page->save();
             //return $this->_helper->redirector('index','advice',"admin",Array('msg'=>base64_encode("'{$page->getTitle()}' has been updated successfully!")));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Article has been saved & published successfully.";
                 $this->_helper->redirector('index', 'advice', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Article has been saved successfully.";
                     $this->_helper->redirector('index', 'advice', 'admin');
                 } else {
                     $this->_helper->redirector('edit', 'advice', 'admin', array('id' => $id, 'preview' => 'true'));
                 }
             }
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
 public function addCountryImageEXPAction()
 {
     $this->_helper->layout->disableLayout();
     //$this->_helper->viewRenderer->setNoRender(true);
     //get request variables
     $id = $this->_getParam("id");
     $page = $this->_getParam("page");
     $selTab = $this->_getParam("tab", "tabs-7");
     $this->view->cityId = $id;
     //create image upload form
     $uploadForm = new Admin_Form_CityImages();
     $elements = $uploadForm->getElements();
     $uploadForm->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     $this->view->uploadForm = $uploadForm;
     //selects country images to edit
     $oldImageArr = array();
     $oldImageSortingArr = array();
     $lonelyPlanetCountryM = new Application_Model_LonelyPlanetCountry();
     $lonelyPlanetCountryM = $lonelyPlanetCountryM->find($id);
     if (false !== $lonelyPlanetCountryM) {
         $oldImageArr = unserialize($lonelyPlanetCountryM->getImages());
         //echo "<pre>";
         //print_r($oldImageArr);
         for ($oCnt = 0; $oCnt < count($oldImageArr); $oCnt++) {
             $imgArr = $oldImageArr[$oCnt];
             $imgArr["alt_text"] = "";
             $imgArr["slide_link_url"] = "";
             $imgArr["slide_link_target"] = "";
             $imgArr["weight"] = $oCnt + 1;
             $oldImageSortingArr[] = $imgArr;
         }
         //print_r($oldImageSortingArr);
         //echo "</pre>";
         //exit;
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($uploadForm->isValid($options)) {
             $target_file_name = "";
             //Upload image strat here
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid()) {
                 $upload->setDestination("media/picture/country/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('countryImage');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "country{$country_id}_" . time() . ".{$ext}";
                 $targetPath = "media/picture/country/images/" . $target_file_name;
                 $targetPathThumb = "media/picture/country/images/thumbs/" . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(625, 330);
                 $thumb->save($targetPathThumb);
             }
             //end if
             //upload image Ends here
             //set country Image array
             $addImageArr = array();
             $addImageArr["image_caption"] = $options["slideTitle"];
             $addImageArr["image_photographer"] = "Gap Daemon";
             $addImageArr["image_filename"] = "/images/" . $target_file_name;
             $addImageArr["image_thumbnail_filename"] = "/images/thumbs/" . $target_file_name;
             $addImageArr["alt_text"] = $options["altText"];
             $addImageArr["slide_link_url"] = $options["slideLinkUrl"];
             $addImageArr["slide_link_target"] = $options["slideLinkTarget"];
             $addImageArr["weight"] = $options["weight"];
             $oldImageSortingArr[count($oldImageSortingArr)] = $addImageArr;
             $newCountryImageArr = serialize($oldImageSortingArr);
             $lonelyPlanetCountryM->setImages($newCountryImageArr);
             $resImg = $lonelyPlanetCountryM->save();
             if ($resImg) {
                 $_SESSION['errorMsg'] = "Images has been saved successfully.";
                 echo "<script>window.opener.location='/admin/featured-city/edit-country/id/{$id}/page/{$page}/tab/{$selTab}';</script>";
                 echo "<script>window.close();</script>";
             } else {
                 $this->view->errorMsg = "Error occured, please try again later.";
             }
         } else {
             $uploadForm->reset();
             $uploadForm->populate($options);
         }
     }
     //end if
     $this->render("add-city-image");
 }
Example #16
0
 public function upload()
 {
     if ($this->_helper->Identity()) {
         //Check if images path directory is writable
         if (!is_writable(IMAGE_PATH)) {
             throw new Pas_Exception_NotAuthorised('The images directory is not writable', 500);
         }
         // Create the imagedir path
         $imagedir = IMAGE_PATH . '/' . $this->_helper->Identity()->username;
         //Check if a directory and if not make directory
         if (!is_dir($imagedir)) {
             mkdir($imagedir, 0775, true);
         }
         //Check if the personal image directory is writable
         if (!is_writable($imagedir)) {
             throw new Pas_Exception_NotAuthorised('The user image directory is not writable', 500);
         }
         // Get images and do the magic
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination($imagedir);
         $adapter->setOptions(array('useByteString' => false));
         // Only allow good image files!
         $adapter->addValidator('Extension', false, 'jpg, tiff');
         $adapter->addValidator('NotExists', false, array($imagedir));
         $files = $adapter->getFileInfo();
         // Create an array for the images
         $images = array();
         // Loop through the submitted files
         foreach ($files as $file => $info) {
             // file uploaded & is valid
             //                if (!$adapter->isUploaded($file)) continue;
             //                if (!$adapter->isValid($file)) continue;
             // Clean up the image name for crappy characters
             $filename = pathinfo($adapter->getFileName($file));
             // Instantiate the renamer
             $reNamer = new Pas_Image_Rename();
             // Clean the filename
             $cleaned = $reNamer->strip($filename['filename'], $filename['extension']);
             // Rename the file
             $adapter->addFilter('rename', $cleaned);
             // receive the files into the user directory
             $adapter->receive($file);
             // this has to be on top
             if (!$adapter->hasErrors()) {
                 // Create the object for reuse
                 $image = new stdClass();
                 $image->cleaned = $cleaned;
                 $image->basename = $filename['basename'];
                 $image->extension = $filename['extension'];
                 $image->thumbnailUrl = $this->createThumbnailUrl($adapter->getFileName($file, false));
                 $image->deleteUrl = $this->_createUrl($adapter->getFileName($file, false));
                 $image->path = $adapter->getFileName($file);
                 $image->name = $adapter->getFileName($file, false);
                 $image->size = $adapter->getFileSize($file);
                 $image->mimetype = $adapter->getMimeType($file);
                 // The secure ID stuff for linking images
                 $image->secuid = $this->_helper->GenerateSecuID();
                 // Get the image dims
                 $imagesize = getimagesize($adapter->getFileName($file));
                 $image->width = $imagesize[0];
                 $image->height = $imagesize[1];
                 $params = $this->getAllParams();
                 $image->findID = $params['findID'];
                 // Create the raw image url
                 $image->url = $this->_createUrl($adapter->getFileName($file, false));
                 $image->deleteType = 'DELETE';
                 $images[] = $image;
                 $slides = new Slides();
                 $insert = $slides->addAndResize($images);
                 $this->view->data = $images;
                 $this->_helper->solrUpdater->update('images', (int) $insert);
                 $this->_helper->solrUpdater->update('objects', $params['findID'], 'artefacts');
             } else {
                 $image = new stdClass();
                 $image->error = $adapter->getErrors();
                 $images[] = $image;
                 $this->view->data = $images;
             }
         }
     } else {
         throw new Pas_Exception_NotAuthorised('Your account does not seem enabled to do this', 500);
     }
 }
Example #17
0
 public function resizeAndSave()
 {
     $path = APPLICATION_ROOT . '/public_html/images/subcategory/';
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($path);
     $adapter->setOptions(array('ignoreNoFile' => true));
     if (!$adapter->receive()) {
         $msgr = Sanmax_MessageStack::getInstance('SxModule_Faq');
         $msgr->addMessage('file', $adapter->getMessages(), 'file');
     }
     $files = $adapter->getFileInfo();
     foreach ($files as $file) {
         if ($file['tmp_name'] == '') {
             continue;
         }
         $path0 = $path . "228X123/";
         $path1 = $path . "466X123/";
         $filename = $this->_faq->createThumbName($file['name']) . '_' . time() . '.jpg';
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(228, 123);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(100);
         $image->setImageFormat('jpeg');
         $image->writeImage($path0 . $filename);
         $image->clear();
         $image->destroy();
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(466, 123);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(100);
         $image->setImageFormat('jpeg');
         $image->writeImage($path1 . $filename);
         $image->clear();
         $image->destroy();
         unlink($file['tmp_name']);
         $this->_faq->setPicture($filename);
     }
 }
 public function uploadAction()
 {
     $page_id = $this->_getParam('page_id');
     if ($this->getRequest()->isPost()) {
         $uploadPath = APPLICATION_ROOT . '/public_html/images/page';
         //var_dump($uploadPath);die();
         $uploadAdapter = new Zend_File_Transfer_Adapter_Http();
         $uploadAdapter->setDestination($uploadPath);
         $uploadAdapter->setOptions(array('ignoreNoFile' => true));
         $extValidator = new Zend_Validate_File_Extension('jpg,png,gif');
         $extValidator->setMessage('Ongeldige foto extensie', Zend_Validate_File_Extension::FALSE_EXTENSION);
         $uploadAdapter->addValidator($extValidator);
         $uploadAdapter->receive();
         $messages = $uploadAdapter->getMessages();
         if (count($messages)) {
             $this->_helper->layout()->disableLayout();
             $this->view->result = Zend_Json::encode(array('success' => false));
             return;
         }
         $basePath = APPLICATION_ROOT . '/public_html/images/page/page_' . $page_id;
         $old_umask = umask(0);
         if (!is_dir($basePath)) {
             mkdir($basePath, 0777, true);
         }
         if (!is_dir($basePath . '/100x100')) {
             mkdir($basePath . '/100x100', 0777, true);
         }
         if (!is_dir($basePath . '/726x1035')) {
             mkdir($basePath . '/726x1035', 0777, true);
         }
         umask($old_umask);
         $files = $uploadAdapter->getFilename(null, false);
         if (!is_array($files)) {
             $files = array($files);
         }
         $text = $this->_getParam('text');
         foreach ($files as $key => $filename) {
             $picnumber = substr($key, 8, 1);
             $oFname = $uploadPath . '/' . $filename;
             if (!$oFname) {
                 continue;
             }
             $ext = '.' . strtolower(substr(strrchr($oFname, '.'), 1));
             $nFname = $basePath . '/' . md5(time() . $oFname) . $ext;
             rename($oFname, $nFname);
             $im = new Imagick($nFname);
             $im->cropThumbnailImage(100, 100);
             $im->writeImage($basePath . '/100x100/' . basename($nFname));
             $im = new Imagick($nFname);
             $im->cropThumbnailImage(726, 1035);
             $im->writeImage($basePath . '/726x1035/' . basename($nFname));
             //count al items in DB en doe +1 voor de laatste positite aan de foto toe te kennen
             $x = new SxCms_Page_Picture_Proxy();
             $x = $x->countByPage($page_id) + 1;
             //save pic
             $picture = new SxCms_Page_Picture();
             $picture->setPageId($page_id);
             $picture->setFile(basename($nFname));
             $picture->setText($text[$picnumber]);
             $picture->setSeason(0);
             $picture->setPlace($x);
             $picture->save();
         }
         $this->_helper->layout()->disableLayout();
         $this->view->result = Zend_Json::encode(array('success' => true));
         $this->render('result');
     }
 }
 public function resizeAndSave()
 {
     $path = APPLICATION_ROOT . '/public_html/images/faqcategory/';
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($path);
     $adapter->setOptions(array('ignoreNoFile' => true));
     if (!$adapter->receive()) {
         $msgr = Sanmax_MessageStack::getInstance('SxModule_Faq_Category');
         $msgr->addMessage('file', $adapter->getMessages(), 'file');
     }
     $files = $adapter->getFileInfo();
     foreach ($files as $file) {
         if ($file['tmp_name'] == '') {
             continue;
         }
         //unlink($file['tmp_name']);
         $this->_cat->setPicture($file['name']);
     }
 }
Example #20
0
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Admin_Form_Articles();
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     $model = new Application_Model_Articles();
     $page_id = $this->_getParam('id');
     $this->view->msg = "";
     if ($this->_getParam('m') == 's') {
         $this->view->msg = "Article has been saved successfully.";
     }
     //select logged in user as default seleted for Author
     $usersNs = new Zend_Session_Namespace("members");
     $author = array('userId' => $usersNs->userId);
     $form->populate($author);
     /*-----------------------------------------*/
     if ($this->getRequest()->isPost()) {
         $options = $request->getPost();
         if (trim($options['identifire']) == "") {
             $options['identifire'] = $options['title'];
         }
         if (trim($options['identifire']) != "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $sanitize->clearInputs($options['identifire']);
             $options['identifire'] = $sanitize->sanitize($options['identifire']);
         }
         if ($form->isValid($options)) {
             /*------------------------------Image Upload ---------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             $target_file_name = "";
             if ($upload->isValid()) {
                 $upload->setDestination("images/articles/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "art_" . time() . ".{$ext}";
                 $targetPath = 'images/articles/' . $target_file_name;
                 $targetPathThumb = 'images/articles/thumb_' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 64);
                 $thumb->save($targetPathThumb);
             }
             //end if
             /*------------------------------Image Upload ---------------------------*/
             $params = $options;
             $params['status'] = 1;
             if ($options["savePublish"] != "Save and Publish") {
                 $params['status'] = 0;
             }
             //commented by mahipal on 29-dec-2010 and replaced with user dropdown list
             //$usersNs = new Zend_Session_Namespace("members");
             //$params['userId']		=	$usersNs->userId;
             $params['image'] = $target_file_name;
             // file name
             $model = new Application_Model_Articles($params);
             $id = $page_id = $model->save();
             $seo_url_title = $options['identifire'];
             $articleM = new Application_Model_Articles();
             $article = $articleM->find($id);
             $seo_url = "";
             $actual_url = "/work-study-volunteer/article-detail/id/{$id}";
             if (false !== $article) {
                 $sanitizeM = new Base_Sanitize();
                 $category_id = $article->getCategoryId();
                 $categoryM = new Application_Model_Category();
                 $category = $categoryM->find($category_id);
                 if (false !== $category) {
                     //$seo_url="/work-study-volunteer/".$category->getType()."/".$sanitizeM->sanitize($category->getName())."/".$seo_url_title;
                     $seo_url = "/work-study-volunteer/" . $sanitizeM->sanitize($category->getName()) . "/" . $seo_url_title;
                 }
             }
             $seoUrlM = new Application_Model_SeoUrl();
             $seoUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
             if (false !== $seoUrl) {
                 if ($seo_url != "") {
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             } else {
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
             //$this->_helper->redirector('add','articles','admin',array('id'=>$page_id,'m'=>'s'));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Article has been saved & published successfully.";
                 $this->_helper->redirector('index', 'articles', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Article has been saved successfully.";
                     $this->_helper->redirector('index', 'articles', 'admin');
                 } else {
                     $this->_helper->redirector('edit', 'articles', 'admin', array('id' => $page_id, 'preview' => 'true'));
                 }
             }
         }
         //end if
     }
     //end if
     $this->view->form = $form;
 }
 protected function _imageResizeAndSave($object)
 {
     $path = APPLICATION_ROOT . '/public_html/images/events/';
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($path);
     $adapter->setOptions(array('ignoreNoFile' => true));
     if (!$adapter->receive()) {
         $msgr = Sanmax_MessageStack::getInstance('SxModule_News_Validator');
         $msgr->addMessage('file', $adapter->getMessages(), 'title');
     }
     if ($object->getImage() == null) {
         $object->setImage('');
     }
     $files = $adapter->getFileInfo();
     foreach ($files as $file) {
         if (!$file['tmp_name']) {
             continue;
         }
         $path0 = $path . "280x160/";
         if (!is_dir($path0)) {
             mkdir($path0, 0777, true);
         }
         $path1 = $path . "630x355/";
         if (!is_dir($path1)) {
             mkdir($path1, 0777, true);
         }
         $filename = $object->createThumbName($file['name']) . '_' . time() . '.jpg';
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(280, 160);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(80);
         $image->setImageFormat('jpeg');
         $image->writeImage($path0 . $filename);
         $image->clear();
         $image->destroy();
         $image = new Imagick($file['tmp_name']);
         $image->cropThumbnailImage(630, 355);
         $image->setCompression(Imagick::COMPRESSION_JPEG);
         $image->setImageCompressionQuality(80);
         $image->setImageFormat('jpeg');
         $image->writeImage($path1 . $filename);
         $image->clear();
         $image->destroy();
         unlink($file['tmp_name']);
         $object->setImage($filename);
     }
 }
Example #22
0
 public function homepageBottomContentAction()
 {
     $id = $this->_getParam('id', 1);
     $modelRes = new Application_Model_HomeBottomContent();
     $modelRes = $modelRes->find($id);
     $options = array('leftTitle' => $modelRes->getLeftTitle(), 'leftText' => $modelRes->getLeftText(), 'rightText' => $modelRes->getRightText(), 'rightTitle' => $modelRes->getRightTitle(), 'backgroundImage' => $modelRes->getBackgroundImage(), 'status' => $modelRes->getStatus());
     $form = new Admin_Form_HomeBottomContent();
     $this->view->backgroundImage = $modelRes->getBackgroundImage();
     $form->populate($options);
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     //submit form
     $request = $this->getRequest();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             //set previous image name if not uploaded new one
             $target_file_name = $modelRes->getBackgroundImage();
             // Image Upload START
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid()) {
                 $upload->setDestination("media/picture/home/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 //unlink previous uploaded image file if exists
                 if (file_exists("media/picture/home/" . $modelRes->getBackgroundImage())) {
                     unlink("media/picture/home/" . $modelRes->getBackgroundImage());
                     unlink("media/picture/home/thumb_" . $modelRes->getBackgroundImage());
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('backgroundImage');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "bottom_" . time() . ".{$ext}";
                 $targetPath = "media/picture/home/" . $target_file_name;
                 $targetPathThumb = "media/picture/home/thumb_" . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(641, 299);
                 $thumb->save($targetPathThumb);
             }
             //Image Upload END
             //set image
             $options['backgroundImage'] = $target_file_name;
             //set user id
             $usersNs = new Zend_Session_Namespace("members");
             $options['userId'] = $usersNs->userId;
             $modelRes->setOptions($options);
             $updateRes = $modelRes->save();
             if ($updateRes) {
                 $_SESSION['errorMsg'] = "Content has been updated successfully.";
                 $this->_helper->redirector('homepage-bottom-content', 'widgets', 'admin', array('id' => $id));
             } else {
                 $this->view->errorMsg = "Error occured, please try again later.";
             }
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     //end if
     //set form
     $this->view->form = $form;
     //set message
     if (isset($_SESSION['errorMsg'])) {
         $this->view->errorMsg = $_SESSION['errorMsg'];
         unset($_SESSION['errorMsg']);
     }
 }
Example #23
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;
 }
Example #24
0
 public function editAction()
 {
     $type = "module";
     if ($this->_getParam('type') != "") {
         $type = $this->_getParam('type');
     }
     $this->view->type = $type;
     $id = $this->_getParam('id');
     $page = $this->_getParam('page');
     $model = new Application_Model_Content();
     $model = $model->find($id);
     $options['title'] = $model->getTitle();
     $options['alias'] = $model->getAlias();
     $options['body'] = $model->getBody();
     $options['status'] = $model->getStatus();
     $options['weight'] = $model->getWeight();
     $request = $this->getRequest();
     $form = new Admin_Form_Content();
     /****************************  Show/Hide fields as per module structure START ***************/
     //by default fields should be enabled
     $displayEditor = true;
     //remove form fields for fixed content
     if (in_array($model->getAlias(), $this->fixedTextMod)) {
         $form->removeElement('weight');
         $form->removeElement('status');
         $form->removeElement('whereText');
         $form->removeElement('whereUrl');
         $form->removeElement('whereUrlTarget');
         $form->removeElement('whereBodyText');
         $form->removeElement('whereBodyUrl');
         $form->removeElement('whereBodyUrlTarget');
         $form->removeElement('weekPhoto');
     } else {
         if ($model->getAlias() == "home_login_where_i_am") {
             $form->removeElement('body');
             $displayEditor = false;
             $arrBodyText = unserialize($model->getBody());
             foreach ($arrBodyText as $key => $value) {
                 $options[$key] = $value;
             }
             $form->removeElement('weekPhoto');
         } else {
             if ($model->getAlias() == "home_journal" || $model->getAlias() == "home_advertise") {
                 $form->removeElement('body');
                 $displayEditor = false;
                 $form->removeElement('whereText');
                 $form->removeElement('whereUrl');
                 $form->removeElement('whereUrlTarget');
                 $form->removeElement('whereBodyText');
                 $form->removeElement('whereBodyUrl');
                 $form->removeElement('whereBodyUrlTarget');
                 $form->removeElement('weekPhoto');
             } else {
                 if ($model->getAlias() == "home_photo_week") {
                     $form->removeElement('whereText');
                     $form->removeElement('whereUrl');
                     $form->removeElement('whereUrlTarget');
                     $form->removeElement('whereBodyText');
                     $form->removeElement('whereBodyUrl');
                     $form->removeElement('whereBodyUrlTarget');
                     $photoBodyArr = unserialize($model->getBody());
                     $target_file_name = $photoBodyArr["weekPhoto"];
                     //$options['weekPhoto'] = $photoBodyArr["weekPhoto"];
                     $this->view->weekPhoto = $target_file_name;
                     $options['body'] = $photoBodyArr["body"];
                 } else {
                     $form->removeElement('whereText');
                     $form->removeElement('whereUrl');
                     $form->removeElement('whereUrlTarget');
                     $form->removeElement('whereBodyText');
                     $form->removeElement('whereBodyUrl');
                     $form->removeElement('whereBodyUrlTarget');
                     $form->removeElement('weekPhoto');
                 }
             }
         }
     }
     //display editor as per module requirement
     $this->view->displayEditor = $displayEditor;
     /****************************  Show/Hide fields as per module structure END ***************/
     //populate form options
     $form->populate($options);
     if ($this->getRequest()->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             //create array for module as per their structure and save in database as serialize array
             if ($options["alias"] == "home_login_where_i_am") {
                 $bodyTextArr["whereText"] = $options["whereText"];
                 $bodyTextArr["whereUrl"] = $options["whereUrl"];
                 $bodyTextArr["whereUrlTarget"] = $options["whereUrlTarget"];
                 $bodyTextArr["whereBodyText"] = $options["whereBodyText"];
                 $bodyTextArr["whereBodyUrl"] = $options["whereBodyUrl"];
                 $bodyTextArr["whereBodyUrlTarget"] = $options["whereBodyUrlTarget"];
                 $options["body"] = serialize($bodyTextArr);
             }
             //upload photo image for Photo of The Week Module
             if ($options["alias"] == "home_photo_week") {
                 //Upload image start here
                 $upload = new Zend_File_Transfer_Adapter_Http();
                 if ($upload->isValid()) {
                     $upload->setDestination("media/picture/home/");
                     try {
                         $upload->receive();
                     } catch (Zend_File_Transfer_Exception $e) {
                         $msg = $e->getMessage();
                     }
                     $upload->setOptions(array('useByteString' => false));
                     $file_name = $upload->getFileName('weekPhoto');
                     $cardImageTypeArr = explode(".", $file_name);
                     $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                     //unlink existing image
                     if ($ext != "" && $target_file_name != "") {
                         if (file_exists("media/picture/home/" . $target_file_name)) {
                             unlink("media/picture/home/" . $target_file_name);
                             unlink("media/picture/home/thumb_" . $target_file_name);
                         }
                     }
                     //$target_file_name = "weekPhoto_".time().".{$ext}";
                     $target_file_name = "photo-of-the-week.{$ext}";
                     $targetPath = "media/picture/home/" . $target_file_name;
                     $targetPathThumb = "media/picture/home/thumb_" . $target_file_name;
                     $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                     $filterFileRename->filter($file_name);
                     $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                     $thumb->resize(278, 129);
                     $thumb->save($targetPathThumb);
                 }
                 //upload image Ends here
                 $bodyTextArr["weekPhoto"] = $target_file_name;
                 $bodyTextArr["body"] = $options["body"];
                 $options["body"] = serialize($bodyTextArr);
             }
             $model->setOptions($options);
             $model->save();
             return $this->_helper->redirector('index', 'content', "admin", array('type' => $type, 'msg' => base64_encode("Content has been saved successfully!")));
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->msg = base64_decode($this->getRequest()->getParam("msg"));
     // Assign the form to the view
     $this->view->form = $form;
     //render different view for Photo Of The Week module
     if ($model->getAlias() == "home_photo_week") {
         //clear form element decorators
         $elements = $form->getElements();
         $form->clearDecorators();
         foreach ($elements as $element) {
             $element->removeDecorator('label');
             $element->removeDecorator('td');
             $element->removeDecorator('tr');
             $element->removeDecorator('row');
             $element->removeDecorator('HtmlTag');
             $element->removeDecorator('class');
             $element->removeDecorator('placement');
             $element->removeDecorator('data');
         }
         $this->render('edit-photo');
     }
 }
Example #25
0
 public function myProfileAction()
 {
     /*--- find user data and populate the edit form ----*/
     $userNs = new Zend_Session_Namespace('members');
     $userId = $userNs->userId;
     //$user	=	unserialize($userNs->userObj);
     //$userId	=	$user->getId();
     $userM = new Application_Model_User();
     $user = $userM->find($userId);
     $params['firstName'] = $user->getFirstName();
     $params['lastName'] = $user->getLastName();
     $params['email'] = $user->getEmail();
     $params['countryPassport'] = $user->getCountryPassport();
     $params['preferredLanguage'] = $user->getPreferredLanguage();
     $params['otherLanguages'] = $user->getOtherLanguages();
     $params['cityId'] = $user->getCityId();
     $params['cityName'] = $user->getCityName();
     $arrDob = explode("-", $user->getDob());
     if (count($arrDob) > 0) {
         $params['year'] = $arrDob[0];
         $params['month'] = $arrDob[1];
         $params['day'] = $arrDob[2];
     }
     $params['sex'] = $user->getSex();
     $params['firstTimeTraveller'] = $user->getFirstTimeTraveller();
     $params['mobileCountryCode'] = $user->getMobileCountryCode();
     $params['mobile'] = $user->getMobile();
     $params['dreamDestination'] = $user->getDreamDestination();
     $params['wayToTravel'] = $user->getWayToTravel();
     $params['travelGear'] = $user->getTravelGear();
     $params['yearGoal'] = $user->getYearGoal();
     $params['leaveHomeWithout'] = $user->getLeaveHomeWithout();
     $params['interests'] = $user->getInterests();
     $params['evenTakenGapYear'] = $user->getEvenTakenGapYear();
     $params['nextTravelToDoList'] = $user->getNextTravelToDoList();
     $params['favouriteTravelExperience'] = $user->getFavouriteTravelExperience();
     $this->view->username = $user->getUsername();
     /*-------------------------------------------------------*/
     $form = new Application_Form_Profile();
     $form->populate($params);
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
     }
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getPost();
         /*---- email validation ----*/
         if ($params['email'] != $user->getEmail()) {
             $form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address'))));
         }
         /*-------------------------*/
         /*--- validations for change password -------*/
         if (trim($params['currentPassword']) != "") {
             $params['currentPassword'] = md5($params['currentPassword']);
             $form->getElement('currentPassword')->addValidators(array(array('Db_RecordExists', false, array('table' => 'user', 'field' => 'password', 'messages' => 'Incorrect current password'))));
             $form->getElement('password')->setRequired(true);
         }
         if (trim($params['password']) != "" && $params['currentPassword'] == "") {
             $form->getElement('currentPassword')->setRequired(true);
             $form->getElement('currentPassword')->addValidators(array(array('NotEmpty', false, array('messages' => array('isEmpty' => 'You must enter the current password')))));
         }
         /*--- validations for change password -------*/
         if ($form->isValid($params)) {
             $upload = new Zend_File_Transfer_Adapter_Http();
             //---main image
             if ($upload->isValid('image')) {
                 //unlink existing images
                 if ($user->getImage() != "" && file_exists("media/picture/profile/" . $user->getImage())) {
                     unlink("media/picture/profile/" . $user->getImage());
                     //main uploaded image
                     unlink("media/picture/profile/thumb_" . $user->getImage());
                     //thumb image
                 }
                 $upload->setDestination("images/uploads/");
                 try {
                     $upload->receive('image');
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $id = $userId;
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "profile_" . $id . ".{$ext}";
                 $targetPath = 'media/picture/profile/' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $params['image'] = $target_file_name;
                 /*--- Generate Thumbnail ---*/
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(200, 200);
                 $thumb->save($targetPath = 'media/picture/profile/thumb_' . $target_file_name);
             }
             //-----------
             $params['dob'] = $params['year'] . "-" . $params['month'] . "-" . $params['day'];
             $pass = $user->getPassword();
             if (trim($params['password']) != "") {
                 $params['password'] = md5($params['password']);
             } else {
                 $params['password'] = $pass;
             }
             $user->setOptions($params);
             $user->save();
             $this->view->msg = "Profile updated successfully!";
             $userNs->userObj = serialize($user);
         }
         //$this->_helper->_redirector->gotoUrl($this->view->seoUrl("/gapper/my-profile"));
         //$this->_redirect($this->view->seoUrl("/gapper/my-profile"));
     }
     $this->view->thumbImage = $user->getThumbnail();
     $this->view->image_name = $user->getImage();
     $this->view->gender = $user->getSex();
     $this->view->form = $form;
 }
Example #26
0
 public function editAction()
 {
     $id = $this->_getParam('id');
     $page = $this->_getParam('page');
     $model = new Cms_Model_Banner();
     $model = $model->find($id);
     $options['title'] = $model->getTitle();
     $options['image'] = $model->getImage();
     $options['url'] = $model->getUrl();
     $options['description'] = $model->getDescription();
     $options['position'] = $model->getPosition();
     $options['bannerType'] = $model->getBannerType();
     $request = $this->getRequest();
     $form = new Admin_Form_Banner();
     $form->getElement('image')->removeValidator('NotEmpty');
     $form->getElement('image')->setRequired(false);
     $form->populate($options);
     if ($this->getRequest()->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             /*--Image Upload ----*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid()) {
                 $upload->setDestination("images/uploads/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "banner_{$id}_image.{$ext}";
                 $targetPath = 'media/banner/' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $options['image'] = $target_file_name;
             }
             /*---------------------*/
             $model->setOptions($options);
             $model->save();
             return $this->_helper->redirector('index', 'banner', "admin", array('msg' => base64_encode("Banner [Id:{$id}] is updated successfully!")));
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->msg = base64_decode($this->getRequest()->getParam("msg"));
     // Assign the form to the view
     $this->view->image_path = "media/banner/" . $model->getImage();
     $this->view->form = $form;
 }
 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;
 }