コード例 #1
0
 /**
  * @param int[] $params Deleted contact_id
  * @see waEventHandler::execute()
  * @return void
  */
 public function execute(&$params)
 {
     $contact_ids = $params;
     $photo_model = new photosPhotoModel();
     $photo_model->updateByField(array('contact_id' => $contact_ids), array('contact_id' => 0));
     wa()->event(array('photos', 'contacts_delete'), $params);
 }
 public function save(waRequestFile $file, $data)
 {
     // check image
     if (!($image = $file->waImage())) {
         throw new waException(_w('Incorrect image'));
     }
     $plugin = wa()->getPlugin('publicgallery');
     $min_size = $plugin->getSettings('min_size');
     if ($min_size && ($image->height < $min_size || $image->width < $min_size)) {
         throw new waException(sprintf(_w("Image is too small. Minimum image size is %d px"), $min_size));
     }
     $max_size = $plugin->getSettings('max_size');
     if ($max_size && ($image->height > $max_size || $image->width > $max_size)) {
         throw new waException(sprintf(_w("Image is too big. Maximum image size is %d px"), $max_size));
     }
     $id = $this->model->add($file, $data);
     if (!$id) {
         throw new waException(_w("Save error"));
     }
     $tag = $plugin->getSettings('assign_tag');
     if ($tag) {
         $photos_tag_model = new photosPhotoTagsModel();
         $photos_tag_model->set($id, $tag);
     }
     return array('name' => $file->name, 'type' => $file->type, 'size' => $file->size);
 }
コード例 #3
0
 public static function getLink($photo, $album = null)
 {
     static $wa = null;
     $wa = $wa ? $wa : wa();
     $link = null;
     if (is_null($album)) {
         $link = $wa->getRouteUrl('photos/frontend/photo', array('url' => $photo['url'] . (isset($photo['status']) && $photo['status'] <= 0 ? ':' . $photo['hash'] : '')), true);
     } else {
         if (is_array($album)) {
             $link = $wa->getRouteUrl('photos/frontend/photo', array('url' => $album['full_url'] . '/' . $photo['url']), true);
         } else {
             $hash = $album;
             if (substr($hash, 0, 1) == '#') {
                 $hash = substr($hash, 1);
             }
             $hash = trim($hash, '/');
             $hash = explode('/', $hash);
             $params = array('url' => $photo['url']);
             if (count($hash) >= 2) {
                 $params[$hash[0]] = $hash[1];
             } else {
                 if (count($hash) == 1) {
                     $params[$hash[0]] = $hash[0];
                 }
             }
             $link = $wa->getRouteUrl('photos/frontend/photo', $params, true);
         }
     }
     return $link ? rtrim($link, '/') . '/' : null;
 }
コード例 #4
0
 public function execute()
 {
     $query = trim(waRequest::post('q'), ' /');
     $hash = '/search/' . $query;
     $collection = new photosCollection($hash);
     if ($query == 'rate>0') {
         $collection->orderBy('p.rate DESC, p.id');
     }
     $this->template = 'templates/actions/photo/PhotoList.html';
     $count = $this->getConfig()->getOption('photos_per_page');
     $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, $count);
     $photos = photosCollection::extendPhotos($photos);
     $frontend_link = $query == 'rate>0' ? photosCollection::getFrontendLink('favorites', false) : photosCollection::getFrontendLink($hash, false);
     /**
      * @event search_frontend_link
      * @param string $query
      * @return array of bool|string if false - default frontend_link isn't overridden, if string - override default frontend link
      */
     $res = wa()->event('search_frontend_link', $query);
     foreach ($res as $r) {
         if (is_string($r)) {
             $frontend_link = $r;
             break;
         }
     }
     $config = $this->getConfig();
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('frontend_link', $frontend_link);
     $this->view->assign('photos', $photos);
     $this->view->assign('title', $query == 'rate>0' ? _w('Rated') : $collection->getTitle());
     $this->view->assign('total_count', $collection->count());
     $this->view->assign('sort_method', $query == 'rate>0' ? 'rate' : 'upload_datetime');
     $this->view->assign('hash', $hash);
 }
コード例 #5
0
ファイル: wacabConfig.class.php プロジェクト: Alexkurd/wacab
 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/');
     }
 }
