コード例 #1
0
ファイル: payment.php プロジェクト: codigoaberto/SEBLOD
 public static function g_onCCK_PaymentValidate($data, $success, &$config)
 {
     $update = 'pay_return = "' . JCckDatabase::escape(json_encode($data['order'])) . '",' . 'pay_return_payments = "' . JCckDatabase::escape(json_encode($data['payments'])) . '",' . 'state = ' . $data['order_state'];
     JCckDatabase::execute('UPDATE #__cck_more_ecommerce_orders SET ' . $update . ' WHERE pay_key = "' . $config['pay_key'] . '"');
     if (!$success) {
         return;
     }
     // Cart
     $cart_id = (int) JCckDatabase::loadResult('SELECT a.id FROM #__cck_more_ecommerce_carts AS a WHERE a.pay_key = "' . $config['pay_key'] . '"');
     if ($cart_id) {
         JCckDatabase::execute('UPDATE #__cck_more_ecommerce_carts SET pay_key = "" WHERE id = ' . $cart_id);
         JCckDatabase::execute('DELETE a.* FROM #__cck_more_ecommerce_cart_product AS a WHERE a.cart_id = ' . $cart_id);
     }
     // Execute Processings (Invoice, Notifications, ...)
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onCckPaymentSuccess';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile, options FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
         if (isset($processing[$event])) {
             foreach ($processing[$event] as $p) {
                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                     $options = new JRegistry($p->options);
                     include_once JPATH_SITE . $p->scriptfile;
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: cck.php プロジェクト: codigoaberto/SEBLOD
 public function batchFolder($pks, $type)
 {
     $app = JFactory::getApplication();
     $folder = $app->input->getInt('batch_folder', 0);
     if (!$folder) {
         return false;
     }
     return JCckDatabase::execute('UPDATE #__cck_core_' . $type . ' SET folder = ' . $folder . ' WHERE id IN (' . $pks . ')');
 }
コード例 #3
0
ファイル: helper.php プロジェクト: hamby/SEBLOD
 public static function alterTableAddColumn($table, $column, $column_prev = '', $type = 'VARCHAR(50)')
 {
     $db = JFactory::getDbo();
     $columns = $db->getTableColumns($table);
     if ($column_prev != '' && $column != $column_prev) {
         if (!isset($columns[$column])) {
             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' CHANGE ' . JCckDatabase::quoteName($column_prev) . ' ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL');
         }
     } elseif (!isset($columns[$column])) {
         JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' ADD ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL');
     }
 }
コード例 #4
0
ファイル: table.php プロジェクト: hamby/SEBLOD
 public function load($pk = null, $force = false)
 {
     $return = parent::load($pk);
     $k = $this->_tbl_key;
     if (!$return) {
         if ($force === true) {
             JCckDatabase::execute('INSERT INTO ' . $this->_tbl . ' (' . $k . ') VALUES (' . (int) $pk . ')');
             $return = parent::load($pk);
         }
     }
     return $return;
 }
コード例 #5
0
ファイル: site.php プロジェクト: hamby/SEBLOD
 protected function postSaveHook(CCKModelSite &$model, $validData = array())
 {
     $recordId = $model->getState($this->context . '.id');
     if ($recordId == 10 || $recordId == 500) {
         $db = JFactory::getDbo();
         $params = JCckDatabase::loadResult('SELECT params FROM #__extensions WHERE element = "com_cck"');
         $config = JCckDev::fromJSON($params, 'object');
         $config->multisite = 1;
         $params = $db->escape(JCckDev::toJSON($config));
         JCckDatabase::execute('UPDATE #__extensions SET params = "' . $params . '" WHERE element = "com_cck"');
     }
 }
コード例 #6
0
ファイル: search.php プロジェクト: codigoaberto/SEBLOD
 public function delete($pk = null)
 {
     if ($this->id) {
         $clients = array('search', 'filter', 'list', 'item');
         foreach ($clients as $client) {
             $Pf = 'template_' . $client;
             $style = JCckDatabase::loadObject('SELECT a.id, a.template FROM #__template_styles AS a' . ' WHERE a.template IN ( SELECT b.template FROM #__template_styles as b WHERE b.id = ' . (int) $this->{$Pf} . ' )' . ' ORDER BY a.id');
             if ($style->id != $this->{$Pf}) {
                 JCckDatabase::execute('DELETE a.* FROM #__template_styles AS a WHERE a.id=' . (int) $this->{$Pf});
             }
         }
         JCckDatabase::execute('DELETE IGNORE a.*, b.*' . ' FROM #__cck_core_search_field AS a' . ' LEFT JOIN #__cck_core_search_position AS b ON b.searchid = a.searchid' . ' WHERE a.searchid=' . (int) $this->id);
     }
     return parent::delete();
 }
コード例 #7
0
ファイル: field.php プロジェクト: kenyonjohnston/hott_theater
 public function delete($pk = null)
 {
     if ($this->id) {
         if (strpos($this->storage_table, '#__cck_store_item_') !== false || strpos($this->storage_table, '#__cck_store_form_') !== false) {
             if (!$this->storage_field2) {
                 $db = JFactory::getDbo();
                 $table = (string) $this->storage_table;
                 $column = $this->storage_field ? $this->storage_field : $this->name;
                 $columns = $db->getTableColumns($table);
                 if (isset($columns[$column])) {
                     if (JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core_fields WHERE storage_table = "' . (string) $table . '" AND storage_field = "' . (string) $column . '"') == 1) {
                         JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' DROP COLUMN ' . JCckDatabase::quoteName((string) $column));
                     }
                 }
             }
         }
     }
     return parent::delete();
 }
