getConfigTable() 공개 정적인 메소드

Get config table name
public static getConfigTable ( ) : string
리턴 string
예제 #1
0
 private function _getParams($groupName)
 {
     $where = "`config_group` = '{$groupName}' AND `type` != 'hidden' " . ($this->_type ? 'AND `custom` = 1' : '') . ' ORDER BY `order`';
     $params = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, $where, null, null, iaCore::getConfigTable());
     if ($this->_type) {
         $custom = 'user' == $this->_type ? $this->_iaCore->getCustomConfig($this->_typeId) : $this->_iaCore->getCustomConfig(null, $this->_typeId);
         $custom2 = 'user' == $this->_type ? $this->_getUsersSpecificConfig() : array();
     }
     $iaItem = $this->_iaCore->factory('item');
     $itemsList = $iaItem->getItems();
     foreach ($params as &$entry) {
         $className = 'default';
         if ($this->_type) {
             $className = 'custom';
             if (self::TYPE_DIVIDER != $entry['type']) {
                 if (isset($custom2[$entry['name']])) {
                     $entry['default'] = $custom2[$entry['name']];
                     $entry['value'] = $custom2[$entry['name']];
                 } else {
                     $entry['default'] = $this->_iaCore->get($entry['name']);
                 }
                 if (isset($custom[$entry['name']])) {
                     $className = 'common';
                     $entry['value'] = $custom[$entry['name']];
                 }
             }
         }
         if ('itemscheckbox' == $entry['type']) {
             $array = $this->_iaCore->get($entry['extras'] . '_items_implemented');
             $array = $array ? explode(',', $array) : array();
             $array = array_values(array_intersect($array, $itemsList));
             if ($array) {
                 $enabledItems = $iaItem->getEnabledItemsForPlugin($entry['extras']);
                 for ($i = 0; $i < count($array); $i++) {
                     $array[$i] = trim($array[$i]);
                     $entry['items'][] = array('name' => $array[$i], 'title' => iaLanguage::get($array[$i]), 'checked' => (int) in_array($array[$i], $enabledItems));
                 }
             }
         }
         if (self::TYPE_SELECT == $entry['type']) {
             switch ($entry['name']) {
                 case 'timezone':
                     $entry['values'] = iaUtil::getFormattedTimezones();
                     break;
                 case 'lang':
                     $entry['values'] = $this->_iaCore->languages;
                     break;
                 default:
                     $entry['values'] = explode(',', $entry['multiple_values']);
             }
         }
         $entry['class'] = $className;
     }
     return $params;
 }
예제 #2
0
 protected function _createJsFile($file, $type = 'config')
 {
     $this->iaCore->factory('util');
     // required in order the class iaUtil to be loaded
     $iaDb =& $this->iaCore->iaDb;
     switch ($type) {
         case 'lang':
         case 'admin_lang':
             // get phrases
             $stmt = "`code` = :lang AND `category` NOT IN ('tooltip', 'page', :category)";
             $iaDb->bind($stmt, array('lang' => $this->iaCore->iaView->language, 'category' => $type == 'admin_lang' ? 'frontend' : iaCore::ADMIN));
             $phrases = $iaDb->keyvalue(array('key', 'value'), $stmt, iaLanguage::getTable());
             // get list of languages
             $languagesList = $iaDb->assoc(array('code', 'title', 'direction', 'flagicon', 'iso' => 'code'), 'admin_lang' == $type ? null : "`status` = 'active'", 'languages');
             $fileContent = 'intelli.' . ('admin_lang' == $type ? 'admin.' : '') . 'lang = ' . iaUtil::jsonEncode($phrases) . ';' . 'intelli.languages = ' . iaUtil::jsonEncode($languagesList) . ';';
             break;
         case 'config':
             $stmt = "`private` = 0 && `type` != 'divider' && `config_group` != 'email_templates'";
             $config = $iaDb->keyvalue(array('name', 'value'), $stmt, iaCore::getConfigTable());
             if (file_exists(IA_INCLUDES . 'custom.inc.php')) {
                 include IA_INCLUDES . 'custom.inc.php';
             }
             $config['ia_url'] = IA_CLEAR_URL;
             $config['packages'] = $this->iaCore->setPackagesData();
             $config['items'] = array();
             $config['extras'] = array(array('core', iaLanguage::get('core', 'Core')));
             $array = $iaDb->all(array('name', 'title'), "`status` = 'active' ORDER BY `type`", null, null, 'extras');
             foreach ($array as $item) {
                 $config['extras'][] = array($item['name'], $item['title']);
             }
             $array = $iaDb->onefield('`item`', "`item` != 'transactions'", null, null, 'items');
             foreach ($array as $item) {
                 $config['items'][] = array($item, iaLanguage::get($item, $item));
             }
             $fileContent = 'intelli.config = ' . iaUtil::jsonEncode($config) . ';';
     }
     if (isset($fileContent)) {
         if ($fh = fopen($file, 'w')) {
             fwrite($fh, $fileContent);
             fclose($fh);
         }
     }
 }
