Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Return all mail attachments for given mail id
  *
  * @param int $mailId
  * @return Gpf_Data_RecordSet
  */
 public static function getMailAttachments($mailId)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('f.*');
     $select->select->add('ma.is_included_image', 'is_included_image');
     $select->from->add(Gpf_Db_Table_MailAttachments::getName(), 'ma');
     $select->from->addInnerJoin(Gpf_Db_Table_Files::getName(), 'f', 'f.fileid=ma.fileid');
     $select->where->add('mailid', '=', $mailId);
     return $select->getAllRows();
 }
Ejemplo n.º 3
0
 private function updateReferenced($increment = 1)
 {
     $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder();
     $updateBuilder->from->add(Gpf_Db_Table_Files::getName());
     $updateBuilder->set->add('referenced', 'referenced + (' + $increment + ')', false);
     $updateBuilder->where->add('fileid', '=', $this->get('fileid'));
     if ($increment < 0) {
         $updateBuilder->where->add('referenced', '>', 0);
     }
     return $updateBuilder->update();
 }
 /**
  * Return list of files assigned to mail template
  * @service mail_template read
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Data_RecordSet
  */
 public function getUploadedFiles(Gpf_Rpc_Params $params)
 {
     $templateId = $params->get("templateId");
     $dbRow = $this->loadMailTemplate($templateId);
     $sql = new Gpf_SqlBuilder_SelectBuilder();
     $sql->select->add(Gpf_Db_Table_Files::ID, Gpf_Db_Table_Files::ID, 'f');
     $sql->select->add(Gpf_Db_Table_Files::FILE_NAME);
     $sql->select->add(Gpf_Db_Table_Files::FILE_TYPE);
     $sql->select->add(Gpf_Db_Table_Files::FILE_SIZE);
     $sql->select->add(Gpf_Db_Table_MailTemplateAttachments::IS_INCLUDED_IMAGE);
     $sql->from->add(Gpf_Db_Table_MailTemplateAttachments::getName(), 'ma');
     $sql->from->addInnerJoin(Gpf_Db_Table_Files::getName(), 'f', 'f.fileid=ma.fileid');
     $sql->where->add(Gpf_Db_Table_MailTemplates::ID, '=', $templateId);
     return $sql->getAllRows();
 }
Ejemplo n.º 5
0
 /**
  * @param $body Html body of mail
  * @return Gpf_Data_RecordSet
  */
 protected function getIncludedFilesRecordset($body)
 {
     $fileIds = $this->includedImageFileIds;
     if (count($fileIds) == 0) {
         return new Gpf_Data_RecordSet();
     }
     $sql = new Gpf_SqlBuilder_SelectBuilder();
     $sql->select->addAll(Gpf_Db_Table_Files::getInstance());
     $sql->from->add(Gpf_Db_Table_Files::getName());
     $sql->where->add(Gpf_Db_Table_Files::ID, 'IN', $fileIds);
     try {
         return $sql->getAllRows();
     } catch (Gpf_DbEngine_NoRowException $e) {
         return new Gpf_Data_RecordSet();
     }
 }
Ejemplo n.º 6
0
 /**
  * @return Gpf_DbEngine_Row_Collection<Gpf_Db_File>
  */
 public function getAttachements()
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->addAll(Gpf_Db_Table_Files::getInstance(), 'f');
     $select->from->add(Gpf_Db_Table_MailAttachments::getName(), 'ma');
     $select->from->addInnerJoin(Gpf_Db_Table_Files::getName(), 'f', 'ma.' . Gpf_Db_Table_MailAttachments::FILE_ID . ' = f.' . Gpf_Db_Table_Files::ID);
     $select->where->add("ma." . Gpf_Db_Table_Mails::ID, "=", $this->getId());
     $file = new Gpf_Db_File();
     return $file->loadCollectionFromRecordset($select->getAllRows());
 }