本文整理汇总了PHP中waAppSettingsModel::set方法的典型用法代码示例。如果您正苦于以下问题:PHP waAppSettingsModel::set方法的具体用法?PHP waAppSettingsModel::set怎么用?PHP waAppSettingsModel::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waAppSettingsModel
的用法示例。
在下文中一共展示了waAppSettingsModel::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCount
public function onCount()
{
return;
$settings_model = new waAppSettingsModel();
$settings = $settings_model->get('wacab');
if (!isset($settings['count']) || $settings['count'] == 0) {
return null;
}
if (!isset($settings['count_ts'])) {
$settings_model->set('wacab', 'count_ts', time());
return null;
}
if (!isset($settings['timeout'])) {
$settings['timeout'] = 60;
}
if (time() - $settings['count_ts'] < $settings['timeout'] * 60) {
return null;
}
$auth = new wacabWaauth();
$new = new wacabGetpayment();
$ps = $new->getPayment($auth);
if (isset($settings['new_count'])) {
$newcount = $settings['new_count'] + $ps;
} else {
$newcount = 0;
}
$settings_model->set('wacab', 'new_count', $newcount);
$settings['count_ts'] = time();
unset($auth);
if ($newcount == 0) {
return null;
} else {
return array('count' => $newcount, 'url' => wa()->getUrl(true) . 'wacab/#/transactions/');
}
}
示例2: execute
public function execute()
{
$model = new shopStockModel();
foreach ($this->getEditData() as $id => $item) {
$model->updateById($id, $item);
}
$inventory_stock_id = null;
foreach ($this->getAddData() as $before_id => $data) {
foreach ($data as $item) {
$id = $model->add($item, $before_id);
if (!empty($item['inventory'])) {
$inventory_stock_id = $id;
}
}
}
if ($inventory_stock_id) {
// Assign all inventory to this stock
$product_stocks_model = new shopProductStocksModel();
$product_stocks_model->insertFromSkus($inventory_stock_id);
}
$app_id = $this->getAppId();
$app_settings_model = new waAppSettingsModel();
if (waRequest::post('ignore_stock_count')) {
$app_settings_model->set($app_id, 'ignore_stock_count', 1);
} else {
$app_settings_model->set($app_id, 'ignore_stock_count', 0);
}
if (waRequest::post('update_stock_count_on_create_order')) {
$app_settings_model->set($app_id, 'update_stock_count_on_create_order', 1);
} else {
$app_settings_model->set($app_id, 'update_stock_count_on_create_order', 0);
}
}
示例3: setCount
public function setCount($n = null)
{
wa()->getStorage()->open();
$model = new waAppSettingsModel();
$app_id = $this->getApplication();
$model->set($app_id, 'update_counter', $n);
$model->set($app_id, 'update_counter_timestamp', $n === false ? 0 : time());
return parent::setCount($n);
}
示例4: execute
public function execute()
{
$plugin_id = array('shop', 'orderstock');
try {
$app_settings_model = new waAppSettingsModel();
$settings = waRequest::post('settings');
$state_ids = implode(',', $settings['states']);
$app_settings_model->set($plugin_id, 'status', (int) $settings['status']);
$app_settings_model->set($plugin_id, 'state_ids', $state_ids);
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
示例5: execute
public function execute()
{
if (wa()->getUser()->getRights('wacab', 'backend') >= 2) {
$settings = waRequest::get('settings');
$settings_model = new waAppSettingsModel();
foreach ($settings as $key => $s) {
if (is_array($s)) {
$settings_model->set('wacab', $key, json_encode($s));
} else {
$settings_model->set('wacab', $key, $s);
}
}
} else {
$this->setError(_wp('No permission to add the server'));
}
}
示例6: execute
function execute()
{
try {
$message = array();
$settings = waRequest::get('setting');
if ($settings) {
$model = new waAppSettingsModel();
$changed = false;
foreach ((array) $settings as $setting) {
if (in_array($setting, array('auth_form_background'))) {
if ($value = $model->get('webasyst', $setting)) {
waFiles::delete(wa()->getDataPath($value, true, 'webasyst'));
$message[] = _w('Image deleted');
}
} else {
$changed = true;
}
$model->set('webasyst', $setting, false);
}
if ($changed) {
$message[] = _w('Settings saved');
}
}
$params = array('module' => 'settings', 'msg' => installerMessage::getInstance()->raiseMessage(implode(', ', $message)));
$this->redirect($params);
} catch (waException $ex) {
$msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL);
$params = array('module' => 'settings', 'msg' => $msg);
$this->redirect($params);
}
}
示例7: execute
public function execute()
{
ob_start();
$app = $this->getApp();
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set($app, 'cron_schedule', time());
waFiles::create($this->getConfig()->getPath('log') . '/' . $app . '/');
$log_file = "{$app}/cron.txt";
$post_model = new blogPostModel();
$params = array('datetime' => date("Y-m-d H:i:s"), 'status' => blogPostModel::STATUS_SCHEDULED);
$posts_schedule = $post_model->select("id,blog_id,contact_id,status,datetime")->where('datetime <= s:datetime AND status=s:status', $params)->fetchAll();
if ($posts_schedule) {
foreach ($posts_schedule as $post) {
try {
waLog::log("Attempt publishing post with id [{$post['id']}]", $log_file);
$data = array("status" => blogPostModel::STATUS_PUBLISHED);
waLog::log($post_model->updateItem($post['id'], $data, $post) ? "success" : "fail", $log_file);
} catch (Exception $ex) {
waLog::log($ex->getMessage(), $log_file);
waLog::log($ex->getTraceAsString(), $log_file);
}
}
}
$action = __FUNCTION__;
/**
* @event cron_action
* @param string $action
* @return void
*/
wa()->event('cron_action', $action);
if ($log = ob_get_clean()) {
waLog::log($log, $log_file);
}
}
示例8: postPublishAction
public function postPublishAction($params)
{
$post_id = (int) $params['id'];
$blog_id = (int) $params['blog_id'];
// check rights for this blog at first and unsubscribe user if he hasn't
$sql = "SELECT c.id FROM blog_emailsubscription s\n JOIN wa_contact c ON s.contact_id = c.id\n WHERE s.blog_id = " . $blog_id;
$model = new waModel();
$unsubscribe_contact_ids = array();
foreach ($model->query($sql) as $row) {
$rights = 1;
try {
$rights = blogHelper::checkRights($blog_id, $row['id'], blogRightConfig::RIGHT_READ);
} catch (Exception $e) {
$rights = 0;
}
if (!$rights) {
$unsubscribe_contact_ids[] = $row['id'];
}
}
if ($unsubscribe_contact_ids) {
$em = new blogEmailsubscriptionModel();
$em->deleteByField(array('contact_id' => $unsubscribe_contact_ids, 'blog_id' => $blog_id));
}
// add subscribers to queue
$sql = "REPLACE INTO blog_emailsubscription_log (post_id, contact_id, name, email, datetime)\n SELECT " . $post_id . ", c.id, c.name, e.email, '" . date('Y-m-d H:i:s') . "' FROM blog_emailsubscription s\n JOIN wa_contact c ON s.contact_id = c.id\n JOIN wa_contact_emails e ON c.id = e.contact_id AND e.sort = 0\n WHERE s.blog_id = " . $blog_id;
$model->exec($sql);
// save backend url for cron
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set(array($this->app_id, $this->id), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
}
示例9: execute
public function execute()
{
$type = waRequest::request('type');
if (!$type) {
return;
}
$asm = new waAppSettingsModel();
$asm->set('shop', 'discount_' . $type, waRequest::request('enable') ? 1 : null);
}
示例10: saveDomainsSettings
public static function saveDomainsSettings($domains_settings)
{
$app_settings_model = new waAppSettingsModel();
$routing = wa()->getRouting();
$domains_routes = $routing->getByApp('shop');
$app_settings_model->set(shopPricePlugin::$plugin_id, 'domains_settings', json_encode($domains_settings));
$cache = new waSerializeCache('shopPricePlugin');
if ($cache && $cache->isCached()) {
$cache->delete();
}
}
示例11: postPublishAction
public function postPublishAction($params)
{
$post_id = (int) $params['id'];
$blog_id = (int) $params['blog_id'];
// add subscribers to queue
$sql = "REPLACE INTO blog_emailsubscription_log (post_id, contact_id, name, email, datetime)\n SELECT " . $post_id . ", c.id, c.name, e.email, '" . date('Y-m-d H:i:s') . "' FROM blog_emailsubscription s\n JOIN wa_contact c ON s.contact_id = c.id\n JOIN wa_contact_emails e ON c.id = e.contact_id AND e.sort = 0\n WHERE s.blog_id = " . $blog_id;
$model = new waModel();
$model->exec($sql);
// save backend url for cron
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set(array($this->app_id, $this->id), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
}
示例12: execute
public function execute()
{
$asm = new waAppSettingsModel();
if (waRequest::post()) {
$conf = waRequest::post('conf');
if ($conf && is_array($conf)) {
$conf['affiliate_credit_rate'] = str_replace(',', '.', (double) str_replace(',', '.', ifset($conf['affiliate_credit_rate'], '0')));
$conf['affiliate_usage_rate'] = str_replace(',', '.', (double) str_replace(',', '.', ifset($conf['affiliate_usage_rate'], '0')));
foreach ($conf as $k => $v) {
$asm->set('shop', $k, $v);
}
}
}
$enabled = shopAffiliate::isEnabled();
$def_cur = waCurrency::getInfo(wa()->getConfig()->getCurrency());
$tm = new shopTypeModel();
$product_types = $tm->getAll();
$conf = $asm->get('shop');
if (!empty($conf['affiliate_product_types'])) {
$conf['affiliate_product_types'] = array_fill_keys(explode(',', $conf['affiliate_product_types']), true);
} else {
$conf['affiliate_product_types'] = array();
}
$this->view->assign('conf', $conf);
$this->view->assign('enabled', $enabled);
$this->view->assign('product_types', $product_types);
$this->view->assign('def_cur_sym', ifset($def_cur['sign'], wa()->getConfig()->getCurrency()));
/**
* Backend affiliate settings
*
* Plugins are expected to return one item or a list of items to to add to affiliate menu.
* Each item is represented by an array:
* array(
* 'id' => string, // Required.
* 'name' => string, // Required.
* 'url' => string, // Required (unless you hack into JS using 'html' parameter). Content for settings page is fetched from this URL.
* )
*
* @event backend_settings_discounts
*/
$plugins = wa()->event('backend_settings_affiliate');
$config = wa('shop')->getConfig();
foreach ($plugins as $k => &$p) {
if (substr($k, -7) == '-plugin') {
$plugin_id = substr($k, 0, -7);
$plugin_info = $config->getPluginInfo($plugin_id);
$p['img'] = $plugin_info['img'];
}
}
$this->view->assign('plugins', $plugins);
$this->view->assign('installer', $this->getUser()->getRights('installer', 'backend'));
}
示例13: execute
public function execute()
{
$plugin_id = array('shop', 'deliveryshop');
try {
$app_settings_model = new waAppSettingsModel();
$settings = waRequest::post('settings');
$app_settings_model->set($plugin_id, 'status', (int) $settings['status']);
$model = new waModel();
$domains = $model->query("SELECT * FROM site_domain")->fetchAll();
$reset_tpls = waRequest::post('reset_tpls');
$template = waRequest::post('template');
$prices = waRequest::post('prices');
$this->response['pri'] = $prices;
foreach ($domains as $d) {
$id_price = $model->query("SELECT id FROM shop_deliveryshop_delivery WHERE domain = '" . $d['name'] . "'")->fetchField();
if ($id_price) {
$model->query("UPDATE shop_deliveryshop_delivery SET price = '" . $prices[$d['name']]['price'] . "' WHERE domain = '" . $d['name'] . "'");
} else {
$model->query("INSERT INTO shop_deliveryshop_delivery (domain, price)\n VALUES ('" . $d['name'] . "', '" . $prices[$d['name']]['price'] . "')");
}
if (isset($reset_tpls[$d['name']])) {
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
@unlink($template_path);
} else {
if (!isset($template[$d['name']])) {
throw new waException('Не определён шаблон');
}
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
if (!file_exists($template_path)) {
$template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
}
$template_content = file_get_contents($template_path);
if ($template_content != $template[$d['name']]) {
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
$f = fopen($template_path, 'w');
if (!$f) {
throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path);
}
fwrite($f, $template[$d['name']]);
fclose($f);
}
}
$this->response['template'] = $template;
}
$this->response['message'] = "Сохранено";
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
示例14: run
public function run($params = NULL)
{
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set(array('blog', 'emailsubscription'), 'last_emailsubscription_cron_time', time());
$model = new blogEmailsubscriptionLogModel();
$row = $model->getByField('status', 0);
if ($row) {
$post_id = $row['post_id'];
$post_model = new blogPostModel();
$post = $post_model->getById($post_id);
$blog_model = new blogBlogModel();
$blog = $blog_model->getById($post['blog_id']);
$subject = $blog['name'] . ': ' . $post['title'];
$post_title = htmlspecialchars($post['title']);
if ($blog['status'] == blogBlogModel::STATUS_PUBLIC) {
$post_url = blogPost::getUrl($post);
} else {
$app_settings_model = new waAppSettingsModel();
$post_url = $app_settings_model->get(array('blog', 'emailsubscription'), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
$post_url .= "/blog/?module=post&id=" . $post_id;
}
$blog_name = htmlspecialchars($blog['name']);
$body = '<html><body>' . sprintf(_wp("New post in the blog “%s”"), $blog_name) . ': <strong><a href="' . $post_url . '">' . $post_title . '</a></strong></body></html>';
$message = new waMailMessage();
$message->setEncoder(Swift_Encoding::getBase64Encoding());
$message->setSubject($subject);
$message->setBody($body);
$rows = $model->getByField(array('status' => 0, 'post_id' => $post_id), true);
$message_count = 0;
foreach ($rows as $row) {
try {
$message->setTo($row['email'], $row['name']);
$status = $message->send() ? 1 : -1;
$model->setStatus($row['id'], $status);
if ($status) {
$message_count++;
}
} catch (Exception $e) {
$model->setStatus($row['id'], -1, $e->getMessage());
}
}
/**
* Notify plugins about sending emailsubscripition
* @event followup_send
* @return void
*/
wa()->event('emailsubscription_send', $message_count);
}
}
示例15: execute
public function execute()
{
try {
$app_settings_model = new waAppSettingsModel();
$shop_price = waRequest::post('shop_price');
$domains_settings = waRequest::post('domains_settings', array());
foreach ($shop_price as $key => $value) {
$app_settings_model->set(shopPricePlugin::$plugin_id, $key, $value);
}
shopPrice::saveDomainsSettings($domains_settings);
$this->response['message'] = "Сохранено";
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}