コード例 #6
0
 public function execute()
 {
     $this->setLayout(new guestbook2BackendLayout());
     // Creating a model instance for retrieving data from the database
     // Создаем экземпляр модели для получения данных из БД
     $model = new guestbook2Model();
     // Retrieving all guestbook records from the database
     // Получаем все записи гостевой книги из БД
     $records = $model->getRecords(0, 0);
     foreach ($records as &$r) {
         if ($r['contact_id']) {
             $r['name'] = $r['contact_name'];
             // getting the contact photo URL
             // получаем URL на фотографию контакта
             $r['photo_url'] = waContact::getPhotoUrl($r['contact_id'], $r['photo'], 20);
         }
     }
     unset($r);
     // Passing records to the template
     // Передаем записи в шаблон
     $this->view->assign('records', $records);
     // Passing the frontend URL to the template
     // Передаём в шаблон УРЛ фронтенда
     $this->view->assign('url', wa()->getRouteUrl($this->getAppId(), true));
     // Passing user's record deletion access rights value to the template
     // Access rights are defined in config file lib/config/guestbookRightConfig.class.php
     // Передаём в шаблон права пользователя на удаление записей из гостевой книги
     // Права описаны в конфиге lib/config/guestbookRightConfig.class.php
     $this->view->assign('rights_delete', $this->getRights('delete'));
     // If user is an admin of the Contacts app then show links to Contacts
     // Если пользователь админ приложения контакты, то показывать ссылки на контакты
     $this->view->assign('rights_contacts', $this->getUser()->isAdmin('contacts'));
 }
コード例 #7
0
 public function execute()
 {
     $name = basename(waRequest::get('file', 'export.csv'));
     $profile = waRequest::get('profile', 0, waRequest::TYPE_INT);
     $file = wa()->getTempPath('csv/download/' . $profile . '/' . $name);
     waFiles::readFile($file, $name);
 }
コード例 #8
0
 public function settingsAction()
 {
     $plugin_id = waRequest::get('id', null);
     $plugins_count = 0;
     $vars = array();
     if ($plugin_id) {
         $plugins = $this->getConfig()->getPlugins();
         $plugins_count = count($plugins);
         if (isset($plugins[$plugin_id])) {
             /**
              * @var shopPlugin $plugin
              */
             $plugin = waSystem::getInstance()->getPlugin($plugin_id, true);
             $namespace = wa()->getApp() . '_' . $plugin_id;
             $params = array();
             $params['id'] = $plugin_id;
             $params['namespace'] = $namespace;
             $params['title_wrapper'] = '%s';
             $params['description_wrapper'] = '<br><span class="hint">%s</span>';
             $params['control_wrapper'] = '<div class="name">%s</div><div class="value">%s %s</div>';
             $settings_controls = $plugin->getControls($params);
             $this->getResponse()->setTitle(_w(sprintf('Plugin %s settings', $plugin->getName())));
             $vars['plugin_info'] = $plugins[$plugin_id];
             $vars['plugin_id'] = $plugin_id;
             $vars['settings_controls'] = $settings_controls;
         }
         waSystem::popActivePlugin();
     }
     $template = $this->getTemplatePath('settings');
     $vars['plugins_count'] = $plugins_count;
     $this->display($vars, $template);
 }
