Exemplo n.º 1
0
 public function checkAndSend()
 {
     $res = frameGmp::_()->getTable("usage_stat")->get("id", '`visits`>9');
     if (!empty($res)) {
         $this->sendUsageStat();
     }
 }
Exemplo n.º 2
0
 public function put($d = array())
 {
     $res = new responseGmp();
     $id = $this->_getIDFromReq($d);
     $d = prepareParamsGmp($d);
     if (is_numeric($id) && $id) {
         if (isset($d['active'])) {
             $d['active'] = is_string($d['active']) && $d['active'] == 'true' || $d['active'] == 1 ? 1 : 0;
         }
         //mmm.... govnokod?....)))
         /* else
            $d['active'] = 0;*/
         if (frameGmp::_()->getTable('modules')->update($d, array('id' => $id))) {
             $res->messages[] = __('Module Updated', GMP_LANG_CODE);
             $mod = frameGmp::_()->getTable('modules')->getById($id);
             $newType = frameGmp::_()->getTable('modules_type')->getById($mod['type_id'], 'label');
             $newType = $newType['label'];
             $res->data = array('id' => $id, 'label' => $mod['label'], 'code' => $mod['code'], 'type' => $newType, 'active' => $mod['active']);
         } else {
             if ($tableErrors = frameGmp::_()->getTable('modules')->getErrors()) {
                 $res->errors = array_merge($res->errors, $tableErrors);
             } else {
                 $res->errors[] = __('Module Update Failed', GMP_LANG_CODE);
             }
         }
     } else {
         $res->errors[] = __('Error module ID', GMP_LANG_CODE);
     }
     return $res;
 }
Exemplo n.º 3
0
 public function init()
 {
     if (frameGmp::isAdminPlugPage()) {
         $this->_styles = array('styleGmp' => array('path' => GMP_CSS_PATH . 'style.css'), 'adminStylesGmp' => array('path' => GMP_CSS_PATH . 'adminStyles.css'), 'farbtastic' => array(), 'wp-jquery-ui-dialog' => array(), 'jquery-dialog' => array('path' => GMP_CSS_PATH . 'jquery-dialog.css'));
     }
     $defaultPlugTheme = frameGmp::_()->getModule('options')->get('default_theme');
     $ajaxurl = admin_url('admin-ajax.php');
     if (frameGmp::_()->getModule('options')->get('ssl_on_ajax')) {
         $ajaxurl = uriGmp::makeHttps($ajaxurl);
     }
     $jsData = array('siteUrl' => GMP_SITE_URL, 'imgPath' => GMP_IMG_PATH, 'cssPath' => GMP_CSS_PATH, 'loader' => GMP_LOADER_IMG, 'close' => GMP_IMG_PATH . 'cross.gif', 'ajaxurl' => $ajaxurl, 'animationSpeed' => frameGmp::_()->getModule('options')->get('js_animation_speed'), 'siteLang' => langGmp::getData(), 'options' => frameGmp::_()->getModule('options')->getAllowedPublicOptions(), 'GMP_CODE' => GMP_CODE, 'ball_loader' => GMP_IMG_PATH . 'ajax-loader-ball.gif', 'ok_icon' => GMP_IMG_PATH . 'ok-icon.png', 'isHttps' => uriGmp::isHttps());
     if (frameGmp::isAdminPlugPage()) {
         frameGmp::_()->addScript('commonGmp', GMP_JS_PATH . 'common.js');
         frameGmp::_()->addScript('coreGmp', GMP_JS_PATH . 'core.js');
         $jsData = dispatcherGmp::applyFilters('jsInitVariables', $jsData);
         frameGmp::_()->addJSVar('coreGmp', 'GMP_DATA', $jsData);
         frameGmp::_()->addScript('datatable', GMP_JS_PATH . 'jquery.dataTables.min.js');
         frameGmp::_()->addScript('farbtastic', get_bloginfo('wpurl') . '/wp-admin/js/farbtastic.js', array('jquery'));
         frameGmp::_()->addScript('jquery-ui-tabs', '', array('jquery'), false, true);
         frameGmp::_()->addScript('jquery-ui-autocomplete', '', array('jquery'), false, true);
         frameGmp::_()->getModule('marker')->connectAssets();
         frameGmp::_()->addScript('jquery-ui-dialog', '', array('jquery'));
         frameGmp::_()->addScript('adminOptionsGmp', GMP_JS_PATH . 'admin.options.js');
     }
     if (is_admin()) {
         frameGmp::_()->addScript('ajaxupload', GMP_JS_PATH . 'ajaxupload.js');
         frameGmp::_()->addScript('postbox', get_bloginfo('wpurl') . '/wp-admin/js/postbox.js');
         add_action('wp_enqueue_scripts', array($this, 'addThickbox'));
         $jsData['allCheckRegPlugs'] = modInstallerGmp::getCheckRegPlugs();
     } else {
     }
     foreach ($this->_styles as $s => $sInfo) {
         if (isset($sInfo['for'])) {
             if ($sInfo['for'] == 'frontend' && is_admin() || $sInfo['for'] == 'admin' && !is_admin()) {
                 continue;
             }
         }
         $canBeSubstituted = true;
         if (isset($sInfo['substituteFor'])) {
             switch ($sInfo['substituteFor']) {
                 case 'frontend':
                     $canBeSubstituted = !is_admin();
                     break;
                 case 'admin':
                     $canBeSubstituted = is_admin();
                     break;
             }
         }
         if ($canBeSubstituted && file_exists(GMP_TEMPLATES_DIR . $defaultPlugTheme . DS . $s . '.css')) {
             frameGmp::_()->addStyle($s, GMP_TEMPLATES_PATH . $defaultPlugTheme . '/' . $s . '.css');
         } elseif ($canBeSubstituted && file_exists(utilsGmp::getCurrentWPThemeDir() . 'gmp' . DS . $s . '.css')) {
             frameGmp::_()->addStyle($s, utilsGmp::getCurrentWPThemePath() . '/toe/' . $s . '.css');
         } elseif (!empty($sInfo['path'])) {
             frameGmp::_()->addStyle($s, $sInfo['path']);
         } else {
             frameGmp::_()->addStyle($s);
         }
     }
     parent::init();
 }
