本文整理汇总了PHP中Settings::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::model方法的具体用法?PHP Settings::model怎么用?PHP Settings::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register()
{
$user = new Users();
$user->attributes = $this->attributes;
$salt = md5(uniqid() . time());
$user->email = $this->email;
$user->salt = $salt;
$user->pass = crypt(trim($this->pass) . $salt);
if ($user->validate() && $user->save()) {
if (!Settings::model()->getValue('mail_confirm')) {
$user->status = 1;
$user->save();
return 1;
}
Yii::import('ext.YiiMailer.YiiMailer');
$code = md5(md5($user->pass . $user->email));
$mail = new YiiMailer();
$mail->setFrom(Settings::model()->getValue('register'));
$mail->setTo($user->email);
$mail->setSubject(Yii::t('register', 'Account activation'));
$mail->setBody(Yii::t('register', "Hello {nick},<br/><br/>Your activation code: {code}<br/>{link}", array('{nick}' => $user->nick, '{code}' => $code, '{link}' => Yii::app()->createAbsoluteUrl('site/confirm', array('user' => $user->nick, 'code' => $code)))));
$mail->send();
return 1;
}
}
示例2: init
public function init()
{
$this->_logger->log(__METHOD__);
$this->settings = Settings::model()->find();
$this->synchronization = new Synchronization();
return true;
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Page();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Page'])) {
// echo "<pre>";print_r($model->attributes); echo "</pre>";
$arr = $_POST["Page"];
if (empty($arr["user_id"])) {
$arr['user_id'] = Yii::app()->user->id;
}
if (empty($arr["date"])) {
$arr["date"] = time();
}
if (empty($arr["status"])) {
$setting = Settings::model()->findByPk(1);
if ($setting->defaultPageStatus == 1) {
$arr["status"] = 0;
} else {
$arr["status"] = 1;
}
}
if (empty($arr["category_id"])) {
$arr["category_id"] = 1;
}
$model->attributes = $arr;
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例4: filesUpdate
private static function filesUpdate($data)
{
$version = $data['version'];
$data = $data['data'];
foreach ($data as $zip) {
if (preg_match('/\\{YiiPath:(.*?)\\}/si', $zip['name'], $path)) {
$dir = Yii::getPathOfAlias($path[1]) . '/';
if (file_exists($dir)) {
$zip['name'] = preg_replace('/\\{YiiPath:(.*?)\\}/si', $dir, $zip['name']);
} elseif (!mkdir($dir)) {
Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('admin', 'Can`t create dir: {dir}', array('{dir}' => $dir))));
return;
}
}
$zip['name'] = str_replace(array('{tmp}', '{dir}'), array(TMP, DIR), $zip['name']);
if (file_exists($zip['name']) && is_writeable($zip['name']) || !file_exists($zip['name']) && is_writeable(dirname($zip['name']))) {
file_put_contents($zip['name'], base64_decode($zip['data']));
} else {
Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('admin', 'Can`t create file: {file}', array('{file}' => $zip['name']))));
return;
}
}
$model = Settings::model()->findByAttributes(array('option' => 'version'));
$model->value = $version;
$model->save();
return true;
}
示例5: loadModel
public function loadModel($id)
{
$model=Settings::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
示例6: __construct
/**
*构造方法获取公共的变量参数
*
*/
public function __construct($id, $module = null)
{
parent::__construct($id, $module);
/**
* 该段代码用于获取后台的设置信息,
* 并将获得的信息缓存&读取到公共的Settings变量中.
*/
$this->Settings = Yii::app()->cache->get('Settings');
if (!$this->Settings) {
$Info = Settings::model()->findAllBySql("SELECT * FROM {{settings}}");
$ArraySettings = array();
foreach ($Info as $key) {
$ArraySettings[$key->key] = $key->value;
}
$this->Settings = (object) $ArraySettings;
Yii::app()->cache->set('Settings', $this->Settings, 10);
}
/**
* 如果用户登录了
* 该段代码调用了经过权限处理后的操作模块,
* 否则跳转回登录页
*/
if (Yii::app()->session->get('IsLogin') || $this->getId('login')) {
$this->roleAction = $this->actionMeun();
} else {
$Url = $this->createUrl('admin/Login/Login');
$this->redirect($Url);
}
}
示例7: getValue
public static function getValue($name)
{
if ($settings = Settings::model()->findByAttributes(array('name' => $name))) {
return $settings->value;
}
throw new Exception('Can\'t get settings by name ' . $name);
}
示例8: actionIndex
public function actionIndex()
{
if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) {
$this->redirect(Yii::app()->homeUrl);
}
$this->pageTitle = Yii::t('title', 'Bound settings');
$form = Settings::model()->find();
if (isset($_POST['Settings'])) {
$form->attributes = $_POST['Settings'];
if (isset($_POST['Settings']['referal_enable'])) {
$form->referal_enable = 1;
} else {
$form->referal_enable = 0;
}
if (isset($_POST['Settings']['trial_enable'])) {
$form->trial_enable = 1;
} else {
$form->trial_enable = 0;
}
if (isset($_POST['Settings']['email_activation'])) {
$form->email_activation = 1;
} else {
$form->email_activation = 0;
}
if ($form->save()) {
Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Settings saved!') . '</div>');
$this->refresh();
}
}
$this->render('/admin/settings', array('form' => $form));
}
示例9: beforeAction
public function beforeAction($action)
{
$criteria = new CDbCriteria();
$criteria->addCondition('status = 1');
$criteria->addCondition('created_by = ' . Yii::app()->user->getInfo());
$this->servicesArray = Services::model()->findAll($criteria);
$arrayForSettings = array();
$Settings = Settings::model()->findAll();
foreach ($Settings as $key => $val) {
$arrayForSettings[$val->setting_name] = $val->setting_value;
}
self::$settings = $arrayForSettings;
$this->pageTitle = Yii::app()->name;
$this->pageName = 'Account';
$this->pageClass = 'blue';
Yii::app()->session['securityCheck'] = md5(ip2long(Yii::app()->request->userHostAddress) + date("Y"));
/* @var $cs CClientScript */
$cs = Yii::app()->clientScript;
// register jQuery script
$cs->registerPackage('jquery');
// register bootstrap script
$cs->registerPackage('bootstrap');
// If application is using a theme, replace default layout controller variable that start with '//layouts/' with a theme link
if (empty(Yii::app()->theme->name) == false && isset($this->layout) == true && strpos($this->layout, '//layouts/') === 0) {
// Replace path with slash by dot.
$sThemeLayout = 'webroot.themes.' . Yii::app()->theme->name . '.views.layouts.' . str_replace('/', '.', substr($this->layout, 10));
// If theme override given layout, get it from theme
if ($this->getLayoutFile($sThemeLayout) !== false) {
$this->layout = $sThemeLayout;
}
}
return true;
}
示例10: actionRegistration
public function actionRegistration()
{
$model = new User();
$model->setScenario('registration');
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$setting = Settings::model()->findByPk(1);
if ($setting->defaultUserStatus == 1) {
$model->status = 0;
} else {
$model->status = 1;
}
if ($model->save()) {
if ($setting->defaultUserStatus == 1) {
Yii::app()->user->setFlash('registration', 'Регистрация прошла успешно. Теперь вы можете авторизоваться..');
} else {
Yii::app()->user->setFlash('registration', 'Ждите подтверждения администратора.');
}
$this->refresh();
}
}
$this->render('registration', array('model' => $model));
}
示例11: actionInline
public function actionInline()
{
if (!Yii::app()->getRequest()->getIsAjaxRequest()) {
$this->redirect(Controller::$settings['site_url'] . "adminPanel/login");
Yii::app()->end();
}
$_pk = Yii::app()->request->getParam("pk");
$_method = Yii::app()->request->getParam("m");
$_value = Yii::app()->request->getParam("value");
$_lang = Yii::app()->request->getParam("l");
$resp = array();
if (isset($_POST) && count($_POST) > 0) {
if ((int) $_pk > 0 && $_pk == (int) $_pk) {
$model = Settings::model()->findByPk($_pk);
if (isset($_lang) && $_lang != '') {
$tmpValue = unserialize($model->setting_value);
if ($tmpValue) {
$tmpValue[$_lang] = $_value;
}
$model->setting_value = serialize($tmpValue);
} else {
$model->setting_value = $_value;
}
if ($model->save()) {
$resp = array('error' => false, 'message' => Yii::t('site', 'Data successfully saved'));
} else {
$errors = array();
foreach ($model->getErrors() as $e) {
$errors = array_merge($errors, $e);
}
$resp = array('error' => true, 'message' => implode("<br />", $errors));
}
} else {
$resp = array('error' => false, 'message' => Yii::t('site', "Unknown param id"));
}
} else {
if (isset($_GET) && count($_GET) > 0) {
switch ($_method) {
case "maintenance":
$resp = array(Yii::t('site', 'Disabled'), Yii::t('site', 'Enabled'));
break;
case "zoom_google_with_scroll":
$resp = array(Yii::t('site', 'Disabled'), Yii::t('site', 'Enabled'));
break;
case "map_type":
$resp = array(Yii::t('site', 'ROADMAP'), Yii::t('site', 'SATELLITE'), Yii::t('site', 'HYBRID'), Yii::t('site', 'TERRAIN'));
break;
case "payment_enabled":
$resp = array(Yii::t('site', 'Disabled'), Yii::t('site', 'Enabled'));
break;
default:
$resp = array('error' => false, 'message' => Yii::t('site', "Unknown method"));
break;
}
}
}
header('Content-Type: application/json');
echo json_encode($resp);
}
示例12: init
public function init()
{
$model = Settings::model()->findByPk(1);
$this->site_name = $model->site_name;
$this->email = $model->email;
$this->top_news_count = $model->top_news_count;
$this->short_description_symbols = $model->short_description_symbols;
}
示例13: sendReport
protected function sendReport($sendLogObject)
{
if (is_object($sendLogObject->report_processed->ex_schedule_report)) {
$file_name = $sendLogObject->report_processed->getFileName($sendLogObject->report_processed->ex_schedule_report);
$file_path = $sendLogObject->report_processed->full_file_name;
if ($sendLogObject->destination->method === 'mail') {
$this->logger->log(__METHOD__, array('method' => $sendLogObject->destination->method, 'email' => $sendLogObject->destination->destination_email));
$mail_params = array('actuality_time' => $sendLogObject->created, 'schedule_period' => '', 'report_file_name' => $file_name, 'link' => '', 'report_type' => $sendLogObject->report_processed->ex_schedule_report->report_type);
$subject = Yii::t('letter', 'scheduled_report_mail_subject', $mail_params, null, 'en');
$settings = Settings::model()->findByPk(1);
$mailSender = new mailSender('odss_reports', array());
$sendResult = $mailSender->setAttachments(array(array('file_path' => $file_path, 'file_name' => $file_name)))->setRecipient($sendLogObject->destination->destination_email)->setFrom($settings->mail__sender_address, $settings->mail__sender_name)->setSubject($subject)->setHtmlBody()->send();
if ($sendResult !== false) {
$sendLogObject->sent = 1;
$sendLogObject->save();
}
$this->logger->log(__METHOD__ . ' $sendResult: ' . $sendResult);
$this->logger->log(__METHOD__ . ' Message send with attached file');
$this->logger->log(__METHOD__ . ' Deliver via mail DONE.');
} else {
if ($sendLogObject->destination->method === 'ftp') {
// use it if you have some superstition about "../"
// $fileCopier = new FileCopier;
// $file_path = $fileCopier->rmPathSteps($file_path);
$ftpClient = new FtpClient();
$errors = $ftpClient->connect($sendLogObject->destination->destination_ip, $sendLogObject->destination->destination_ip_port)->login($sendLogObject->destination->destination_ip_user, $sendLogObject->destination->destination_ip_password)->setFolder($sendLogObject->destination->destination_ip_folder)->openLocalFile($file_path)->upload($file_name)->closeLocalFile()->getErrors();
if (!count($errors)) {
$sendLogObject->sent = 1;
$sendLogObject->save();
} else {
$sendLogObject->send_logs = serialize($errors);
$sendLogObject->save();
}
$this->logger->log(__METHOD__ . " ftp errors:" . print_r($errors, 1));
$this->logger->log(__METHOD__ . ' Deliver via ftp DONE.');
} else {
if ($sendLogObject->destination->method === 'local_folder') {
$this->logger->log(__METHOD__, array('report_type' => $sendLogObject->report_processed->ex_schedule_report->report_type, 'method' => $sendLogObject->destination->method, 'destination_folder' => $sendLogObject->destination->destination_local_folder));
$destinationPath = $sendLogObject->report_processed->getFileDir() . DIRECTORY_SEPARATOR . $sendLogObject->destination->destination_local_folder;
$this->logger->log(__METHOD__ . ' $file_path: ' . $file_path);
$this->logger->log(__METHOD__ . ' $destinationPath: ' . $destinationPath);
$this->logger->log(__METHOD__ . ' $file_name: ' . $file_name);
$fileCopier = new FileCopier();
$errors = $fileCopier->copy($file_path, $destinationPath . DIRECTORY_SEPARATOR . $file_name)->getErrors();
if (!count($errors)) {
$sendLogObject->sent = 1;
$sendLogObject->save();
} else {
$sendLogObject->send_logs = serialize($errors);
$sendLogObject->save();
}
$this->logger->log(__METHOD__ . ' errors:' . print_r($errors, 1));
$this->logger->log(__METHOD__ . ' Deliver to local folder DONE.');
}
}
}
}
}
示例14: beforeAction
public function beforeAction($action)
{
Yii::app()->clientScript->registerCoreScript('jquery');
$o_db = Settings::model()->findAll();
foreach ($o_db as $item) {
$this->settings[$item->alias] = $item->value;
}
return parent::beforeAction($action);
}
示例15: beforeAction
public function beforeAction($action)
{
$o_db = Settings::model()->findAll();
foreach ($o_db as $item) {
$this->settings[$item->alias] = $item->value;
}
$this->project = Projects::model()->getProjectByDomain($_SERVER['HTTP_HOST']);
return parent::beforeAction($action);
}