1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Issue #3232 Correct user search of extended fields. (set field 'data' to 'str')

Fixes #3677 Wrong message displayed.
This commit is contained in:
Cameron
2019-03-19 15:11:36 -07:00
parent 95d63cd166
commit 6c682dffae
3 changed files with 38 additions and 29 deletions

View File

@@ -290,17 +290,17 @@ class users_admin_ui extends e_admin_ui
// 'user_status' => array('title' => LAN_STATUS, 'type' => 'method', 'alias'=>'user_status', 'width' => 'auto','forced' => true, 'nosort'=>TRUE), // 'user_status' => array('title' => LAN_STATUS, 'type' => 'method', 'alias'=>'user_status', 'width' => 'auto','forced' => true, 'nosort'=>TRUE),
'user_ban' => array('title' => LAN_STATUS, 'tab'=>0, 'type' => 'method', 'width' => 'auto', 'filter'=>true, 'batch'=>true,'thclass'=>'center', 'class'=>'center'), 'user_ban' => array('title' => LAN_STATUS, 'tab'=>0, 'type' => 'method', 'width' => 'auto', 'filter'=>true, 'batch'=>true,'thclass'=>'center', 'class'=>'center'),
'user_name' => array('title' => LAN_USER_01, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto','thclass' => 'left first'), // Display name 'user_name' => array('title' => LAN_USER_01, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'safestr', 'width' => 'auto','thclass' => 'left first'), // Display name
'user_loginname' => array('title' => LAN_USER_02, 'tab'=>0, 'type' => 'text', 'data'=>'str', 'width' => 'auto'), // User name 'user_loginname' => array('title' => LAN_USER_02, 'tab'=>0, 'type' => 'text', 'data'=>'safestr', 'width' => 'auto'), // User name
'user_login' => array('title' => LAN_USER_03, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto'), // Real name (no real vetting) 'user_login' => array('title' => LAN_USER_03, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'safestr', 'width' => 'auto'), // Real name (no real vetting)
'user_customtitle' => array('title' => LAN_USER_04, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto'), // No real vetting 'user_customtitle' => array('title' => LAN_USER_04, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'safestr', 'width' => 'auto'), // No real vetting
'user_password' => array('title' => LAN_PASSWORD, 'tab'=>0, 'type' => 'method', 'data'=>'safestr', 'width' => 'auto'), //TODO add md5 option to form handler? 'user_password' => array('title' => LAN_PASSWORD, 'tab'=>0, 'type' => 'method', 'data'=>'safestr', 'width' => 'auto'), //TODO add md5 option to form handler?
'user_sess' => array('title' => LAN_SESSION, 'tab'=>0, 'noedit'=>true, 'type' => 'text', 'width' => 'auto'), // Photo 'user_sess' => array('title' => LAN_SESSION, 'tab'=>0, 'noedit'=>true, 'type' => 'text', 'width' => 'auto'), // Photo
'user_image' => array('title' => LAN_USER_07, 'tab'=>0, 'type' => 'dropdown', 'data'=>'str', 'width' => 'auto'), // Avatar 'user_image' => array('title' => LAN_USER_07, 'tab'=>0, 'type' => 'dropdown', 'data'=>'str', 'width' => 'auto'), // Avatar
'user_email' => array('title' => LAN_EMAIL, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto', 'writeParms'=>array('size'=>'xxlarge')), 'user_email' => array('title' => LAN_EMAIL, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'safestr', 'width' => 'auto', 'writeParms'=>array('size'=>'xxlarge')),
'user_hideemail' => array('title' => LAN_USER_10, 'tab'=>0, 'type' => 'boolean', 'data'=>'int', 'width' => 'auto', 'thclass'=>'center', 'class'=>'center', 'filter'=>true, 'batch'=>true, 'readParms'=>'trueonly=1'), 'user_hideemail' => array('title' => LAN_USER_10, 'tab'=>0, 'type' => 'boolean', 'data'=>'int', 'width' => 'auto', 'thclass'=>'center', 'class'=>'center', 'filter'=>true, 'batch'=>true, 'readParms'=>'trueonly=1'),
'user_xup' => array('title' => 'Xup', 'tab'=>0, 'noedit'=>true, 'type' => 'text', 'data'=>'str', 'width' => 'auto'), 'user_xup' => array('title' => 'Xup', 'tab'=>0, 'noedit'=>true, 'type' => 'text', 'data'=>'str', 'width' => 'auto'),
'user_class' => array('title' => LAN_USER_12, 'tab'=>0, 'type' => 'userclasses' , 'data'=>'str', 'inline'=>true, 'writeParms' => 'classlist=classes,new', 'readParms'=>'classlist=classes,new&defaultLabel=--', 'filter'=>true, 'batch'=>true), 'user_class' => array('title' => LAN_USER_12, 'tab'=>0, 'type' => 'userclasses' , 'data'=>'safestr', 'inline'=>true, 'writeParms' => 'classlist=classes,new', 'readParms'=>'classlist=classes,new&defaultLabel=--', 'filter'=>true, 'batch'=>true),
'user_join' => array('title' => LAN_USER_14, 'tab'=>0, 'noedit'=>true, 'type' => 'datestamp', 'width' => 'auto', 'writeParms'=>'readonly=1'), 'user_join' => array('title' => LAN_USER_14, 'tab'=>0, 'noedit'=>true, 'type' => 'datestamp', 'width' => 'auto', 'writeParms'=>'readonly=1'),
'user_lastvisit' => array('title' => LAN_USER_15, 'tab'=>0, 'noedit'=>true, 'type' => 'datestamp', 'width' => 'auto'), 'user_lastvisit' => array('title' => LAN_USER_15, 'tab'=>0, 'noedit'=>true, 'type' => 'datestamp', 'width' => 'auto'),
'user_currentvisit' => array('title' => LAN_USER_16, 'tab'=>0, 'noedit'=>true, 'type' => 'datestamp', 'width' => 'auto'), 'user_currentvisit' => array('title' => LAN_USER_16, 'tab'=>0, 'noedit'=>true, 'type' => 'datestamp', 'width' => 'auto'),
@@ -369,6 +369,7 @@ class users_admin_ui extends e_admin_ui
// Extended fields - FIXME - better field types // Extended fields - FIXME - better field types
if($rows = $sql->retrieve('user_extended_struct', '*', "user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' ORDER BY user_extended_struct_parent ASC",true)) if($rows = $sql->retrieve('user_extended_struct', '*', "user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' ORDER BY user_extended_struct_parent ASC",true))
@@ -376,12 +377,15 @@ class users_admin_ui extends e_admin_ui
// TODO FIXME use the handler to build fields and field attributes // TODO FIXME use the handler to build fields and field attributes
// FIXME a way to load 3rd party language files for extended user fields // FIXME a way to load 3rd party language files for extended user fields
e107::coreLan('user_extended'); e107::coreLan('user_extended');
$dataMode = ($this->getAction() === 'list') ? 'str' : false; // allow for search of extended fields.
foreach ($rows as $row) foreach ($rows as $row)
{ {
$field = "user_".$row['user_extended_struct_name']; $field = "user_".$row['user_extended_struct_name'];
// $title = ucfirst(str_replace("user_","",$field)); // $title = ucfirst(str_replace("user_","",$field));
$label = $tp->toHTML($row['user_extended_struct_text'],false,'defs'); $label = $tp->toHTML($row['user_extended_struct_text'],false,'defs');
$this->fields[$field] = array('__tableField'=>'ue.'.$field, 'title' => $label,'width' => 'auto', 'type'=>'method', 'readParms'=>array('ueType'=>$row['user_extended_struct_type']), 'method'=>'user_extended', 'data'=>false, 'tab'=>1, 'noedit'=>false); $this->fields[$field] = array('__tableField'=>'ue.'.$field, 'title' => $label,'width' => 'auto', 'type'=>'method', 'readParms'=>array('ueType'=>$row['user_extended_struct_type']), 'method'=>'user_extended', 'data'=>$dataMode, 'tab'=>1, 'noedit'=>false);
$this->extended[] = $field; $this->extended[] = $field;
$this->extendedData[$field] = $row; $this->extendedData[$field] = $row;
@@ -430,16 +434,6 @@ class users_admin_ui extends e_admin_ui
} }
//FIXME - handle user extended search...
//$this->_alias_parsed = false;
//$this->parseAliases();
// if(isset ($_POST['adduser']))
// {
// addUser();
// }
} }
@@ -580,7 +574,7 @@ class users_admin_ui extends e_admin_ui
} }
else else
{ {
// e107::getMessage()->addSuccess(LAN_UPDATED.': '.ADLAN_78); // not needed pull/1816 e107::getMessage()->reset(E_MESSAGE_SUCCESS)->addSuccess(LAN_UPDATED);
e107::getMessage()->addDebug(LAN_UPDATED.': '.ADLAN_78); // let's put it in debug instead e107::getMessage()->addDebug(LAN_UPDATED.': '.ADLAN_78); // let's put it in debug instead
} }
} }
@@ -1376,6 +1370,13 @@ class users_admin_ui extends e_admin_ui
e107::getMessage()->addError(USRLAN_236); e107::getMessage()->addError(USRLAN_236);
} }
public function EditSubmitTrigger()
{
$this->_manageSubmit('beforeUpdate', 'afterUpdate', 'onUpdateError', 'edit', true); // force update.
}
/** /**
* Quick Add user submit trigger * Quick Add user submit trigger
*/ */
@@ -2430,10 +2431,6 @@ class users_admin_form_ui extends e_admin_form_ui
return e107::getUserExt()->renderValue($data, $att['ueType']); return e107::getUserExt()->renderValue($data, $att['ueType']);
return print_a($att,true);
return $data;
} }
if($mode == 'write') if($mode == 'write')