Exemplo n.º 4
0
 public function getMarkerForm($params)
 {
     $marker_opts = frameGmp::_()->getModule('marker')->getModel()->constructMarkerOptions();
     $this->assign('marker_opts', $marker_opts);
     $this->assign('params', $params);
     return parent::getContent('markerForm');
 }
Exemplo n.º 5
0
 public function initMenu()
 {
     $mainCap = $this->getMainCap();
     $mainSlug = dispatcherGmp::applyFilters('adminMenuMainSlug', $this->_mainSlug);
     $mainMenuPageOptions = array('page_title' => GMP_WP_PLUGIN_NAME, 'menu_title' => GMP_WP_PLUGIN_NAME, 'capability' => $mainCap, 'menu_slug' => $mainSlug, 'function' => array(frameGmp::_()->getModule('options'), 'getAdminPage'));
     $mainMenuPageOptions = dispatcherGmp::applyFilters('adminMenuMainOption', $mainMenuPageOptions);
     add_menu_page($mainMenuPageOptions['page_title'], $mainMenuPageOptions['menu_title'], $mainMenuPageOptions['capability'], $mainMenuPageOptions['menu_slug'], $mainMenuPageOptions['function'], 'dashicons-admin-site');
     //remove duplicated WP menu item
     //add_submenu_page($mainMenuPageOptions['menu_slug'], '', '', $mainMenuPageOptions['capability'], $mainMenuPageOptions['menu_slug'], $mainMenuPageOptions['function']);
     $tabs = frameGmp::_()->getModule('options')->getTabs();
     $subMenus = array();
     foreach ($tabs as $tKey => $tab) {
         if ($tKey == 'main_page') {
             continue;
         }
         // Top level menu item - is main page, avoid place it 2 times
         if (isset($tab['hidden']) && $tab['hidden'] || isset($tab['hidden_for_main']) && $tab['hidden_for_main'] || isset($tab['is_main']) && $tab['is_main']) {
             continue;
         }
         $subMenus[] = array('title' => $tab['label'], 'capability' => $mainCap, 'menu_slug' => 'admin.php?page=' . $mainSlug . '&tab=' . $tKey, 'function' => '');
     }
     $subMenus = dispatcherGmp::applyFilters('adminMenuOptions', $subMenus);
     foreach ($subMenus as $opt) {
         add_submenu_page($mainSlug, $opt['title'], $opt['title'], $opt['capability'], $opt['menu_slug'], $opt['function']);
     }
 }
