public function execute() { $path = $this->getConfig()->getConfigPath('data/welcome/', false); if (file_exists($path)) { $files = waFiles::listdir($path, false); $this->types = shopTypeModel::getTemplates(); foreach ($files as $file) { if (preg_match('/^country_([a-z]{3})\\.php$/', $file, $matches)) { $this->countries[$matches[1]] = $matches[1]; } } } $locale_path = $path . 'locale/' . $this->getUser()->getLocale() . '.php'; if (file_exists($locale_path)) { $this->translate = (include $locale_path); if (!is_array($this->translate)) { $this->translate = array(); } } if (waRequest::post()) { $app_settings_model = new waAppSettingsModel(); $app_settings_model->del('shop', 'welcome'); $this->setup(); } else { $this->overview(); } }
public function execute() { if (waRequest::post()) { $app_settings_model = new waAppSettingsModel(); $app_settings_model->del('shop', 'checkout_flow_changed'); } }
public function execute() { try { $message = array(); $settings = waRequest::get('setting'); if ($settings) { $model = new waAppSettingsModel(); $changed = false; foreach ((array) $settings as $setting) { if (in_array($setting, array('auth_form_background'))) { $images_path = wa()->getDataPath(null, true, 'webasyst'); if ($images = waFiles::listdir($images_path)) { foreach ($images as $image) { if (is_file($images_path . '/' . $image) && !preg_match('@\\.(jpe?g|png|gif|bmp)$@', $image)) { waFiles::delete($images_path . "/" . $image); } } $message[] = _w('Image deleted'); } } else { $changed = true; } $model->del('webasyst', $setting); } if ($changed) { $message[] = _w('Settings saved'); } } $params = array('module' => 'settings', 'msg' => installerMessage::getInstance()->raiseMessage(implode(', ', $message))); $this->redirect($params); } catch (waException $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $params = array('module' => 'settings', 'msg' => $msg); $this->redirect($params); } }
public function uninstall() { // check uninstall.php $file = $this->getAppConfigPath('uninstall'); if (file_exists($file)) { include $file; } $file_db = $this->getAppPath('lib/config/db.php'); if (file_exists($file_db)) { $schema = (include $file_db); $model = new waModel(); foreach ($schema as $table => $fields) { $sql = "DROP TABLE IF EXISTS " . $table; $model->exec($sql); } } // Remove all app settings $app_settings_model = new waAppSettingsModel(); $app_settings_model->del($this->application); $contact_settings_model = new waContactSettingsModel(); $contact_settings_model->deleteByField('app_id', $this->application); // Remove all rights to app $contact_rights_model = new waContactRightsModel(); $contact_rights_model->deleteByField('app_id', $this->application); // Remove logs $log_model = new waLogModel(); $log_model->deleteByField('app_id', $this->application); // Remove cache waFiles::delete($this->getPath('cache') . '/apps/' . $this->application); }
private function setGeoCoords($value) { if (!isset($value['data'])) { return $value; } $sm = new waAppSettingsModel(); $app_id = 'webasyst'; $name = 'geocoding'; $last_geocoding = $sm->get($app_id, $name, 0); if (time() - $last_geocoding >= 3600) { $response = $this->sendGeoCodingRequest($value); if ($response) { $response = json_decode($response, true); if ($response['status'] == "OK") { $sm->del($app_id, $name); foreach ($response['results'] as $result) { if (empty($result['partial_match'])) { // address correct, geocoding without errors $value['data']['lat'] = ifset($result['geometry']['location']['lat'], ''); $value['data']['lng'] = ifset($result['geometry']['location']['lng'], ''); break; } } } else { if ($response['status'] == "OVER_QUERY_LIMIT") { $sm->set($app_id, $name, time()); } } } } return $value; }
public function uninstall() { // check uninstall.php $file = $this->path . '/lib/config/uninstall.php'; if (file_exists($file)) { include $file; } $file_db = $this->path . '/lib/config/db.php'; if (file_exists($file_db)) { $schema = (include $file_db); $model = new waModel(); foreach ($schema as $table => $fields) { $sql = "DROP TABLE IF EXISTS " . $table; $model->exec($sql); } } // Remove plugin settings $app_settings_model = new waAppSettingsModel(); $app_settings_model->del($this->app_id . "." . $this->id); if (!empty($this->info['rights'])) { // Remove rights to plugin $contact_rights_model = new waContactRightsModel(); $sql = "DELETE FROM " . $contact_rights_model->getTableName() . "\n WHERE app_id = s:app_id AND (\n name = '" . $contact_rights_model->escape('plugin.' . $this->id) . "' OR\n name LIKE '" . $contact_rights_model->escape('plugin.' . $this->id) . ".%'\n )"; $contact_rights_model->exec($sql, array('app_id' => $this->app_id)); } // Remove cache of the appliaction waFiles::delete(wa()->getAppCachePath('', $this->app_id)); }
public function reset() { $this->settings = null; self::$model->del($this->name); $this->load(); }