示例#1
0
 /**
  * Internal function to return an MinutesFile object from a row.
  * @param $row array
  * @return MinutesFile
  */
 function &_returnMinutesFileFromRow(&$row)
 {
     $minutesFile = new MinutesFile();
     $minutesFile->setFileId($row['file_id']);
     $minutesFile->setMeetingId($row['meeting_id']);
     $minutesFile->setFileName($row['file_name']);
     $minutesFile->setOriginalFileName($row['original_file_name']);
     $minutesFile->setFileType($row['file_type']);
     $minutesFile->setFileSize($row['file_size']);
     $minutesFile->setType($row['type']);
     $minutesFile->setArticleId($row['article_id']);
     $minutesFile->setDateCreated($row['date_created']);
     HookRegistry::call('MinutesFileDAO::_returnMinutesFileFromRow', array(&$minutesFile, &$row));
     return $minutesFile;
 }
示例#2
0
 /**
  * PRIVATE routine to write a minutes file and add it to the database.
  * @param $fileName original filename of the file
  * @param $contents string contents of the file to write
  * @param $mimeType string the mime type of the file
  * @param $type string identifying type
  * @param $fileId int ID of an existing file to update
  * @return int the file ID (false if upload failed)
  */
 function handleWrite(&$pdf, $type, $fileId = null)
 {
     if (HookRegistry::call('MinutesFileManager::handleWrite', array(&$contents, &$fileId, &$result))) {
         return $result;
     }
     $minutesFileDao =& DAORegistry::getDAO('MinutesFileDAO');
     $typePath = $this->typeToPath($type);
     $dir = $this->filesDir . $typePath . '/';
     if (!$fileId) {
         $minutesFile =& $minutesFileDao->getGeneratedMinutesFile($this->meeting->getId(), $typePath);
         if (!$minutesFile) {
             $minutesFile =& $this->generateDummyFile($this->meeting);
         }
         $dummyFile = true;
     } else {
         $dummyFile = false;
         $minutesFile = new MinutesFile();
         $minutesFile->setMeetingId($this->meetingId);
         $minutesFile->setFileId($fileId);
     }
     $minutesFile->setFileType('application/pdf');
     $minutesFile->setOriginalFileName(null);
     $minutesFile->setType($typePath);
     $minutesFile->setDateCreated(Core::getCurrentDate());
     $newFileName = $this->generateFilename($minutesFile, $typePath, '.pdf');
     if (!FileManager::fileExists($dir, 'dir')) {
         FileManager::mkdirtree($dir);
     }
     if ($pdf->Output($dir . $newFileName, "F") != '') {
         $minutesFileDao->deleteMinutesFileById($minutesFile->getFileId());
         return false;
     } else {
         $minutesFile->setFileSize(filesize($dir . $newFileName));
     }
     if ($dummyFile) {
         $minutesFileDao->updateMinutesFile($minutesFile);
     } else {
         $minutesFileDao->insertMinutesFile($minutesFile);
     }
     return $minutesFile->getFileId();
 }