Example #1
0
    public function getAdminsList()
    {
        global $wpdb;
        $admins = dbGmp::get('SELECT * FROM #__users 
			INNER JOIN #__usermeta ON #__users.ID = #__usermeta.user_id
			WHERE #__usermeta.meta_key = "#__capabilities" AND #__usermeta.meta_value LIKE "%administrator%"');
        return $admins;
    }
Example #2
0
 public function save($marker = array(), &$update = false)
 {
     $id = isset($marker['id']) ? (int) $marker['id'] : 0;
     $marker['title'] = isset($marker['title']) ? trim($marker['title']) : '';
     $marker['coord_x'] = isset($marker['coord_x']) ? (double) $marker['coord_x'] : 0;
     $marker['coord_y'] = isset($marker['coord_y']) ? (double) $marker['coord_y'] : 0;
     $update = (bool) $id;
     if (!empty($marker['title'])) {
         if (!isset($marker['marker_group_id'])) {
             $marker['marker_group_id'] = 0;
         }
         if (!isset($marker['icon']) || !frameGmp::_()->getModule('icons')->getModel()->iconExists($marker['icon'])) {
             $marker['icon'] = 1;
         }
         $marker['map_id'] = isset($marker['map_id']) ? (int) $marker['map_id'] : 0;
         if (!$update) {
             $marker['create_date'] = date('Y-m-d H:i:s');
             if ($marker['map_id']) {
                 $maxSortOrder = (int) dbGmp::get('SELECT MAX(sort_order) FROM @__markers WHERE map_id = "' . $marker['map_id'] . '"', 'one');
                 $marker['sort_order'] = ++$maxSortOrder;
             }
         }
         $marker['params'] = isset($marker['params']) ? utilsGmp::serialize($marker['params']) : '';
         if ($update) {
             dispatcherGmp::doAction('beforeMarkerUpdate', $id, $marker);
             $dbRes = frameGmp::_()->getTable('marker')->update($marker, array('id' => $id));
             dispatcherGmp::doAction('afterMarkerUpdate', $id, $marker);
         } else {
             dispatcherGmp::doAction('beforeMarkerInsert', $marker);
             $dbRes = frameGmp::_()->getTable('marker')->insert($marker);
             dispatcherGmp::doAction('afterMarkerInsert', $dbRes, $marker);
         }
         if ($dbRes) {
             if (!$update) {
                 $id = $dbRes;
             }
             return $id;
         } else {
             $this->pushError(frameGmp::_()->getTable('marker')->getErrors());
         }
     } else {
         $this->pushError(__('Please enter marker name'), 'marker_opts[title]', GMP_LANG_CODE);
     }
     return false;
 }
Example #3
0
 public function setDefaultIcons()
 {
     $jsonFile = frameGmp::_()->getModule('icons')->getModDir() . 'icons_files/icons.json';
     $icons = utilsGmp::jsonDecode(file_get_contents($jsonFile));
     $uplDir = wp_upload_dir();
     if (!is_dir($uplDir['basedir'])) {
         @mkdir($uplDir['basedir'], 0777);
     }
     $icons_upload_path = $uplDir['basedir'] . $this->getIconsPath();
     if (!is_dir($icons_upload_path)) {
         @mkdir($icons_upload_path, 0777);
     }
     $qItems = array();
     foreach ($icons as $icon) {
         $qItems[] = "('" . $icon['title'] . "','" . $icon['description'] . "','" . $icon['img'] . "')";
     }
     $query = "insert into `@__icons` (`title`,`description`,`path`) VALUES " . implode(",", $qItems);
     dbGmp::query($query);
     update_option('gmp_def_icons_installed', true);
 }
Example #4
0
 public static function get($query, $get = 'all', $outputType = ARRAY_A)
 {
     global $wpdb;
     $get = strtolower($get);
     $res = NULL;
     $query = self::prepareQuery($query);
     self::$query = $query;
     switch ($get) {
         case 'one':
             $res = $wpdb->get_var($query);
             break;
         case 'row':
             $res = $wpdb->get_row($query, $outputType);
             break;
         case 'col':
             $res = $wpdb->get_col($query);
             break;
         case 'all':
         default:
             $res = $wpdb->get_results($query, $outputType);
             break;
     }
     return $res;
 }
Example #5
0
 public static function init()
 {
     global $wpdb;
     $wpPrefix = $wpdb->prefix;
     /* add to 0.0.3 Versiom */
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $current_version = get_option($wpPrefix . GMP_DB_PREF . 'db_version', 0);
     $installed = (int) get_option($wpPrefix . GMP_DB_PREF . 'db_installed', 0);
     /**
      * modules 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "modules")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "modules` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) NOT NULL,\r\n\t\t\t  `active` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t  `type_id` smallint(3) NOT NULL DEFAULT '0',\r\n\t\t\t  `params` text,\r\n\t\t\t  `has_tab` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t  `label` varchar(128) DEFAULT NULL,\r\n\t\t\t  `description` text,\r\n\t\t\t  `ex_plug_dir` varchar(255) DEFAULT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  UNIQUE INDEX `code` (`code`)\r\n\t\t\t) DEFAULT CHARSET=utf8;");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t\t\t(NULL, 'adminmenu',1,1,'',0,'Admin Menu',''),\r\n\t\t\t\t(NULL, 'options',1,1,'',1,'Options',''),\r\n\t\t\t\t(NULL, 'user',1,1,'',1,'Users',''),\r\n\t\t\t\t(NULL, 'templates',1,1,'',1,'Templates for Plugin',''),\r\n\r\n\t\t\t\t(NULL, 'shortcodes', 1, 6, '', 0, 'Shortcodes', 'Shortcodes data'),\r\n\t\t\t\t(NULL, 'gmap', 1, 1, '',1, 'Gmap', 'Gmap'),\r\n\t\t\t\t(NULL, 'marker', 1, 1, '', 0, 'Markers', 'Google Maps Markers'),\r\n\t\t\t\t(NULL, 'marker_groups', 1, 1, '', 0, 'Marker Gropus', 'Marker Groups'),                  \r\n\t\t\t\t(NULL, 'supsystic_promo', 1, 1, '', 0, 'Promo', 'Promo'),\r\n\t\t\t\t(NULL, 'icons', 1, 1, '', 1, 'Marker Icons', 'Marker Icons'),\r\n\t\t\t\t(NULL, 'mail', 1, 1, '', 1, 'mail', 'mail');");
     }
     if (dbGmp::exist('@__modules', 'code', 'promo')) {
         dbGmp::query('UPDATE @__modules SET code = "supsystic_promo" WHERE code = "promo"');
     }
     if (!dbGmp::exist('@__modules', 'code', 'mail')) {
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t\t\t(NULL, 'mail', 1, 1, '', 1, 'mail', 'mail');");
     }
     if (!dbGmp::exist('@__modules', 'code', 'supsystic_promo')) {
         dbGmp::query("INSERT INTO `@__modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\r\n\t\t\t\t(NULL, 'supsystic_promo', 1, 1, '', 1, 'supsystic_promo', 'supsystic_promo');");
     }
     /**
      *  modules_type 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "modules_type")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "modules_type` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(64) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`)\r\n\t\t\t) AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "modules_type` VALUES\r\n\t\t\t  (1,'system'),\r\n\t\t\t  (4,'widget'),\r\n\t\t\t  (6,'addons'),\r\n\t\t\t  (7,'template')");
     }
     /**
      * options 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "options")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "options` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) CHARACTER SET latin1 NOT NULL,\r\n\t\t\t  `value` text NULL,\r\n\t\t\t  `label` varchar(128) CHARACTER SET latin1 DEFAULT NULL,\r\n\t\t\t  `description` text CHARACTER SET latin1,\r\n\t\t\t  `htmltype_id` smallint(2) NOT NULL DEFAULT '1',\r\n\t\t\t  `params` text NULL,\r\n\t\t\t  `cat_id` mediumint(3) DEFAULT '0',\r\n\t\t\t  `sort_order` mediumint(3) DEFAULT '0',\r\n\t\t\t  `value_type` varchar(16) CHARACTER SET latin1 DEFAULT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  KEY `id` (`id`),\r\n\t\t\t  UNIQUE INDEX `code` (`code`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("insert into `" . $wpPrefix . GMP_DB_PREF . "options` (  `code` ,  `value` ,  `label` ) \r\n\t\t\t\t\tVALUES ( 'save_statistic',  '0',  'Send statistic')");
         dbGmp::query("insert into `@__options` (`code`,`value`,`label`) VALUES\r\n\t\t\t('infowindow_size','" . utilsGmp::serialize(array('width' => '100', 'height' => '100')) . "','Info Window Size')");
     }
     /* options categories */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "options_categories")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "options_categories` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `label` varchar(128) NOT NULL,\r\n\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t  KEY `id` (`id`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "options_categories` VALUES\r\n\t\t\t\t(1, 'General'),\r\n\t\t\t\t(2, 'Template'),\r\n\t\t\t\t(3, 'Subscribe'),\r\n\t\t\t\t(4, 'Social');");
     }
     /*
      * Create table for map
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "maps")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "maps` (\r\n\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t`title` varchar(125) CHARACTER SET utf8  NOT NULL,\r\n\t\t\t\t`description` text CHARACTER SET utf8 NULL,\r\n\t\t\t\t`params` text NULL,\r\n\t\t\t\t`html_options` text NOT NULL,\r\n\t\t\t\t`create_date` datetime,\r\n\t\t\t\tPRIMARY KEY (`id`),\r\n\t\t\t\tUNIQUE INDEX `id` (`id`)\r\n\t\t\t  ) DEFAULT CHARSET=utf8");
     }
     /**
      * Create table for markers    
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "markers")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "markers" . "` (\r\n\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t`title` varchar(125) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t\t\t`description` text CHARACTER SET utf8 NULL,\r\n\t\t\t\t\t`coord_x` varchar(30) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t\t\t`coord_y` varchar(30) CHARACTER SET utf8 NOT NULL,\r\n\t\t\t\t\t`icon` int(11),\r\n\t\t\t\t\t`map_id` int(11),\r\n\t\t\t\t\t`marker_group_id` int(11),\r\n\t\t\t\t\t`address` text CHARACTER SET utf8,\r\n\t\t\t\t\t`animation` int(1),\r\n\t\t\t\t\t`create_date` datetime,\r\n\t\t\t\t\t`params` text  CHARACTER SET utf8 NOT NULL,\r\n\t\t\t\t\t`sort_order` tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t\t\tPRIMARY KEY (`id`)\r\n\t\t\t\t) DEFAULT CHARSET=utf8");
     }
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "markers", 'sort_order')) {
         dbGmp::query("ALTER TABLE `@__markers` ADD COLUMN `sort_order` tinyint(1) NOT NULL DEFAULT '0';");
     }
     /**
      * Create table for marker Icons
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "icons")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "icons" . "` (\r\n\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t`title` varchar(100) CHARACTER SET utf8,   \r\n\t\t\t\t`description` text CHARACTER SET utf8,   \r\n\t\t\t\t`path` varchar(250) CHARACTER SET utf8,   \r\n\t\t\t\t PRIMARY KEY (`id`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
     }
     /**
      * Create table for marker groups
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "marker_groups")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "marker_groups" . "` (\r\n\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t`title` varchar(250) CHARACTER SET utf8,\r\n\t\t\t\t\t`description` text CHARACTER SET utf8,\r\n\t\t\t\t PRIMARY KEY (`id`)\r\n\t\t\t\t  ) DEFAULT CHARSET=utf8");
     }
     $markerGroupsClearedInvalid = get_option($wpPrefix . GMP_DB_PREF . 'mg_cleared_inv', 0);
     if (!$markerGroupsClearedInvalid) {
         dbGmp::query('UPDATE @__markers SET marker_group_id = 0 WHERE marker_group_id = 1');
         // This was wrong update in markers table before - fix this one time before update plugin
         update_option($wpPrefix . GMP_DB_PREF . 'mg_cleared_inv', 1);
     }
     /**
      * Plugin usage statistics
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "usage_stat")) {
         dbDelta("CREATE TABLE `" . $wpPrefix . GMP_DB_PREF . "usage_stat` (\r\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t  `code` varchar(64) NOT NULL,\r\n\t\t\t  `visits` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t  `spent_time` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t  `modify_timestamp` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\r\n\t\t\t  UNIQUE INDEX `code` (`code`),\r\n\t\t\t  PRIMARY KEY (`id`)\r\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "usage_stat` (code, visits) VALUES ('installed', 1)");
     }
     update_option($wpPrefix . GMP_DB_PREF . 'db_version', GMP_VERSION_PLUGIN);
     add_option($wpPrefix . GMP_DB_PREF . 'db_installed', 1);
     installerDbUpdaterGmp::runUpdate();
 }
Example #6
0
 public function getLastInsertID()
 {
     return dbGmp::get('SELECT MAX(' . $this->_id . ') FROM ' . $this->_table, 'one');
 }
Example #7
0
 public static function init()
 {
     global $wpdb;
     $wpPrefix = $wpdb->prefix;
     /* add to 0.0.3 Versiom */
     //$start = microtime(true);					// Speed debug info
     //$queriesCountStart = $wpdb->num_queries;	// Speed debug info
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $current_version = get_option($wpPrefix . GMP_DB_PREF . 'db_version', 0);
     $installed = (int) get_option($wpPrefix . GMP_DB_PREF . 'db_installed', 0);
     /**
      * htmltype 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "htmltype")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "htmltype` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `label` varchar(32) NOT NULL,\n\t\t\t  `description` varchar(255) NOT NULL,\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  UNIQUE INDEX `label` (`label`)\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "htmltype` VALUES\n\t\t\t\t(1, 'text', 'Text'),\n\t\t\t\t(2, 'password', 'Password'),\n\t\t\t\t(3, 'hidden', 'Hidden'),\n\t\t\t\t(4, 'checkbox', 'Checkbox'),\n\t\t\t\t(5, 'checkboxlist', 'Checkboxes'),\n\t\t\t\t(6, 'datepicker', 'Date Picker'),\n\t\t\t\t(7, 'submit', 'Button'),\n\t\t\t\t(8, 'img', 'Image'),\n\t\t\t\t(9, 'selectbox', 'Drop Down'),\n\t\t\t\t(10, 'radiobuttons', 'Radio Buttons'),\n\t\t\t\t(11, 'countryList', 'Countries List'),\n\t\t\t\t(12, 'selectlist', 'List'),\n\t\t\t\t(13, 'countryListMultiple', 'Country List with posibility to select multiple countries'),\n\t\t\t\t(14, 'block', 'Will show only value as text'),\n\t\t\t\t(15, 'statesList', 'States List'),\n\t\t\t\t(16, 'textFieldsDynamicTable', 'Dynamic table - multiple text options set'),\n\t\t\t\t(17, 'textarea', 'Textarea'),\n\t\t\t\t(18, 'checkboxHiddenVal', 'Checkbox with Hidden field')");
     }
     /**
      * modules 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "modules")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "modules` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `code` varchar(64) NOT NULL,\n\t\t\t  `active` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t  `type_id` smallint(3) NOT NULL DEFAULT '0',\n\t\t\t  `params` text,\n\t\t\t  `has_tab` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t  `label` varchar(128) DEFAULT NULL,\n\t\t\t  `description` text,\n\t\t\t  `ex_plug_dir` varchar(255) DEFAULT NULL,\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  UNIQUE INDEX `code` (`code`)\n\t\t\t) DEFAULT CHARSET=utf8;");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "modules` (id, code, active, type_id, params, has_tab, label, description) VALUES\n\t\t\t\t(NULL, 'adminmenu',1,1,'',0,'Admin Menu',''),\n\t\t\t\t(NULL, 'options',1,1,'',1,'Options',''),\n\t\t\t\t(NULL, 'user',1,1,'',1,'Users',''),\n\t\t\t\t(NULL, 'templates',1,1,'',1,'Templates for Plugin',''),\n\n\t\t\t\t(NULL, 'shortcodes', 1, 6, '', 0, 'Shortcodes', 'Shortcodes data'),\n\t\t\t\t(NULL, 'gmap', 1, 1, '',1, 'Gmap', 'Gmap'),\n\t\t\t\t(NULL, 'marker', 1, 1, '', 0, 'Markers', 'Google Maps Markers'),\n\t\t\t\t(NULL, 'marker_groups', 1, 1, '', 0, 'Marker Gropus', 'Marker Groups'),                  \n\t\t\t\t(NULL, 'promo_ready', 1, 1, '', 0, 'Promo Ready', 'Promo Ready'),                  \n\t\t\t\t(NULL, 'icons', 1, 1, '', 1, 'Marker Icons', 'Marker Icons');");
     }
     /**
      *  modules_type 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "modules_type")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "modules_type` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `label` varchar(64) NOT NULL,\n\t\t\t  PRIMARY KEY (`id`)\n\t\t\t) AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "modules_type` VALUES\n\t\t\t  (1,'system'),\n\t\t\t  (2,'payment'),\n\t\t\t  (3,'shipping'),\n\t\t\t  (4,'widget'),\n\t\t\t  (5,'product_extra'),\n\t\t\t  (6,'addons'),\n\t\t\t  (7,'template')");
     }
     /**
      * options 
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "options")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "options` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `code` varchar(64) CHARACTER SET latin1 NOT NULL,\n\t\t\t  `value` text NULL,\n\t\t\t  `label` varchar(128) CHARACTER SET latin1 DEFAULT NULL,\n\t\t\t  `description` text CHARACTER SET latin1,\n\t\t\t  `htmltype_id` smallint(2) NOT NULL DEFAULT '1',\n\t\t\t  `params` text NULL,\n\t\t\t  `cat_id` mediumint(3) DEFAULT '0',\n\t\t\t  `sort_order` mediumint(3) DEFAULT '0',\n\t\t\t  `value_type` varchar(16) CHARACTER SET latin1 DEFAULT NULL,\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  KEY `id` (`id`),\n\t\t\t  UNIQUE INDEX `code` (`code`)\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("`" . $wpPrefix . GMP_DB_PREF . "options` (  `code` ,  `value` ,  `label` ) \n\t\t\t\t\tVALUES ( 'save_statistic',  '0',  'Send statistic')");
     }
     $eol = "\n";
     /* options categories */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "options_categories")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "options_categories` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `label` varchar(128) NOT NULL,\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  KEY `id` (`id`)\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "options_categories` VALUES\n\t\t\t\t(1, 'General'),\n\t\t\t\t(2, 'Template'),\n\t\t\t\t(3, 'Subscribe'),\n\t\t\t\t(4, 'Social');");
     }
     /*
      * Create table for map
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "maps")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "maps` (\n\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`title` varchar(125) CHARACTER SET utf8  NOT NULL,\n\t\t\t\t`description` text CHARACTER SET utf8 NULL,\n\t\t\t\t`params` text NULL,\n\t\t\t\t`html_options` text NOT NULL,\n\t\t\t\t`create_date` datetime,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tUNIQUE INDEX `id` (`id`)\n\t\t\t  ) DEFAULT CHARSET=utf8");
     }
     /**
      * Create table for markers    
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "markers")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "markers" . "` (\n\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`title` varchar(125) CHARACTER SET utf8  NOT NULL,\n\t\t\t\t\t`description` text CHARACTER SET utf8 NULL,\n\t\t\t\t\t`coord_x` varchar(30) NOT NULL,\n\t\t\t\t\t`coord_y` varchar(30) NOT NULL,\n\t\t\t\t\t`icon` int(11),\n\t\t\t\t\t`map_id` int(11),\n\t\t\t\t\t`marker_group_id` int(11),\n\t\t\t\t\t`address` text,\n\t\t\t\t\t`animation` int(1),\n\t\t\t\t\t`create_date` datetime,\n\t\t\t\t\t`params` text  CHARACTER SET utf8  NOT NULL,\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t)");
     }
     /**
      * Create table for marker Icons
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "icons")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "icons" . "` (\n\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`title` varchar(100) CHARACTER SET utf8,   \n\t\t\t\t\t`description` text CHARACTER SET utf8,   \n\t\t\t\t\t`path` varchar(250) CHARACTER SET utf8,   \n\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t)");
     }
     /**
      * Create table for marker groups
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "marker_groups")) {
         dbDelta("CREATE TABLE IF NOT EXISTS `" . $wpPrefix . GMP_DB_PREF . "marker_groups" . "` (\n\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`title` varchar(250) CHARACTER SET utf8,\n\t\t\t\t\t`description` text CHARACTER SET utf8,\n\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t  )");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "marker_groups` VALUES('null', 'Default Group','Default Group');");
     }
     /*
      * Create table for statistic
      * 
      */
     /**
      * Plugin usage statistics
      */
     if (!dbGmp::exist($wpPrefix . GMP_DB_PREF . "usage_stat")) {
         dbDelta("CREATE TABLE `" . $wpPrefix . GMP_DB_PREF . "usage_stat` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `code` varchar(64) NOT NULL,\n\t\t\t  `visits` int(11) NOT NULL DEFAULT '0',\n\t\t\t  `spent_time` int(11) NOT NULL DEFAULT '0',\n\t\t\t  `modify_timestamp` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n\t\t\t  UNIQUE INDEX `code` (`code`),\n\t\t\t  PRIMARY KEY (`id`)\n\t\t\t) DEFAULT CHARSET=utf8");
         dbGmp::query("INSERT INTO `" . $wpPrefix . GMP_DB_PREF . "usage_stat` (code, visits) VALUES ('installed', 1)");
     }
     update_option($wpPrefix . GMP_DB_PREF . 'db_version', GMP_VERSION);
     add_option($wpPrefix . GMP_DB_PREF . 'db_installed', 1);
     dbGmp::query("UPDATE `" . $wpPrefix . GMP_DB_PREF . "options` SET value = '" . GMP_VERSION . "' WHERE code = 'version' LIMIT 1");
     installerDbUpdaterGmp::runUpdate();
     //$time = microtime(true) - $start;	// Speed debug info
 }
