Example #1
0
 public static function getRow($id, $content_type = '')
 {
     if (!$id) {
         return NULL;
     }
     $index = $id . '_' . $content_type;
     if (isset(self::$_items[$index])) {
         return self::$_items[$index];
     }
     $row = JTable::getInstance('content');
     $row->load($id);
     if (!$content_type) {
         $content_type = JCckDatabase::loadResult('SELECT cck FROM #__cck_core WHERE storage_location = "joomla_article" AND pk = ' . (int) $row->id);
     }
     if ($content_type) {
         $tables = JCckDatabaseCache::getTableList(true);
         $hasMore = isset($tables[JFactory::getConfig()->get('dbprefix') . 'cck_store_form_' . $content_type]);
         if ($hasMore) {
             $fields = JCckDatabase::loadObject('SELECT * FROM #__cck_store_form_' . $content_type . ' WHERE id = ' . (int) $row->id);
             if (count($fields)) {
                 foreach ($fields as $k => $v) {
                     $row->{$k} = $v;
                 }
             }
         }
     }
     self::$_items[$index] = $row;
     return $row;
 }
Example #2
0
 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;
                 }
             }
         }
     }
 }
Example #3
0
 public static function process($event)
 {
     $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile 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)) {
                 include_once JPATH_SITE . $p->scriptfile;
             }
         }
     }
 }
Example #4
0
 public function onUserBeforeSave($user, $isNew, $user2)
 {
     // Processing
     JLoader::register('JCckToolbox', JPATH_PLATFORM . '/cms/cck/toolbox.php');
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onUserBeforeSave';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile 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)) {
                     include_once JPATH_SITE . $p->scriptfile;
                 }
             }
         }
     }
 }
Example #5
0
 public function create($cck, $data_content, $data_more = null)
 {
     if ($this->_id) {
         return;
     }
     $this->_type = $cck;
     if (empty($this->_object)) {
         $this->_object = JCckDatabaseCache::loadResult('SELECT storage_location FROM #__cck_core_types WHERE name = "' . $this->_type . '"');
         $this->_columns = $this->_getProperties();
     }
     $this->_instance_core = JTable::getInstance($this->_columns['table_object'][0], $this->_columns['table_object'][1]);
     $author_id = 0;
     // TODO: Get default author id
     $parent_id = 0;
     // TODO: Get default parent_id
     // Set the author_id
     if (isset($this->_columns['author']) && $this->_columns['author'] && isset($data_content[$this->_columns['author']])) {
         $author_id = $data_content[$this->_columns['author']];
     } else {
         $user_id = JFactory::getUser()->get('id');
         if ($user_id) {
             $author_id = $user_id;
         }
     }
     // Set the parent_id
     if (isset($this->_columns['parent']) && $this->_columns['parent'] && isset($data_content[$this->_columns['parent']])) {
         $parent_id = $data_content[$this->_columns['parent']];
     }
     // -------- -------- --------
     if (!$this->save('core', $data_content)) {
         return false;
     }
     if (!$this->save('base', array('cck' => $this->_type, 'pk' => $this->_pk, 'storage_location' => $this->_object, 'author_id' => $author_id, 'parent_id' => $parent_id, 'date_time' => JFactory::getDate()->toSql()))) {
         return false;
     }
     if (is_array($data_more) && count($data_more)) {
         $this->_instance_more = JCckTable::getInstance('#__cck_store_form_' . $this->_type);
         $this->_instance_more->load($this->_pk, true);
         if (!$this->save('more', $data_more)) {
             return false;
         }
     }
     //TODO : Load instance info
     return $this->_pk;
 }