コード例 #9
0
 public function execute()
 {
     $order_id = waRequest::request('order_id', 0, 'int');
     $id = waRequest::request('id', 0, 'int');
     $to = waRequest::request('to');
     $nm = new shopNotificationModel();
     $n = $nm->getById($id);
     if (!$n) {
         $this->errors = sprintf_wp('%s entry not found', _w('Notification'));
         return;
     }
     $om = new shopOrderModel();
     $o = $om->getById($order_id);
     if (!$o) {
         $this->errors = _w('Order not found');
         return;
     }
     shopHelper::workupOrders($o, true);
     $opm = new shopOrderParamsModel();
     $o['params'] = $opm->get($order_id);
     try {
         $contact = $o['contact_id'] ? new shopCustomer($o['contact_id']) : wa()->getUser();
         $contact->getName();
     } catch (Exception $e) {
         $contact = new shopCustomer(wa()->getUser()->getId());
     }
     $cm = new shopCustomerModel();
     $customer = $cm->getById($contact->getId());
     if (!$customer) {
         $customer = $cm->getEmptyRow();
     }
     $workflow = new shopWorkflow();
     // send notifications
     shopNotifications::sendOne($id, array('order' => $o, 'customer' => $contact, 'status' => $workflow->getStateById($o['state_id'])->getName()), $to);
 }
 public function execute()
 {
     $lazy = !is_null(waRequest::get('lazy'));
     if (!$lazy) {
         $this->setLayout(new photosDefaultFrontendLayout());
     } else {
         $this->setTemplate('FrontendPhotos');
     }
     $photos_per_page = wa('photos')->getConfig()->getOption('photos_per_page');
     $limit = $photos_per_page;
     $page = 1;
     if ($lazy) {
         $offset = max(0, waRequest::get('offset', 0, waRequest::TYPE_INT));
     } else {
         $page = max(1, waRequest::get('page', 1, waRequest::TYPE_INT));
         $offset = ($page - 1) * $photos_per_page;
     }
     $c = new photosCollection('publicgallery/myphotos');
     $photos = $c->getPhotos('*', $offset, $limit);
     $photos = photosCollection::extendPhotos($photos);
     $v = wa()->getVersion();
     wa('photos')->getResponse()->addJs('js/lazy.load.js?v=' . $v, true);
     wa('photos')->getResponse()->addJs('js/frontend.photos.js?v=' . $v, true);
     $storage = wa()->getStorage();
     $current_auth = $storage->read('auth_user_data');
     $current_auth_source = $current_auth ? $current_auth['source'] : null;
     $this->view->assign('current_auth', $current_auth, true);
     $adapters = wa()->getAuthAdapters();
     $total_count = $c->count();
     $this->view->assign(array('photos' => $photos, 'page' => $page, 'offset' => $offset, 'photos_per_page' => $photos_per_page, 'total_photos_count' => $total_count, 'lazy_load' => $lazy, 'image_upload_url' => wa()->getRouteUrl('photos/frontend/imageUpload'), 'pages_count' => floor($total_count / $photos_per_page) + 1, 'current_auth_source' => $current_auth_source, 'adapters' => $adapters));
 }
コード例 #11
0
 public function postView()
 {
     $url = wa()->getAppStaticUrl() . $this->getUrl('css/troll.css', true);
     $content = array();
     $content['head'] = "<link href=\"{$url}\" rel=\"stylesheet\" type=\"text/css\">";
     return $content;
 }
コード例 #12
0
 public function execute()
 {
     // only allowed to global admin
     if (!wa()->getUser()->getRights('webasyst', 'backend')) {
         throw new waRightsException('Access denied.');
     }
     $collection = new contactsCollection('users/all');
     $group = null;
     $memberIds = array();
     if ($id = waRequest::get('id')) {
         $group_model = new waGroupModel();
         $group = $group_model->getById($id);
     }
     if ($group) {
         $user_groups_model = new waUserGroupsModel();
         $memberIds = $user_groups_model->getContactIds($id);
     }
     $users = $collection->getContacts('id,name');
     // array(id => array(id=>...,name=>...))
     $members = array();
     foreach ($memberIds as $mid) {
         if (isset($users[$mid])) {
             $members[$mid] = $users[$mid];
             unset($users[$mid]);
         }
     }
     usort($members, array($this, '_cmp'));
     usort($users, array($this, '_cmp'));
     $this->view->assign('group', $group);
     $this->view->assign('notIncluded', $users);
     $this->view->assign('members', $members);
 }
 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);
 }
コード例 #14
0
 public static function getAppAlbums($force_app_ids = array())
 {
     $photo_model = new photosPhotoModel();
     $apps = wa()->getApps();
     $result = array();
     $counts = $photo_model->countAllByApp();
     $counts += array_fill_keys((array) $force_app_ids, 0);
     $force_app_ids = array_fill_keys((array) $force_app_ids, true);
     foreach ($counts as $app_id => $count) {
         // Check that app exists and check access rights, unless app is forced to be present in the result
         if (empty($force_app_ids[$app_id])) {
             if ($count <= 0 || empty($apps[$app_id]) || !wa()->getUser()->getRights($app_id, 'backend')) {
                 continue;
             }
         }
         if (!empty($apps[$app_id])) {
             $name = $apps[$app_id]['name'];
             if (!empty($apps[$app_id]['icon'][16])) {
                 $icon = $apps[$app_id]['icon'][16];
             } else {
                 $icon = reset($apps[$app_id]['icon']);
             }
         } else {
             $name = $app_id;
             $icon = $apps['photos']['icon'][16];
         }
         if ($icon) {
             $icon = wa()->getConfig()->getRootUrl() . $icon;
         }
         $result[$app_id] = array('id' => $app_id, 'name' => $name, 'count' => $count, 'icon' => $icon);
     }
     return $result;
 }
