本文整理汇总了PHP中waModel类的典型用法代码示例。如果您正苦于以下问题:PHP waModel类的具体用法?PHP waModel怎么用?PHP waModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了waModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: execute
public function execute()
{
$model_settings = new waAppSettingsModel();
$settings = $model_settings->get($key = array('shop', 'deliveryshop'));
$model = new waModel();
$domains = $model->query("SELECT * FROM site_domain")->fetchAll();
$prices = $model->query("SELECT * FROM shop_deliveryshop_delivery")->fetchAll('domain');
foreach ($domains as $d) {
$tab = explode('.', $d['name']);
$info[$d['name']]['tab_name'] = $tab[0];
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
$change_tpl[$d['name']] = true;
if (!file_exists($template_path)) {
$template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
$change_tpl[$d['name']] = false;
}
$template_content[$d['name']] = file_get_contents($template_path);
unset($template_path);
}
$this->view->assign('info', $info);
$this->view->assign('prices', $prices);
$this->view->assign('change_tpl', $change_tpl);
$this->view->assign('template', $template_content);
$this->view->assign('settings', $settings);
}
示例3: execute
public function execute()
{
$model = new waModel();
$payment_model = new wacabPaymentModel();
$payments = $payment_model->getAll();
$apps_model = new wacabAppsModel();
$apps = $apps_model->getByField('stat', 1, true);
$total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` is not null')->fetchAll();
$plugins_stat = array();
foreach ($apps as $app) {
$app_total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` = ' . $app['id'])->fetch();
$app_count = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` >= 0 AND `apps_id` = ' . $app['id'])->fetch();
$app_return = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` < 0 AND `apps_id` = ' . $app['id'])->fetch();
$names = json_decode($app['name'], true);
if ($app['parent'] == 'no_parent' || $app['parent'] == '') {
$pname = $names[0];
} else {
$pname = $names[0] . " (" . $app['parent'] . ")";
}
$plugins_stat[] = array('id' => $app['app_id'], 'total' => $app_total[0], 'name' => $pname, 'count' => $app_count[0], 'return' => $app_return[0]);
}
$this->view->assign('total', $total);
$this->view->assign('apps', $plugins_stat);
$this->setTemplate(wacabHelper::getAppPath() . '/templates/actions/statistic/stat_page.html');
}
示例4: getSql
protected function getSql()
{
$model = new waModel();
$where = array();
if ($discountcard = waRequest::get('discountcard')) {
$where[] = "discountcard LIKE '" . $model->escape($discountcard) . "'";
}
$sql = "FROM `shop_discountcards`" . ($where ? " WHERE " . implode(" AND ", $where) : "") . " ORDER BY `id` DESC";
return $sql;
}
示例5: execute
public function execute(&$params)
{
$master_id = $params['id'];
$merge_ids = $params['contacts'];
$m = new waModel();
foreach (array(array('blog_comment', 'contact_id')) as $pair) {
list($table, $field) = $pair;
$sql = "UPDATE {$table} SET {$field} = :master WHERE {$field} in (:ids)";
$m->exec($sql, array('master' => $master_id, 'ids' => $merge_ids));
}
return null;
}
示例6: 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());
}
示例7: execute
public function execute()
{
$term = waRequest::request('term');
$limit = waRequest::request('limit', 30, 'int');
if (mb_strlen($term) < 2) {
return;
}
$type = waRequest::request('type', null, waRequest::TYPE_STRING_TRIM);
$model = new waModel();
if (strpos($term, '@') !== FALSE) {
$contacts = new contactsCollection('/search/email*=' . $term);
} else {
$contacts = new contactsCollection();
$t_a = preg_split("/\\s+/", $term);
$cond = array();
foreach ($t_a as $t) {
$t = trim($t);
if ($t) {
$t = $model->escape($t, 'like');
if ($type === 'person') {
$cond[] = "(c.firstname LIKE '{$t}%' OR c.middlename LIKE '{$t}%' OR c.lastname LIKE '{$t}%')";
} else {
if ($type === 'company') {
$cond[] = "c.name LIKE '{$t}%'";
} else {
$cond[] = "(c.firstname LIKE '{$t}%' OR c.middlename LIKE '{$t}%' OR c.lastname LIKE '{$t}%' OR c.name LIKE '{$t}%')";
}
}
}
}
if ($cond) {
$contacts->addWhere(implode(" AND ", $cond));
}
}
if ($type) {
if ($type === 'person') {
$contacts->addWhere("is_company = 0");
} else {
if ($type === 'company') {
$contacts->addWhere("is_company = 1");
}
}
}
$this->response = array();
$term_safe = htmlspecialchars($term);
foreach ($contacts->getContacts('id,name,company,email', 0, $limit) as $c) {
$name = $this->prepare($c['name'], $term_safe);
$email = $this->prepare(ifset($c['email'][0], ''), $term_safe);
$company = $this->prepare($c['company'], $term_safe);
$this->response[] = array('label' => implode(', ', array_filter(array($name, $company, $email))), 'value' => $c['id'], 'name' => $c['name'], 'email' => ifset($c['email'][0], ''), 'company' => $c['company']);
}
}
示例8: execute
public function execute()
{
switch (waRequest::get('event')) {
case 'del_trans':
$model = new waModel();
$model->query('TRUNCATE TABLE `wacab_payment`');
break;
case 'del_reviews':
$model = new waModel();
$model->query('TRUNCATE TABLE `wacab_review`');
break;
}
}
示例9: execute
public function execute()
{
try {
$data = waRequest::post();
$model = new waModel();
foreach ($data['data'] as $k => $v) {
if ($v['id'] != 'new') {
$is = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code = '" . $v['id'] . "' AND domain = '" . $k . "'")->fetchAssoc();
if (!$is) {
$d = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code = '" . $v['id'] . "'")->fetchAssoc();
if ($d && $d['domain'] == '') {
$model->query("UPDATE shop_deliveryshop_pvz SET \n address = '" . $v['address'] . "',\n workTime = '" . $v['workTime'] . "',\n email = '" . $v['email'] . "',\n TK = '" . $v['TK'] . "',\n note = '" . $v['note'] . "',\n phone = '" . $v['phone'] . "',\n domain = '" . $k . "'\n WHERE id = '" . $d['id'] . "'");
} else {
$model->query("INSERT INTO shop_deliveryshop_pvz \n (code, name, city, cityCode, workTime, address, phone, note, coordX, coordY, \n weightMin, weightMax, TK, domain, status, email)\n VALUES ('" . $v['id'] . "', '" . $d['name'] . "', '" . $d['city'] . "',\n '" . $d['cityCode'] . "', '" . $v['workTime'] . "',\n '" . $v['address'] . "', '" . $v['phone'] . "', '" . $v['note'] . "',\n '" . $d['coordX'] . "', '" . $d['coordY'] . "', '" . $d['weightMin'] . "',\n '" . $d['weightMax'] . "', '" . $v['TK'] . "', '" . $k . "', '" . $d['status'] . "', '" . $v['email'] . "')");
}
} else {
$model->query("UPDATE shop_deliveryshop_pvz SET \n address = '" . $v['address'] . "',\n workTime = '" . $v['workTime'] . "',\n email = '" . $v['email'] . "',\n TK = '" . $v['TK'] . "',\n note = '" . $v['note'] . "',\n phone = '" . $v['phone'] . "'\n WHERE id = '" . $is['id'] . "' AND domain = '" . $k . "'");
}
} else {
if ($v['city']) {
$city = $model->query("SELECT city FROM shop_deliveryshop_city WHERE cityCode = '" . $v['city'] . "'")->fetchField();
$model->query("INSERT INTO shop_deliveryshop_pvz \n (code, name, city, cityCode, workTime, address, phone, note, coordX, coordY, \n weightMin, weightMax, TK, domain, status, email)\n VALUES ('" . $v['code'] . "', '" . $v['name'] . "', '" . $city . "',\n '" . $v['city'] . "', '" . $v['workTime'] . "',\n '" . $v['address'] . "', '" . $v['phone'] . "', '" . $v['note'] . "',\n '" . $v['coordX'] . "', '" . $v['coordY'] . "', '" . $v['weightMin'] . "',\n '" . $v['weightMax'] . "', '" . $v['TK'] . "', '" . $k . "', 'new', '" . $v['email'] . "')");
} else {
$this->response['stat'] = 'error';
}
}
}
$this->response['message'] = 'ok';
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:32,代码来源:shopDeliveryshopPluginBackendSavepvz.controller.php
示例10: execute
public function execute()
{
$url = waRequest::param('url');
$domain = waRequest::server('HTTP_HOST');
$model = new waModel();
// $main_domain = $model->query("SELECT value FROM wa_app_settings WHERE app_id = 'webasyst' AND name = 'url'")->fetchField();
$app_settings_model = new waAppSettingsModel();
$main_domain = trim(str_replace(array('https', 'http', '://'), '', $app_settings_model->get('webasyst', 'url')), "/");
$data = $model->query("\nSELECT\n shop_deliveryshop_city_description.*\n, shop_deliveryshop_city.city\n, shop_deliveryshop_city.region\nFROM\n shop_deliveryshop_city_description\nLEFT JOIN\n shop_deliveryshop_city ON shop_deliveryshop_city_description.cityCode = shop_deliveryshop_city.cityCode\nLEFT JOIN\n wa_region ON wa_region.code = shop_deliveryshop_city.region AND wa_region.country_iso3='rus'\nWHERE\n (url = '{$url}' OR city = '{$url}')\nAND\n domain IN ('{$domain}', '{$main_domain}')\nLIMIT 1\n ")->fetchAssoc();
// Уменьшаем стоимость доставки на сумму указанную в настройках плагина
$delivery_compensation = $model->query("SELECT price FROM shop_deliveryshop_delivery WHERE domain = '" . $domain . "'")->fetchField();
$delivery_compensation = intval($delivery_compensation);
$delivery_price = intval($data['delivery_price']);
$courier_price = intval($data['courier_price']);
if ($delivery_price > $delivery_compensation) {
$data['delivery_price'] = (int) (($delivery_price - $delivery_compensation) / 50) * 50;
//Уменьшаем до ближайшего полтинника
} else {
$data['delivery_price'] = 0;
}
if ($courier_price > $delivery_compensation) {
$data['courier_price'] = (int) (($courier_price - $delivery_compensation) / 50) * 50;
//Уменьшаем до ближайшего полтинника
} else {
$data['courier_price'] = 0;
}
foreach (array('meta_title' => $main_domain, 'meta_description' => '', 'meta_keywords' => '', 'delivery_time' => '', 'courier_time' => '') as $key => $value) {
$data[$key] = isset($data[$key]) ? $data[$key] : $value;
}
wa()->getResponse()->setTitle($data['meta_title']);
wa()->getResponse()->setMeta('description', $data['meta_description']);
wa()->getResponse()->setMeta('keywords', $data['meta_keywords']);
$city_code = isset($data['cityCode']) ? $data['cityCode'] : 0;
$pvz = $model->query("\nSELECT\n shop_deliveryshop_pvz.*\nFROM\n shop_deliveryshop_pvz\nWHERE\n cityCode = {$city_code}\nAND\n status = 'completed'\nAND\n (domain IN ('{$domain}', '{$main_domain}') OR domain IS NULL)\n")->fetchAll();
//$site_model = new siteDomainModel();
//$domain_id = $site_model->getByName($domain);
$domain_id = $model->query("SELECT id FROM site_domain WHERE name = '" . $domain . "'")->fetchField();
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $domain_id . '.html', false, 'shop', true);
if (!file_exists($template_path)) {
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', false, 'shop', true);
}
if (!file_exists($template_path)) {
$template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
}
$this->view->assign('data', $data);
$this->view->assign('pvz', $pvz);
$this->view->assign('page', array('id' => null, 'name' => '', 'content' => $this->view->fetch($template_path)));
$this->setThemeTemplate('page.html');
waSystem::popActivePlugin();
}
示例11: getSql
protected function getSql()
{
$model = new waModel();
$where = array();
if ($discountcard = waRequest::get('discountcard')) {
$where[] = "`discountcard` LIKE '" . $model->escape($discountcard) . "'";
}
if ($order_id = waRequest::get('order_id')) {
$order_id = $this->decodeOrderId($order_id);
$where[] = "`order_id` = '" . $order_id . "'";
}
$sql = "FROM `shop_discountcards_order`" . ($where ? " WHERE " . implode(" AND ", $where) : "") . " ORDER BY `order_id` DESC";
return $sql;
}
示例12: 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());
}
}
示例13: getUserCategoryId
public static function getUserCategoryId($contact_id = null)
{
if ($contact_id === null) {
$contact_id = wa()->getUser()->getId();
}
$model = new waModel();
$sql = "SELECT * FROM `wa_contact_categories` WHERE `contact_id` = '" . $model->escape($contact_id) . "'";
$categories = $model->query($sql)->fetchAll();
$category_ids = array();
$category_ids[] = 0;
foreach ($categories as $category) {
$category_ids[] = $category['category_id'];
}
return $category_ids;
}
示例14: deleteByField
public function deleteByField($field, $value = null)
{
if (is_array($field)) {
$items = $this->getByField($field, $this->id);
} else {
$items = $this->getByField($field, $value, $this->id);
}
$res = false;
if ($ids = array_keys($items)) {
$res = parent::deleteByField($this->id, $ids);
if ($res) {
$type_upselling_model = new shopTypeUpsellingModel();
$type_upselling_model->deleteByField('feature_id', $ids);
$params_model = new shopProductFeaturesModel();
$params_model->deleteByField('feature_id', $ids);
$types = $this->groupByValueType($items);
foreach ($types as $type => $type_ids) {
if ($model = self::getValuesModel($type)) {
$model->deleteByField('feature_id', $type_ids);
}
}
$this->deleteByField('parent_id', $ids);
}
}
return $res;
}
示例15: updateById
public function updateById($id, $data, $options = null, $return_object = false)
{
if ($cache = wa()->getCache()) {
$cache->delete('block_' . $id);
}
return parent::updateById($id, $data, $options, $return_object);
}