Example #6
0
 public function create($cck, $data_content, $data_more = null)
 {
     $db = JFactory::getDbo();
     if ($this->_id) {
         return;
     }
     //if object is joomla_user do validate first
     //login and email must be unique
     if ($this->_object == "joomla_user") {
         $username = $data_content['username'];
         $email = $data_content['email'];
         $query = $db->getQuery(true);
         $field = array('id');
         $table = '#__users';
         $query->select($db->quoteName($field));
         $query->from($db->quoteName($table));
         $query->where($db->quoteName('username') . '= ' . $db->quote($username), 'OR');
         $query->where($db->quoteName('email') . '= ' . $db->quote($email));
         $db->setQuery($query);
         $result = $db->loadObject();
         if ($result) {
             return false;
         }
     }
     $this->_type = $cck;
     if (empty($this->_object)) {
         $this->_object = JCckDatabaseCache::loadResult('SELECT storage_location FROM #__cck_core_types WHERE name = "' . $this->_type . '"');
         $this->_columns = $this->_getProperties();
     }
     $this->_instance_core = JTable::getInstance($this->_columns['table_object'][0], $this->_columns['table_object'][1]);
     $author_id = 0;
     // TODO: Get default author id
     $parent_id = 0;
     // TODO: Get default parent_id
     // Set the author_id
     if (isset($this->_columns['author']) && $this->_columns['author'] && isset($data_content[$this->_columns['author']])) {
         $author_id = $data_content[$this->_columns['author']];
     } else {
         $user_id = JFactory::getUser()->get('id');
         if ($user_id) {
             $author_id = $user_id;
         }
     }
     // Set the parent_id
     if (isset($this->_columns['parent']) && $this->_columns['parent'] && isset($data_content[$this->_columns['parent']])) {
         $parent_id = $data_content[$this->_columns['parent']];
     }
     // -------- -------- --------
     if (!$this->save('core', $data_content)) {
         return false;
     }
     if (!$this->save('base', array('cck' => $this->_type, 'pk' => $this->_pk, 'storage_location' => $this->_object, 'author_id' => $author_id, 'parent_id' => $parent_id, 'date_time' => JFactory::getDate()->toSql()))) {
         return false;
     }
     if (is_array($data_more) && count($data_more)) {
         $this->_instance_more = JCckTable::getInstance('#__cck_store_form_' . $this->_type);
         $this->_instance_more->load($this->_pk, true);
         if (!$this->save('more', $data_more)) {
             return false;
         }
     }
     return $this->_pk;
 }
 public function download()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $fieldname = $app->input->getString('file', '');
     $collection = $app->input->getString('collection', '');
     $xi = $app->input->getString('xi', 0);
     $client = $app->input->getString('client', 'content');
     $restricted = '';
     $user = JFactory::getUser();
     if (!$id) {
         $file = $fieldname;
         $path = JPATH_ROOT . '/' . $file;
         $paths = JCck::getConfig_Param('media_paths', '');
         if ($paths != '') {
             $allowed = false;
             $paths = strtr($paths, array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />'));
             $paths = explode('<br />', $paths);
             if (count($paths)) {
                 $paths[] = 'tmp/';
                 foreach ($paths as $p) {
                     if (strpos($path, JPATH_ROOT . '/' . $p) !== false) {
                         $allowed = true;
                         break;
                     }
                 }
             }
             if (!$allowed) {
                 $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
                 return;
             }
         } elseif (strpos($path, JPATH_ROOT . '/tmp/') === false) {
             $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
             return;
         }
     } else {
         $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . ($collection != '' ? $collection : $fieldname) . '"');
         //#
         $query = 'SELECT a.id, a.pk, a.author_id, a.cck as type, a.storage_location, b.' . $field->storage_field . ' as value, c.id as type_id' . ' FROM #__cck_core AS a' . ' LEFT JOIN ' . $field->storage_table . ' AS b on b.id = a.pk' . ' LEFT JOIN #__cck_core_types AS c on c.name = a.cck' . ' WHERE a.id =' . (int) $id;
         $core = JCckDatabase::loadObject($query);
         $config = array('author' => $core->author_id, 'client' => $client, 'collection' => $collection, 'fieldname' => $fieldname, 'id' => $core->id, 'isNew' => 0, 'location' => $core->storage_location, 'pk' => $core->pk, 'pkb' => 0, 'task' => 'download', 'type' => $core->type, 'type_id' => $core->type_id, 'xi' => $xi);
         $dispatcher = JDispatcher::getInstance();
         $field->value = $core->value;
         $pk = $core->pk;
         $value = '';
         JPluginHelper::importPlugin('cck_storage');
         $dispatcher->trigger('onCCK_StoragePrepareDownload', array(&$field, &$value, &$config));
         // Access
         $clients = JCckDatabase::loadObjectList('SELECT a.fieldid, a.client, a.access, a.restriction, a.restriction_options FROM #__cck_core_type_field AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE a.fieldid = ' . (int) $field->id . ' AND b.name="' . (string) $config['type'] . '"', 'client');
         $access = isset($clients[$client]->access) ? (int) $clients[$client]->access : 0;
         $autorised = $user->getAuthorisedViewLevels();
         $restricted = isset($clients[$client]->restriction) ? $clients[$client]->restriction : '';
         if (!($access > 0 && array_search($access, $autorised) !== false)) {
             $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
             return;
         }
         JPluginHelper::importPlugin('cck_field');
         $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . $fieldname . '"');
         //#
         if ($restricted) {
             JPluginHelper::importPlugin('cck_field_restriction');
             $field->restriction = $restricted;
             $field->restriction_options = $clients[$client]->restriction_options;
             $allowed = JCck::callFunc_Array('plgCCK_Field_Restriction' . $restricted, 'onCCK_Field_RestrictionPrepareContent', array(&$field, &$config));
             if ($allowed !== true) {
                 $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
                 return;
             }
         }
         $dispatcher->trigger('onCCK_FieldPrepareDownload', array(&$field, $value, &$config));
         $file = $field->filename;
     }
     $path = JPATH_ROOT . '/' . $file;
     if (is_file($path) && $file) {
         $size = filesize($path);
         $ext = strtolower(substr(strrchr($path, '.'), 1));
         if ($ext == 'php' || $file == '.htaccess') {
             return;
         }
         $name = substr($path, strrpos($path, '/') + 1, strrpos($path, '.'));
         if ($path) {
             $task2 = isset($field->task) ? $field->task : 'download';
             if ($task2 == 'read') {
                 $this->setRedirect(JURI::root(true) . '/' . $file);
             } else {
                 if ($id) {
                     $event = 'onCckDownloadSuccess';
                     if (JCckToolbox::getConfig()->get('processing', 0)) {
                         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile 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)) {
                                     include_once JPATH_SITE . $p->scriptfile;
                                 }
                             }
                         }
                     }
                     $this->_download_hits($id, $fieldname, $collection, $xi);
                 }
                 set_time_limit(0);
                 @ob_end_clean();
                 include JPATH_ROOT . '/components/com_cck/download.php';
             }
         }
     } else {
         $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_DOESNT_EXIST'), 'error');
     }
 }