コード例 #15
0
 public function getInfo()
 {
     $path = wa()->getConfig()->getPath('plugins') . '/sms/' . $this->getId();
     $info = (include $path . '/lib/config/plugin.php');
     $info['icon'] = wa()->getRootUrl() . 'wa-plugins/sms/' . $this->getId() . '/' . $info['icon'];
     return $info;
 }
コード例 #16
0
 public function isRequired()
 {
     if ($this->options['required'] === null) {
         $this->options['required'] = !wa()->getUser()->getRights('contacts', 'category.all');
     }
     return parent::isRequired();
 }
コード例 #17
0
 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);
 }
コード例 #18
0
 public function payment($payment_form_data, $order_data, $transaction_type)
 {
     if (!in_array($order_data['currency_id'], $this->allowedCurrency())) {
         throw new waException('Оплата на сайте WebMoney производится только в рублях (RUB) и в данный момент невозможна, так как эта валюта не определена в настройках.');
     }
     if (empty($order_data['description'])) {
         $order_data['description'] = 'Заказ ' . $order_data['order_id'];
     }
     $hidden_fields = array('LMI_MERCHANT_ID' => $this->LMI_MERCHANT_ID, 'LMI_PAYMENT_AMOUNT' => number_format($order_data['amount'], 2, '.', ''), 'LMI_CURRENCY' => strtoupper($order_data['currency_id']), 'LMI_PAYMENT_NO' => $order_data['order_id'], 'LMI_PAYMENT_DESC' => $order_data['description'], 'LMI_RESULT_URL' => $this->getRelayUrl(), 'wa_app' => $this->app_id, 'wa_merchant_contact_id' => $this->merchant_id);
     if ($this->LMI_PAYEE_PURSE) {
         $hidden_fields['LMI_PAYEE_PURSE'] = $this->LMI_PAYEE_PURSE;
     }
     if ($this->TESTMODE) {
         $hidden_fields['LMI_SIM_MODE'] = $this->LMI_SIM_MODE;
     }
     if (!empty($order_data['customer_info']['email'])) {
         $hidden_fields['LMI_PAYER_EMAIL'] = $order_data['customer_info']['email'];
     }
     $transaction_data = $this->formalizeData($hidden_fields);
     $hidden_fields['LMI_SUCCESS_URL'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_SUCCESS, $transaction_data);
     $hidden_fields['LMI_FAILURE_URL'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $transaction_data);
     $view = wa()->getView();
     $view->assign('url', wa()->getRootUrl());
     $view->assign('hidden_fields', $hidden_fields);
     $view->assign('form_url', $this->getEndpointUrl());
     return $view->fetch($this->path . '/templates/payment.html');
 }
コード例 #19
0
 protected function getId()
 {
     if (!empty($this->params['limited_own_profile'])) {
         return wa()->getUser()->getId();
     }
     return (int) waRequest::get('id');
 }
コード例 #20
0
 public function execute()
 {
     $this->getResponse()->addJs("js/jquery.pageless2.js?v=" . wa()->getVersion(), true);
     $this->view->assign('site_theme_url', wa()->getDataUrl('themes', true, 'site') . '/' . waRequest::param('theme', 'default') . '/');
     $this->view->assign('action', $action = waRequest::param('action', 'default'));
     waRequest::setParam('action', $action);
     $params = waRequest::param();
     /**
      * @event frontend_action_default
      * @event frontend_action_post
      * @event frontend_action_page
      * @event frontend_action_error
      * @param array[string]mixed $params request params
      * @return array[string][string]string $return['%plugin_id%']
      * @return array[string][string]string $return['%plugin_id%'][nav_before]
      * @return array[string][string]string $return['%plugin_id%'][footer]
      * @return array[string][string]string $return['%plugin_id%'][head]
      * @return array[string][string]string $return['%plugin_id%'][sidebar]
      */
     $this->view->assign('settlement_one_blog', isset($params['blog_id']) && $params['blog_url_type'] == $params['blog_id']);
     $this->view->assign('frontend_action', $res = wa()->event('frontend_action_' . $action, $params));
     if (!$this->view->getVars('links')) {
         $this->view->assign('links', array());
     }
     $this->setThemeTemplate('index.html');
 }
コード例 #21
0
 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);
     }
 }