Example #8
0
 public function getListForTable()
 {
     $res = new responseGmp();
     $res->ignoreShellData();
     $count = $this->getModel()->getCount();
     $listReqData = array('limitFrom' => reqGmp::getVar('iDisplayStart'), 'limitTo' => reqGmp::getVar('iDisplayLength'));
     $displayColumns = $this->getView()->getDisplayColumns();
     $displayColumnsKeys = array_keys($displayColumns);
     $iSortCol = reqGmp::getVar('iSortCol_0');
     if (!is_null($iSortCol) && is_numeric($iSortCol)) {
         $listReqData['orderBy'] = $displayColumns[$displayColumnsKeys[$iSortCol]]['db'];
         $iSortDir = reqGmp::getVar('sSortDir_0');
         if (!is_null($iSortDir)) {
             $listReqData['orderBy'] .= ' ' . strtoupper($iSortDir);
         }
     }
     $search = reqGmp::getVar('sSearch');
     if (!is_null($search) && !empty($search)) {
         $dbSearch = dbGmp::escape($search);
         $listReqData['additionalCondition'] = 'title LIKE "%' . $dbSearch . '%" OR description LIKE "%' . $dbSearch . '%"';
     }
     $list = $this->getModel()->getAllMarkers($listReqData, true);
     $res->addData('aaData', $this->_convertDataForDatatable($list));
     $res->addData('iTotalRecords', $count);
     $res->addData('iTotalDisplayRecords', $count);
     $res->addData('sEcho', reqGmp::getVar('sEcho'));
     $res->addMessage(__('Done'));
     return $res->ajaxExec();
 }