Example #8
0
 protected function _render($context, &$article, $tpl, $contentType, $fields, $property, $client, $cck, $parent_type)
 {
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     $user = JFactory::getUser();
     $params = array('template' => $tpl['folder'], 'file' => 'index.php', 'directory' => $tpl['root']);
     $lang = JFactory::getLanguage();
     $lang->load('com_cck_default', JPATH_SITE);
     JPluginHelper::importPlugin('cck_field');
     JPluginHelper::importPlugin('cck_field_link');
     JPluginHelper::importPlugin('cck_field_restriction');
     $p_sef = isset($this->loaded[$contentType . '_' . $client . '_options']['sef']) ? $this->loaded[$contentType . '_' . $client . '_options']['sef'] : JCck::getConfig_Param('sef', '2');
     $p_title = isset($this->loaded[$contentType . '_' . $client . '_options']['title']) ? $this->loaded[$contentType . '_' . $client . '_options']['title'] : '';
     $p_typo = isset($this->loaded[$contentType . '_' . $client . '_options']['typo']) ? $this->loaded[$contentType . '_' . $client . '_options']['typo'] : 1;
     if ($p_typo) {
         JPluginHelper::importPlugin('cck_field_typo');
     }
     jimport('cck.rendering.document.document');
     $doc = CCK_Document::getInstance('html');
     $positions = array();
     if ($parent_type != '') {
         $w_type = '(b.name = "' . $contentType . '" OR b.name = "' . $parent_type . '")';
     } else {
         $w_type = 'b.name = "' . $contentType . '"';
     }
     if ($client == 'intro') {
         $positions_more = JCckDatabaseCache::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position');
         // todo::improve
     } else {
         $positions_more = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position');
         // todo::improve
     }
     // Fields
     if (count($fields)) {
         JPluginHelper::importPlugin('cck_storage');
         $config = array('author' => 0, 'client' => $client, 'doSEF' => $p_sef, 'doTranslation' => JCck::getConfig_Param('language_jtext', 0), 'doTypo' => $p_typo, 'error' => 0, 'fields' => array(), 'id' => $cck->id, 'isNew' => 0, 'Itemid' => $app->input->getInt('Itemid', 0), 'location' => $cck->storage_location, 'pk' => $article->id, 'pkb' => $cck->pkb, 'storages' => array(), 'store_id' => (int) $cck->store_id, 'type' => $cck->cck, 'type_id' => (int) $cck->type_id, 'type_alias' => $cck->type_alias ? $cck->type_alias : $cck->cck);
         foreach ($fields as $field) {
             $field->typo_target = 'value';
             $fieldName = $field->name;
             $value = '';
             $name = !empty($field->storage_field2) ? $field->storage_field2 : $fieldName;
             //-
             if ($fieldName) {
                 $Pt = $field->storage_table;
                 if ($Pt && !isset($config['storages'][$Pt])) {
                     $config['storages'][$Pt] = '';
                     $dispatcher->trigger('onCCK_Storage_LocationPrepareContent', array(&$field, &$config['storages'][$Pt], $config['pk'], &$config, &$article));
                 }
                 $dispatcher->trigger('onCCK_StoragePrepareContent', array(&$field, &$value, &$config['storages'][$Pt]));
                 if (is_string($value)) {
                     $value = trim($value);
                 }
                 if ($p_title != '' && $p_title == $field->name) {
                     $this->title = $value;
                 }
                 $hasLink = $field->link != '' ? 1 : 0;
                 $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config));
                 $target = $field->typo_target;
                 if ($hasLink) {
                     $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$field, &$config));
                     if ($field->link) {
                         JCckPluginLink::g_setHtml($field, $target);
                     }
                 }
                 if (@$field->typo && ($field->{$target} !== '' || $field->typo_label == -2) && $p_typo) {
                     $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$field, $field->typo_target, &$config));
                 } else {
                     $field->typo = '';
                 }
                 $position = $field->position;
                 $positions[$position][] = $fieldName;
                 // Was it the last one?
                 if ($config['error']) {
                     break;
                 }
             }
         }
         // Merge
         if (count($config['fields'])) {
             $fields = array_merge($fields, $config['fields']);
             // Test: a loop may be faster.
             $config['fields'] = NULL;
             unset($config['fields']);
         }
     }
     // BeforeRender
     if (isset($config['process']['beforeRenderContent']) && count($config['process']['beforeRenderContent'])) {
         foreach ($config['process']['beforeRenderContent'] as $process) {
             if ($process->type) {
                 JCck::callFunc_Array('plg' . $process->group . $process->type, 'on' . $process->group . 'BeforeRenderContent', array($process->params, &$fields, &$config['storages'], &$config));
             }
         }
     }
     // Finalize
     $doc->fields =& $fields;
     $infos = array('context' => $context, 'params' => $tpl['params'], 'path' => $tpl['path'], 'root' => JURI::root(true), 'template' => $tpl['folder'], 'theme' => $tpl['home']);
     $doc->finalize('content', $contentType, $client, $positions, $positions_more, $infos, $cck->id);
     $data = $doc->render(false, $params);
     $article->{$property} = str_replace($article->{$property}, $data, $article->{$property});
 }