コード例 #8
0
ファイル: version.php プロジェクト: densem-2013/exikom
 public function revert($pk, $type)
 {
     $db = $this->getDbo();
     $table = $this->getTable();
     if (!$pk || !$type) {
         return false;
     }
     $table->load($pk);
     if (JCck::getConfig_Param('version_revert', 1) == 1) {
         Helper_Version::createVersion($type, $table->e_id, JText::sprintf('COM_CCK_VERSION_AUTO_BEFORE_REVERT', $table->e_version));
     }
     $row = JTable::getInstance($type, 'CCK_Table');
     $row->load($table->e_id);
     $core = JCckDev::fromJSON($table->e_core);
     if (isset($row->asset_id) && $row->asset_id && isset($core['rules'])) {
         JCckDatabase::execute('UPDATE #__assets SET rules = "' . $db->escape($core['rules']) . '" WHERE id = ' . (int) $row->asset_id);
     }
     // More
     if ($type == 'search') {
         $clients = array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order');
     } else {
         $clients = array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content');
     }
     foreach ($clients as $i => $client) {
         $name = 'e_more' . $i;
         $this->_revert_more($type, $client, $table->e_id, $table->{$name});
     }
     // Override
     if ($row->version && $row->version != $table->e_version) {
         $core['version'] = ++$row->version;
     }
     $core['checked_out'] = 0;
     $core['checked_out_time'] = '0000-00-00 00:00:00';
     $row->bind($core);
     $row->check();
     $row->store();
     return true;
 }
コード例 #9
0
 protected function _download_hits($id, $fieldname, $collection = '', $x = 0)
 {
     $where = 'a.id = ' . (int) $id . ' AND a.field = "' . (string) $fieldname . '" AND a.collection = "' . (string) $collection . '" AND a.x = ' . (int) $x;
     $hits = JCckDatabase::loadResult('SELECT a.hits FROM #__cck_core_downloads AS a WHERE ' . $where);
     if (!$hits) {
         JCckDatabase::execute('INSERT INTO #__cck_core_downloads(`id`, `field`, `collection`, `x`, `hits`) VALUES(' . (int) $id . ', "' . (string) $fieldname . '", "' . (string) $collection . '", ' . (int) $x . ', 1)');
     } else {
         $hits++;
         JCckDatabase::execute('UPDATE #__cck_core_downloads AS a SET a.hits = ' . (int) $hits . ' WHERE ' . $where . ' AND a.id = ' . (int) $id);
     }
     return $hits;
 }
