Exemple #1
0
$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 = '';
        // Restriction
        if (isset($field->restriction) && $field->restriction) {
            $field->authorised = JCck::callFunc_Array('plgCCK_Field_Restriction' . $field->restriction, 'onCCK_Field_RestrictionPrepareStore', array(&$field, &$config));
            if (!$field->authorised) {
                continue;
            }
        }
        if ($task != 'save2copy' && ($field->variation == 'hidden' || $field->variation == 'hidden_auto' || $field->variation == 'disabled' || $field->variation == 'value') && !$field->live && $field->live_value != '') {
            $value = $field->live_value;
        } else {
            if (isset($post[$name])) {
Exemple #2
0
 public function onContentAfterDelete($context, $data)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('name AS object')->from('#__cck_core_objects')->where('context = ' . $db->quote($context));
     $db->setQuery($query);
     $object = $db->loadResult();
     if (!$object) {
         return true;
     }
     $tableKey = $data->getKeyName();
     $pk = $data->{$tableKey};
     $base = str_replace('#__', '', $data->getTableName());
     require_once JPATH_SITE . '/plugins/cck_storage_location/' . $object . '/' . $object . '.php';
     $properties = array('custom');
     $properties = JCck::callFunc('plgCCK_Storage_Location' . $object, 'getStaticProperties', $properties);
     $custom = $properties['custom'];
     $type = '';
     // Core
     if ($custom) {
         preg_match('#::cck::(.*)::/cck::#U', $data->{$custom}, $matches);
         $id = $matches[1];
         if (!$id) {
             return true;
         }
         $table = JCckTable::getInstance('#__cck_core', 'id', $id);
         $type = $table->cck;
     } else {
         $table = JCckTable::getInstance('#__cck_core');
         if ($table->load(array('pk' => $pk, 'storage_location' => $object))) {
             $type = $table->cck;
         }
     }
     if ($table->pk > 0) {
         // -- Leave nothing behind
         if ($type != '') {
             require_once JPATH_LIBRARIES . '/cck/base/form/form.php';
             JPluginHelper::importPlugin('cck_field');
             JPluginHelper::importPlugin('cck_storage');
             JPluginHelper::importPlugin('cck_storage_location');
             $config = array('pk' => $table->pk, 'storages' => array(), 'type' => $table->cck);
             $dispatcher = JDispatcher::getInstance();
             $parent = JCckDatabase::loadResult('SELECT parent FROM #__cck_core_types WHERE name = "' . $type . '"');
             $fields = CCK_Form::getFields(array($type, $parent), 'all', -1, '', true);
             if (count($fields)) {
                 foreach ($fields as $field) {
                     $Pt = $field->storage_table;
                     $value = '';
                     /* Yes but, .. */
                     if ($Pt && !isset($config['storages'][$Pt])) {
                         $config['storages'][$Pt] = '';
                         $dispatcher->trigger('onCCK_Storage_LocationPrepareDelete', array(&$field, &$config['storages'][$Pt], $pk, &$config));
                     }
                     $dispatcher->trigger('onCCK_StoragePrepareDelete', array(&$field, &$value, &$config['storages'][$Pt], &$config));
                     $dispatcher->trigger('onCCK_FieldDelete', array(&$field, $value, &$config, array()));
                 }
             }
         }
         // -- Leave nothing behind
         $table->delete();
     }
     // Processing
     JLoader::register('JCckToolbox', JPATH_PLATFORM . '/cms/cck/toolbox.php');
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onContentAfterDelete';
         $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;
                     /* Variables: $id, $pk, $type */
                 }
             }
         }
     }
     $tables = JCckDatabase::loadColumn('SHOW TABLES');
     $prefix = JFactory::getConfig()->get('dbprefix');
     if (in_array($prefix . 'cck_store_item_' . $base, $tables)) {
         $table = JCckTable::getInstance('#__cck_store_item_' . $base, 'id', $pk);
         if ($table->id) {
             $table->delete();
         }
     }
     if (in_array($prefix . 'cck_store_form_' . $type, $tables)) {
         $table = JCckTable::getInstance('#__cck_store_form_' . $type, 'id', $pk);
         if ($table->id) {
             $table->delete();
         }
     }
     return true;
 }
Exemple #3
0
if (count($config['fields'])) {
    $fields = array_merge($fields, $config['fields']);
    // Test: a loop may be faster.
    $config['fields'] = NULL;
    unset($config['fields']);
}
// ACL
if (!$canAccess && $canEditOwn && !$config['author']) {
    if (empty($config['id'])) {
        $location = $type->storage_location ? $type->storage_location : $config['base']['location'];
        $config['author'] = JCckDatabase::loadResult('SELECT a.author_id FROM #__cck_core AS a WHERE a.storage_location = "' . $location . '" AND a.pk = ' . (int) $config['pk']);
    } else {
        $config['author'] = JCckDatabase::loadResult('SELECT a.author_id FROM #__cck_core AS a WHERE a.id = ' . (int) $config['id']);
    }
    if ((!$config['author'] || $config['author'] != $user->get('id')) && !$canEditOwnContent) {
        CCK_Form::redirect($no_action, $no_redirect, $no_message, $no_style, $config);
        return;
    }
}
// BeforeRender
if (isset($config['process']['beforeRenderForm']) && count($config['process']['beforeRenderForm'])) {
    foreach ($config['process']['beforeRenderForm'] as $process) {
        if ($process->type) {
            JCck::callFunc_Array('plg' . $process->group . $process->type, 'on' . $process->group . 'beforeRenderForm', array($process->params, &$fields, &$config['storages'], &$config));
        }
    }
}
// Finalize
$doc->fields =& $fields;
$infos = array('context' => '', 'params' => $templateStyle->params, 'path' => $path, 'root' => JURI::root(true), 'template' => $templateStyle->name, 'theme' => $tpl['home']);
$doc->finalize('form', $type->name, $config['client'], $positions, $positions_more, $infos);