Example #9
0
 protected static function _getOptionsList($options2, $free_sql, $lang_code, $static = false)
 {
     $options = '';
     if ($free_sql == 0) {
         $opt_table = isset($options2['table']) ? ' FROM ' . $options2['table'] : '';
         $opt_name = isset($options2['name']) ? $options2['name'] : '';
         $opt_value = isset($options2['value']) ? $options2['value'] : '';
         $opt_where = @$options2['where'] != '' ? ' WHERE ' . $options2['where'] : '';
         $opt_orderby = @$options2['orderby'] != '' ? ' ORDER BY ' . $options2['orderby'] . ' ' . (@$options2['orderby_direction'] != '' ? $options2['orderby_direction'] : 'ASC') : '';
         // Language Detection
         $opt_value = str_replace('[lang]', $lang_code, $opt_value);
         $opt_name = str_replace('[lang]', $lang_code, $opt_name);
         $opt_where = str_replace('[lang]', $lang_code, $opt_where);
         $opt_orderby = str_replace('[lang]', $lang_code, $opt_orderby);
         if ($opt_name && $opt_table) {
             $query = 'SELECT ' . $opt_name . ',' . $opt_value . $opt_table . $opt_where . $opt_orderby;
             $query = JCckDevHelper::replaceLive($query);
             $lists = $static ? JCckDatabaseCache::loadObjectList($query) : JCckDatabase::loadObjectList($query);
             if (count($lists)) {
                 foreach ($lists as $list) {
                     $options .= $list->{$opt_name} . '=' . $list->{$opt_value} . '||';
                 }
             }
         }
     } else {
         $opt_query = isset($options2['query']) ? $options2['query'] : '';
         // Language Detection
         $opt_query = str_replace('[lang]', $lang_code, $opt_query);
         $opt_query = JCckDevHelper::replaceLive($opt_query);
         $lists = $static ? JCckDatabaseCache::loadObjectList($opt_query) : JCckDatabase::loadObjectList($opt_query);
         if (count($lists)) {
             foreach ($lists as $list) {
                 $options .= @$list->text . '=' . @$list->value . '||';
             }
         }
     }
     return $options;
 }