コード例 #10
0
 public static function importTables($data)
 {
     $db = JFactory::getDbo();
     $path = $data['root'] . '/tables';
     if (file_exists($path)) {
         $items = JFolder::files($path, '\\.xml$');
         if (count($items)) {
             $prefix = JFactory::getConfig()->get('dbprefix');
             $tables = array_flip(JCckDatabase::loadColumn('SHOW TABLES'));
             foreach ($items as $item) {
                 $xml = JCckDev::fromXML($path . '/' . $item);
                 if (!$xml || (string) $xml->attributes()->type != 'tables') {
                     return;
                 }
                 $name = (string) $xml->table->name;
                 $table_key = (string) $xml->table->primary_key;
                 $short = str_replace('#__', $prefix, $name);
                 if (isset($tables[$short])) {
                     $table = JCckTable::getInstance($name);
                     $table_fields = $table->getFields();
                     $previous = '';
                     // Fields
                     $fields = $xml->fields->children();
                     if (count($fields)) {
                         foreach ($fields as $field) {
                             $column = (string) $field;
                             $type = (string) $field->attributes()->type;
                             $default = (string) $field->attributes()->default;
                             if (!isset($table_fields[$column])) {
                                 $query = 'ALTER TABLE ' . $name . ' ADD ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL';
                                 $query .= $default != '' ? ' DEFAULT "' . $default . '"' : '';
                                 $query .= $previous != '' ? ' AFTER ' . JCckDatabase::quoteName($previous) : ' FIRST';
                                 JCckDatabase::execute($query);
                             } else {
                                 if ($type != $table_fields[$column]->Type) {
                                     $query = 'ALTER TABLE ' . $name . ' CHANGE ' . JCckDatabase::quoteName($column) . ' ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL';
                                     $query .= $default != '' ? ' DEFAULT "' . $default . '"' : '';
                                     JCckDatabase::execute($query);
                                 }
                             }
                             $previous = $column;
                         }
                     }
                     // Indexes
                     $indexes = $xml->indexes->children();
                     $indexes2 = array();
                     if (count($indexes)) {
                         foreach ($indexes as $index) {
                             $idx = (string) $index;
                             $indexes2[$idx][(string) $index->attributes()->seq_in_type] = (string) $index->attributes()->column_name;
                         }
                     }
                     if (count($indexes2)) {
                         foreach ($indexes2 as $k => $v) {
                             if ($k == 'PRIMARY') {
                                 JCckDatabase::execute('ALTER TABLE ' . $name . ' DROP PRIMARY KEY, ADD PRIMARY KEY ( ' . implode(',', $v) . ' )');
                             } else {
                                 // todo
                             }
                         }
                     }
                 } else {
                     $sql_query = '';
                     // Fields
                     $fields = $xml->fields->children();
                     if (count($fields)) {
                         foreach ($fields as $field) {
                             $type = (string) $field->attributes()->type;
                             $default = (string) $field->attributes()->default;
                             $sql_query .= ' ' . JCckDatabase::quoteName((string) $field) . ' ' . $type . ' NOT NULL';
                             if ($default != '') {
                                 $sql_query .= ' DEFAULT "' . $default . '"';
                             }
                             $sql_query .= ',';
                         }
                     }
                     // Indexes
                     $indexes = $xml->indexes->children();
                     $indexes2 = array();
                     if (count($indexes)) {
                         foreach ($indexes as $index) {
                             $idx = (string) $index;
                             $indexes2[$idx][(string) $index->attributes()->seq_in_type] = (string) $index->attributes()->column_name;
                         }
                     }
                     if (count($indexes2)) {
                         foreach ($indexes2 as $k => $v) {
                             $sql_query .= $k == 'PRIMARY' ? ' PRIMARY KEY ( ' . implode(',', $v) . ' ),' : ' KEY ' . $k . ' ( ' . implode(',', $v) . ' ),';
                         }
                     }
                     $sql_query = $sql_query ? substr($sql_query, 0, -1) : '';
                     JCckDatabase::execute('CREATE TABLE IF NOT EXISTS ' . $name . ' (' . $sql_query . ') ENGINE=InnoDB DEFAULT CHARSET=utf8;');
                 }
             }
         }
     }
 }
