示例#1
0
 {
     return self::getSession('userGroupId', '');
 }
 public static function getUserGroupName()
 {
     $group = self::getSession('userGroupName', '');
     if ($group == '') {
         $user = Sam_Auth::getInstance()->getUser();
         $gid = $user->getGroupid();
         $group = new Sam_Model_User_Group();
         $group->find($gid);
         $groupname = $group->getName();
         self::setSession('userGroupName', $groupname);
示例#2
0
 public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
 {
     parent::__construct($request, $response, $invokeArgs);
     $ss = $this->_request->getParam("s-s", "");
     if ("" != $ss) {
         $ss = substr($ss, 1, strlen($ss) - 1);
         //echo $ss ,"\n";
         //echo App_Util::decrypt($ss);
     }
     $printMode = false;
     $this->view->printmode = false;
     if ($this->_request->getParam("print", '') != '') {
         $this->setPrintLayout();
         $this->view->printmode = true;
     }
     $this->_translate = Zend_Registry::get('translator');
     $this->init_controller();
     $this->_formatter = new App_Formatter();
     // echo 'App_Controller_Action';
     ob_start();
     if (!$this->_ignoreAuthen) {
         $sam = Sam_Auth::getInstance();
         $sam->Authorization();
         // echo $sam->getUserType();
         if ($sam->getUserType() != 'admin') {
             $sam->clearIdentity();
             $this->_helper->redirector('logout', 'index');
         }
         ob_end_clean();
         $resource = $request->getControllerName();
         if ($resource == 'menu-header') {
             $resource = 'menu';
         }
         // echo $resource;
         if ($resource != 'dashboard') {
             $controller = $resource;
             $module = $this->_request->getModuleName();
             $resource = strtolower("{$module}:{$controller}");
             if ($this->isAllowed($resource, 'view') == false) {
                 //$this->_helper->re
                 $this->_helper->redirector('index', 'index', 'app');
             }
         }
     }
     // จำ page  ล่าสุดไว้สำหรับใช้ในปุ่ม black
     $this->_init();
 }
示例#3
0
 public function uploadformAction()
 {
     try {
         $this->view->maxFileZise = 9000000;
         $request = $this->getRequest();
         $fileDescription = $request->getParam('file_description', '');
         $this->_folder = $request->getParam('folder', 'all');
         //echo $_SERVER ['DOCUMENT_ROOT'];
         if ($request->getPost()) {
             $folder = 'files';
             $targetPath = UPLOAD_PATH . '/' . $folder . '/' . $this->_folder . '/';
             //echo $targetPath;
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $adapter->setDestination($targetPath);
             if (!$adapter->isValid()) {
                 throw new Exception('Bad file data: ' . implode(',', $adapter->getMessages()));
             }
             $filePath = $adapter->getFileName();
             $fileSize = $adapter->getFileSize();
             $fileInfo = pathinfo($filePath);
             $fileExtension = $fileInfo['extension'];
             $fileNameUTF = basename($filePath, '.' . $fileExtension);
             $fileName = iconv("UTF-8", "TIS-620", $fileNameUTF);
             $fileUrl = '/' . $folder . '/' . $this->_folder . '/' . $fileName . '.' . $fileExtension;
             $thumbnailName = $fileName . '_thumbnails' . '.' . $fileExtension;
             $thumbnailUrl = "/files/" . $this->_folder . '/' . $thumbnailName;
             $renamePath = $targetPath . $fileName . '.' . $fileExtension;
             $adapter->addFilter('Rename', $renamePath);
             //$fileName = uniqid ();
             if ($this->isBadFile($fileExtension)) {
                 throw new Exception('Bad file type  : not accept \'' . $fileExtension . '\'');
             }
             $file = new Cms_Model_File();
             $result = $file->fetchAll("name='{$fileNameUTF}' AND folder='{$this->_folder}'");
             if (count($result) > 0) {
                 $this->_setWarning('Duplicate file name :' . $fileNameUTF);
                 throw new Exception('Duplicate file name :' . $fileNameUTF);
             }
             $file = new Cms_Model_File();
             $fileNameUTF = iconv("TIS-620", "UTF-8", $fileName);
             $fileUrlUTF = iconv("TIS-620", "UTF-8", $fileUrl);
             $file->setName($fileNameUTF)->setPath($fileUrlUTF)->setType($fileExtension)->setDescription($fileDescription);
             if ($this->_folder != 'all') {
                 $file->setFolder($this->_folder);
             }
             $file->setCreated(new DateTime());
             $file->setCreatedBy(Sam_Auth::getInstance()->getUser()->getId());
             $adapter->receive();
             if ($this->isImage($fileExtension)) {
                 $this->rezise($renamePath, $targetPath, $thumbnailName);
                 $thumbnailUrlUTF = iconv("TIS-620", "UTF-8", $thumbnailUrl);
                 $file->setThumbnailPath($thumbnailUrlUTF);
             }
             $file->save();
             $this->view->layout()->infocode = 22;
         }
     } catch (Zend_File_Transfer_Exception $e) {
         $this->_setWarning($e->getMessage() . $targetPath);
         //throw new Exception ( 'Bad file data: ' . $e->getMessage () );
     } catch (Exception $e) {
         $this->_setWarning($e->getMessage());
         //throw new Exception ( 'Bad file data: ' . $e->getMessage () );
     }
 }
示例#4
0
 static function getInstance()
 {
     //session_start();
     //if(APPLICATION_ENV == 'development'){
     $session = new Zend_Session_Namespace('sam_session' . uniqid(), true);
     //}
     if (isset($_SESSION['ses_SamX_obj'])) {
         $objSam = $_SESSION['ses_SamX_obj'];
         // true ; //$_SESSION ['ses_SamX_obj'];
         //die("isset");
     } else {
         //die("not isset");
         $objSam = new Sam_Auth();
         $_SESSION['ses_SamX_obj'] = $objSam;
     }
     App_Env::setSession("userType", 'admin');
     $objSam->setUserType('admin');
     return $objSam;
 }