Пример #1
0
 public static function afterImportCategory($elemtype, &$table, $xml, &$data)
 {
     $app = isset($xml->app) ? (string) $xml->app : '';
     $core = $app ? JCckDatabase::loadObject('SELECT id, pk FROM #__cck_core WHERE app = "' . $app . '"') : 0;
     if (is_object($core)) {
         $id = $core->id;
         $isNew = false;
     } else {
         $id = JCckPluginLocation::g_onCCK_Storage_LocationPrepareStore();
         $isNew = true;
     }
     if (@$core->pk > 0) {
         $table->id = $core->pk;
     }
     $table->description = '::cck::' . $id . '::/cck::<br />::description::::/description::';
     //todo
     $table->parent_id = $data['root_category'] > 0 ? $data['root_category'] : 1;
     $rules = new JAccessRules('{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}');
     $table->setRules($rules);
     $table->setLocation($table->parent_id, 'last-child');
     $table->check();
     $table->store();
     $data['root_category'] = $data['root_category'] > 0 ? $data['root_category'] : $table->id;
     $data['categories'][$app] = $table->id;
     if ($table->rebuildPath($table->id)) {
         $table->rebuild($table->id, $table->lft, $table->level, $table->path);
     }
     if ($isNew === true) {
         $core = JCckTable::getInstance('#__cck_core', 'id');
         $core->load($id);
         $core->pk = $table->id;
         $core->cck = 'category';
         //todo
         $core->storage_location = 'joomla_category';
         $core->author_id = JCck::getConfig_Param('integration_user_default_author', 42);
         //todo
         $core->parent_id = $table->parent_id;
         $core->date_time = '';
         //todo
         $core->app = $app;
         $core->storeIt();
     }
 }
Пример #2
0
 protected function _core($data, &$config = array(), $pk = 0, $params = array())
 {
     $app = JFactory::getApplication();
     $parameters = JComponentHelper::getParams('com_users');
     $data['params'] = isset($data['params']) ? JCckDev::fromJSON($data['params']) : array();
     //Fix
     if (!$config['id']) {
         $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore();
     }
     if ($app->isSite()) {
         // Site
         // Init
         $table = self::_getTable_fromSite($pk);
         $isNew = $pk > 0 ? false : true;
         self::_initTable_fromSite($table, $data, $config);
         if ($isNew) {
             $activation = $parameters->get('useractivation');
             if ($activation == 1 || $activation == 2) {
                 $data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
                 $data['block'] = 1;
                 $config['registration_activation'] = $data['activation'];
             }
         }
         // Prepare
         $table->bind($data);
         JPluginHelper::importPlugin('user');
         self::_completeTable_fromSite($table, $data, $config, $parameters);
         // Store
         if (!$table->save()) {
             $app->enqueueMessage(JText::sprintf('COM_CCK_REGISTRATION_SAVE_FAILED', $table->getError()), 'error');
             $config['error'] = true;
             return;
         }
         if ($isNew) {
             self::_sendMails($table, $activation, $params['auto_email'], $parameters->get('mail_to_admin'), $parameters->get('sendpassword', 1));
         }
         self::$pk = $table->{self::$key};
         if (!$config['pk']) {
             $config['pk'] = self::$pk;
         }
     } else {
         // Admin
         // Init
         $table = self::_getTable($pk);
         $isNew = $pk > 0 ? false : true;
         self::_initTable($table, $data, $config);
         // Check Error
         if (self::$error === true) {
             return false;
         }
         // Prepare
         if (is_array($data)) {
             $table->bind($data);
         }
         self::_completeTable($table, $data, $config, $parameters);
         // Store
         $table->save();
         self::$pk = $table->{self::$key};
         if (!$config['pk']) {
             $config['pk'] = self::$pk;
         }
     }
     $config['author'] = $table->id;
     parent::g_onCCK_Storage_LocationStore($data, self::$table, self::$pk, $config, $params);
 }
Пример #3
0
 protected function _core($data, &$config = array(), $pk = 0)
 {
     if (!$config['id']) {
         $isNew = true;
         $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore();
     } else {
         $isNew = false;
     }
     // Init
     $table = self::_getTable($pk);
     $isNew = $pk > 0 ? false : true;
     if (isset($table->tags)) {
         $tags = $table->tags;
         unset($table->tags);
     } else {
         $tags = null;
     }
     if (isset($data['tags'])) {
         if (!empty($data['tags']) && $data['tags'][0] != '') {
             $table->newTags = $data['tags'];
         }
         unset($data['tags']);
     }
     self::_initTable($table, $data, $config);
     // Check Error
     if (self::$error === true) {
         return false;
     }
     // Prepare
     if (is_array($data)) {
         $table->bind($data);
     }
     if ($isNew && !isset($data['rules'])) {
         $data['rules'] = array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array());
     }
     if (isset($data['rules']) && $data['rules']) {
         if (!is_array($data['rules'])) {
             $data['rules'] = json_decode($data['rules']);
         }
         $rules = new JAccessRules(JCckDevHelper::getRules($data['rules']));
         $table->setRules($rules);
     }
     $table->check();
     self::_completeTable($table, $data, $config);
     // Store
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $dispatcher->trigger('onContentBeforeSave', array(self::$context, &$table, $isNew));
     if ($isNew === true && parent::g_isMax($table->{self::$author}, $table->{self::$parent}, $config)) {
         return;
     }
     if (!$table->store()) {
         JFactory::getApplication()->enqueueMessage($table->getError(), 'error');
         if ($isNew) {
             parent::g_onCCK_Storage_LocationRollback($config['id']);
         }
         return false;
     }
     // Checkin
     parent::g_checkIn($table);
     self::$pk = $table->{self::$key};
     if (!$config['pk']) {
         $config['pk'] = self::$pk;
     }
     $config['author'] = $table->{self::$author};
     $config['parent'] = $table->{self::$parent};
     parent::g_onCCK_Storage_LocationStore($data, self::$table, self::$pk, $config);
     $dispatcher->trigger('onContentAfterSave', array(self::$context, &$table, $isNew));
     // Associations
     // todo
 }
Пример #4
0
 protected function _core($data, &$config = array(), $pk = 0, $params = array())
 {
     if (!$config['id']) {
         $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore();
     }
     // Init
     $table = self::_getTable($pk);
     $isNew = $pk > 0 ? false : true;
     self::_initTable($table, $data, $config);
     // Check Error
     if (self::$error === true) {
         return false;
     }
     // Prepare
     if (is_array($data)) {
         $table->bind($data);
     }
     $table->check();
     self::_completeTable($table, $data, $config);
     // Store
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('user');
     $dispatcher->trigger('onUserBeforeSaveGroup', array(self::$context, &$table, $isNew));
     if (!$table->store()) {
         JFactory::getApplication()->enqueueMessage($table->getError(), 'error');
         if ($isNew) {
             parent::g_onCCK_Storage_LocationRollback($config['id']);
         }
         return false;
     }
     $dispatcher->trigger('onUserAfterSaveGroup', array(self::$context, &$table, $isNew));
     self::$pk = $table->{self::$key};
     if (!$config['pk']) {
         $config['pk'] = self::$pk;
     }
     $config['author'] = JFactory::getUser()->get('id');
     parent::g_onCCK_Storage_LocationStore($data, self::$table, self::$pk, $config, $params);
 }