View File

@@ -4436,7 +4436,7 @@ class e_admin_controller_ui extends e_admin_controller
* @param string $noredirectAction passed to doAfterSubmit() * @param string $noredirectAction passed to doAfterSubmit()
* @return boolean * @return boolean
*/ */
protected function _manageSubmit($callbackBefore = '', $callbackAfter = '', $callbackError = '', $noredirectAction = '') protected function _manageSubmit($callbackBefore = '', $callbackAfter = '', $callbackError = '', $noredirectAction = '', $forceSave=false)
{ {
$model = $this->getModel(); $model = $this->getModel();
@@ -4522,7 +4522,7 @@ class e_admin_controller_ui extends e_admin_controller
// Scenario I - use request owned POST data - toForm already executed // Scenario I - use request owned POST data - toForm already executed
$model->setPostedData($_posted, null, false) // insert() or update() dbInsert(); $model->setPostedData($_posted, null, false) // insert() or update() dbInsert();
->save(true); ->save(true, $forceSave);

View File

@@ -2754,6 +2754,8 @@ class e_front_model extends e_model
return null; return null;
} }
public function destroy() public function destroy()
{ {
parent::destroy(); parent::destroy();
@@ -2783,17 +2785,18 @@ class e_front_model extends e_model
if($this->hasError()) return false; if($this->hasError()) return false;
if(!$this->data_has_changed && !$force)
if(!$this->data_has_changed && $force === false)
{ {
$this->addMessageInfo(LAN_NO_CHANGE); $this->addMessageInfo(LAN_NO_CHANGE);
return 0; return 0;
} }
$sql = e107::getDb(); $sql = e107::getDb();
$qry = $this->toSqlQuery('update'); $qry = $this->toSqlQuery('update');
$table = $this->getModelTable(); $table = $this->getModelTable();
$res = $sql->db_Update($table, $qry, $this->getParam('db_debug', false)); $res = $sql->update($table, $qry, $this->getParam('db_debug', false));
$this->_db_qry = $sql->getLastQuery(); $this->_db_qry = $sql->getLastQuery();
if(!$res) if(!$res)
{ {
@@ -2807,7 +2810,16 @@ class e_front_model extends e_model
return false; return false;
} }
if($force === false)
{
$this->addMessageInfo(LAN_NO_CHANGE); $this->addMessageInfo(LAN_NO_CHANGE);
}
else
{
$this->addMessageDebug(LAN_NO_CHANGE);
}
return 0; return 0;
} }
$this->clearCache()->addMessageSuccess(LAN_UPDATED); $this->clearCache()->addMessageSuccess(LAN_UPDATED);