we had the same issue, as we are redeveloping a part of our website from evolution to revolution and was using smf previously. we installed discuss and these issues arose. we figured it would be quicker to amend the code to get it to work than integrate smf. hopefully the completed version will be out soon.
we found it worked mostly fine with the admin logged in, as it adds the installing admin user into the ’discuss’ user list.
in the code below, we added this above the comment /* @TODO: auto-create profile if not exists as fallback */
\core\components\discuss\model\discuss\discuss.class.php line 120(ish)
The orignal code
$this->user =& $this->modx->user;
$this->user->profile = $this->modx->getObject('disUserProfile',array('user' => $this->user->get('id')));
if ($this->user->profile == null) {
/* @TODO: auto-create profile if not exists as fallback */
} else {
$this->user->profile->set('last_active',strftime('%Y-%m-%d %H:%M:%S'));
$this->user->profile->set('ip',$_SERVER['REMOTE_ADDR']);
$this->user->profile->save();
}
The code added before/after /* @TODO: auto-create profile if not exists as fallback */
$oProfile = $this->user->getOne('Profile');
$object = $this->modx->newObject('disUserProfile');
$object->set('user', $this->user->get('id'));
$sName = $oProfile->get('fullname');
$sFirstName = array_shift(explode(' ',$sName,2));
$sLastName = strstr($sName,' ');
$object->set('name_first', $sFirstName);
$object->set('name_last', $sLastName);
$object->set('createdon', strftime('%Y-%m-%d %H:%M:%S'));
$object->set('email', $oProfile->get('email'));
$object->set('gender', $oProfile->get('gender'));
$object->set('birthdate', strftime('%Y-%m-%d %H:%M:%S',$oProfile->get('dob')));
$object->set('status', '1');
$object->set('website', $oProfile->get('website'));
$location = $oProfile->get('address').' '.$oProfile->get('city').' '.$oProfile->get('country').' '.$oProfile->get('zip');
$object->set('location', $location);
$object->set('confirmed', '1');
$object->set('posts', '0');
$object->set('show_email', '1');
$object->set('show_online', '1');
$object->set('last_active',strftime('%Y-%m-%d %H:%M:%S'));
$object->set('ip',$_SERVER['REMOTE_ADDR']);
$object->save();
$this->user->profile = $this->modx->getObject('disUserProfile',array('user' => $this->user->get('id')));
[]
this appears to work fine, as it checks the logged in user against the user table in discuss and if it does not find the user, it adds it.
when i tried it as an anonymous user (i.e. not logged in) it came up with errors. i had to put an if statement around three bits of code in the above file as well as the dispost.class.php file in the same directory.
public function setSessionPlace($place) {
if ($userId != null){ // this is the is statement here
$this->session->set('place',$place);
$this->session->save();
}
}
and here...
if ($userId != null){ //this is the is statement here
$session->set('user',$this->user->get('id'));
$session->set('access',time());
$session->set('data','');
$session->save();
$this->session =& $session;
}
and here in dispost.class.php...
elseif($userId != null) { $members = $modx->lexicon('discuss.zero_members'); } //gw added the if($userId !- null)
seems to be okay, but still going through and testing it. i am not sure if this is inline with the development of discuss, but suits our purpose for now.
geoff white
MODx Revolution 2.0.8-pl (traditional)
IIS