コード例 #22
0
 public function execute()
 {
     $photo_id = $this->post('id', true);
     if (!is_array($photo_id)) {
         if (strpos($photo_id, ',') !== false) {
             $photo_id = array_map('intval', explode(',', $photo_id));
         } else {
             $photo_id = array($photo_id);
         }
     }
     $photo_model = new photosPhotoModel();
     $photo_rights_model = new photosPhotoRightsModel();
     $allowed_photo_id = $photo_rights_model->filterAllowedPhotoIds($photo_id, true);
     if ($allowed_photo_id) {
         foreach ($allowed_photo_id as $id) {
             $photo_model->delete($id);
             /**
              * Extend delete process
              * Make extra workup
              * @event photo_delete
              */
             wa()->event('photo_delete', $id);
         }
         $this->response = true;
     } else {
         throw new waAPIException('access_denied', 403);
     }
 }
コード例 #23
0
 public function execute()
 {
     $path = rtrim(waRequest::post('path'), ' /');
     $path = wa()->getDataPath($path, true);
     if (!file_exists($path)) {
         throw new waException("File not found", 404);
     }
     $files = array();
     $dh = opendir($path);
     $names = array();
     while (($f = readdir($dh)) !== false) {
         if ($f !== '.' && $f !== '..' && is_file($path . '/' . $f)) {
             $t = filemtime($path . '/' . $f);
             $name = htmlspecialchars($f);
             $files[$name] = array('file' => $name, 'type' => $this->getType($f), 'size' => filesize($path . '/' . $f), 'timestamp' => $t, 'datetime' => waDateTime::format('humandatetime', $t));
             $names[] = $name;
         }
     }
     natcasesort($names);
     $sorted_files = array();
     foreach ($names as $name) {
         $sorted_files[] =& $files[$name];
     }
     closedir($dh);
     $this->response = $sorted_files;
 }
コード例 #24
0
 public function auth()
 {
     // check code
     $code = $this->getCode();
     if (!$code) {
         $url = $this->getRedirectUri();
         if ($this->check_state) {
             $state = md5(uniqid(rand(), true));
             wa()->getStorage()->set('auth_state', $state);
             $url .= '&state=' . $state;
         }
         // redirect to provider auth page
         wa()->getResponse()->redirect($url);
     }
     if ($this->check_state && waRequest::get('state') != wa()->getStorage()->get('auth_state')) {
         // @todo: error
         return array();
     }
     // close session
     wa()->getStorage()->close();
     // get token
     if ($token = $this->getAccessToken($code)) {
         // get user info
         return $this->getUserData($token);
     }
     return array();
 }
 public function execute()
 {
     try {
         $app_settings_model = new waAppSettingsModel();
         if (waRequest::post('cancel')) {
             wa()->getStorage()->set('shop/discountcard', '');
         } else {
             if ($discountcard_number = waRequest::post('discountcard')) {
                 $model = new shopDiscountcardsPluginModel();
                 if ($app_settings_model->get(shopDiscountcardsPlugin::$plugin_id, 'binding_customer')) {
                     $contact_id = wa()->getUser()->getId();
                     $discountcard = $model->getByField(array('contact_id' => $contact_id, 'discountcard' => $discountcard_number));
                     if (empty($discountcard)) {
                         $discountcard = $model->getByField(array('contact_id' => 0, 'discountcard' => $discountcard_number));
                     }
                 } else {
                     $discountcard = $model->getByField('discountcard', $discountcard_number);
                 }
                 if ($discountcard) {
                     wa()->getStorage()->set('shop/discountcard', $discountcard['discountcard']);
                 } else {
                     throw new waException('Дисконтная карта не найдена');
                 }
             } else {
                 throw new waException('Укажите номер дисконтной карты');
             }
         }
     } catch (Exception $ex) {
         $this->setError($ex->getMessage());
     }
 }
 protected function initOptions()
 {
     if (!extension_loaded('simplexml')) {
         throw new waException(_wp('PHP extension SimpleXML required'));
     }
     $this->addOption('path', array('title' => _wp('Path to folder'), 'value' => wa()->getConfig()->getRootPath(), 'description' => _wp('Path to folder of the WebAsyst (old version) installation'), 'control_type' => waHtmlControl::INPUT));
 }
