示例#1
0
 public function remove()
 {
     $res = new responseGmp();
     if (!$this->getModel()->remove(reqGmp::get('post'))) {
         $res->pushError($this->getModel()->getErrors());
     }
     return $res->ajaxExec();
 }
示例#2
0
 public function remove()
 {
     $res = new responseGmp();
     if (!$this->getModel()->remove(reqGmp::get('post'))) {
         $res->pushError($this->getModel()->getErrors());
     }
     //frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat('icon.delete');
     return $res->ajaxExec();
 }
示例#3
0
 public function importData()
 {
     $res = new responseGmp();
     if (!isset($_FILES['BackupFileCsv'])) {
         $res->addError(langGmp::_("Cannot Upload File"));
         return $res->ajaxExec();
     }
     $fileData = $_FILES['BackupFileCsv'];
     $uplDir = wp_upload_dir();
     $filePath = $uplDir['path'];
     $source = $fileData['tmp_name'];
     $dest = $filePath . DS . $fileData['name'];
     if (!copy($source, $dest)) {
         $res->addError(langRpw::_("Cannot Copy File"));
         return $res->ajaxExec();
     }
     $backupInfoCsv = file_get_contents($dest);
     $backupInfo = utilsGmp::unserialize($backupInfoCsv);
     if (empty($backupInfo)) {
         $res->addError(langRpw::_("Wrong Format"));
         return $res->ajaxExec();
     }
     $mapsKeys = array();
     $mapModel = frameGmp::_()->getModule("gmap")->getModel();
     $groupModule = frameGmp::_()->getModule("marker_groups");
     $markerModule = FrameGmp::_()->getModule("marker");
     $group_params = array();
     $groupKeys = array();
     $markersArr = array();
     foreach ($backupInfo as $map) {
         $map_params = array("title" => $map["title"], "description" => $map["description"], "params" => utilsGmp::serialize($map["params"]), "html_options" => utilsGmp::serialize($map["html_options"]), "create_date" => $map["create_date"]);
         //outeGmp($map_params);
         $map_new_id = frameGmp::_()->getTable("maps")->store($map_params);
         $mapsKeys[$map['id']] = $map_new_id;
         foreach ($map['markers'] as $marker) {
             if (isset($marker['groupObj']) && !empty($marker['groupObj'])) {
                 $group_params[$marker['groupObj']['id']] = $marker['groupObj'];
             }
             $markersArr[] = $marker;
         }
     }
     foreach ($group_params as $oldId => $groupInfo) {
         $gParams = array("title" => $groupInfo['title'], "description" => $groupInfo['description'], "mode" => "insert");
         $groupKeys[$oldId] = $groupModule->getModel()->saveGroup($gParams);
     }
     foreach ($markersArr as $marker) {
         $mParams = array("title" => $marker['title'], "description" => $marker['description'], "coord_x" => $marker['coord_x'], "coord_y" => $marker['coord_y'], "map_id" => $mapsKeys[$marker['map_id']], "marker_group_id" => $groupKeys[$marker['marker_group_id']], "address" => $marker['address'], "animation" => (int) $marker['animation'], "create_date" => $marker['create_date'], "params" => $marker['params'], "titleLink" => utilsGmp::serialize($marker['titleLink']));
         if (is_array($marker['icon'])) {
             $mParams['icon'] = $marker['icon']['id'];
         } elseif (is_string($marker['icon'])) {
             $mParams['icon'] = $marker['icon'];
         }
         $markerModule->getModel()->saveMarker($mParams);
     }
     outGmp($mapsKeys);
     outeGmp($groupKeys);
 }
示例#4
0
 public function saveGroup()
 {
     $res = new responseGmp();
     if ($this->getModel()->saveGroup(reqGmp::get('post'))) {
         $res->addMessage(__('Done', GMP_LANG_CODE));
     } else {
         $res->pushError($this->getModel('options')->getErrors());
     }
     return $res->ajaxExec();
 }
示例#5
0
 public function remove()
 {
     $res = new responseGmp();
     if ($this->getModel()->remove(reqGmp::getVar('id', 'post'))) {
         $res->addMessage(__('Done', GMP_LANG_CODE));
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     $res->ajaxExec();
 }
示例#6
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();
 }
示例#7
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();
 }
示例#8
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();
 }
示例#9
0
 public function getMarker()
 {
     $res = new responseGmp();
     $id = (int) reqGmp::getVar('id');
     if ($id) {
         $marker = $this->getModel()->getById($id);
         if (!empty($marker)) {
             $res->addData('marker', $marker);
         } else {
             $res->pushError($this->getModel()->getErrors());
         }
     } else {
         $res->pushError(langGmp::_('Empty or invalid marker ID'));
     }
     return $res->ajaxExec();
 }
示例#10
0
 public function hideUsageStat()
 {
     $res = new responseGmp();
     $this->getModule()->setUserHidedSendStats();
     return $res->ajaxExec();
 }
示例#11
0
 public function clear()
 {
     $res = new responseGmp();
     if ($this->getModel()->clear()) {
         $res->addMessage(__('Done', GMP_LANG_CODE));
     } else {
         $res->pushError($this->getModel()->getErrors());
     }
     $res->ajaxExec();
 }
示例#12
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();
 }
示例#13
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()->getAllMaps($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();
 }
示例#14
0
 public function import()
 {
     @ini_set('auto_detect_line_endings', true);
     $res = new responseGmp();
     $this->_connectCsvLib();
     $csvGenerator = toeCreateObjGmp('csvgeneratorGmp', array($fileName));
     $file = reqGmp::getVar('csv_import_file', 'file');
     if (empty($file) || empty($file['size'])) {
         $res->pushError(langGmp::_('Missing File'));
     }
     if (!empty($file['error'])) {
         $res->pushError(langGmp::_(array('File uploaded with error code', $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');
                 $importRes = $this->getModel()->import($fileArray, $overwriteSameNames);
                 if ($importRes) {
                     if ($importRes['map']['added']) {
                         $res->addMessage(langGmp::_(array('Added', $importRes['map']['added'], 'maps')));
                     }
                     if ($importRes['map']['updated']) {
                         $res->addMessage(langGmp::_(array('Updated', $importRes['map']['updated'], 'maps')));
                     }
                     if ($importRes['marker']['added']) {
                         $res->addMessage(langGmp::_(array('Added', $importRes['marker']['added'], 'markers')));
                     }
                     if ($importRes['marker']['updated']) {
                         $res->addMessage(langGmp::_(array('Updated', $importRes['marker']['updated'], 'markers')));
                     }
                 } else {
                     $res->pushError($this->getModel()->getErrors());
                 }
             } else {
                 $res->pushError(langGmp::_('File should contain more then 1 row, at least 1 row should be for headers'));
             }
         } else {
             $res->pushError(langGmp::_('Empty data in file'));
         }
     }
     frameGmp::_()->getModule('promo_ready')->getModel()->saveUsageStat('csv.import');
     $res->ajaxExec();
 }