Example #10
0
 public static function access($pk)
 {
     return JCckDatabaseCache::loadResult('SELECT ' . self::$key . ' FROM ' . self::$table . ' WHERE ' . self::$key . ' = ' . $pk . ' AND ' . self::$access . ' IN (' . implode(',', JFactory::getUser()->getAuthorisedViewLevels()) . ') AND ' . self::$status . ' = 1');
 }
Example #11
0
 public static function getDefaultTemplate()
 {
     $name = JCckDatabaseCache::loadResult('SELECT name FROM #__cck_core_templates WHERE featured = 1 ORDER BY id');
     if (!$name) {
         $name = 'seb_one';
     }
     return $name;
 }
Example #12
0
 public function onContentPrepareForm($form, $data)
 {
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onContentPrepareForm';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile 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)) {
                     include_once JPATH_SITE . $p->scriptfile;
                 }
             }
         }
     }
 }
Example #13
0
 protected static function _setStorage(&$tables, &$config, &$inherit)
 {
     if (isset($tables['#__cck_core']['fields']['storage_location'])) {
         $config['location'] = $tables['#__cck_core']['fields']['storage_location'];
         $inherit['table'] = '';
     } elseif (isset($tables['#__cck_core']['fields']['cck'])) {
         $cck = str_replace(array(',', ' '), array('","', '","'), $tables['#__cck_core']['fields']['cck']);
         $core = JCckDatabaseCache::loadObject('SELECT storage_location, storage_table FROM #__cck_core WHERE cck IN ("' . $cck . '") ORDER BY id DESC LIMIT 1');
         if (is_object($core)) {
             $config['location'] = $core->storage_location;
             $inherit['table'] = $core->storage_table;
         }
     }
     if (!$config['location'] && isset($config['type_object']) && $config['type_object']) {
         $config['location'] = $config['type_object'];
         $inherit['table'] = '';
     }
 }
Example #14
0
 public function load($identifier, $data = true)
 {
     $this->_type = '';
     $this->_pk = '';
     $this->_id = '';
     if (is_array($identifier)) {
         $this->_object = $identifier[0];
         $this->_columns = $this->_getProperties();
         $this->_instance_base = JTable::getInstance($this->_columns['table_object'][0], $this->_columns['table_object'][1]);
         if (!isset($identifier[1])) {
             return;
         }
         $core = JCckDatabase::loadObject('SELECT id, cck, pk, storage_location FROM #__cck_core WHERE storage_location = "' . (string) $identifier[0] . '" AND pk = ' . (int) $identifier[1]);
     } else {
         $core = JCckDatabase::loadObject('SELECT id, cck, pk, storage_location FROM #__cck_core WHERE id = ' . (int) $identifier);
         $this->_object = $core->storage_location;
         $this->_columns = $this->_getProperties();
         $this->_instance_base = JTable::getInstance($this->_columns['table_object'][0], $this->_columns['table_object'][1]);
     }
     if (!(@$core->id && @$core->pk)) {
         return false;
     }
     $this->_type = $core->cck;
     $this->_pk = $core->pk;
     $this->_id = $core->id;
     $this->_instance_core->load($this->_id);
     $this->_instance_base->load($this->_pk);
     if (!$this->_columns['table']) {
         return;
     }
     $this->_table = $this->_columns['table'];
     $tables = JCckDatabaseCache::getTableList(true);
     $hasMore = isset($tables[JFactory::getConfig()->get('dbprefix') . 'cck_store_form_' . $this->_type]);
     if ($hasMore) {
         $this->_instance_more = JCckTable::getInstance('#__cck_store_form_' . $this->_type);
         $this->_instance_more->load($this->_pk);
     }
     if ($data === true) {
         if ($hasMore) {
             $this->_properties = JCckDatabase::loadObject('SELECT a.*, b.* FROM ' . $this->_table . ' AS a' . ' LEFT JOIN #__cck_store_form_' . $this->_type . ' AS b ON b.id = a.' . $this->_columns['key'] . ' WHERE a.' . $this->_columns['key'] . ' = ' . (int) $this->_pk);
         } else {
             $this->_properties = JCckDatabase::loadObject('SELECT a.* FROM ' . $this->_table . ' AS a' . ' WHERE a.' . $this->_columns['key'] . ' = ' . (int) $this->_pk);
         }
     } elseif (is_array($data)) {
         if (isset($data[$this->_table])) {
             $select = implode(',', $data[$this->_table]);
             unset($data[$this->_table]);
         } else {
             $select = '*';
         }
         $b = 'a';
         $i = 98;
         foreach ($data as $k => $v) {
             $a = chr($i);
             $select .= ', ' . $a . '.' . implode(', ' . $a . '.', $v);
             $join .= ' LEFT JOIN ' . $k . ' AS ' . $a . ' ON ' . $a . '.id = ' . $b . '.' . $this->_columns['key'];
             $b = $a;
             $i++;
         }
         $query = 'SELECT a.' . $select . ' FROM ' . $this->_table . ' AS a' . $join . ' WHERE a.' . $this->_columns['key'] . ' = ' . (int) $this->_pk;
         $this->_properties = JCckDatabase::loadObject($query);
     }
 }
