1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Switched add/remove functions to make use of the unified functions

from the user_class class (user_class::ucAdd(), user_class::ucRemove())
Fixed some typo and removed missing template vars
This commit is contained in:
Achim Ennenbach
2019-03-02 10:08:37 +01:00
parent a2d5b9c31e
commit 322b5ba60d

View File

@@ -1062,16 +1062,19 @@ class e_user_model extends e_admin_model
return false; return false;
} }
$curClasses = explode(",", $this->getData('user_class')); // $curClasses = explode(",", $this->getData('user_class'));
$curClasses[] = $userClassId; // $curClasses[] = $userClassId;
$curClasses = array_unique($curClasses); // $curClasses = array_unique($curClasses);
//
$insert = implode(",", $curClasses); // $insert = implode(",", $curClasses);
//FIXME - @SecretR - I'm missing something here with setCore() etc. //FIXME - @SecretR - I'm missing something here with setCore() etc.
// $this->setCore('user_class',$insert ); // $this->setCore('user_class',$insert );
// $this->saveDebug(false); // $this->saveDebug(false);
// Switched to unified remove user class method
$insert = e107::getUserClass()->ucAdd($userClassId, $this->getData('user_class'), false);
if(!$uid = $this->getData('user_id')) if(!$uid = $this->getData('user_id'))
{ {
return false; return false;
@@ -1094,19 +1097,27 @@ class e_user_model extends e_admin_model
return false; return false;
} }
$curClasses = explode(",", $this->getData('user_class')); // $curClasses = explode(",", $this->getData('user_class'));
//
// foreach($curClasses as $k=>$v)
// {
// if($v == $userClassId)
// {
// unset($curClasses[$k]);
// }
// }
foreach($curClasses as $k=>$v) // $uid = $this->getData('user_id');
// $insert = implode(",", $curClasses);
// Switched to unified remove user class method
$insert = e107::getUserClass()->ucRemove($userClassId, $this->getData('user_class'), false);
if(!$uid = $this->getData('user_id'))
{ {
if($v == $userClassId) return false;
{
unset($curClasses[$k]);
} }
}
$uid = $this->getData('user_id');
$insert = implode(",", $curClasses);
return e107::getDb()->update('user',"user_class='".$insert."' WHERE user_id = ".$uid." LIMIT 1"); return e107::getDb()->update('user',"user_class='".$insert."' WHERE user_id = ".$uid." LIMIT 1");
@@ -1241,6 +1252,7 @@ class e_system_user extends e_user_model
*/ */
public function renderEmail($type, $userInfo) public function renderEmail($type, $userInfo)
{ {
global $SIGNUPEMAIL_USETHEME, $QUICKADDUSER_TEMPLATE, $NOTIFY_TEMPLATE;
$pref = e107::getPref(); $pref = e107::getPref();
$ret = array(); $ret = array();
$tp = e107::getParser(); $tp = e107::getParser();
@@ -1286,8 +1298,8 @@ class e_system_user extends e_user_model
$EMAIL_TEMPLATE['signup']['attachments'] = $SIGNUPEMAIL_ATTACHMENTS; $EMAIL_TEMPLATE['signup']['attachments'] = $SIGNUPEMAIL_ATTACHMENTS;
$EMAIL_TEMPLATE['signup']['body'] = $SIGNUPEMAIL_TEMPLATE; $EMAIL_TEMPLATE['signup']['body'] = $SIGNUPEMAIL_TEMPLATE;
$EMAIL_TEMPLATE['quickadduser']['body'] = $QUICKADDUSER_TEMPLATE['email_body']; $EMAIL_TEMPLATE['quickadduser']['body'] = vartrue($QUICKADDUSER_TEMPLATE['email_body'], '');
$EMAIL_TEMPLATE['notify']['body'] = $NOTIFY_TEMPLATE['email_body']; $EMAIL_TEMPLATE['notify']['body'] = vartrue($NOTIFY_TEMPLATE['email_body'], '');
} }
@@ -1928,12 +1940,12 @@ class e_user extends e_user_model
{ {
$this->set('user_lastvisit', (integer) $this->get('user_currentvisit')); $this->set('user_lastvisit', (integer) $this->get('user_currentvisit'));
$this->set('user_currentvisit', time()); $this->set('user_currentvisit', time());
$sql->db_Update('user', "user_visits = user_visits + 1, user_lastvisit = ".$this->get('user_lastvisit').", user_currentvisit = ".$this->get('user_currentvisit')."{$update_ip} WHERE user_id='".$this->getId()."' "); $sql->update('user', "user_visits = user_visits + 1, user_lastvisit = ".$this->get('user_lastvisit').", user_currentvisit = ".$this->get('user_currentvisit')."{$update_ip} WHERE user_id='".$this->getId()."' ");
} }
else else
{ {
$this->set('user_currentvisit', time()); $this->set('user_currentvisit', time());
$sql->db_Update('user', "user_currentvisit = ".$this->get('user_currentvisit')."{$update_ip} WHERE user_id='".$this->getId()."' "); $sql->update('user', "user_currentvisit = ".$this->get('user_currentvisit')."{$update_ip} WHERE user_id='".$this->getId()."' ");
} }
} }
} }
@@ -2518,7 +2530,7 @@ class e_user_extended_model extends e_admin_model
/** /**
* Doesn't save anything actually... * Doesn't save anything actually...
*/ */
public function saveDebug($retrun = false, $undo = true) public function saveDebug($return = false, $undo = true)
{ {
$this->_buildManageRules(); $this->_buildManageRules();
return parent::saveDebug($return, $undo); return parent::saveDebug($return, $undo);
@@ -2842,7 +2854,7 @@ class e_user_pref extends e_front_model
{ {
$data = $this->toString(true); $data = $this->toString(true);
$this->apply(); $this->apply();
return (e107::getDb('user_prefs')->db_Update('user', "user_prefs='{$data}' WHERE user_id=".$this->_user->getId()) ? true : false); return (e107::getDb('user_prefs')->update('user', "user_prefs='{$data}' WHERE user_id=".$this->_user->getId()) ? true : false);
} }
return 0; return 0;
} }