Example #9
0
 public function getUserStatsCount()
 {
     $query = 'SELECT COUNT(*) AS total FROM @__usage_stat';
     return (int) dbGmp::get($query, 'one');
 }
Example #10
0
 public function import()
 {
     @ini_set('auto_detect_line_endings', true);
     $res = new responseGmp();
     $this->_connectCsvLib();
     $csvGenerator = toeCreateObjGmp('csvgeneratorGmp', array(''));
     $type = reqGmp::getVar('type');
     $file = $type == 'maps' ? reqGmp::getVar('csv_import_file_maps', 'file') : reqGmp::getVar('csv_import_file_markers', 'file');
     if (empty($file) || empty($file['size'])) {
         $res->pushError(__('Missing File', GMP_LANG_CODE));
     }
     if (!empty($file['error'])) {
         $res->pushError(sprintf(__('File uploaded with error code %s', $file['error'])));
     }
     if (!$res->error()) {
         $fileArray = array();
         $handle = fopen($file['tmp_name'], 'r');
         $csvParams['delimiter'] = $csvGenerator->getDelimiter();
         $csvParams['enclosure'] = $csvGenerator->getEnclosure();
         $csvParams['escape'] = $csvGenerator->getEscape();
         //if(version_compare( phpversion(), '5.3.0' ) == -1) //for PHP lower than 5.3.0 third parameter - escape - is not implemented
         while ($row = @fgetcsv($handle, 0, $csvParams['delimiter'], '"')) {
             $fileArray[] = $row;
         }
         /*else
         		while($row = @fgetcsv( $handle, 0, $csvParams['delimiter'], $csvParams['enclosure'], $csvParams['escape'] )) $fileArray[] = $row;*/
         /*var_dump($fileArray);
         		exit();*/
         if (!empty($fileArray)) {
             if (count($fileArray) > 1) {
                 //$overwriteSameNames = (int) reqGmp::getVar('overwrite_same_names');
                 $keys = array_shift($fileArray);
                 switch ($type) {
                     case 'maps':
                         $mapModel = frameGmp::_()->getModule('gmap')->getModel();
                         foreach ($fileArray as $i => $row) {
                             $map = array();
                             foreach ($keys as $j => $key) {
                                 $value = $this->_prepareValueToImport($row[$j]);
                                 if (strpos($key, '.')) {
                                     $realKeys = explode('.', $key);
                                     $realKey = array_pop($realKeys);
                                     $realPreKey = array_pop($realKeys);
                                     if ($realPreKey == 'map_center') {
                                         $valueMapCenter = isset($map['map_center']) ? $map['map_center'] : array();
                                         $valueMapCenter[$realKey] = $value;
                                         $value = $valueMapCenter;
                                         $realKey = 'map_center';
                                     }
                                 } else {
                                     $realKey = $key;
                                 }
                                 if ($value === '') {
                                     $value = NULL;
                                 }
                                 $map[$realKey] = $value;
                             }
                             if (isset($map['id']) && $mapModel->existsId($map['id'])) {
                                 $mapModel->updateMap($map);
                             } else {
                                 $originalMapId = isset($map['id']) ? isset($map['id']) : 0;
                                 if (isset($map['id'])) {
                                     unset($map['id']);
                                 }
                                 $newMapId = $mapModel->saveNewMap($map);
                                 if ($newMapId && $originalMapId) {
                                     dbGmp::query("UPDATE @__maps SET id = '{$originalMapId}' WHERE id = '{$newMapId}'");
                                     if ($originalMapId > $newMapId) {
                                         dbGmp::setAutoIncrement('@__popup', $originalMapId + 1);
                                     }
                                 }
                             }
                         }
                         break;
                     case 'markers':
                         $markerModel = frameGmp::_()->getModule('marker')->getModel();
                         foreach ($fileArray as $i => $row) {
                             $marker = array();
                             foreach ($keys as $j => $key) {
                                 $this->_setKeyVal($marker, $key, $this->_prepareValueToImport($row[$j]));
                             }
                             if (isset($marker['id']) && !$markerModel->existsId($marker['id'])) {
                                 unset($marker['id']);
                             }
                             $markerModel->save($marker);
                         }
                         break;
                 }
                 /*$importRes = $this->getModel()->import($fileArray, $overwriteSameNames);
                 		if($importRes) {
                 			if($importRes['map']['added'])
                 				$res->addMessage (sprintf(__('Added %s maps', GMP_LANG_CODE), $importRes['map']['added']));
                 			if($importRes['map']['updated'])
                 				$res->addMessage (sprintf(__('Updated %s maps', GMP_LANG_CODE), $importRes['map']['added']));
                 			if($importRes['marker']['added'])
                 				$res->addMessage (sprintf(__('Added %s markers', GMP_LANG_CODE), $importRes['map']['added']));
                 			if($importRes['marker']['updated'])
                 				$res->addMessage (sprintf(__('Updated %s markers', GMP_LANG_CODE), $importRes['map']['added']));
                 		} else
                 			$res->pushError ($this->getModel()->getErrors());*/
             } else {
                 $res->pushError(__('File should contain more then 1 row, at least 1 row should be for headers', GMP_LANG_CODE));
             }
         } else {
             $res->pushError(__('Empty data in file', GMP_LANG_CODE));
         }
     }
     frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat('csv.import');
     $res->ajaxExec();
 }
Example #11
0
 public static function update_109()
 {
     dbGmp::query("INSERT INTO `@__modules` (id, code, active, type_id, params, has_tab, label, description)\n\t\t\tVALUES (NULL, 'gmap_widget', 1, 1, '', 0, 'gmap_widget', 'gmap_widget')");
 }
 public static function update_117()
 {
     dbGmp::query("UPDATE @__options SET value_type = 'array' WHERE code = 'infowindow_size' LIMIT 1");
 }