コード例 #11
0
ファイル: free.php プロジェクト: codigoaberto/SEBLOD
 public function onCCK_Storage_LocationSearch($type, $tables, $fields, $fields_order, &$config, &$inherit, &$results)
 {
     if (self::$type != $type) {
         return;
     }
     if ($config['doQuery'] === false && isset($config['query']) && $config['query']) {
         if (isset($config['query_variables']) && count($config['query_variables'])) {
             foreach ($config['query_variables'] as $var) {
                 if ($var != '') {
                     JCckDatabase::execute($var);
                 }
             }
         }
         $results = JCckDatabase::loadObjectList($config['query']);
         $inherit['query'] = $config['query'];
         unset($config['query']);
     }
 }
コード例 #12
0
ファイル: joomla_article.php プロジェクト: hamby/SEBLOD
 public static function onCCK_FieldAfterStore($process, &$fields, &$storages, &$config = array())
 {
     $table = '#__cck_store_join_' . $process['name'];
     $value = $process['value'];
     static $bool = 1;
     if ($bool == 1) {
         $bool = 0;
         JCckDatabase::execute('DELETE a.* FROM ' . $table . ' AS a WHERE a.id = ' . (int) $config['pk']);
     }
     if ($value > 0) {
         JCckDatabase::execute('INSERT IGNORE INTO ' . $table . ' VALUES (' . (int) $config['pk'] . ', ' . $value . ')');
     }
 }
コード例 #13
0
ファイル: helper_version.php プロジェクト: hamby/SEBLOD
 public static function revert($type, $pk, $version = 0)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_cck/tables/version.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_cck/tables/' . $type . '.php';
     $db = JFactory::getDbo();
     $pkv = JCckDatabase::loadResult('SELECT id FROM #__cck_core_versions WHERE e_type ="' . $type . '" AND e_version = ' . $version . ' AND e_id = ' . $pk);
     $table = JTable::getInstance('Version', 'CCK_Table');
     $table->load($pkv);
     $row = JTable::getInstance(ucfirst($type), 'CCK_Table');
     $row->load($pk);
     $core = JCckDev::fromJSON($table->e_core);
     if (isset($row->asset_id) && $row->asset_id && isset($core['rules'])) {
         JCckDatabase::execute('UPDATE #__assets SET rules = "' . $db->escape($core['rules']) . '" WHERE id = ' . (int) $row->asset_id);
     }
     // More
     if ($type == 'search') {
         $clients = array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order');
     } else {
         $clients = array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content');
     }
     foreach ($clients as $i => $client) {
         $name = 'e_more' . $i;
         self::revert_more($type, $client, $pk, $table->{$name});
     }
     // --
     if ($row->version && $row->version != $table->e_version) {
         $core['version'] = ++$row->version;
     }
     $row->bind($core);
     $row->check();
     $row->store();
 }
コード例 #14
0
ファイル: template.php プロジェクト: codigoaberto/SEBLOD
 protected function prepareData()
 {
     $data = JRequest::get('post');
     $data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
     if ($data['mode']) {
         $data['featured'] = 0;
     } else {
         if ($data['featured']) {
             JCckDatabase::execute('UPDATE #__cck_core_templates SET featured = 0 WHERE id');
         } else {
             if (!JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core_templates WHERE featured = 1 AND id != ' . (int) $data['id'])) {
                 $data['featured'] = 1;
             }
         }
     }
     return $data;
 }
