当前位置: 首页>>代码示例>>PHP>>正文


PHP Env::useLibrary方法代码示例

本文整理汇总了PHP中Env::useLibrary方法的典型用法代码示例。如果您正苦于以下问题:PHP Env::useLibrary方法的具体用法?PHP Env::useLibrary怎么用?PHP Env::useLibrary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Env的用法示例。


在下文中一共展示了Env::useLibrary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_textile

/**
 * Just textile the text and return
 *
 * @param string $text Input text
 * @return string
 */
function do_textile($text)
{
    Env::useLibrary('textile');
    $textile = new Textile();
    $text = $textile->TextileRestricted($text, false, false);
    return add_links($text);
}
开发者ID:469306621,项目名称:Languages,代码行数:13,代码来源:textile.php

示例2: diff

 function diff()
 {
     $page = Wiki::getPageById(get_id(), active_project());
     if (!instance_of($page, 'WikiPage')) {
         flash_error('wiki page dnx');
         $this->redirectTo('wiki');
     }
     // if
     if (!$page->canView(logged_user())) {
         flash_error('no access permissions');
         $this->redirectTo('wiki');
     }
     // if
     $rev1 = $page->getRevision(array_var($_GET, 'rev1', -1));
     $rev2 = $page->getRevision(array_var($_GET, 'rev2', -1));
     if (!instance_of($rev1, 'Revision') || !instance_of($rev2, 'Revision')) {
         flash_error(lang('wiki page revision dnx'));
         $this->redirectTo('wiki');
     }
     // if
     $this->addHelper('textile');
     //Load text diff library
     Env::useLibrary('diff', 'wiki');
     $diff = new diff($rev1->getContent(), $rev2->getContent());
     $output = new diff_renderer_inline();
     tpl_assign('diff', $output->render($diff));
     tpl_assign('page', $page);
     tpl_assign('revision', $page->getLatestRevision());
     tpl_assign('rev1', $rev1);
     tpl_assign('rev2', $rev2);
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:31,代码来源:WikiController.class.php

示例3: generatePictureFile

 private function generatePictureFile($source_file, $max_size, $tmp_filename = "")
 {
     if (!$tmp_filename) {
         $tmp_filename = CACHE_DIR . "/" . gen_id() . ".png";
     }
     if (!is_file($source_file)) {
         return null;
     }
     if (!$max_size) {
         $max_size = 600;
     }
     Env::useLibrary('simplegd');
     $image = new SimpleGdImage($source_file);
     if ($image->getWidth() > $max_size || $image->getHeight() > $max_size) {
         if ($image->getWidth() > $image->getHeight()) {
             $w = $max_size;
             $ratio = $image->getHeight() / $image->getWidth();
             $h = $ratio * $w;
         } else {
             $h = $max_size;
             $ratio = $image->getWidth() / $image->getHeight();
             $w = $ratio * $h;
         }
         $new_image = $image->resize($w, $h, false);
         $new_image->saveAs($tmp_filename);
         $repo_id = FileRepository::addFile($tmp_filename, array('type' => 'image/png', 'public' => true));
         @unlink($tmp_filename);
         return $repo_id;
     } else {
         return null;
     }
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:32,代码来源:Contact.class.php

示例4: sendEmail

 /**
  * Send an email using Swift (send commands)
  * 
  * @param string to_address
  * @param string from_address
  * @param string subject
  * @param string body, optional
  * @param string content-type,optional
  * @param string content-transfer-encoding,optional
  * @return bool successful
  */
 static function sendEmail($to, $from, $subject, $body = false, $type = 'text/plain', $encoding = '8bit')
 {
     Env::useLibrary('swift');
     $mailer = self::getMailer();
     if (!$mailer instanceof Swift) {
         throw new NotifierConnectionError();
     }
     // if
     $result = $mailer->send($to, $from, $subject, $body, $type, $encoding);
     $mailer->close();
     return $result;
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:23,代码来源:Notifier.class.php

示例5: getContent

 function getContent($smtp_server, $smtp_port, $transport, $smtp_username, $smtp_password, $body, $attachments)
 {
     //Load in the files we'll need
     Env::useLibrary('swift');
     switch ($transport) {
         case 'ssl':
             $transport = SWIFT_SSL;
             break;
         case 'tls':
             $transport = SWIFT_TLS;
             break;
         default:
             $transport = 0;
             break;
     }
     //Start Swift
     $mailer = new Swift(new Swift_Connection_SMTP($smtp_server, $smtp_port, $transport));
     if (!$mailer->isConnected()) {
         return false;
     }
     // if
     $mailer->setCharset('UTF-8');
     if ($smtp_username != null) {
         if (!$mailer->authenticate($smtp_username, self::ENCRYPT_DECRYPT($smtp_password))) {
             return false;
         }
     }
     if (!$mailer->isConnected()) {
         return false;
     }
     // add attachments
     $mailer->addPart($body);
     // real body
     if (is_array($attachments) && count($attachments) > 0) {
         foreach ($attachments as $att) {
             $mailer->addAttachment($att["data"], $att["name"], $att["type"]);
         }
     }
     $content = $mailer->getFullContent(false);
     $mailer->close();
     return $content;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:42,代码来源:MailUtilities.class.php

示例6: setPicture

 /**
  * Set contact picture from $source file
  *
  * @param string $source Source file
  * @param integer $max_width Max picture widht
  * @param integer $max_height Max picture height
  * @param boolean $save Save user object when done
  * @return string
  */
 function setPicture($source, $fileType, $max_width = 50, $max_height = 50, $save = true)
 {
     if (!is_readable($source)) {
         return false;
     }
     do {
         $temp_file = ROOT . '/cache/' . sha1(uniqid(rand(), true));
     } while (is_file($temp_file));
     Env::useLibrary('simplegd');
     $image = new SimpleGdImage($source);
     if ($image->getImageType() == IMAGETYPE_PNG) {
         if ($image->getHeight() > 128 || $image->getWidth() > 128) {
             //	resize images if are png bigger than 128 px
             $thumb = $image->scale($max_width, $max_height, SimpleGdImage::BOUNDARY_DECREASE_ONLY, false);
             $thumb->saveAs($temp_file, IMAGETYPE_PNG);
             $public_fileId = FileRepository::addFile($temp_file, array('type' => 'image/png', 'public' => true));
         } else {
             //keep the png as it is.
             $public_fileId = FileRepository::addFile($source, array('type' => 'image/png', 'public' => true));
         }
     } else {
         $thumb = $image->scale($max_width, $max_height, SimpleGdImage::BOUNDARY_DECREASE_ONLY, false);
         $thumb->saveAs($temp_file, IMAGETYPE_PNG);
         $public_fileId = FileRepository::addFile($temp_file, array('type' => 'image/png', 'public' => true));
     }
     if ($public_fileId) {
         $this->setPictureFile($public_fileId);
         if ($save) {
             $this->save();
         }
         // if
     }
     // if
     $result = true;
     // Cleanup
     if (!$result && $public_fileId) {
         FileRepository::deleteFile($public_fileId);
     }
     // if
     @unlink($temp_file);
     return $result;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:51,代码来源:Contact.class.php

示例7: download

 /**
  * Download task list as attachment
  *
  * @access public
  * @param void
  * @return null
  */
 function download()
 {
     $project = active_project();
     //$times = $project->getTimes();
     $times = ProjectTimes::findAll(array('conditions' => array('`project_id` = ?', $project->getId()), 'order' => '`done_date` DESC'));
     if (!is_array($times)) {
         flash_error(lang('time dnx'));
         $this->redirectTo('time');
     }
     // if
     $this->canGoOn();
     $filtered = array();
     foreach ($times as $time) {
         if ($time->canView(logged_user())) {
             $filtered[] = $time;
         }
     }
     // if
     $times = null;
     $output = array_var($_GET, 'output', 'csv');
     $project_name = active_project()->getName();
     $task_count = 0;
     if ($output == 'pdf') {
         Env::useLibrary('fpdf');
         $download_name = "{$project_name}-times.pdf";
         $download_type = 'application/pdf';
         $pdf = new FPDF();
         $pdf->AddPage();
         $pdf->SetTitle($project_name);
         $pdf->SetFont('Arial', 'B', 16);
         $task_lists = active_project()->getOpenTaskLists();
         $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'C');
         $pdf->Ln();
         $w = array(0 => 6, 140, 140);
         $pdf->SetFont('Arial', 'I', 14);
         foreach ($filtered as $time) {
             $line++;
             $time_id = '' . $time->getId();
             $time_done = format_date($time->getDoneDate(), null, 0);
             if ($time->getIsClosed()) {
                 $time_status = lang('completed');
                 $time_completion_info = format_date($task->getUpdatedOn());
             } else {
                 $time_status = lang('open');
                 $time_completion_info = '                ';
             }
             if ($time->getAssignedTo()) {
                 $time_assignee = $time->getAssignedTo()->getObjectName();
             } else {
                 $time_assignee = lang('not assigned');
             }
             $pdf->Cell($w[0], 6, $line);
             $pdf->Cell($w[1], 6, $time_id . " / " . $time_status . " / " . $time_completion_info . " / " . $time_assignee . " / " . $time_done, "TLRB");
             $pdf->Ln();
             $pdf->Cell($w[0], 6, '');
             $pdf->MultiCell($w[2], 6, $time->getDescription());
             $pdf->Ln();
         }
         $pdf->Output($download_name, 'D');
     } else {
         $download_name = "{$project_name}-times.txt";
         $download_type = 'text/csv';
         $s = "Project name\tId\tDate\tDescription\tHours\tBillable\n";
         foreach ($filtered as $time) {
             $s .= $project_name;
             $s .= "\t";
             $s .= $time->getId();
             $s .= "\t";
             $s .= format_date($time->getDoneDate(), null, 0);
             $s .= "\t";
             $s .= $time->getDescription();
             $s .= "\t";
             $s .= $time->getHours();
             $s .= "\t";
             $s .= $time->getIsBillable();
             $s .= "\n";
         }
         $download_contents = $s;
         download_headers($download_name, $download_type, strlen($download_contents), true);
         echo $download_contents;
     }
     die;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:90,代码来源:TimeController.class.php

示例8: setLogo

 /**
  * Set logo value
  *
  * @param string $source Source file
  * @param integer $max_width
  * @param integer $max_height
  * @param boolean $save Save object when done
  * @return null
  */
 function setLogo($source, $max_width = 50, $max_height = 50, $save = true)
 {
     if (!is_readable($source)) {
         return false;
     }
     do {
         $temp_file = ROOT . '/cache/' . sha1(uniqid(rand(), true));
     } while (is_file($temp_file));
     try {
         Env::useLibrary('simplegd');
         $image = new SimpleGdImage($source);
         $thumb = $image->scale($max_width, $max_height, SimpleGdImage::BOUNDARY_DECREASE_ONLY, false);
         $thumb->saveAs($temp_file, IMAGETYPE_PNG);
         $public_filename = PublicFiles::addFile($temp_file, 'png');
         if ($public_filename) {
             $this->setLogoFile($public_filename);
             if ($save) {
                 $this->save();
             }
             // if
         }
         // if
         $result = true;
     } catch (Exception $e) {
         $result = false;
     }
     // try
     // Cleanup
     if (!$result && $public_filename) {
         PublicFiles::deleteFile($public_filename);
     }
     // if
     @unlink($temp_file);
     return $result;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:44,代码来源:ProjectLink.class.php

示例9: do_textile

/**
 * Just textile the text and return
 *
 * @param string $text Input text
 * @param boolean $lite Skip lists, tables and blocks
 * @param boolean $encode Encode and return
 * @param boolean $noimage Don't insert images
 * @param boolean $strict Fix entities and fix whitespace
 * @param string $rel
 * @return string
 */
function do_textile($text, $lite = false, $encode = false, $noimage = false, $strict = false, $rel = '')
{
    Env::useLibrary('textile');
    $textile = new Textile();
    return '<div class="textile-rewrite">' . $textile->TextileThis($text, $lite, $encode, $noimage, $strict, $rel) . '</div>';
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:17,代码来源:textile.php

示例10: fodt2text

function fodt2text($filename,$id) {    
    Env::useLibrary('ezcomponents');
    
    $odt = new ezcDocumentOdt();
    $odt->loadFile( $filename );

    $docbook = $odt->getAsDocbook();

    $converter = new ezcDocumentDocbookToRstConverter();
    $rst = $converter->convert( $docbook );
    
    $file_path_txt = 'tmp/fodt2text_' . $id . '.txt';
    file_put_contents( $file_path_txt, $rst );
    $content = file_get_contents($file_path_txt); //Guardamos archivo.txt en $archivo
    unlink($file_path_txt);
    return $content;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:17,代码来源:functions.php

示例11: sendEmail

 /**
  * Send an email using Swift (send commands)
  * 
  * @param string to_address
  * @param string from_address
  * @param string subject
  * @param string body, optional
  * @param string content-type,optional
  * @param string content-transfer-encoding,optional
  * @return bool successful
  */
 static function sendEmail($to, $from, $subject, $body = false, $type = 'text/plain', $encoding = '8bit')
 {
     //static function sendEmail($to, $from, $subject, $body = false, $type = 'text/html', $encoding = '') {
     Env::useLibrary('swift');
     $mailer = self::getMailer();
     if (!$mailer instanceof Swift) {
         throw new NotifierConnectionError();
     }
     // if
     /** 
      * Set name address in ReplyTo, some MTA think we're usurpators
      * (which is quite true actually...)
      */
     if (config_option('mail_use_reply_to', 0) == 1) {
         $i = strpos($from, ' <');
         $name = '?';
         if ($i !== false) {
             $name = substr($from, 0, $i);
         }
         $mailer->setReplyTo($from);
         $mail_from = trim(config_option('mail_from'));
         if ($mail_from == '') {
             $mail_from = 'projectpier@' . $_SERVER['SERVER_NAME'];
         }
         $from = "{$name} <{$mail_from}>";
     }
     // from must be address known on server when authentication is selected
     $smtp_authenticate = config_option('smtp_authenticate', false);
     if ($smtp_authenticate) {
         $from = config_option('smtp_username');
     }
     trace("mailer->send({$to}, {$from}, {$subject}, {$body}, {$type}, {$encoding})");
     $result = $mailer->send($to, $from, $subject, $body, $type, $encoding);
     $mailer->close();
     return $result;
 }
开发者ID:noxstyle,项目名称:Project-Pier,代码行数:47,代码来源:Notifier.class.php

示例12: render_pie_chart

<?php

Env::useLibrary('openflashchart');
function render_pie_chart($options)
{
    $values = array();
    $colours = array();
    if (is_array($options['data'])) {
        foreach ($options['data'] as $data) {
            //	$values[]  = new OFC_Charts_Pie_Value($data['value'], $data['text']) ;
            $value = new OFC_Charts_Pie_Value($data['value'], $data['text']);
            $value->label = $data['text'];
            $values[] = $value;
            $colours[] = $data['color'];
        }
    }
    $chart = new OFC_Chart();
    $chart->set_bg_colour(array_var($options, 'background-color', '#FFFFFF'));
    $chart->set_title(new OFC_Elements_Title(array_var($options, 'title', "")));
    $pie = new OFC_Charts_Pie();
    if (array_var($options, 'start_angle')) {
        $pie->set_start_angle(array_var($options, 'start_angle'));
    }
    $pie->tip = array_var($options, 'tip') ? array_var($options, 'tip') : "#val#/#total#<br>#percent#";
    $pie->values = $values;
    $pie->colours = $colours;
    $pie->alpha = array_var($options, 'alpha') ? array_var($options, 'alpha') : 0.7;
    $pie->set_animate(array_var($options, 'animate', true));
    $chart->add_element($pie);
    $chart->x_axis = null;
    $filename = 'tmp/' . gen_id() . '.json';
开发者ID:rorteg,项目名称:fengoffice,代码行数:31,代码来源:chart.php

示例13: sendEmail

 /**
  * Send an email using Swift (send commands)
  * 
  * @param string to_address
  * @param string from_address
  * @param string subject
  * @param string body, optional
  * @param string content-type,optional
  * @param string content-transfer-encoding,optional
  * @return bool successful
  */
 static function sendEmail($to, $from, $subject, $body = false, $type = 'text/plain', $encoding = '8bit')
 {
     //static function sendEmail($to, $from, $subject, $body = false, $type = 'text/html', $encoding = '') {
     Env::useLibrary('swift');
     $mailer = self::getMailer();
     if (!$mailer instanceof Swift) {
         throw new NotifierConnectionError();
     }
     // if
     /** 
      * If the 'expose user e-mail' flag is cleared, then replace the user's
      * email with the site e-mail.
      */
     if (config_option('mail_expose_user_emails', 0) == 0) {
         $from = self::getSiteEmailAddress();
     } elseif (config_option('mail_use_reply_to', 0) == 1) {
         $i = strpos($from, ' <');
         $name = '';
         if ($i !== false) {
             $name = substr($from, 0, $i);
         }
         $mailer->setReplyTo($from);
         $from = self::getSiteEmailAddress($name);
     }
     // from must be address known on server when authentication is selected
     $smtp_authenticate = config_option('smtp_authenticate', false);
     if ($smtp_authenticate) {
         $from = config_option('smtp_username');
     }
     trace("mailer->send({$to}, {$from}, {$subject}, {$body}, {$type}, {$encoding})");
     $result = $mailer->send($to, $from, $subject, $body, $type, $encoding);
     $mailer->close();
     return $result;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:45,代码来源:Notifier.class.php

示例14: sendQueuedEmails

 static function sendQueuedEmails()
 {
     $date = DateTimeValueLib::now();
     $date->add("d", -2);
     $emails = QueuedEmails::getQueuedEmails($date);
     if (count($emails) <= 0) {
         return 0;
     }
     Env::useLibrary('swift');
     $mailer = self::getMailer();
     if (!$mailer instanceof Swift_Mailer) {
         throw new NotifierConnectionError();
     }
     // if
     $fromSMTP = config_option("mail_transport", self::MAIL_TRANSPORT_MAIL) == self::MAIL_TRANSPORT_SMTP && config_option("smtp_authenticate", false);
     $count = 0;
     foreach ($emails as $email) {
         try {
             $body = $email->getBody();
             $subject = $email->getSubject();
             Hook::fire('notifier_email_body', $body, $body);
             Hook::fire('notifier_email_subject', $subject, $subject);
             if ($fromSMTP && config_option("smtp_address")) {
                 $pos = strrpos($email->getFrom(), "<");
                 if ($pos !== false) {
                     $sender_name = trim(substr($email->getFrom(), 0, $pos));
                 } else {
                     $sender_name = "";
                 }
                 $from = array(config_option("smtp_address") => $sender_name);
             } else {
                 $pos = strrpos($email->getFrom(), "<");
                 if ($pos !== false) {
                     $sender_name = trim(substr($email->getFrom(), 0, $pos));
                     $sender_address = str_replace(array("<", ">"), array("", ""), trim(substr($email->getFrom(), $pos, strlen($email->getFrom()) - 1)));
                 } else {
                     $sender_name = "";
                     $sender_address = $email->getFrom();
                 }
                 $from = array($sender_address => $sender_name);
             }
             $message = Swift_Message::newInstance($subject)->setFrom($from)->setBody($body)->setContentType('text/html');
             if ($email->columnExists('attachments')) {
                 $attachments = json_decode($email->getColumnValue('attachments'));
                 foreach ($attachments as $a) {
                     // if file does not exists or its size is greater than 20 MB then don't process the atachments
                     if (!file_exists($a->path) || filesize($a->path) / (1024 * 1024) > 20) {
                         continue;
                     }
                     $attach = Swift_Attachment::fromPath($a->path, $a->type);
                     $attach->setDisposition($a->disposition);
                     if ($a->cid) {
                         $attach->setId($a->cid);
                     }
                     if ($a->name) {
                         $attach->setFilename($a->name);
                     }
                     $message->attach($attach);
                 }
             }
             $to = prepare_email_addresses(implode(",", explode(";", $email->getTo())));
             foreach ($to as $address) {
                 $message->addTo(array_var($address, 0), array_var($address, 1));
             }
             $cc = prepare_email_addresses(implode(",", explode(";", $email->getCc())));
             foreach ($cc as $address) {
                 $message->addCc(array_var($address, 0), array_var($address, 1));
             }
             $bcc = prepare_email_addresses(implode(",", explode(";", $email->getBcc())));
             foreach ($bcc as $address) {
                 $message->addBcc(array_var($address, 0), array_var($address, 1));
             }
             $result = $mailer->send($message);
             if ($result) {
                 DB::beginWork();
                 // save notification history after cron sent the email
                 self::saveNotificationHistory(array('email_object' => $email));
                 // delte from queued_emails
                 $email->delete();
                 DB::commit();
             }
             $count++;
         } catch (Exception $e) {
             DB::rollback();
             // save log in server
             if (defined('EMAIL_ERRORS_LOGDIR') && file_exists(EMAIL_ERRORS_LOGDIR) && is_dir(EMAIL_ERRORS_LOGDIR)) {
                 $err_msg = ROOT_URL . "\nError sending notification (queued_email_id=" . $email->getId() . ") using account " . print_r($from, 1) . "\n\nError detail:\n" . $e->getMessage() . "\n" . $e->getTraceAsString();
                 file_put_contents(EMAIL_ERRORS_LOGDIR . basename(ROOT), $err_msg, FILE_APPEND);
             }
             Logger::log("There has been a problem when sending the Queued emails.\nError Message: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
             $msg = $e->getMessage();
             if (strpos($msg, 'Failed to authenticate') !== false) {
                 $from_k = array_keys($from);
                 $usu = Contacts::getByEmail($from_k[0]);
                 $rem = ObjectReminders::instance()->findOne(array('conditions' => "context='eauthfail " . $from_k[0] . "'"));
                 if (!$rem instanceof ObjectReminder && $usu instanceof Contact) {
                     $reminder = new ObjectReminder();
                     $reminder->setMinutesBefore(0);
                     $reminder->setType("reminder_popup");
                     $reminder->setContext("eauthfail " . $from_k[0]);
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:101,代码来源:Notifier.class.php

示例15: sendQueuedEmails

	static function sendQueuedEmails() {
		$date = DateTimeValueLib::now();
		$date->add("d", -2);
		$emails = QueuedEmails::getQueuedEmails($date);
		if (count($emails) <= 0) return 0;
		
		Env::useLibrary('swift');
		$mailer = self::getMailer();
		if(!($mailer instanceof Swift_Mailer)) {
			throw new NotifierConnectionError();
		} // if
		$fromSMTP = config_option("mail_transport", self::MAIL_TRANSPORT_MAIL) == self::MAIL_TRANSPORT_SMTP && config_option("smtp_authenticate", false);
		$count = 0;
		foreach ($emails as $email) {
			try {
				
				$body = $email->getBody();
				$subject = $email->getSubject();
				Hook::fire('notifier_email_body', $body, $body);
				Hook::fire('notifier_email_subject', $subject, $subject);
				
				if ($fromSMTP && config_option("smtp_address")) {
					$pos = strrpos($email->getFrom(), "<");
					if ($pos !== false) {
						$sender_name = trim(substr($email->getFrom(), 0, $pos));
					} else {
						$sender_name = "";
					}
					$from = array(config_option("smtp_address") => $sender_name);
				} else {
					$pos = strrpos($email->getFrom(), "<");
					if ($pos !== false) {
						$sender_name = trim(substr($email->getFrom(), 0, $pos));
						$sender_address = str_replace(array("<",">"),array("",""), trim(substr($email->getFrom(), $pos, strlen($email->getFrom())-1)));
					} else {
						$sender_name = "";
						$sender_address = $email->getFrom();
					}
					$from = array($sender_address => $sender_name);
				}
				$message = Swift_Message::newInstance($subject)
				  ->setFrom($from)
				  ->setBody($body)
				  ->setContentType('text/html')
				;
				
				if ($email->columnExists('attachments')) {
					$attachments = json_decode($email->getColumnValue('attachments'));
					foreach ($attachments as $a) {
						$attach = Swift_Attachment::fromPath($a->path, $a->type);
						$attach->setDisposition($a->disposition);
						if ($a->cid) $attach->setId($a->cid);
						if ($a->name) $attach->setFilename($a->name);
						$message->attach($attach);
					}
				}
				
				$to = prepare_email_addresses(implode(",", explode(";", $email->getTo())));
				foreach ($to as $address) {
					$message->addTo(array_var($address, 0), array_var($address, 1));
				}
				$result = $mailer->send($message);

				DB::beginWork();
				$email->delete();
				DB::commit();
				$count++;
			} catch (Exception $e) {
				DB::rollback();
				Logger::log('There has been a problem when sending the Queued emails. Problem:'.$e->getTraceAsString());
			}
		}
		return $count;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:74,代码来源:Notifier.class.php


注:本文中的Env::useLibrary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。