Example #15
0
 public function delete()
 {
     if ($this->_object == '') {
         return false;
     }
     if (!($this->_id && $this->_pk)) {
         return false;
     }
     $config = array('author' => $this->_instance_base->author_id, 'type' => $this->_instance_base->cck, 'type_id' => 0);
     $nb = 0;
     if ($config['type']) {
         $config['type_id'] = JCckDatabaseCache::loadResult('SELECT id FROM #__cck_core_types WHERE name = "' . $config['type'] . '"');
     }
     if (!$config['type_id']) {
         return false;
     }
     JPluginHelper::importPlugin('content');
     if (JCck::callFunc_Array('plgCCK_Storage_Location' . $this->_object, 'onCCK_Storage_LocationDelete', array($this->_pk, &$config))) {
         $nb++;
     }
     return $nb ? true : false;
 }
Example #16
0
 public static function parseRoute(&$vars, $segments, $n, $config)
 {
     $join = '';
     $where = '';
     $vars['option'] = 'com_content';
     $vars['view'] = 'categories';
     if ($n == 2) {
         if ($config['doSEF'][0] == '3') {
             $join = ' LEFT JOIN #__cck_core AS b on b.' . $config['join_key'] . ' = a.id';
             $where = ' AND b.cck = "' . (string) $segments[0] . '"';
         } else {
             $join = ' LEFT JOIN #__categories AS b on b.id = a.parent_id';
             if ($config['doSEF'] == '1') {
                 $where = ' AND b.id = ' . (int) $segments[0];
                 $vars['catid'] = $segments[0];
             } else {
                 $segments[0] = str_replace(':', '-', $segments[0]);
                 $where = ' AND b.alias = "' . $segments[0] . '"';
             }
         }
     } else {
         if ($config['doSEF'][0] == '2' && isset($config['doSEF'][1]) && $config['doSEF'][1] == '4') {
             $active = JFactory::getApplication()->getMenu()->getActive();
             if (isset($active->query['search']) && $active->query['search']) {
                 $cck = JCckDatabaseCache::loadResult('SELECT sef_route FROM #__cck_core_searchs WHERE name = "' . $active->query['search'] . '"');
                 if ($cck) {
                     $join = ' LEFT JOIN #__cck_core AS b on b.' . $config['join_key'] . ' = a.id';
                     $where = strpos($cck, ',') !== false ? ' AND b.cck IN ("' . str_replace(',', '","', $cck) . '")' : ' AND b.cck = "' . $cck . '"';
                 }
             }
         }
     }
     if (self::$sef[$config['doSEF']] == 'full') {
         list($id, $alias) = explode(':', $segments[$n - 1], 2);
         $vars['id'] = $id;
     } else {
         if (is_numeric($segments[$n - 1])) {
             $vars['id'] = $segments[$n - 1];
         } else {
             $segments[$n - 1] = str_replace(':', '-', $segments[$n - 1]);
             $query = 'SELECT a.id FROM ' . self::$table . ' AS a' . $join . ' WHERE a.alias = "' . $segments[$n - 1] . '"' . $where;
             $vars['id'] = JCckDatabaseCache::loadResult($query);
         }
     }
 }
