/**
  * @return Gpf_Db_Table_MailTemplateAttachments
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #2
0
 public function deleteAll($templateId)
 {
     $deleteBulider = new Gpf_SqlBuilder_DeleteBuilder();
     $deleteBulider->from->add(self::getName());
     $deleteBulider->where->add(self::ID, '=', $templateId);
     $this->createDatabase()->execute($deleteBulider->toString());
     $deleteAttachments = Gpf_Db_Table_MailTemplateAttachments::getInstance();
     $deleteAttachments->deleteAll($templateId);
 }
 /**
  * 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();
 }
예제 #4
0
 protected function createMailAttachments(Gpf_Db_MailTemplate $template, Gpf_Db_Mail $mail)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('fileid', 'fileid');
     $select->select->addConstant($mail->get('mailid'), 'mailid');
     $select->select->add('is_included_image', 'is_included_image');
     $select->from->add(Gpf_Db_Table_MailTemplateAttachments::getName());
     $select->where->add('templateid', '=', $template->get('templateid'));
     $insert = new Gpf_SqlBuilder_InsertBuilder();
     $insert->setTable(Gpf_Db_Table_MailAttachments::getInstance());
     $insert->fromSelect($select);
     $insert->execute();
 }
예제 #5
0
 protected function deleteAllOldAtachments($templateId = false, $fileId = false)
 {
     Gpf_Db_Table_MailTemplateAttachments::getInstance()->deleteAll($templateId, $fileId);
 }
 function init()
 {
     $this->setTable(Gpf_Db_Table_MailTemplateAttachments::getInstance());
     parent::init();
 }