Exemplo n.º 6
0
 public function isAdmin()
 {
     if (!function_exists('wp_get_current_user')) {
         frameGmp::_()->loadPlugins();
     }
     return current_user_can('administrator');
 }
Exemplo n.º 7
0
 public function getSettingsTabContent()
 {
     frameGmp::_()->addScript('admin.settings', $this->getModule()->getModPath() . 'js/admin.settings.js');
     frameGmp::_()->addStyle('admin.settings', $this->getModule()->getModPath() . 'css/admin.settings.css');
     frameGmp::_()->getModule('templates')->loadJqueryUi();
     $options = frameGmp::_()->getModule('options')->getAll();
     $this->assign('options', $options);
     return parent::getContent('optionsSettingsTabContent');
 }
Exemplo n.º 8
0
 public function initMenu()
 {
     $mainSlug = dispatcherGmp::applyFilters('adminMenuMainSlug', $this->_mainSlug);
     $this->_options = dispatcherGmp::applyFilters('adminMenuOptions', $this->_options);
     add_menu_page(langGmp::_('Ready! Google Maps'), langGmp::_('Ready! Google Maps'), 10, $this->_mainSlug, array(frameGmp::_()->getModule('options')->getView(), 'getAdminPage'), 'dashicons-admin-site');
     foreach ($this->_options as $opt) {
         add_submenu_page($mainSlug, langGmp::_($opt['title']), langGmp::_($opt['title']), $opt['capability'], $opt['menu_slug'], $opt['function']);
     }
 }
Exemplo n.º 9
0
 public function drawMapFromShortcode($params = null)
 {
     frameGmp::_()->addScript('commonGmp', GMP_JS_PATH . 'common.js', array('jquery'));
     frameGmp::_()->addScript('coreGmp', GMP_JS_PATH . 'core.js');
     frameGmp::_()->addScript('mutal_opts', GMP_JS_PATH . 'mutal.js');
     if (!isset($params['id'])) {
         return $this->getController()->getDefaultMap();
     }
     return $this->getController()->getView()->drawMap($params);
 }
Exemplo n.º 10
0
 public function init()
 {
     parent::init();
     $this->getModel()->checkDefIcons();
     if (frameGmp::isAdminPlugPage()) {
         $gmpExistsIcons = $this->getModel()->getIcons();
         frameGmp::_()->addJSVar('iconOpts', 'gmpExistsIcons', $gmpExistsIcons);
         frameGmp::_()->addScript('iconOpts', $this->getModPath() . 'js/iconOpts.js');
     }
 }
Exemplo n.º 11
0
 /**
  * Get the content for templates module tab
  * 
  * @return type 
  */
 public function getTabContent()
 {
     $templates = frameGmp::_()->getModule('templatesGmp')->getModel()->get();
     if (empty($templates)) {
         $tpl = 'noTemplates';
     } else {
         $this->assign('templatesGmp', $templates);
         $this->assign('default_theme', frameGmp::_()->getModule('optionsGmp')->getModel()->get('default_theme'));
         $tpl = 'templatesTab';
     }
     return parent::getContent($tpl);
 }
Exemplo n.º 12
0
 protected function _loadUserData()
 {
     if (!$this->_dataLoaded) {
         if (!function_exists('wp_get_current_user')) {
             frameGmp::_()->loadPlugins();
         }
         $user = wp_get_current_user();
         $this->_data = $user->data;
         $this->_curentID = $user->ID;
         $this->_dataLoaded = true;
     }
 }