Example #17
0
 protected static function _link($link, &$field, &$config)
 {
     $app = JFactory::getApplication();
     $custom = $link->get('custom', '');
     $form = $link->get('form', '');
     $edit = $link->get('form_edition', 1);
     $edit = !$form && $edit ? '&id=' . $config['pk'] : '';
     $form = $form ? $form : $config['type'];
     $itemId = $link->get('itemid', $app->input->getInt('Itemid', 0));
     $redirection = $link->get('redirection', '');
     $uri = (string) JFactory::getUri();
     if (strpos($uri, 'format=raw&infinite=1') !== false) {
         $return = $app->input->get('return');
     } else {
         $return = base64_encode($uri);
     }
     if (!$form) {
         return;
     }
     // Check
     if ($edit != '') {
         static $cache = array();
         $stage = $link->get('form_edition_stage', '');
         if ($stage != '') {
             $edit .= '&stage=' . (int) $stage;
         }
         $user = JCck::getUser();
         $canEdit = $user->authorise('core.edit', 'com_cck.form.' . $config['type_id']);
         // if ( $user->id && !$user->guest ) {
         $canEditOwn = $user->authorise('core.edit.own', 'com_cck.form.' . $config['type_id']);
         // } else {
         //	$canEditOwn		=	false; // todo: guest
         // }
         $canEditOwnContent = '';
         // canEditOwnContent
         jimport('cck.joomla.access.access');
         $canEditOwnContent = CCKAccess::check($user->id, 'core.edit.own.content', 'com_cck.form.' . $config['type_id']);
         if ($canEditOwnContent) {
             $field2 = JCckDatabaseCache::loadObject('SELECT storage, storage_table, storage_field FROM #__cck_core_fields WHERE name = "' . $canEditOwnContent . '"');
             $canEditOwnContent = false;
             if (is_object($field2) && $field2->storage == 'standard') {
                 $pks = isset($config['pks']) ? $config['pks'] : $config['pk'];
                 $query = 'SELECT ' . $field2->storage_field . ' as map, id FROM ' . $field2->storage_table . ' WHERE id IN (' . $pks . ')';
                 $index = md5($query);
                 if (!isset($cache[$index])) {
                     $cache[$index . '_pks'] = JCckDatabase::loadObjectList($query, 'id');
                     $values = array();
                     if (count($cache[$index . '_pks'])) {
                         foreach ($cache[$index . '_pks'] as $p) {
                             $values[] = $p->map;
                         }
                     }
                     $values = count($values) ? implode(',', $values) : '0';
                     $cache[$index] = JCckDatabase::loadObjectList('SELECT author_id, pk FROM #__cck_core WHERE storage_location = "joomla_article" AND pk IN ( ' . $values . ' )', 'pk');
                 }
                 if (isset($cache[$index . '_pks'][$config['pk']]) && isset($cache[$index][$cache[$index . '_pks'][$config['pk']]->map]) && $cache[$index][$cache[$index . '_pks'][$config['pk']]->map]->author_id == $user->get('id')) {
                     $canEditOwnContent = true;
                 }
             }
         } else {
             $canEditOwnContent = '';
         }
         // Check Permissions
         if (!($canEdit && $canEditOwn || $canEdit && !$canEditOwn && $config['author'] != $user->get('id') || $canEditOwn && $config['author'] == $user->get('id') || $canEditOwnContent)) {
             if (!$link->get('no_access', 0)) {
                 $field->display = 0;
             }
             return;
         }
     } elseif ($form != '') {
         $user = JCck::getUser();
         $type_id = (int) JCckDatabase::loadResult('SELECT id FROM #__cck_core_types WHERE name = "' . $form . '"');
         $canCreate = $type_id ? $user->authorise('core.create', 'com_cck.form.' . $type_id) : false;
         // Check Permissions
         if (!$canCreate) {
             return;
         }
     }
     // Prepare
     $link_class = $link->get('class', '');
     $link_rel = $link->get('rel', '');
     $link_target = $link->get('target', '');
     $link_title = $link->get('title', '');
     $link_title2 = $link->get('title_custom', '');
     $tmpl = $link->get('tmpl', '');
     $tmpl = $tmpl ? '&tmpl=' . $tmpl : '';
     $vars = $tmpl;
     // + live
     /*
     if ( $config['client'] == 'admin' || $config['client'] == 'site' || $config['client'] == 'search' ) {
     	$redirection		=	'-1'; // todo
     }
     */
     // Set
     if (is_array($field->value)) {
         foreach ($field->value as $f) {
             $c = $custom;
             $c = parent::g_getCustomSelfVars(self::$type, $f, $c, $config);
             $c = $c ? '&' . $c : '';
             $f->link = 'index.php?option=com_cck&view=form&layout=edit&type=' . $form . $edit . $vars . '&Itemid=' . $itemId . $c;
             if ($redirection != '-1') {
                 $f->link .= '&return=' . $return;
             }
             $f->link = JRoute::_($f->link);
             $f->link_class = $link_class ? $link_class : (isset($f->link_class) ? $f->link_class : '');
             $f->link_rel = $link_rel ? $link_rel : (isset($f->link_rel) ? $f->link_rel : '');
             $f->link_state = $link->get('state', 1);
             $f->link_target = $link_target ? $link_target : (isset($f->link_target) ? $f->link_target : '');
             $f->link_title = $link_title ? $link_title == '2' ? $link_title2 : (isset($f->link_title) ? $f->link_title : '') : '';
         }
         $field->link = '#';
         //todo
     } else {
         $custom = parent::g_getCustomVars(self::$type, $field, $custom, $config);
         $field->link = JRoute::_('index.php?option=com_cck&view=form&layout=edit&type=' . $form . $edit . $vars . '&Itemid=' . $itemId);
         $separator = strpos($field->link, '?') !== false ? '&' : '?';
         if ($custom) {
             $field->link .= $separator . $custom;
             $separator = '&';
         }
         if ($redirection != '-1') {
             $field->link .= $separator . 'return=' . $return;
         }
         $field->link_class = $link_class ? $link_class : (isset($field->link_class) ? $field->link_class : '');
         $field->link_rel = $link_rel ? $link_rel : (isset($field->link_rel) ? $field->link_rel : '');
         $field->link_state = $link->get('state', 1);
         $field->link_target = $link_target ? $link_target : (isset($field->link_target) ? $field->link_target : '');
         $field->link_title = $link_title ? $link_title == '2' ? $link_title2 : (isset($field->link_title) ? $field->link_title : '') : '';
     }
 }