コード例 #27
0
 public function execute()
 {
     $photo_id = waRequest::get('photo_id', null, waRequest::TYPE_INT);
     $size = waRequest::get('size', null, waRequest::TYPE_STRING);
     $album = null;
     $photo_model = new photosPhotoModel();
     $photo = $photo_model->getById($photo_id);
     if (!$photo) {
         throw new waException(_w("Unknown photo"));
     }
     $photo['frontend_link'] = photosFrontendPhoto::getLink($photo, $album);
     $sizes = $this->getConfig()->getSizes();
     $contexts = array();
     foreach ($sizes as $sz) {
         $contexts[$sz]['html'] = photosPhoto::getEmbedImgHtml($photo, $sz);
         $contexts[$sz]['url'] = photosPhoto::getPhotoUrl($photo, $sz, true);
     }
     if (!$size || !isset($contexts[$size])) {
         $size = $sizes[0];
     }
     $domains = photosPhoto::getDomains(null, $photo);
     if (count($domains) <= 1) {
         $domains = array();
     }
     $this->view->assign('photo', $photo);
     $this->view->assign('sizes', $sizes);
     $this->view->assign('size', $size);
     $this->view->assign('contexts', $contexts);
     $this->view->assign('original_domain', wa()->getRootUrl(true));
     $this->view->assign('domains', $domains);
 }
コード例 #28
0
 public function execute()
 {
     $app_settings_model = new waAppSettingsModel();
     $settings = $app_settings_model->get(shopPricePlugin::$plugin_id);
     $ccm = new waContactCategoryModel();
     $categories = array(array('id' => 0, 'name' => 'Все покупатели'));
     foreach ($ccm->getAll() as $c) {
         if ($c['app_id'] == 'shop') {
             $categories[$c['id']] = $c;
         }
     }
     $price_model = new shopPricePluginModel();
     $prices = $price_model->getAll();
     $_prices = array();
     foreach ($prices as $price) {
         $_prices[$price['domain_hash']][] = $price;
     }
     $domain_routes = wa()->getRouting()->getByApp('shop');
     $domains_settings = shopPrice::getDomainsSettings();
     $this->view->assign('prices', $_prices);
     $this->view->assign('domain_routes', $domain_routes);
     $this->view->assign('categories', $categories);
     $this->view->assign('settings', $settings);
     $this->view->assign('domain_settings', $domains_settings);
 }
コード例 #29
0
 public function execute()
 {
     // Layout caching is forbidden
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Expires: " . date("r"));
     $this->executeAction('sidebar', new contactsBackendSidebarAction());
     $fields = array();
     // normally this is done with waContactFields::getInfo() but we don't need most of the info
     // so we loop through fields manually.
     foreach (waContactFields::getAll('enabled') as $field_id => $f) {
         /**
          * @var $f waContactField
          */
         $fields[$field_id] = array();
         $fields[$field_id]['id'] = $field_id;
         $fields[$field_id]['name'] = $f->getName();
         $fields[$field_id]['fields'] = $f instanceof waContactCompositeField;
         if ($ext = $f->getParameter('ext')) {
             $fields[$field_id]['ext'] = $ext;
             foreach ($fields[$field_id]['ext'] as &$v) {
                 $v = _ws($v);
             }
         }
     }
     // Plugin assets
     if ($this->getConfig()->getInfo('edition') === 'full') {
         wa()->event('assets');
     }
     $this->view->assign('admin', wa()->getUser()->getRights('contacts', 'backend') > 1);
     $this->view->assign('global_admin', wa()->getUser()->getRights('webasyst', 'backend') > 0);
     $this->view->assign('fields', $fields);
     $this->view->assign('versionFull', $this->getConfig()->getInfo('edition') === 'full');
 }
コード例 #30
0
 public function execute()
 {
     $p = $path = rtrim(waRequest::post('path'), ' /');
     $file = waRequest::post('file');
     try {
         if ($file) {
             if (!is_array($file)) {
                 $file = array($file);
             }
             foreach ($file as $f) {
                 $f = $path . '/' . $f;
                 waFiles::delete(wa()->getDataPath($f, true, null, false));
             }
             $this->log('file_delete', count($file));
         } else {
             $path = wa()->getDataPath($path, true, null, false);
             if (!is_writable($path)) {
                 $this->errors = sprintf(_w("Folder could not bet deleted due to the insufficient permissions."), $p);
             } else {
                 waFiles::delete($path);
                 $this->log('file_delete', 1);
             }
         }
     } catch (Exception $e) {
         $this->errors = $e->getMessage();
     }
 }