public function init() { parent::init(); if ($this->model === null) { $model = Yii::createComponent(array('class' => $this->formClass)); $model->objectId = $this->objectParameter->id_object; $model->parameterId = $this->objectParameter->id_parameter; if ($this->mainModel->isNewRecord) { if (!$this->mainModel->getTmpId()) { $this->mainModel->setTmpId($this->generateTmpId()); } $model->tmpId = $this->mainModel->getTmpId(); } else { $model->instanceId = $this->mainModel->getIdInstance(); } $this->model = $model; } if ($this->uploadTemplate === null) { $this->uploadTemplate = 'template-upload-' . $this->id; } if ($this->downloadTemplate === null) { $this->downloadTemplate = 'template-download-' . $this->id; } if (!isset($this->htmlOptions['id'])) { $this->htmlOptions['id'] = $this->id; } $this->options = CMap::mergeArray($this->options, array('formData' => $this->model->toRequestParams(), 'uploadTemplateId' => $this->uploadTemplate, 'downloadTemplateId' => $this->downloadTemplate)); if (!array_key_exists('previewMaxHeight', $this->options) && array_key_exists('height', $this->thumbConfig)) { $this->options['previewMaxHeight'] = $this->thumbConfig['height']; } if (!array_key_exists('previewMaxWidth', $this->options) && array_key_exists('width', $this->thumbConfig)) { $this->options['previewMaxWidth'] = $this->thumbConfig['width']; } }
/** * Download content as text */ public function downloadAs($title, $name, $content, $type = 'text') { $types = array('text' => 'text/plain', 'pdf' => 'application/pdf', 'word' => 'application/msword'); $exts = array('text' => 'txt', 'pdf' => 'pdf', 'word' => 'doc'); // Load anything? if ($type == 'pdf') { $pdf = Yii::createComponent('application.extensions.tcpdf.ETcPdf', 'P', 'cm', 'A4', true, 'UTF-8'); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(Yii::app()->name); $pdf->SetTitle($title); $pdf->SetSubject($title); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->writeHTML($content, true, 0, true, 0); $pdf->Output($name . '.' . $exts[$type], "I"); } header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache'); header("Content-Type: " . $types[$type] . ""); header("Content-Disposition: attachment; filename=\"" . $name . '.' . $exts[$type] . "\";"); header("Content-Length: " . mb_strlen($content)); echo $content; exit; }
/** * This method is Copyright (c) 2008-2014 by Yii Software LLC * http://www.yiiframework.com/license/ */ public function createUrlWithoutBase($route, $params = array(), $ampersand = '&') { unset($params[$this->routeVar]); foreach ($params as $i => $param) { if ($param === null) { $params[$i] = ''; } } if (isset($params['#'])) { $anchor = '#' . $params['#']; unset($params['#']); } else { $anchor = ''; } $route = trim($route, '/'); foreach ($this->_rules as $i => $rule) { if (is_array($rule)) { $this->_rules[$i] = $rule = Yii::createComponent($rule); } if (($url = $rule->createUrl($this, $route, $params, $ampersand)) !== false) { /* x2modstart */ if ($rule->hasHostInfo) { return $url === '' ? '/' . $anchor : $url . $anchor; } else { return '/' . $url . $anchor; } /* x2modend */ } } return $this->createUrlWithoutBaseDefault($route, $params, $ampersand) . $anchor; }
/** * @static * @return CTextHighlighter */ public static function getTextHighlighter() { if (is_null(self::$_textHighlighter)) { self::$_textHighlighter = Yii::createComponent(array('class' => 'CTextHighlighter', 'language' => 'sql', 'showLineNumbers' => false)); } return self::$_textHighlighter; }
/** * */ public function init() { parent::init(); $this->setHasher(Yii::createComponent($this->hasher)); $this->setTokenStorage(Yii::createComponent($this->tokenStorage)); $this->userModule = Yii::app()->getModule('user'); }
public function send($via, $to, $subject, $message, $params = array()) { if (!is_array($to)) { $to = array($to); } if ($via == 'email') { $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); foreach ($this->email as $k => $v) { $mailer->{$k} = mb_convert_encoding($v, 'CP-1251', 'UTF-8'); } foreach ($params as $k => $v) { $mailer->{$k} = mb_convert_encoding($v, 'CP-1251', 'UTF-8'); } foreach ($to as $v) { $mailer->AddAddress($v); } $mailer->AddReplyTo($mailer->From); $mailer->CharSet = 'WINDOWS-1251'; $mailer->SetLanguage(Yii::app()->language); $mailer->Subject = mb_convert_encoding($subject, 'CP-1251', 'UTF-8'); $mailer->MsgHTML(mb_convert_encoding($message, 'CP-1251', 'UTF-8'), Yii::getPathOfAlias('webroot')); try { return $mailer->Send(); } catch (phpmailerException $e) { // TODO: Отправлять в специальную таблицу недоставленных сообщений. // Чтобы можно было переотправить по крону или просмотреть на сайте //echo $e->getMessage()."\n"; return false; } } }
protected function getToolbarWidget() { if (null === $this->_toolbarWidget) { $this->_toolbarWidget = Yii::createComponent('YiiDebugToolbar', $this); } return $this->_toolbarWidget; }
protected function setUp() { $component = Yii::createComponent(array('class' => 'application.extensions.simpleWorkflow.SWPhpWorkflowSource', 'basePath' => 'application.tests.unit.task.workflows')); Yii::app()->setComponent('swSource', $component); Task_2_Test::$task2 = null; parent::setUp(); }
/** * Генерируется уникальная метка страницы, подключается модуль просмотра, * устанавливается обработчик для сбора отладочной информации, регистрируются * скрипты для вывода дебаг-панели */ public function init() { parent::init(); if (!$this->enabled) { return; } Yii::setPathOfAlias('yii2-debug', dirname(__FILE__)); Yii::app()->setImport(array('yii2-debug.*', 'yii2-debug.panels.*')); if ($this->logPath === null) { $this->logPath = Yii::app()->getRuntimePath() . '/debug'; } $panels = array(); foreach (CMap::mergeArray($this->corePanels(), $this->panels) as $id => $config) { if (!isset($config['highlightCode'])) { $config['highlightCode'] = $this->highlightCode; } $panels[$id] = Yii::createComponent($config, $this, $id); } $this->panels = $panels; Yii::app()->setModules(array($this->moduleId => array('class' => 'Yii2DebugModule', 'owner' => $this))); if ($this->internalUrls && Yii::app()->getUrlManager()->urlFormat == 'path') { $rules = array(); foreach ($this->coreUrlRules() as $key => $value) { $rules[$this->moduleId . '/' . $key] = $this->moduleId . '/' . $value; } Yii::app()->getUrlManager()->addRules($rules, false); } Yii::app()->attachEventHandler('onEndRequest', array($this, 'onEndRequest')); $this->initToolbar(); }
/** * Sends passed message to all enabled channels matching specified level and category. * * @param mixed $msg if string, is treated as message to be logged, if an array, should contain 'old' and 'new' keys with CModel objects as values * @param string $level level of the message (e.g. 'trace', 'warning', 'error'). It is case-insensitive. * @param string $category category of the message (e.g. 'system.web'). It is case-insensitive. */ public static function log($msg,$level=CLogger::LEVEL_INFO,$category='application') { $cacheDuration=3600; $channels = NfyChannels::model()->cache($cacheDuration)->findAll('t.enabled=:enabled', array(':enabled'=>true)); foreach($channels as $key=>$channel) { if ($channel->levels !== null) { $levels=preg_split('/[\s,]+/',strtolower($channel->levels),-1,PREG_SPLIT_NO_EMPTY); if (!in_array($level, $levels)) continue; } if ($channel->categories !== null) { $categories=preg_split('/[\s,]+/',strtolower($channel->categories),-1,PREG_SPLIT_NO_EMPTY); if (!in_array($category, $categories)) continue; } $route = Yii::createComponent(array( 'class'=>$channel->route_class, 'message_template'=>$channel->message_template, )); if (!($route instanceof INfyRoute)) { $error = Yii::t('NfyModule.app', 'Route class {route} specified for channel {channel_name} must implement the INfyRoute interface.', array( '{route}' => $channel->route_class, '{channel_name}' => $channel->name, )); // fail silently so the normal app workflow won't be disrupted by invalid notification configuration Yii::log($error, 'error', 'nfy'); continue; } $route->process($msg, $channel->id, $channel->subscriptions); } }
/** * @return CDbConnection */ public function getDbConnection() { if ($this->dbc === null) { $this->dbc = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => $this->getConnectionString(), 'username' => $this->user, 'password' => $this->password, 'charset' => 'utf8')); } return $this->dbc; }
public function actionSendEmail($id) { $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); $mailer->IsSMTP(); $mailer->IsHTML(true); $mailer->SMTPAuth = true; /* $mailer->SMTPSecure = "ssl"; $mailer->Host = "smtp.gmail.com"; $mailer->Port = 465; $mailer->Username = "******"; $mailer->Password = '******'; $mailer->From = "*****@*****.**"; */ /**/ $mailer->Host = "smtp.mail.yahoo.co.id"; $mailer->Port = 25; $mailer->Username = "******"; $mailer->Password = '******'; $mailer->From = "*****@*****.**"; /**/ $mailer->CharSet = 'UTF-8'; $mailer->addAttachment(Yii::app()->basePath . "/reports/BuktiTerima.php"); //$mailer->addAttachment(Yii::app()->basePath."/reports/bukti_".$id.".pdf"); $mailer->FromName = "Festival of Live 2013"; $mailer->AddAddress("*****@*****.**", "*****@*****.**"); $mailer->Subject = "FOL Bukti Registrasi"; $mailer->Body = "FOL Bukti Registrasi"; $mailer->Send(); $this->redirect(array('/peserta')); }
/** * Создает экземпляр класса по свойству данного модуля, которое содержит * конфигурацию компонента Yii. * * Вызов $module->createProfileForm(), вернет компонент, конфигурация которого * находится в свойстве profileFormConfig * * @param type $name Имя метода * @param type $parameters Параметры * @return type mixed */ protected function _instantiateByConfig($name, $parameters) { $config = str_replace('create', '', $name, $replacements = 1); $config = lcfirst($config) . 'Config'; $config = $this->{$config}; return Yii::createComponent($config); }
/** * Construct a slave connection CDbConnection for read operation. * * @return CDbConnection */ public function getSlave() { if (!isset($this->_slave)) { foreach ($this->slaves as $slaveConfig) { if (!isset($slaveConfig['class'])) { $slaveConfig['class'] = 'CDbConnection'; } try { if ($slave = Yii::createComponent($slaveConfig)) { Yii::app()->setComponent('dbslave', $slave); $this->_slave = $slave; break; } } catch (Exception $e) { Yii::log('Create slave database connection failed!', 'warn'); continue; } } if (!$this->_slave) { $this->_slave = clone $this; $this->_slave->enableSlave = false; } } return $this->_slave; }
public function getFormatter() { if (!isset($this->_formatter)) { $this->_formatter = Yii::createComponent(array('class' => $this->fieldFormatterClass, 'owner' => $this)); } return $this->_formatter; }
public function init() { parent::init(); if ($this->rankKey === null) { if ($this->dataProvider->getItemCount() > 0) { $data = $this->dataProvider->data[0]; $keys = array_keys($data instanceof CActiveRecord ? $data->attributes : $data); $this->rankKey = isset($data['rank']) ? 'rank' : $keys[0]; } } $hasRankColumn = false; foreach ($this->columns as $column) { if ($column instanceof RankColumn) { $hasRankColumn = true; break; } } if ($hasRankColumn === false) { array_unshift($this->columns, Yii::createComponent(array('class' => 'RankColumn', 'value' => '$displayRank', 'header' => Yii::t('statistics', 'Rank')), $this)); } $this->lastRank = $this->rank; if ($this->count != $this->rank && $this->rankKey !== null) { $this->rank++; if ($this->dataProvider->getItemCount() > 0) { $data = $this->dataProvider->data[0]; $this->lastRankValue = CHtml::value($data, $this->rankKey); } } }
public function init() { $data = array('content' => array(), 'error' => Yii::t('main', 'Модуль отключен.')); if (config('forum_threads.allow') == 1) { $data = cache()->get(CacheNames::FORUM_THREADS); if ($data === FALSE) { $data = array(); try { // Подключаюсь к БД $this->db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . config('forum_threads.db_host') . ';port=' . config('forum_threads.db_port') . ';dbname=' . config('forum_threads.db_name'), 'enableProfiling' => YII_DEBUG, 'enableParamLogging' => TRUE, 'username' => config('forum_threads.db_user'), 'password' => config('forum_threads.db_pass'), 'charset' => 'utf8', 'emulatePrepare' => TRUE, 'tablePrefix' => config('forum_threads.prefix'))); app()->setComponent('ForumThreadsDb', $this->db); $forumType = config('forum_threads.type'); if (method_exists($this, $forumType)) { $data['content'] = $this->{$forumType}(); foreach ($data['content'] as $k => $v) { $data['content'][$k]['user_link'] = $this->getUserLink($v['starter_id'], $v['starter_name']); $data['content'][$k]['theme_link'] = $this->getForumLink($v['id_topic'], $v['title'], $v['id_forum']); $data['content'][$k]['start_date'] = $this->getStartDate($v['start_date']); } if (config('forum_threads.cache')) { cache()->set(CacheNames::FORUM_THREADS, $data, config('forum_threads.cache') * 60); } } else { $data['error'] = Yii::t('main', 'Метод для обработки форума: :type не найден.', array(':type' => '<b>' . $forumType . '</b>')); } } catch (Exception $e) { $data['error'] = $e->getMessage(); } } } app()->controller->renderPartial('//forum-threads', $data); }
protected function getToolbarWidget() { if (null === $this->_toolbarWidget) { $this->_toolbarWidget = Yii::createComponent(array('class' => 'YiiDebugToolbar', 'panels' => $this->panels), $this); } return $this->_toolbarWidget; }
public function run($args) { $user_info = Admin::model()->findAll(); $count = Advice::model()->count('status=0'); foreach ($user_info as $row) { if ($row->send_email == 0 || empty($row->email)) { continue; } $message = "您今天新增" . $count . "条后勤办反馈建议\n\t \t\t'http://localhost/logistics/index.php?r=admin/index/index' 点击链接登录后台进行查看"; $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); $mailer->Host = 'smtp.qq.com'; $mailer->IsSMTP(); $mailer->SMTPAuth = true; $mailer->From = '*****@*****.**'; $mailer->AddReplyTo("{$row->email}"); $mailer->AddAddress("{$row->email}"); $mailer->FromName = '你大爷'; $mailer->Username = '******'; //这里输入发件地址的用户名 $mailer->Password = '******'; //这里输入发件地址的密码 $mailer->SMTPDebug = true; //设置SMTPDebug为true,就可以打开Debug功能,根据提示去修改配置 $mailer->CharSet = 'UTF-8'; $mailer->Subject = Yii::t('demo', 'Yii rulez!'); $mailer->Body = $message; $x = $mailer->Send(); $x = $mailer->Send(); } }
public function send() { // $this->body = (new CController('__MAIL__'))->renderPartial( Yii::app()->basePath .'application.widgets.mailSender.views.'.$this->view,$this->dataArray, true); $this->body = CBaseController::renderInternal(Yii::app()->basePath . '/widgets/mailSender/views/' . $this->view . '.php', $this->dataArray, true); $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); $mailer->From = $this->from; $mailer->FromName = $this->from_name; if (is_array($this->recipient)) { foreach ($this->recipient as $key => $recipient) { $mailer->AddAddress($recipient); } } elseif (is_string($this->recipient)) { $mailer->AddAddress($this->recipient); } $mailer->isHTML($this->html); $mailer->Subject = $this->subject; $mailer->Body = $this->body; $mailer->CharSet = 'UTF-8'; if ($this->attachments) { foreach ($this->attachments as $key => $attachment) { $mailer->AddAttachment($attachment['file_path'], $attachment['file_name']); } } $result = $mailer->Send(); return $result; }
public function parseUrl($request) { if ($this->getUrlFormat() === self::PATH_FORMAT) { $rawPathInfo = $request->getPathInfo(); if (Settings::get('SEO', 'slugs_enabled') && ($p = Slug::getPath($rawPathInfo))) { $rawPathInfo = trim($p, '/'); Yii::app()->punish = 0; } $pathInfo = $this->removeUrlSuffix($rawPathInfo, $this->urlSuffix); foreach ($this->_rules as $i => $rule) { if (is_array($rule)) { $this->_rules[$i] = $rule = Yii::createComponent($rule); } if (($r = $rule->parseUrl($this, $request, $pathInfo, $rawPathInfo)) !== false) { return isset($_GET[$this->routeVar]) ? $_GET[$this->routeVar] : $r; } } if ($this->useStrictParsing) { throw new AweException(404, Yii::t('yii', 'Unable to resolve the request "{route}".', array('{route}' => $pathInfo))); } else { return $pathInfo; } } else { if (isset($_GET[$this->routeVar])) { return $_GET[$this->routeVar]; } else { if (isset($_POST[$this->routeVar])) { return $_POST[$this->routeVar]; } else { return ''; } } } }
/** * Sets up the database connection. * @param $dsn The datasource name. See: <a href="http://nl3.php.net/manual/en/pdo.construct.php">http://nl3.php.net/manual/en/pdo.construct.php</a> * @code * "sqlite:database.txt" * "mysql:host=localhost;dbname=oodb" * "pgsql:host=localhost;dbname=oodb" * @endcode * @param $username The database user's login username. * @param $password The database user's login password. */ public static function setup($dsn, $username, $password) { assert('is_string($dsn) && $dsn != ""'); assert('$username == null || is_string($username) && $username != ""'); assert('$password == null || is_string($password)'); assert('!self::isSetup()'); try { ZurmoRedBean::setup($dsn, $username, $password); static::freeze(); if (SHOW_QUERY_DATA) { Yii::app()->performance->setRedBeanQueryLogger(ZurmoRedBeanPluginQueryLogger::getInstanceAndAttach(ZurmoRedBean::$adapter)); } if (defined('REDBEAN_DEBUG_TO_FILE') && REDBEAN_DEBUG_TO_FILE) { $queryLoggerComponent = Yii::createComponent(array('class' => 'application.core.models.ZurmoRedBeanQueryFileLogger')); $queryLoggerComponent->init(); Yii::app()->setComponent('queryFileLogger', $queryLoggerComponent); ZurmoRedBean::debug(true, Yii::app()->queryFileLogger); } else { ZurmoRedBean::debug(defined('REDBEAN_DEBUG') && REDBEAN_DEBUG); } self::$isSetup = true; self::$databaseType = substr($dsn, 0, strpos($dsn, ':')); } catch (Exception $e) { self::close(); throw $e; } assert('static::isSetup()'); assert('RedBeanDatabase::isFrozen()'); }
/** * 发送邮件 * @param unknown_type $sendmail * @param unknown_type $subject * @param unknown_type $content * @param unknown_type $replyto * @param unknown_type $fromname * @param unknown_type $fromaddr */ public static function postMail($sendmail, $subject, $content, $replyto = "", $fromname = "", $fromaddr = "") { global $sysSettings; if (!$replyto) { $replyto = $sysSettings['mailer']['username']; } $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); $mailer->Host = $sysSettings['mailer']['host']; // var_dump($mailer->Host); // $mailer->SMTPDebug = 1; $mailer->IsSMTP(); $mailer->SMTPAuth = true; $mailer->From = $sysSettings['mailer']['username']; // $mailer->From = $fromaddr; $mailer->AddReplyTo($replyto); $mailer->AddAddress($sendmail); $mailer->Username = $sysSettings['mailer']['username']; $mailer->Password = $sysSettings['mailer']['password']; $mailer->FromName = $sysSettings['site']['name']; $mailer->CharSet = 'UTF-8'; $mailer->Subject = $subject; $mailer->Body = $content; $mailer->IsHTML(); return $mailer->Send(); }
/** * Gets the redis connection to use with this test * @return ARedisConnection the redis connection */ public function getConnection() { if ($this->_connection === null) { $this->_connection = Yii::createComponent(array("class" => "packages.redis.ARedisConnection", "hostname" => REDIS_HOSTNAME, "port" => REDIS_PORT, "database" => REDIS_DATABASE)); } return $this->_connection; }
protected function initColumns() { if ($this->columns === array()) { // use the keys of the first row of data as the default columns $data = $this->dataProvider->getData(); if (isset($data[0]) && is_array($data[0])) { $this->columns = array_keys($data[0]); } } $id = $this->getId(); foreach ($this->columns as $i => $column) { if (is_string($column)) { $column = $this->createDataColumn($column); } else { if (!isset($column['class'])) { $column['class'] = 'CDataColumn'; } $column = Yii::createComponent($column, $this); } if (!$column->visible) { unset($this->columns[$i]); continue; } if ($column->id === null) { $column->id = $id . '_c' . $i; } $this->columns[$i] = $column; } foreach ($this->columns as $column) { $column->init(); } }
public function Reestablecerpassword($email) { $message = '<html> <body > <h1>¡Hola!</h1> <br> Para reestablecer su contraseña, clickea o pega la siguiente URL en el navegador que quieras: <br> "http://localhost/DOFIT_FINAL/DoFit/aplication/usuario/Recuperarpassword2/?email=' . $email . '; <br> ¡Muchas Gracias! Que disfrutes de la web. <br> El equipo de <b>DoFit!</b>. </body> </html>'; $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); $mailer->SMTPDebug = 1; $mailer->Host = 'ssl://smtp.gmail.com'; $mailer->SMTPAuth = true; $mailer->IsHTML(true); $mailer->IsSMTP(); $mailer->Port = '465'; $mailer->From = '*****@*****.**'; $mailer->Username = '******'; $mailer->Password = '******'; $mailer->AddAddress($email); $mailer->FromName = 'Dofit!'; $mailer->CharSet = 'UTF-8'; $mailer->Subject = 'Reestabler contraseña de DoFit!'; $mailer->Body = $message; $mailer->Send(); }
public static function mysql($params) { $vars = array('hostname', 'port', 'username', 'password', 'basename', 'prefix', 'create'); foreach ($vars as $var) { if (!empty($params[$var]) && isset($_POST[$params[$var]])) { ${$var} = $_POST[$params[$var]]; } } $db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . $hostname . ';port=' . $port . ';dbname=' . $basename, 'username' => $username, 'password' => $password, 'tablePrefix' => $prefix, 'charset' => 'utf8')); $params['status'] = true; try { $db->setActive(true); } catch (CDbException $e) { if (!empty($create)) { $db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . $hostname . ';port=' . $port, 'username' => $username, 'password' => $password, 'tablePrefix' => $prefix, 'charset' => 'utf8')); try { $db->createCommand('create database `' . $basename . '`')->execute(); } catch (CDbException $e) { $params['status'] = false; $params['message'] = $e->getMessage(); } } else { $params['status'] = false; $params['message'] = $e->getMessage(); } } if ($params['status'] && !empty($params['needEmpty'])) { if (count($db->createCommand('show tables' . ($prefix ? '' : ' like "' . $prefix . '%"'))->queryColumn())) { $params['status'] = false; $params['message'] = 'Database is not empty'; } } return $params; }
/** * Enhanced mail function. * * @author Chunsheng Wang <*****@*****.**> * @param string $toList To address list. * @param string $ccList CC address list. * @param string $subject Subject. * @param string $message Message. */ public static function sysMail($toList, $ccList, $subject, $message) { if (CommonService::$TrueFalseStatus['TRUE'] != Yii::app()->params->mail['on']) { return; } // Create an object of PHPMailer class and set the send method $mailInfo = Yii::createComponent('application.extensions.mailer.EMailer'); //$mailInfo = new PHPMailer(); switch (Yii::app()->params->mail['send_method']) { case "SMTP": $mailInfo->isSMTP(); $mailInfo->Host = Yii::app()->params->mail['send_params']['host']; $mailInfo->SMTPAuth = Yii::app()->params->mail['send_params']["smtp_auth"]; $mailInfo->Username = Yii::app()->params->mail['send_params']["username"]; $mailInfo->Password = Yii::app()->params->mail['send_params']["password"]; break; case "MAIL": $mailInfo->isMail(); break; case "SENDMAIL": $mailInfo->isSendmail(); break; case "QMAIL": $mailInfo->isQmail(); break; } // Define From Address. $mailInfo->From = Yii::app()->params->mail['from_address']; $mailInfo->FromName = Yii::app()->params->mail['from_name']; if (!is_array($toList) && $toList != '') { $toList = explode(',', $toList); } if (empty($toList) && is_array($ccList) && !empty($ccList)) { $toList[] = array_pop($ccList); } if (empty($toList)) { return false; } foreach ($toList as $to) { $mailInfo->addAddress($to); } // Add To Address. if (is_array($ccList)) { $ccList = array_diff($ccList, $toList); $ccList = array_unique($ccList); foreach ($ccList as $CC) { $mailInfo->addCC($CC); } } // Add Subject. $mailInfo->Subject = "=?UTF-8?B?" . base64_encode(stripslashes($subject)) . "?="; // Set Body. $mailInfo->IsHTML(true); $mailInfo->CharSet = 'UTF-8'; $mailInfo->Body = $message; if (!$mailInfo->Send()) { Yii::log('mail send failed:' . json_encode($mailInfo->ErrorInfo), 'error', 'bugfree.ProductService'); } }
public function testLoad_06() { $c = Yii::createComponent(array('class' => 'application.extensions.simpleWorkflow.SWPhpWorkflowSource', 'basePath' => 'application.tests.unit.phpworkflowsource.workflows', 'definitionType' => 'class')); $c->init(); $this->assertFalse($c->isWorkflowLoaded('SWWorkflow2')); $this->assertTrue($c->loadWorkflow('SWWorkflow2')); $this->assertTrue($c->isWorkflowLoaded('SWWorkflow2')); }
public function getSchema() { if ($this->_schema === null) { $this->_schema = Yii::createComponent('LoomDbSchema', $this); } $this->_schema->setDbName($this->getDbName()); return $this->_schema; }