Example #18
0
}
if ($app->isSite() && $hashed !== NULL && $hash != $hashed) {
    $config = array('pk' => 0, 'options' => '', 'url' => @$preconfig['url'], 'validate' => '');
    $app->enqueueMessage(JText::_('COM_CCK_ERROR_DATA_INTEGRITY_CHECK_FAILED'), 'error');
    return 0;
}
require_once JPATH_PLUGINS . '/cck_field_validation/required/required.php';
$lang->load('plg_cck_field_validation_required', JPATH_ADMINISTRATOR, null, false, true);
JPluginHelper::importPlugin('cck_field');
JPluginHelper::importPlugin('cck_field_restriction');
JPluginHelper::importPlugin('cck_storage_location');
$dispatcher = JDispatcher::getInstance();
$integrity = array();
$processing = array();
if (JCckToolbox::getConfig()->get('processing', 0)) {
    $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
}
$storages = array();
$config = array('author' => 0, 'client' => $client, 'doTranslation' => JCck::getConfig_Param('language_jtext', 0), 'doValidation' => JCck::getConfig_Param('validation', '2'), 'error' => false, 'fields' => array(), 'id' => $preconfig['id'], 'isNew' => $isNew, 'Itemid' => $preconfig['itemId'], 'message' => $preconfig['message'], 'message_style' => '', 'options' => '', 'pk' => $id, 'post' => $post, 'process' => array(), 'stage' => -1, 'storages' => array(), 'task' => $task, 'type' => $preconfig['type'], 'url' => $preconfig['url'], 'validate' => '');
CCK_Form::applyTypeOptions($config);
$stage = -1;
$stages = isset($config['options']['stages']) ? $config['options']['stages'] : 1;
if ($stages > 1) {
    $stage = $preconfig['stage'];
}
$parent = JCckDatabase::loadResult('SELECT parent FROM #__cck_core_types WHERE name = "' . $preconfig['type'] . '"');
$fields = CCK_Form::getFields(array($preconfig['type'], $parent), $client, $stage, '', true);
if (count($fields)) {
    foreach ($fields as $field) {
        $name = $field->name;
        $field->state = '';