public function deleteAll($fileId) { $content = Gpf_Db_Table_FileContents::getInstance(); $content->deleteAll($fileId); $deleteBulider = new Gpf_SqlBuilder_DeleteBuilder(); $deleteBulider->from->add(self::getName()); $deleteBulider->where->add('fileid', '=', $fileId); $this->createDatabase()->execute($deleteBulider->toString()); }
protected function getContent() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('content'); $selectBuilder->from->add(Gpf_Db_Table_FileContents::getName()); $selectBuilder->where->add('fileid', '=', $this->file->getFileId()); $selectBuilder->orderBy->add('contentid', true); $sth = $this->createDatabase()->execute($selectBuilder->toString()); while ($row = $sth->fetchArray()) { echo $row['content']; } return ''; }
/** * Return file content from database * * @param string $fileId * @return string */ public static function getFileContent($fileId) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('content', 'content'); $select->from->add(Gpf_Db_Table_FileContents::getName()); $select->where->add('fileid', '=', $fileId); $select->orderBy->add('contentid'); $resultSet = $select->getAllRows(); $content = ''; foreach ($resultSet as $result) { $content .= $result->get('content'); } return $content; }
function init() { $this->setTable(Gpf_Db_Table_FileContents::getInstance()); parent::init(); }
/** * Try to send Outbox entry * * @param Gpf_Data_Record $mail */ private function sendMail(Gpf_Data_Record $outbox) { //build mail $mail = new Gpf_Mail(); //set transfer method (smtp or mail) if ($outbox->get('use_smtp') == Gpf::YES) { if ($outbox->get('smtp_ssl') == Gpf::YES) { $this->checkSSL(); } $mail->setTransferMethod('smtp'); $mail->setTransferParams(array('host' => $outbox->get('smtp_server'), 'port' => $outbox->get('smtp_port'), 'auth' => $outbox->get('smtp_auth') == Gpf::YES ? strlen($outbox->get('smtp_auth_method')) ? $outbox->get('smtp_auth_method') : true : false, 'username' => $outbox->get('smtp_username'), 'password' => $outbox->get('smtp_password'), 'localhost' => 'localhost', 'timeout' => 30, 'verp' => false, 'debug' => false, 'persist' => false)); } else { $mail->setTransferMethod('mail'); $mail->setTransferParams(null); } $mail->setRecipients($outbox->get('to_recipients')); $mail->setCcRecipients($outbox->get('cc_recipients')); $mail->setBccRecipients($outbox->get('bcc_recipients')); $mail->setFullFromAddress($outbox->get('from_mail')); $mail->setHtmlBody($outbox->get('body_html')); $mail->setTxtBody($outbox->get('body_text')); if ($outbox->get('reply_to') != '') { $mail->setFrom('', $outbox->get('from_mail')); $mail->setReplyTo($outbox->get('reply_to')); } else { $mail->setReplyTo($outbox->get('from_mail')); } $mail->setSubject($outbox->get('subject')); $mail->setUserAgent('Quality Unit Mail Services'); //add attachments and inner images $attachments = Gpf_Db_Table_MailAttachments::getMailAttachments($outbox->get('mailid')); foreach ($attachments as $attachment) { if ($attachment->get('is_included_image') == Gpf::YES) { $mail->addImage($attachment->get('filename'), Gpf_Db_Table_FileContents::getFileContent($attachment->get('fileid')), $attachment->get('filetype')); } else { $mail->addAttachment($attachment->get('filename'), $attachment->get('filetype'), Gpf_Db_Table_FileContents::getFileContent($attachment->get('fileid'))); } } $mail->send(); return true; }
/** * Print content of file to default output */ private function downloadContent() { if ($this->printHeaders()) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('content', 'content'); $selectBuilder->from->add(Gpf_Db_Table_FileContents::getName()); $selectBuilder->where->add('fileid', '=', $this->file->get('fileid')); $selectBuilder->orderBy->add('contentid', true); $contents = $selectBuilder->getAllRows(); foreach ($contents as $contentRecord) { echo $contentRecord->get('content'); } return true; } return false; }