コード例 #15
0
ファイル: location.php プロジェクト: densem-2013/exikom
 public function g_isMax($author_id, $parent_id, $config = array())
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $typeId = JCckDatabase::loadResult('SELECT id FROM #__cck_core_types WHERE name ="' . $config['type'] . '"');
     jimport('cck.joomla.access.access');
     $max_parent_author = (int) CCKAccess::check($user->id, 'core.create.max.parent.author', 'com_cck.form.' . $typeId);
     $max_parent = (int) CCKAccess::check($user->id, 'core.create.max.parent', 'com_cck.form.' . $typeId);
     $max_author = (int) CCKAccess::check($user->id, 'core.create.max.author', 'com_cck.form.' . $typeId);
     if ($max_parent_author > 0) {
         $count = JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core WHERE cck="' . $config['type'] . '" AND parent_id = ' . $parent_id . ' AND author_id = ' . $author_id);
         if ($count >= $max_parent_author) {
             JCckDatabase::execute('DELETE FROM #__cck_core WHERE id = ' . (int) $config['id']);
             $app->enqueueMessage(JText::_('COM_CCK_ERROR_MAX_PARENT_AUTHOR'), 'error');
             $config['error'] = true;
             return 1;
         }
     }
     if ($max_parent > 0) {
         $count = JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core WHERE cck="' . $config['type'] . '" AND parent_id = ' . $parent_id);
         if ($count >= $max_parent) {
             JCckDatabase::execute('DELETE FROM #__cck_core WHERE id = ' . (int) $config['id']);
             $app->enqueueMessage(JText::_('COM_CCK_ERROR_MAX_PARENT'), 'error');
             $config['error'] = true;
             return 1;
         }
     }
     if ($max_author > 0) {
         $count = JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core WHERE cck="' . $config['type'] . '" AND author_id = ' . $author_id);
         if ($count >= $max_author) {
             JCckDatabase::execute('DELETE FROM #__cck_core WHERE id = ' . (int) $config['id']);
             $app->enqueueMessage(JText::_('COM_CCK_ERROR_MAX_AUTHOR'), 'error');
             $config['error'] = true;
             return 1;
         }
     }
     return 0;
 }
コード例 #16
0
 public static function initACL($options, $pks, $rules = array())
 {
     $db = JFactory::getDbo();
     require_once JPATH_ADMINISTRATOR . '/components/com_cck/tables/' . $options['table'] . '.php';
     $table = JTable::getInstance($options['table'], 'CCK_Table');
     foreach ($pks as $pk) {
         $table->load($pk);
         if (!$table->asset_id) {
             $table->asset_id = JCckDatabase::loadResult('SELECT id FROM #__assets WHERE name = "com_cck.' . $options['name'] . '.' . $pk . '"');
         }
         $table->store();
         if ($table->asset_id > 0) {
             $rule = isset($rules[$pk]) ? $rules[$pk] : $options['rules'];
             JCckDatabase::execute('UPDATE #__assets SET rules = "' . $db->escape($rule) . '" WHERE id = ' . (int) $table->asset_id);
         }
     }
     return true;
 }
コード例 #17
0
ファイル: user.php プロジェクト: densem-2013/exikom
 public static function setPreferences($name, $value)
 {
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $preferences = JCckDatabase::loadResult('SELECT a.options FROM #__cck_core_preferences AS a WHERE a.userid = ' . (int) $user->id);
     if ($preferences) {
         $registry = new JRegistry();
         $registry->loadString($preferences);
         $preferences = $registry->toArray();
         $preferences[$name] = $value;
         $json = '';
         foreach ($preferences as $k => $v) {
             $json .= '"' . $k . '"' . ':' . '"' . $v . '"' . ',';
         }
         if ($json) {
             $json = '{' . substr($json, 0, -1) . '}';
         }
         JCckDatabase::execute('UPDATE #__cck_core_preferences AS a SET a.options = "' . $db->escape($json) . '" WHERE a.userid = ' . (int) $user->id);
     } else {
         $json = '{' . '"' . $name . '"' . ':' . '"' . $value . '"' . '}';
         JCckDatabase::execute('INSERT INTO #__cck_core_preferences ( userid, options ) VALUES ( ' . (int) $user->id . ', "' . $db->escape($json) . '" )');
     }
 }