Exemplo n.º 13
0
    public function initJsVars()
    {
        $ajaxurl = admin_url('admin-ajax.php');
        if (frameGmp::_()->getModule('options')->get('ssl_on_ajax')) {
            $ajaxurl = uriGmp::makeHttps($ajaxurl);
        }
        $jsData = array('siteUrl' => GMP_SITE_URL, 'imgPath' => GMP_IMG_PATH, 'loader' => GMP_LOADER_IMG, 'close' => GMP_IMG_PATH . 'cross.gif', 'ajaxurl' => $ajaxurl, 'animationSpeed' => frameGmp::_()->getModule('options')->get('js_animation_speed'), 'GMP_CODE' => GMP_CODE);
        return '<script type="text/javascript">
		// <!--
			var GMP_DATA = ' . utilsGmp::jsonEncode($jsData) . ';
		// -->
		</script>';
    }
Exemplo n.º 14
0
 public function getOrdersList($uid = 0)
 {
     $user = frameGmp::_()->getModule('user')->getCurrent();
     $searchCriteria = array();
     if (!$user->isAdmin) {
         if (!$uid || !is_numeric($uid)) {
             //!is_numeric($uid) is becouse WP add some first parametr when adding the_content hook
             $uid = $user->ID;
         }
         $searchCriteria['user_id'] = $uid;
     }
     frameGmp::_()->getModule('order')->getView()->getAllOrders($searchCriteria);
 }
Exemplo n.º 15
0
 public function getOverviewTabContent()
 {
     frameGmp::_()->getModule('templates')->loadJqueryUi();
     frameGmp::_()->getModule('templates')->loadSlimscroll();
     frameGmp::_()->addScript('admin.overview', $this->getModule()->getModPath() . 'js/admin.overview.js');
     frameGmp::_()->addStyle('admin.overview', $this->getModule()->getModPath() . 'css/admin.overview.css');
     $this->assign('mainLink', $this->getModule()->getMainLink());
     $this->assign('faqList', $this->getFaqList());
     $this->assign('serverSettings', $this->getServerSettings());
     $this->assign('news', $this->getNewsContent());
     $this->assign('contactFields', $this->getModule()->getContactFormFields());
     return parent::getContent('overviewTabContent');
 }
Exemplo n.º 16
0
 public function adminTextEditorPopup()
 {
     $shortcodes = frameGmp::_()->getModule('shortcodesGmp')->getCodes();
     $shortcodesSelectOptions = array('' => langGmp::_('Select'));
     foreach ($shortcodes as $code => $cinfo) {
         if (in_array($code, array('product', 'category'))) {
             continue;
         }
         $shortcodesSelectOptions[$code] = $code;
     }
     $this->assign('shortcodesGmp', $shortcodes);
     $this->assign('shortcodesSelectOptions', $shortcodesSelectOptions);
     return parent::getContent('adminTextEditorPopup');
 }
Exemplo n.º 17
0
 public function displayForm($data, $widget)
 {
     $maps = frameGmp::_()->getModule('gmap')->getModel()->getAllMaps();
     $mapsOpts = array();
     if (empty($maps)) {
         $mapsOpts[0] = __('You have no maps', GMP_LANG_CODE);
     } else {
         foreach ($maps as $map) {
             $mapsOpts[$map['id']] = $map['title'];
         }
     }
     $this->assign('mapsOpts', $mapsOpts);
     $this->displayWidgetForm($data, $widget);
 }
Exemplo n.º 18
0
 public function getEditMarkerGroup($id = 0)
 {
     frameGmp::_()->addScript('admin.mgr.edit', $this->getModule()->getModPath() . 'js/admin.marker_groups.edit.js');
     frameGmp::_()->addStyle('admin.mgr', $this->getModule()->getModPath() . 'css/admin.marker.groups.css');
     $editMarkerGroup = $id ? true : false;
     if ($editMarkerGroup) {
         $markerGroup = $this->getModel()->getMarkerGroupById($id);
         $this->assign('marker_group', $markerGroup);
         frameGmp::_()->addJSVar('admin.mgr.edit', 'mgrMarkerGroup', $markerGroup);
     }
     $this->assign('editMarkerGroup', $editMarkerGroup);
     $this->assign('addNewLink', frameGmp::_()->getModule('options')->getTabUrl('marker_groups_add_new'));
     return parent::getContent('mgrEditMarkerGroup');
 }
