예제 #1
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);
 }
예제 #2
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
 }
예제 #3
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);
 }