예제 #3
0
 public static function loadCoreClass($name, $type = 'admin')
 {
     if (!class_exists('iaCore')) {
         define('IA_INCLUDES', IA_HOME . 'includes' . IA_DS);
         define('IA_SMARTY', IA_INCLUDES . 'smarty' . IA_DS);
         define('IA_CLASSES', IA_INCLUDES . 'classes' . IA_DS);
         define('IA_PACKAGES', IA_HOME . 'packages' . IA_DS);
         define('IA_PLUGINS', IA_HOME . 'plugins' . IA_DS);
         define('IA_TMP', IA_HOME . 'tmp' . IA_DS);
         define('IA_CACHEDIR', IA_TMP . 'cache' . IA_DS);
         if (file_exists(IA_INCLUDES . 'config.inc.php')) {
             include_once IA_INCLUDES . 'config.inc.php';
         } else {
             define('INTELLI_CONNECT', 'mysql');
             define('INTELLI_DBHOST', self::getPost('dbhost', 'localhost'));
             define('INTELLI_DBPORT', self::getPost('dbport', 3306));
             define('INTELLI_DBUSER', self::getPost('dbuser'));
             define('INTELLI_DBPASS', self::getPost('dbpwd'));
             define('INTELLI_DBNAME', self::getPost('dbname'));
             define('INTELLI_DBPREFIX', self::getPost('prefix', '', false));
             define('INTELLI_DEBUG', false);
         }
         set_include_path(IA_CLASSES);
         require_once 'ia.system.php';
         if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
             spl_autoload_register(array('iaSystem', 'autoload'));
         }
         require_once IA_INCLUDES . 'function.php';
         require_once 'ia.interfaces.php';
         $iaCore = iaCore::instance();
         iaSystem::setDebugMode();
         $iaCore->factory(array('sanitize', 'validate'));
         $iaCore->iaDb = $iaCore->factory('db');
         $iaCore->factory('language');
         $iaCore->iaView = $iaCore->factory('view');
         $iaCore->iaCache = $iaCore->factory('cache');
         $config = array('baseurl', 'timezone');
         $config = $iaCore->iaDb->keyvalue(array('name', 'value'), "`name` IN ('" . implode("','", $config) . "')", iaCore::getConfigTable());
         $iaCore->languages = array('en' => 'English');
         $iaCore->iaView->language = 'en';
         date_default_timezone_set($config['timezone']);
         define('IA_CLEAR_URL', $config['baseurl']);
         define('IA_URL', IA_CLEAR_URL);
         define('IA_FRONT_TEMPLATES', IA_HOME . 'templates' . IA_DS);
         define('IA_TEMPLATES', IA_FRONT_TEMPLATES);
     }
     return iaCore::instance()->factory($name, $type);
 }