コード例 #18
0
ファイル: field.php プロジェクト: kolydart/SEBLOD
 public function g_onCCK_FieldConstruct(&$data)
 {
     $db = JFactory::getDbo();
     $data['display'] = 3;
     $data['script'] = JRequest::getVar('script', '', '', 'string', JREQUEST_ALLOWRAW);
     if (isset($data['selectlabel']) && $data['selectlabel'] == '') {
         $data['selectlabel'] = ' ';
     }
     // JSON
     if (isset($data['json']) && is_array($data['json'])) {
         foreach ($data['json'] as $k => $v) {
             if (is_array($v)) {
                 if (isset($v['options'])) {
                     $options = array();
                     if (count($v['options'])) {
                         foreach ($v['options'] as $option) {
                             $options[] = $option;
                         }
                     }
                     $v['options'] = $options;
                 }
                 $data[$k] = JCckDev::toJSON($v);
             }
         }
     }
     // STRING
     if (isset($data['string']) && is_array($data['string'])) {
         foreach ($data['string'] as $k => $v) {
             if (is_array($v)) {
                 $string = '';
                 foreach ($v as $s) {
                     if ($s != '') {
                         $string .= $s . '||';
                     }
                 }
                 if ($string) {
                     $string = substr($string, 0, -2);
                 }
                 $data[$k] = $string;
             }
         }
     }
     if (empty($data['storage'])) {
         $data['storage'] = 'none';
     }
     if ($data['storage'] == 'dev') {
         $data['published'] = 0;
         $data['storage_location'] = '';
         $data['storage_table'] = '';
     } else {
         // No Table for None!
         if ($data['storage'] == 'none') {
             $data['storage_location'] = '';
             $data['storage_table'] = '';
         }
         // Storage Field is required!
         if (!@$data['storage_field']) {
             if ($data['storage'] == 'none' && $data['storage_field_prev']) {
                 $data['storage_field'] = $data['storage_field_prev'];
             } else {
                 $data['storage_field'] = $data['name'];
                 $dev_prefix = JCck::getConfig_Param('development_prefix', '');
                 if ($dev_prefix) {
                     $data['storage_field'] = str_replace($dev_prefix . '_', '', $data['storage_field']);
                 }
             }
         }
         // Storage Field2 is better for flexibility!
         if ($data['storage'] != 'standard' && $data['storage_field']) {
             if (($cut = strpos($data['storage_field'], '[')) !== false) {
                 $data['storage_field2'] = substr($data['storage_field'], $cut + 1, -1);
                 $data['storage_field'] = substr($data['storage_field'], 0, $cut);
             } else {
                 $data['storage_field2'] = '';
             }
         }
         // Un-existing Fields must be mapped!
         if (!isset($data['alterTable'])) {
             $data['alterTable'] = true;
         }
         if ($data['storage_location'] == '' && $data['storage_table'] == '') {
             $data['storage'] = 'none';
         }
         if ($data['alterTable']) {
             $data['storage_alter_type'] = isset($data['storage_alter_type']) && $data['storage_alter_type'] ? $data['storage_alter_type'] : 'VARCHAR(255)';
             $alter = isset($data['storage_alter']) && $data['storage_alter'] && in_array(1, $data['storage_alter']);
             if (isset($data['storage_alter_table']) && $data['storage_alter_table'] && $alter) {
                 if ($data['storage_table'] && $data['storage_field']) {
                     $columns = $db->getTableColumns($data['storage_table']);
                     if (!isset($columns[$data['storage_field']])) {
                         if ($data['storage_alter_table'] == 2 && $data['storage_field_prev'] != '') {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field_prev']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         } else {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' ADD ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         }
                     } else {
                         JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                     }
                 }
             } else {
                 if ($data['storage_table'] && $data['storage_field']) {
                     if ($data['type'] == 'jform_rules' && $data['storage_field'] == 'rules' || $data['storage_table'] == @$data['core_table'] && in_array($data['storage_field'], $data['core_columns'])) {
                         unset($data['core_table']);
                         unset($data['core_columns']);
                         return;
                     }
                     $columns = $db->getTableColumns($data['storage_table']);
                     if (!isset($columns[$data['storage_field']])) {
                         $prefix = JFactory::getConfig()->get('dbprefix');
                         if ($data['storage_cck'] != '') {
                             // #__cck_store_form_
                             $table = '#__cck_store_form_' . $data['storage_cck'];
                             JCckDatabase::execute('CREATE TABLE IF NOT EXISTS ' . $table . ' ( id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
                         } else {
                             // #__cck_store_item_
                             $table = strpos($data['storage_table'], 'cck_store_item') !== false ? $data['storage_table'] : '#__cck_store_item_' . str_replace('#__', '', $data['storage_table']);
                             JCckDatabase::execute('CREATE TABLE IF NOT EXISTS ' . $table . ' ( id int(11) NOT NULL, cck VARCHAR(50) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
                         }
                         $columns2 = $db->getTableColumns($table);
                         if (!isset($columns2[$data['storage_field']])) {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' ADD ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         }
                         $data['storage_table'] = $table;
                     } else {
                         if ($alter) {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         }
                     }
                 }
             }
         }
     }
     unset($data['core_table']);
     unset($data['core_columns']);
 }
コード例 #19
0
 protected function _setFeatured($table, $isNew)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_content/tables/featured.php';
     $featured = JTable::getInstance('Featured', 'ContentTable');
     if ($isNew) {
         if ($table->featured == 1) {
             JCckDatabase::execute('INSERT INTO #__content_frontpage (`content_id`, `ordering`) VALUES ( ' . $table->id . ', 0)');
             $featured->reorder();
         }
     } else {
         if ($table->featured == 0) {
             JCckDatabase::execute('DELETE FROM #__content_frontpage WHERE content_id = ' . (int) $table->id);
             $featured->reorder();
         } else {
             $id = JCckDatabase::loadResult('SELECT content_id FROM #__content_frontpage WHERE content_id = ' . (int) $table->id);
             if (!$id) {
                 JCckDatabase::execute('INSERT INTO #__content_frontpage (`content_id`, `ordering`) VALUES ( ' . $table->id . ', 0)');
                 $featured->reorder();
             }
         }
     }
 }
コード例 #20
0
ファイル: importer.php プロジェクト: hamby/SEBLOD
 public static function onCCK_Storage_LocationImport($data, &$config = array(), $pk = 0)
 {
     if (!$config['pk']) {
         // Init
         if (!$pk) {
             if (isset($config['key']) && $config['key']) {
                 if (isset($data[$config['key']]) && $data[$config['key']] != '') {
                     $pk = JCckDatabase::loadResult('SELECT ' . self::$key . ' FROM ' . self::$table . ' WHERE ' . $config['key'] . ' = "' . $data[$config['key']] . '"');
                 }
                 $pk = $pk > 0 ? $pk : 0;
             } else {
                 $pk = isset($data[self::$key]) && $data[self::$key] > 0 ? $data[self::$key] : 0;
             }
         }
         $table = self::_getTable($pk);
         $isNew = $table->{self::$key} > 0 ? false : true;
         $iPk = 0;
         if ($isNew) {
             if (isset($data[self::$key])) {
                 $iPk = $data[self::$key];
                 unset($data[self::$key]);
             }
             $config['log'] = 'created';
         } else {
             preg_match('#::cck::(.*)::/cck::#U', $table->{self::$custom}, $matches);
             $config['id'] = $matches[1];
             $config['log'] = 'updated';
         }
         if (!$config['id']) {
             $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore();
         }
         self::_initTable($table, $data, $config, true);
         // Prepare
         $table->bind($data);
         if ($isNew && !isset($data['rules'])) {
             $data['rules'] = array('core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array());
             $rules = new JAccessRules($data['rules']);
             $table->setRules($rules);
         }
         if (!@$table->title) {
             $table->title = JFactory::getDate()->format('Y-m-d-H-i-s');
             $table->check();
             $table->alias .= '-' . $config['x'];
         } else {
             $table->check();
         }
         self::_completeTable($table, $data, $config);
         // Store
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('content');
         $dispatcher->trigger('onContentBeforeSave', array(self::$context, &$table, $isNew));
         if (!$table->store()) {
             $config['error'] = true;
             $config['log'] = 'cancelled';
             $config['pk'] = $pk;
             parent::g_onCCK_Storage_LocationRollback($config['id']);
             return false;
         }
         $dispatcher->trigger('onContentAfterSave', array(self::$context, &$table, $isNew));
         // Featured
         self::_setFeatured($table, $isNew);
         // Tweak
         if ($iPk > 0) {
             if (JCckDatabase::execute('UPDATE ' . self::$table . ' SET ' . self::$key . ' = ' . (int) $iPk . ' WHERE ' . self::$key . ' = ' . (int) $table->{self::$key})) {
                 $table->{self::$key} = $iPk;
                 $config['auto_inc'] = $iPk > $config['auto_inc'] ? $iPk : $config['auto_inc'];
                 if ($table->asset_id) {
                     JCckDatabase::execute('UPDATE #__assets SET name = "com_content.article.' . $iPk . '" WHERE id = ' . (int) $table->asset_id);
                 }
             }
         }
         if (!$config['pk']) {
             $config['pk'] = $table->{self::$key};
         }
         $config['author'] = $table->{self::$author};
         $config['parent'] = $table->{self::$parent};
     }
     parent::g_onCCK_Storage_LocationStore($data, self::$table, $config['pk'], $config);
     return true;
 }
コード例 #21
0
 public function ajaxSaveIntegration()
 {
     $app = JFactory::getApplication();
     $json = JCck::on() ? $app->input->JSON->getRaw() : $app->input->getRaw('integration');
     $objects = json_decode($json);
     if (count($objects)) {
         $query = 'UPDATE #__cck_core_objects SET options = CASE name';
         foreach ($objects as $k => $v) {
             $query .= ' WHEN "' . $k . '" THEN "' . JCckDatabase::escape(json_encode($v)) . '"';
             $in .= '"' . $k . '",';
         }
         $in = substr($in, 0, -1);
         $query .= ' ELSE options END WHERE name IN (' . $in . ')';
         JCckDatabase::execute($query);
     }
 }
コード例 #22
0
 protected function _table_no_key_batch($sql_type, $sql, $table, $key, $val, $excluded = array(), $callback = '')
 {
     $db = JFactory::getDbo();
     if ($sql_type == 'where') {
         $elems = JCckDatabase::loadObjectList('SELECT * FROM ' . $table . ' WHERE ' . $sql);
     } else {
         $elems = JCckDatabase::loadObjectList($sql);
     }
     $str = '';
     foreach ($elems as $elem) {
         $add = 1;
         if ($callback != '') {
             $add = $this->{$callback}($elem);
         }
         if ($add == 1) {
             $str2 = '';
             foreach ($elem as $k => $v) {
                 if (in_array($k, $excluded) !== true) {
                     if ($k == $key) {
                         $v = $val;
                     }
                     $str2 .= '"' . $db->escape($v) . '", ';
                 }
             }
             if ($str2 != '') {
                 $str2 = substr(trim($str2), 0, -1);
                 $str .= '(' . $str2 . '), ';
             }
         }
     }
     if ($str != '') {
         $str = substr(trim($str), 0, -1);
     }
     JCckDatabase::execute('INSERT INTO ' . $table . ' VALUES ' . $str);
     return $str;
 }
コード例 #23
0
ファイル: cck.php プロジェクト: hamby/SEBLOD
 public function onExtensionAfterSave($context, $table, $flag)
 {
     if ($context != 'com_config.component') {
         return;
     }
     if (!(is_object($table) && $table->type == 'component' && $table->element == 'com_cck_updater')) {
         return;
     }
     $params = new JRegistry();
     $params->loadString($table->params);
     if ($proxy = (int) $params->get('proxy', '0')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_cck_updater/helpers/helper_admin.php';
         $proxy = Helper_Admin::getProxy($params, 'proxy_segment');
         JCckDatabase::execute('UPDATE #__update_sites SET location = REPLACE(location, "update.seblod.com", "' . $proxy . '") WHERE location LIKE "%update.seblod.com%" AND location != "http://update.seblod.com/pkg_cck.xml"');
     } elseif (!$proxy && $params->get('proxy_domain')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_cck_updater/helpers/helper_admin.php';
         $proxy = Helper_Admin::getProxy($params, 'proxy_segment');
         JCckDatabase::execute('UPDATE #__update_sites SET location = REPLACE(location, "' . $proxy . '", "update.seblod.com") WHERE location LIKE "%' . $proxy . '%"');
     }
 }