Beispiel #1
0
 /**
  * 
  * 
  * metodo que recebe objeto Devolutive e nomeia arquivo pdf e cria diretorio onde pdf sera gravado
  * 
  * @param Model_Devolutive $objDevolutive
  * 
  * @return boolean
  */
 public function preparaFileSystemParaDevolutiva()
 {
     $result = false;
     $arrUser = array('Id = ?' => $this->objDevolutive->getUserId());
     $this->userSalt = $this->tbUser->fetchRow($arrUser)->getSalt();
     if (!$this->objDevolutive->getIsRA()) {
         $arqName = self::ARQNAME_DEVOLUTIVE . $this->objDevolutive->getQuestionnaireId() . "_" . date("YmdHis") . self::EXTENSION_ARQ;
     } else {
         $arqName = self::ARQNAME_EVALUATION . $this->objDevolutive->getQuestionnaireId() . "_" . date("YmdHis") . self::EXTENSION_ARQ;
     }
     $this->objDevolutive->setArqName($arqName);
     $basePath = self::BASE_PATH . hash("sha256", $this->objDevolutive->getUserId() . "_" . $this->userSalt) . "/";
     $dirName = $this->public_path . $basePath;
     $this->objDevolutive->setDirName($dirName);
     $publicDir = Zend_Controller_Front::getInstance()->getBaseUrl() . $basePath;
     $this->objDevolutive->setPublicDir($publicDir);
     $arqPath = $publicDir . $arqName;
     $this->objDevolutive->setArqPath($arqPath);
     //cria diretorio para pdf
     try {
         if (!is_dir($dirName)) {
             mkdir($dirName);
         }
         chmod($dirName, 0777);
     } catch (Excception $e) {
     }
     return $result;
 }