예제 #4
0
 private function _processCategory(array $entryData, $action = self::ACTION_INSTALL)
 {
     switch ($entryData['category']) {
         case 'payments':
             $iaTransaction = $this->iaCore->factory('transaction');
             if (self::ACTION_INSTALL == $action) {
                 $entry = array('name' => $entryData['name'], 'title' => $entryData['title']);
                 $this->iaDb->insert($entry, null, $iaTransaction->getTableGateways());
             } elseif (self::ACTION_UNINSTALL == $action) {
                 $this->iaDb->delete('`name` = :name', $iaTransaction->getTableGateways(), $entryData);
             }
             break;
         case 'lightbox':
         case 'captchas':
             $configName = 'lightbox' == $entryData['category'] ? 'lightbox_name' : 'captcha_name';
             $stmt = iaDb::convertIds($configName, 'name');
             $this->iaDb->setTable(iaCore::getConfigTable());
             if (self::ACTION_INSTALL == $action) {
                 if ($currentValues = $this->iaDb->one('`multiple_values`', $stmt)) {
                     $values = explode(',', $currentValues);
                 }
                 $values[] = $entryData['name'];
                 $this->iaDb->update(array('multiple_values' => implode(',', $values)), $stmt);
                 if (1 == count($values)) {
                     $this->iaCore->set($configName, $entryData['name'], true);
                 }
             } elseif (self::ACTION_UNINSTALL == $action) {
                 // get possible values
                 if ($values = explode(',', $this->iaDb->one('`multiple_values`', $stmt))) {
                     $installed = array_diff($values, array($entryData['name']));
                     $this->iaDb->update(array('multiple_values' => implode(',', $installed)), $stmt);
                     if ($this->iaCore->get($configName) == $entryData['name']) {
                         $value = empty($installed) ? '' : array_shift($installed);
                         if (in_array($entryData['name'], $this->_builtinPlugins)) {
                             $value = $entryData['name'];
                         }
                         $this->iaCore->set($configName, $value, true);
                     }
                 }
             }
             $this->iaDb->resetTable();
             break;
     }
 }