Exemplo n.º 19
0
 public function saveNewIcon()
 {
     $data = reqGmp::get('post');
     $res = new responseGmp();
     $result = $this->getModel()->saveNewIcon($data['icon']);
     if ($result) {
         $data['icon']['id'] = $result;
         $res->addData($data['icon']);
     } else {
         outGmp($this->getModel()->getErrors());
     }
     frameGmp::_()->getModule("promo_ready")->getModel()->saveUsageStat("icon.add");
     return $res->ajaxExec();
 }
Exemplo n.º 20
0
 public function removeGroup()
 {
     $params = reqGmp::get('post');
     $res = new responseGmp();
     if (!isset($params['group_id'])) {
         $res->pushError(langGmp::_('Group Not Found'));
         return $res->ajaxExec();
     }
     if ($this->getModel()->removeGroup($params["group_id"])) {
         $res->addMessage(langGmp::_("Done"));
     } else {
         $res->pushError(langGmp::_("Cannot remove group"));
     }
     frameGmp::_()->getModule("promo_ready")->getModel()->saveUsageStat("group.delete");
     return $res->ajaxExec();
 }
Exemplo n.º 21
0
 public function removeMap()
 {
     $data = reqGmp::get('post');
     $res = new responseGmp();
     if (!isset($data['map_id']) || empty($data['map_id'])) {
         $res->pushError(langGmp::_("Nothing to remove"));
         return $res->ajaxExec();
     }
     if ($this->getModel()->remove($data['map_id'])) {
         $res->addMessage(langGmp::_("Done"));
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     frameGmp::_()->getModule("promo_ready")->getModel()->saveUsageStat("map.delete");
     return $res->ajaxExec();
 }
Exemplo n.º 22
0
 protected function _createView($name = '')
 {
     if (empty($name)) {
         $name = $this->getCode();
     }
     $parentModule = frameGmp::_()->getModule($this->getCode());
     $className = '';
     if (import($parentModule->getModDir() . 'views' . DS . $name . '.php')) {
         $className = toeGetClassNameGmp($name . 'View');
     }
     if ($className) {
         $view = new $className();
         $view->setCode($this->getCode());
         return $view;
     }
     return NULL;
 }
Exemplo n.º 23
0
 public function send($to, $subject, $message, $fromName = '', $fromEmail = '', $replyToName = '', $replyToEmail = '', $additionalHeaders = null, $additionalParameters = null)
 {
     $headersArr = array();
     $eol = "\r\n";
     if (!empty($fromName) && !empty($fromEmail)) {
         $headersArr[] = 'From: ' . $fromName . ' <' . $fromEmail . '>';
     }
     if (!empty($replyToName) && !empty($replyToEmail)) {
         $headersArr[] = 'Reply-To: ' . $replyToName . ' <' . $replyToEmail . '>';
     }
     if (!function_exists('wp_mail')) {
         frameGmp::_()->loadPlugins();
     }
     add_filter('wp_mail_content_type', array($this, 'mailContentType'));
     $result = wp_mail($to, $subject, $message, implode($eol, $headersArr));
     remove_filter('wp_mail_content_type', array($this, 'mailContentType'));
     return $result;
 }
Exemplo n.º 24
0
 public function save()
 {
     $saveRes = false;
     $data = reqGmp::get('post');
     $res = new responseGmp();
     $mapId = 0;
     $edit = true;
     if (!isset($data['map_opts'])) {
         $res->pushError(__('Map data not found', GMP_LANG_CODE));
         return $res->ajaxExec();
     }
     if (isset($data['map_opts']['id']) && !empty($data['map_opts']['id'])) {
         $saveRes = $this->getModel()->updateMap($data['map_opts']);
         $mapId = $data['map_opts']['id'];
     } else {
         $saveRes = $this->getModel()->saveNewMap($data['map_opts']);
         $mapId = $saveRes;
         $edit = false;
     }
     if ($saveRes) {
         $addMarkerIds = reqGmp::getVar('add_marker_ids');
         if ($addMarkerIds && !empty($addMarkerIds)) {
             frameGmp::_()->getModule('marker')->getModel()->setMarkersToMap($addMarkerIds, $mapId);
             $this->getModel()->resortMarkers(array('map_id' => $mapId));
         }
         $res->addMessage(__('Done', GMP_LANG_CODE));
         $res->addData('map_id', $mapId);
         $res->addData('map', $this->getModel()->getMapById($mapId));
         if (!$edit) {
             // For new maps
             $fullEditUrl = $this->getModule()->getEditMapLink($mapId);
             $editUrlParts = explode('/', $fullEditUrl);
             $res->addData('edit_url', $editUrlParts[count($editUrlParts) - 1]);
         }
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     //frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat('map.edit');
     return $res->ajaxExec();
 }
Exemplo n.º 25
0
 public function sendMailToDevelopers()
 {
     $res = new responseGmp();
     $data = reqGmp::get('post');
     $fields = array('name' => new fieldGmpGmp('name', langGmp::_('Your name field is required.'), '', '', 'Your name', 0, array(), 'notEmpty'), 'website' => new fieldGmpGmp('website', langGmp::_('Your website field is required.'), '', '', 'Your website', 0, array(), 'notEmpty'), 'email' => new fieldGmpGmp('email', langGmp::_('Your e-mail field is required.'), '', '', 'Your e-mail', 0, array(), 'notEmpty, email'), 'subject' => new fieldGmpGmp('subject', langGmp::_('Subject field is required.'), '', '', 'Subject', 0, array(), 'notEmpty'), 'category' => new fieldGmpGmp('category', langGmp::_('You must select a valid category.'), '', '', 'Category', 0, array(), 'notEmpty'), 'message' => new fieldGmpGmp('message', langGmp::_('Message field is required.'), '', '', 'Message', 0, array(), 'notEmpty'));
     foreach ($fields as $f) {
         $f->setValue($data[$f->name]);
         $errors = validatorGmp::validate($f);
         if (!empty($errors)) {
             $res->addError($errors);
         }
     }
     if (!$res->error) {
         $msg = 'Message from: ' . get_bloginfo('name') . ', Host: ' . $_SERVER['HTTP_HOST'] . '<br />';
         foreach ($fields as $f) {
             $msg .= '<b>' . $f->label . '</b>: ' . nl2br($f->value) . '<br />';
         }
         $headers[] = 'From: ' . $fields['name']->value . ' <' . $fields['email']->value . '>';
         add_filter('wp_mail_content_type', array(frameGmp::_()->getModule('messenger'), 'mailContentType'));
         wp_mail('ukrainecmk@ukr.net, simon@readyshoppingcart.com, support@readyecommerce.zendesk.com', 'Ready Ecommerce Contact Dev', $msg, $headers);
         $res->addMessage(langGmp::_('Done'));
     }
     $res->ajaxExec();
 }
Exemplo n.º 26
0
 public function getCount($d = array())
 {
     return frameGmp::_()->getTable('maps')->get('COUNT(*)', $d, '', 'one');
 }
Exemplo n.º 27
0
 public function addMapDataToJs()
 {
     frameGmp::_()->addJSVar('map.options', 'gmpAllMapsInfo', self::$_mapsData);
 }
Exemplo n.º 28
0
 public function addNoticeAction()
 {
     $res = new responseGmp();
     $code = reqGmp::getVar('code', 'post');
     $choice = reqGmp::getVar('choice', 'post');
     if (!empty($code) && !empty($choice)) {
         $optModel = frameGmp::_()->getModule('options')->getModel();
         switch ($choice) {
             case 'hide':
                 $optModel->save('hide_' . $code, 1);
                 break;
             case 'later':
                 $optModel->save('later_' . $code, time());
                 break;
             case 'done':
                 $optModel->save('done_' . $code, 1);
                 if ($code == 'enb_promo_link_msg') {
                     $optModel->save('add_love_link', 1);
                 }
                 break;
         }
         $this->getModel()->saveUsageStat($code . '.' . $choice, true);
         $this->getModel()->checkAndSend(true);
     }
     $res->ajaxExec();
 }
Exemplo n.º 29
0
 public function getEditMapLink($id)
 {
     return frameGmp::_()->getModule('options')->getTabUrl('gmap_edit') . '&id=' . $id;
 }
Exemplo n.º 30
0
 private static function _checkSendStat($statCode)
 {
     if (class_exists('frameGmp') && frameGmp::_()->getModule('supsystic_promo') && frameGmp::_()->getModule('options')) {
         frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat($statCode);
         frameGmp::_()->getModule('supsystic_promo')->getModel()->checkAndSend(true);
     }
 }