예제 #5
0
     break;
 case 'backup':
     require_once IA_INSTALL . 'classes/ia.backup.php';
     $iaBackup = new iaBackup();
     if (iaHelper::isAjaxRequest()) {
         iaHelper::loadCoreClass('view', 'core')->set('nodebug', true);
         echo $iaBackup->save() ? 'success' : array_shift($iaBackup->messages);
         exit;
     } else {
         $iaOutput->backupFile = str_replace(IA_HOME, '', $iaBackup->filePath);
     }
     break;
 case 'finish':
     require_once IA_INSTALL . 'classes/ia.patch.parser.php';
     require_once IA_INSTALL . 'classes/ia.patch.applier.php';
     $iaOutput->adminPath = iaCore::instance()->iaDb->one_bind('value', '`name` = :name', array('name' => 'admin_page'), iaCore::getConfigTable());
     $options = isset($_GET['options']) && is_array($_GET['options']) ? $_GET['options'] : array();
     try {
         $patchFileContent = @file_get_contents(IA_HOME . 'tmp' . IA_DS . 'patch.iap');
         if (false === $patchFileContent) {
             throw new Exception('Could not get downloaded patch file. Please download it again.');
         }
         $patchParser = new iaPatchParser($patchFileContent);
         $patch = $patchParser->patch;
         if ($patch['info']['version_from'] != str_replace('.', '', IA_VERSION)) {
             throw new Exception('Patch is not applicable to your version of Subrion CMS.');
         }
         $patchApplier = new iaPatchApplier(IA_HOME, array('host' => INTELLI_DBHOST . ':' . INTELLI_DBPORT, 'database' => INTELLI_DBNAME, 'user' => INTELLI_DBUSER, 'password' => INTELLI_DBPASS, 'prefix' => INTELLI_DBPREFIX), in_array('force-mode', $options));
         $patchApplier->process($patch, $_SESSION['upgrade_to']);
         $textLog = $patchApplier->getLog();
         $logFile = 'upgrade-log-' . $patch['info']['version_to'] . '_' . date('d-m-y-Hi') . '.txt';
예제 #6
0
 private function _getList()
 {
     $stmt = iaDb::convertIds(iaExtra::TYPE_PACKAGE, 'type');
     $existPackages = $this->_iaDb->keyvalue(array('name', 'version'), $stmt);
     $existPackages || ($existPackages = array());
     $statuses = $this->_iaDb->keyvalue(array('name', 'status'), $stmt);
     $dates = $this->_iaDb->keyvalue(array('name', 'date'), $stmt);
     $directory = opendir($this->_folder);
     $result = $packageNames = array();
     while ($file = readdir($directory)) {
         $installationFile = $this->_folder . $file . IA_DS . iaExtra::INSTALL_FILE_NAME;
         if (substr($file, 0, 1) != '.' && is_dir($this->_folder . $file) && file_exists($installationFile)) {
             if ($fileContents = file_get_contents($installationFile)) {
                 $this->getHelper()->itemData['screenshots'] = array();
                 $this->getHelper()->itemData['url'] = '';
                 $this->getHelper()->setXml($fileContents);
                 $this->getHelper()->parse();
                 $buttons = false;
                 $version = explode('-', $this->getHelper()->itemData['compatibility']);
                 if (!isset($version[1])) {
                     if (version_compare($version[0], IA_VERSION, '<=')) {
                         $buttons = true;
                     }
                 } else {
                     if (version_compare($version[0], IA_VERSION, '<=') && version_compare($version[1], IA_VERSION, '>=')) {
                         $buttons = true;
                     }
                 }
                 if (false === $buttons) {
                     $this->getHelper()->itemData['compatibility'] = '<span style="color:red">' . $this->getHelper()->itemData['compatibility'] . ' ' . iaLanguage::get('incompatible') . '</span>';
                 }
                 $data =& $this->getHelper()->itemData;
                 $status = 'notinstall';
                 $preview = array();
                 $screenshots = array();
                 $items = array('readme' => true, 'activate' => false, 'set_default' => false, 'deactivate' => false, 'install' => false, 'uninstall' => false, 'upgrade' => false, 'config' => false, 'manage' => false, 'import' => false);
                 if (isset($existPackages[$data['name']])) {
                     $status = $statuses[$data['name']];
                 }
                 if ($array = $data['screenshots']) {
                     foreach ($array as $key => $value) {
                         'preview' == $value['type'] ? $preview[] = $value : ($screenshots[] = $value);
                     }
                 }
                 switch ($status) {
                     case 'install':
                     case 'active':
                         $items['deactivate'] = true;
                         $items['set_default'] = true;
                         if (is_dir($this->_folder . $file . IA_DS . 'includes' . IA_DS . 'dumps')) {
                             $items['import'] = true;
                         }
                         if ($extraConfig = $this->_iaDb->row_bind(iaDb::ALL_COLUMNS_SELECTION, '`extras` = :name ORDER BY `order` ASC', array('name' => $data['name']), iaCore::getConfigTable())) {
                             $items['config'] = array('url' => $extraConfig['config_group'], 'anchor' => $extraConfig['name']);
                         }
                         if ($alias = $this->_iaDb->one_bind('alias', '`name` = :name', array('name' => $data['name'] . '_manage'), 'admin_pages')) {
                             $items['manage'] = $alias;
                         }
                         if ($buttons && version_compare($data['info']['version'], $existPackages[$data['name']], '>')) {
                             $items['upgrade'] = true;
                         }
                         break;
                     case 'inactive':
                         $items['activate'] = true;
                         $items['uninstall'] = true;
                         break;
                     case 'notinstall':
                         $items['install'] = true;
                 }
                 $packageNames[] = $data['name'];
                 $result[] = array('title' => $data['info']['title'], 'version' => $data['info']['version'], 'description' => $data['info']['title'], 'contributor' => $data['info']['contributor'], 'compatibility' => $data['compatibility'], 'author' => $data['info']['author'], 'summary' => $data['info']['summary'], 'date' => $data['info']['date'], 'name' => $data['name'], 'buttons' => $buttons, 'url' => $data['url'], 'preview' => $preview, 'img' => IA_CLEAR_URL . 'packages/' . $data['name'] . '/docs/img/icon.png', 'screenshots' => $screenshots, 'file' => $file, 'items' => $items, 'price' => 0, 'status' => $status, 'date_updated' => $status != 'notinstall' ? $dates[$data['name']] : false, 'install' => true, 'remote' => false);
             }
         }
     }
     return array($result, $packageNames);
 }
예제 #7
0
 private function _getInstalledPlugins($start, $limit, $sort, $dir, $filter)
 {
     $where = "`type` = '" . iaExtra::TYPE_PLUGIN . "'" . (empty($filter) ? '' : " AND `title` LIKE '%{$filter}%'");
     $order = $sort && $dir ? " ORDER BY `{$sort}` {$dir}" : '';
     $result = array('data' => $this->_iaDb->all(array('id', 'name', 'title', 'version', 'status', 'author', 'summary', 'removable', 'date'), $where . $order, $start, $limit), 'total' => $this->_iaDb->one(iaDb::STMT_COUNT_ROWS, $where));
     if ($result['data']) {
         foreach ($result['data'] as &$entry) {
             if ($row = $this->_iaDb->row_bind(array('name', 'config_group'), '`extras` = :plugin ORDER BY `order` ASC', array('plugin' => $entry['name']), iaCore::getConfigTable())) {
                 $entry['config'] = $row['config_group'] . '/#' . $row['name'] . '';
             }
             if ($alias = $this->_iaDb->one_bind('alias', '`name` = :name', array('name' => $entry['name']), 'admin_pages')) {
                 $entry['manage'] = $alias;
             }
             $entry['file'] = $entry['name'];
             $entry['info'] = true;
             $entry['reinstall'] = true;
             $entry['uninstall'] = $entry['removable'];
             $entry['remove'] = $entry['removable'];
             if (is_dir(IA_PLUGINS . $entry['name'])) {
                 $installationFile = IA_PLUGINS . $entry['name'] . IA_DS . iaExtra::INSTALL_FILE_NAME;
                 if (file_exists($installationFile)) {
                     $fileContent = file_get_contents($installationFile);
                     $this->getHelper()->setXml($fileContent);
                     $this->getHelper()->parse();
                     if ($this->getHelper()->itemData['compatibility'] && version_compare(IA_VERSION, $iaExtra->itemData['compatibility'], '>=') && version_compare($this->getHelper()->itemData['info']['version'], $entry['version'], '>')) {
                         $entry['upgrade'] = $entry['name'];
                     }
                 }
             }
         }
     }
     return $result;
 }
예제 #8
0
 public function install($type = self::SETUP_REPLACE)
 {
     $iaDb =& $this->iaDb;
     // TODO: check for relations and deactivate all needed extras
     if ($this->_requires) {
         $messages = array();
         foreach ($this->_requires as $require) {
             if ($require['min'] || $require['max']) {
                 $min = $max = false;
                 if (isset($extrasList[$require['name']])) {
                     $info = $extrasList[$require['name']];
                     $min = $require['min'] ? version_compare($require['min'], $info['version'], '<=') : true;
                     $max = $require['max'] ? version_compare($require['max'], $info['version'], '>=') : true;
                 }
                 if (!$max || !$min) {
                     $ver = '';
                     if ($require['min']) {
                         $ver .= $require['min'];
                     }
                     if ($require['max']) {
                         if ($require['min']) {
                             $ver .= '-';
                         }
                         $ver .= $require['max'];
                     }
                     $replace = array(':extra' => $require['type'], ':name' => $require['name'], ':version' => $ver);
                     $messages[] = iaLanguage::getf('required_template_error', $replace);
                     $this->error = true;
                 } else {
                     // TODO: add relations in database to deactivate when parent is uninstalled
                 }
             }
         }
         if ($this->error) {
             $this->_message = implode('<br>', $messages);
             return false;
         }
     }
     if (self::SETUP_REPLACE == $type) {
         $template = $iaDb->one('value', "`name` = 'tmpl'", iaCore::getConfigTable());
         $tablesList = array('hooks', 'blocks', iaLanguage::getTable(), 'pages', iaCore::getConfigTable(), iaCore::getConfigGroupsTable(), iaCore::getCustomConfigTable());
         $iaDb->cascadeDelete($tablesList, "`extras` = '{$template}'");
         $iaDb->cascadeDelete($tablesList, "`extras` = '{$this->name}'");
     }
     $iaDb->update(array('value' => $this->name), "`name` = 'tmpl'", null, iaCore::getConfigTable());
     if ($this->_phrases) {
         $this->_processPhrases();
     }
     if ($this->_config) {
         $iaDb->setTable(iaCore::getConfigTable());
         $maxOrder = $iaDb->one_bind('MAX(`order`) + 1', '`extras` = :extras', array('extras' => $this->name));
         $maxOrder = $maxOrder ? (int) $maxOrder : 1;
         foreach ($this->_config as $entry) {
             $id = $this->iaDb->one(iaDb::ID_COLUMN_SELECTION, iaDb::convertIds($entry['name'], 'name'));
             $entry['order'] = isset($entry['order']) ? $entry['order'] : ++$maxOrder;
             if (!$id || empty($entry['name'])) {
                 $this->iaDb->insert($entry);
             } elseif ($id) {
                 if (isset($entry['value'])) {
                     unset($entry['value']);
                 }
                 $this->iaDb->update($entry, iaDb::convertIds($id));
             }
         }
         $iaDb->resetTable();
     }
     if ($this->_configGroups) {
         $iaDb->setTable(iaCore::getConfigGroupsTable());
         $maxOrder = $iaDb->getMaxOrder() + 1;
         foreach ($this->_configGroups as $title => $entry) {
             $iaDb->insert($entry, array('order' => $maxOrder));
             $this->_addPhrase('config_group_' . $entry['name'], $title, iaLanguage::CATEGORY_ADMIN);
             $maxOrder++;
         }
         $iaDb->resetTable();
     }
     if ($this->_hooks) {
         $iaDb->setTable('hooks');
         $maxOrder = $iaDb->one('MAX(`order`) + 1');
         $maxOrder = $maxOrder ? $maxOrder : 1;
         foreach ($this->_hooks as $hook) {
             $array = explode(',', $hook['name']);
             foreach ($array as $hookName) {
                 if (trim($hookName)) {
                     $hook['name'] = $hookName;
                     if (isset($hook['code']) && $hook['code']) {
                         $hook['code'] = str_replace('{extras}', $this->name, $hook['code']);
                     }
                     $iaDb->insert($hook, array('order' => $maxOrder));
                     $maxOrder++;
                 }
             }
         }
         $iaDb->resetTable();
     }
     $positionsList = array();
     if ($this->_positions) {
         $positionPages = array();
         $iaDb->setTable('positions');
         $iaDb->truncate();
         foreach ($this->_positions as $position) {
             $positionsList[] = $position['name'];
             $iaDb->insert(array('name' => $position['name'], 'menu' => (int) $position['menu'], 'movable' => (int) $position['movable']));
             if (null != $position['default_access']) {
                 $positionPages[] = array('object_type' => 'positions', 'page_name' => '', 'object' => $position['name'], 'access' => (int) $position['default_access']);
             }
             if ($position['pages']) {
                 $pages = explode(',', $position['pages']);
                 foreach ($pages as $page) {
                     $positionPages[] = array('object_type' => 'positions', 'page_name' => $page, 'object' => $position['name'], 'access' => (int) $position['access']);
                 }
             }
         }
         $iaDb->resetTable();
         if ($positionPages) {
             $iaDb->delete("`object_type` = 'positions'", 'objects_pages');
             foreach ($positionPages as $positionPage) {
                 $iaDb->insert($positionPage, null, 'objects_pages');
             }
         }
     }
     $iaBlock = $this->iaCore->factory('block', iaCore::ADMIN);
     if ($this->blocks) {
         $iaDb->setTable($iaBlock::getTable());
         $maxOrder = $iaDb->one('MAX(`order`)');
         $maxOrder = $maxOrder ? $maxOrder : 1;
         foreach ($this->blocks as $block) {
             if (!$block['order']) {
                 $maxOrder++;
                 $block['order'] = $maxOrder;
             } else {
                 $block['order'] = (int) $block['order'];
             }
             if (!empty($block['filename'])) {
                 $block['external'] = 1;
             }
             $blockPages = $block['pages'];
             unset($block['pages'], $block['added']);
             if (!in_array($block['position'], $positionsList)) {
                 $block['position'] = $positionsList[0];
             }
             if (isset($block['contents']) && $block['contents']) {
                 $block['contents'] = str_replace('{extras}', $this->name, $block['contents']);
             }
             $id = $iaDb->insert($block);
             if ($blockPages) {
                 $iaBlock->setVisibility($id, $block['sticky'], explode(',', $blockPages));
             }
         }
         $iaDb->resetTable();
     }
     $rollbackData = array();
     if ($this->_changeset) {
         $tablesMapping = array('block' => 'blocks', 'field' => 'fields', 'menu' => 'blocks', 'page' => 'pages');
         foreach ($this->_changeset as $changeset) {
             if (!isset($tablesMapping[$changeset['type']])) {
                 continue;
             }
             $entity = $changeset['type'];
             $name = $changeset['name'];
             unset($changeset['type'], $changeset['name']);
             switch ($entity) {
                 case 'field':
                     list($fieldName, $itemName) = explode('-', $name);
                     if (empty($fieldName) || empty($itemName)) {
                         continue;
                     }
                     $stmt = iaDb::printf("`name` = ':name' AND `item` = ':item'", array('name' => $fieldName, 'item' => $itemName));
                     break;
                 case 'block':
                 case 'menu':
                     $pagesList = isset($changeset['pages']) ? explode(',', $changeset['pages']) : array();
                     unset($changeset['pages']);
                     // intentionally missing break stmt
                 // intentionally missing break stmt
                 default:
                     $stmt = iaDb::printf("`name` = ':name'", array('name' => $name));
             }
             $tableName = $tablesMapping[$entity];
             $entryData = $iaDb->row('`id`, `' . implode('`,`', array_keys($changeset)) . '`', $stmt, $tableName);
             if ($iaDb->update($changeset, $stmt, null, $tableName)) {
                 if (isset($changeset['sticky']) && ('block' == $entity || 'menu' == $entity)) {
                     $iaBlock->setVisibility($entryData['id'], $changeset['sticky'], $pagesList);
                 }
                 unset($entryData['id']);
                 $rollbackData[$tableName][$name] = $entryData;
             }
         }
     }
     $rollbackData = empty($rollbackData) ? '' : serialize($rollbackData);
     $this->iaCore->set(self::CONFIG_LAYOUT_DATA, serialize($this->_layout), true);
     $this->iaCore->set(self::CONFIG_ROLLBACK_DATA, $rollbackData, true);
     if (self::SETUP_INITIAL != $type) {
         setcookie('template_color_scheme', '', time() - 3600, '/');
     }
     return true;
 }
예제 #9
0
 protected function _processConfig(array $entries)
 {
     $this->iaDb->setTable(iaCore::getConfigTable());
     $maxOrder = $this->iaDb->getMaxOrder();
     foreach ($entries as $entry) {
         $id = $this->iaDb->one(iaDb::ID_COLUMN_SELECTION, iaDb::convertIds($entry['name'], 'name'));
         $entry['order'] = isset($entry['order']) ? $entry['order'] : ++$maxOrder;
         if (!$id || empty($entry['name'])) {
             $this->iaDb->insert($entry);
         } elseif ($id) {
             if (isset($entry['value'])) {
                 unset($entry['value']);
             }
             $this->iaDb->update($entry, iaDb::convertIds($id));
         }
     }
     $this->iaDb->resetTable();
 }
예제 #10
0
 private function _save(&$iaView, $type, $customEntryId)
 {
     $where = "`type` != 'hidden' " . ($type ? 'AND `custom` = 1' : '');
     $params = $this->_iaDb->keyvalue(array('name', 'type'), $where, iaCore::getConfigTable());
     // correct admin dashboard URL generation
     $adminPage = $this->_iaCore->get('admin_page');
     $iaAcl = $this->_iaCore->factory('acl');
     if (!$iaAcl->checkAccess($iaView->name() . iaAcl::SEPARATOR . iaCore::ACTION_EDIT)) {
         return iaView::accessDenied();
     }
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $messages = array();
     $error = false;
     if ($_POST['param'] && is_array($_POST['param'])) {
         $values = $_POST['param'];
         $this->_iaDb->setTable(iaCore::getConfigTable());
         $this->_iaCore->startHook('phpConfigurationChange', array('configurationValues' => &$values));
         foreach ($values as $key => $value) {
             $s = strpos($key, '_items_enabled');
             if ($s !== false) {
                 $p = $this->_iaCore->get($key, '', !is_null($type));
                 $array = $p ? explode(',', $p) : array();
                 $data = array();
                 array_shift($value);
                 if ($diff = array_diff($value, $array)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '+', 'item' => $item));
                     }
                 }
                 if ($diff = array_diff($array, $value)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '-', 'item' => $item));
                     }
                 }
                 $extra = substr($key, 0, $s);
                 $this->_iaCore->startHook('phpPackageItemChangedForPlugin', array('data' => $data), $extra);
             }
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (!utf8_is_valid($value)) {
                 $value = utf8_bad_replace($value);
                 trigger_error('Bad UTF-8 detected (replacing with "?") in configuration', E_USER_NOTICE);
             }
             if ('image' == $params[$key]) {
                 if (isset($_POST['delete'][$key]) && $_POST['delete'][$key] == 'on') {
                     $value = '';
                 } elseif (!empty($_FILES[$key]['name'])) {
                     if (!(bool) $_FILES[$key]['error']) {
                         if (@is_uploaded_file($_FILES[$key]['tmp_name'])) {
                             $ext = strtolower(utf8_substr($_FILES[$key]['name'], -3));
                             // if jpeg
                             if ($ext == 'peg') {
                                 $ext = 'jpg';
                             }
                             if (!array_key_exists(strtolower($_FILES[$key]['type']), $this->_imageTypes) || !in_array($ext, $this->_imageTypes, true) || !getimagesize($_FILES[$key]['tmp_name'])) {
                                 $error = true;
                                 $messages[] = iaLanguage::getf('file_type_error', array('extension' => implode(', ', array_unique($this->_imageTypes))));
                             } else {
                                 if ($this->_iaCore->get($key) && file_exists(IA_UPLOADS . $this->_iaCore->get($key))) {
                                     iaUtil::deleteFile(IA_UPLOADS . $this->_iaCore->get($key));
                                 }
                                 $value = $fileName = $key . '.' . $ext;
                                 @move_uploaded_file($_FILES[$key]['tmp_name'], IA_UPLOADS . $fileName);
                                 @chmod(IA_UPLOADS . $fileName, 0777);
                             }
                         }
                     }
                 } else {
                     $value = $this->_iaCore->get($key, '', !is_null($type));
                 }
             }
             if ($type) {
                 $where = "`name` = '{$key}' AND `type` = '{$type}' AND `type_id` = '{$customEntryId}'";
                 $this->_iaDb->setTable('config_custom');
                 if ($_POST['chck'][$key] == 1) {
                     $values = array('name' => $key, 'value' => $value, 'type' => $type, 'type_id' => $customEntryId);
                     if ($this->_iaDb->exists($where)) {
                         unset($values['value']);
                         $this->_iaDb->bind($where, $values);
                         $this->_iaDb->update(array('value' => $value), $where);
                     } else {
                         $this->_iaDb->insert($values);
                     }
                 } else {
                     $this->_iaDb->delete($where);
                 }
                 $this->_iaDb->resetTable();
             } else {
                 $stmt = '`name` = :key';
                 $this->_iaDb->bind($stmt, array('key' => $key));
                 $this->_iaDb->update(array('value' => $value), $stmt);
             }
         }
         $this->_iaDb->resetTable();
         $this->_iaCore->iaCache->clearAll();
     }
     if (!$error) {
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         if (isset($_POST['param']['admin_page']) && $_POST['param']['admin_page'] != $adminPage) {
             iaUtil::go_to(IA_URL . $_POST['param']['admin_page'] . '/configuration/general/');
         }
     } elseif ($messages) {
         $iaView->setMessages($messages);
     }
 }
예제 #11
0
 public function __construct()
 {
     parent::__construct();
     $this->setTable(iaCore::getConfigTable());
 }