mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
User-extended code cleanup
This commit is contained in:
@@ -260,13 +260,13 @@ if(isset($_POST['deactivate']))
|
||||
|
||||
|
||||
|
||||
/*if($sql->db_Select("user_extended_struct","DISTINCT(user_extended_struct_parent)"))
|
||||
/*if($sql->select("user_extended_struct","DISTINCT(user_extended_struct_parent)"))
|
||||
{
|
||||
$plist = $sql->db_getList();
|
||||
foreach($plist as $_p)
|
||||
{
|
||||
$o = 0;
|
||||
if($sql->db_Select("user_extended_struct", "user_extended_struct_id", "user_extended_struct_parent = {$_p['user_extended_struct_parent']} && user_extended_struct_type != 0 ORDER BY user_extended_struct_order ASC"))
|
||||
if($sql->select("user_extended_struct", "user_extended_struct_id", "user_extended_struct_parent = {$_p['user_extended_struct_parent']} && user_extended_struct_type != 0 ORDER BY user_extended_struct_order ASC"))
|
||||
{
|
||||
$_list = $sql->db_getList();
|
||||
foreach($_list as $r)
|
||||
@@ -302,9 +302,9 @@ if(isset($_POST['table_db']) && !$_POST['add_field'] && !$_POST['update_field'])
|
||||
|
||||
if ($action == "editext")
|
||||
{
|
||||
if($sql->db_Select('user_extended_struct','*',"user_extended_struct_id = '{$sub_action}'"))
|
||||
if($sql->select('user_extended_struct','*',"user_extended_struct_id = '{$sub_action}'"))
|
||||
{
|
||||
$tmp = $sql->db_Fetch();
|
||||
$tmp = $sql->fetch();
|
||||
$user->show_extended($tmp);
|
||||
}
|
||||
else
|
||||
@@ -322,9 +322,9 @@ if($action == 'cat')
|
||||
{
|
||||
if(is_numeric($sub_action))
|
||||
{
|
||||
if($sql->db_Select('user_extended_struct','*',"user_extended_struct_id = '{$sub_action}'"))
|
||||
if($sql->select('user_extended_struct','*',"user_extended_struct_id = '{$sub_action}'"))
|
||||
{
|
||||
$tmp = $sql->db_Fetch();
|
||||
$tmp = $sql->fetch();
|
||||
}
|
||||
}
|
||||
$user->show_categories($tmp);
|
||||
@@ -373,13 +373,13 @@ class users_ext
|
||||
function reorderItems()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
if($sql->db_Select("user_extended_struct","DISTINCT(user_extended_struct_parent)"))
|
||||
if($sql->select("user_extended_struct","DISTINCT(user_extended_struct_parent)"))
|
||||
{
|
||||
$plist = $sql->db_getList();
|
||||
foreach($plist as $_p)
|
||||
{
|
||||
$o = 0;
|
||||
if($sql->db_Select("user_extended_struct", "user_extended_struct_id", "user_extended_struct_parent = {$_p['user_extended_struct_parent']} && user_extended_struct_type != 0 ORDER BY user_extended_struct_order ASC"))
|
||||
if($sql->select("user_extended_struct", "user_extended_struct_id", "user_extended_struct_parent = {$_p['user_extended_struct_parent']} && user_extended_struct_type != 0 ORDER BY user_extended_struct_order ASC"))
|
||||
{
|
||||
$_list = $sql->db_getList();
|
||||
foreach($_list as $r)
|
||||
@@ -397,25 +397,31 @@ class users_ext
|
||||
|
||||
function delete_extended($_name)
|
||||
{
|
||||
global $ue,$admin_log;
|
||||
$emessage = eMessage::getInstance();
|
||||
|
||||
$ue = e107::getUserExt();
|
||||
$log = e107::getAdminLog();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
if ($ue->user_extended_remove($_name, $_name))
|
||||
{
|
||||
$admin_log->log_event('EUF_07',$_name, E_LOG_INFORMATIVE,'');
|
||||
$emessage->add(EXTLAN_30." [".$_name."]", E_MESSAGE_SUCCESS);
|
||||
$log->add('EUF_07',$_name, E_LOG_INFORMATIVE);
|
||||
$mes->addSuccess(LAN_DELETED." [".$_name."]");
|
||||
e107::getCache()->clear_sys('user_extended_struct', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$emessage->add(LAN_ERROR." [".$_name."]", E_MESSAGE_ERROR);
|
||||
$mes->addError(LAN_ERROR." [".$_name."]");
|
||||
}
|
||||
}
|
||||
|
||||
function showExtendedList()
|
||||
{
|
||||
global $sql, $ns, $ue, $curtype, $tp, $mySQLdefaultdb, $action, $sub_action,$frm;
|
||||
global $ue, $curtype, $tp, $mySQLdefaultdb, $action, $sub_action;
|
||||
|
||||
$ue = e107::getUserExt();
|
||||
$frm = e107::getForm();
|
||||
$ns = e107::getRender();
|
||||
$sql = e107::getDb();
|
||||
|
||||
$extendedList = $ue->user_extended_get_fields();
|
||||
|
||||
$emessage = e107::getMessage();
|
||||
@@ -484,11 +490,13 @@ class users_ext
|
||||
$text .= "
|
||||
</td>
|
||||
<td class='center' style='width:10%;white-space:nowrap'>
|
||||
|
||||
<a class='btn btn-large' style='text-decoration:none' href='".e_SELF."?editext.".$id."'>".ADMIN_EDIT_ICON."</a>
|
||||
<input class='btn btn-large' type='image' title='".LAN_DELETE."' name='eudel[".$name."]' src='".ADMIN_DELETE_ICON_PATH."' value='".$id."' onclick='return confirm(\"".EXTLAN_27."\")' />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<a class='btn' style='text-decoration:none' href='".e_SELF."?editext.".$id."'>".ADMIN_EDIT_ICON."</a>
|
||||
".$frm->submit_image('eudel['.$name.']',$id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'action delete btn'.$delcls));
|
||||
|
||||
// ."<input class='btn btn-large' type='image' title='".LAN_DELETE."' name='eudel[".$name."]' src='".ADMIN_DELETE_ICON_PATH."' value='".$id."' onclick='return confirm(\"".EXTLAN_27."\")' />
|
||||
$text .= "</td>
|
||||
</tr>
|
||||
";
|
||||
$i++;
|
||||
}
|
||||
@@ -648,8 +656,11 @@ class users_ext
|
||||
$text .= "<tr><td>".EXTLAN_63."</td><td><select style='width:99%' class='tbox e-select' name='field_id' >\n
|
||||
<option value='' class='caption'>".EXTLAN_61."</option>\n";
|
||||
$table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0] ;
|
||||
if($sql -> db_Select_gen("DESCRIBE ".MPREFIX."{$table_list}")){
|
||||
while($row3 = $sql -> db_Fetch()){
|
||||
|
||||
if($sql->gen("DESCRIBE ".MPREFIX."{$table_list}"))
|
||||
{
|
||||
while($row3 = $sql->fetch())
|
||||
{
|
||||
$field_name=$row3['Field'];
|
||||
$selected = ($curVals[1] == $field_name) ? " selected='selected' " : "";
|
||||
$text .="<option value=\"$field_name\" $selected>".$field_name."</option>\n";
|
||||
@@ -660,8 +671,11 @@ class users_ext
|
||||
$text .= EXTLAN_64."</td><td><select style='width:99%' class='tbox e-select' name='field_value' >
|
||||
<option value='' class='caption'>".EXTLAN_61."</option>\n";
|
||||
$table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0] ;
|
||||
if($sql -> db_Select_gen("DESCRIBE ".MPREFIX."{$table_list}")){
|
||||
while($row3 = $sql -> db_Fetch()){
|
||||
|
||||
if($sql->gen("DESCRIBE ".MPREFIX."{$table_list}"))
|
||||
{
|
||||
while($row3 = $sql->fetch())
|
||||
{
|
||||
$field_name=$row3['Field'];
|
||||
$selected = ($curVals[2] == $field_name) ? " selected='selected' " : "";
|
||||
$text .="<option value=\"$field_name\" $selected>".$field_name."</option>\n";
|
||||
@@ -672,8 +686,11 @@ class users_ext
|
||||
$text .= LAN_ORDER."</td><td><select style='width:99%' class='tbox e-select' name='field_order' >
|
||||
<option value='' class='caption'>".EXTLAN_61."</option>\n";
|
||||
$table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0] ;
|
||||
if($sql -> db_Select_gen("DESCRIBE ".MPREFIX."{$table_list}")){
|
||||
while($row3 = $sql -> db_Fetch()){
|
||||
|
||||
if($sql ->gen("DESCRIBE ".MPREFIX."{$table_list}"))
|
||||
{
|
||||
while($row3 = $sql->fetch())
|
||||
{
|
||||
$field_name=$row3['Field'];
|
||||
$selected = ($curVals[3] == $field_name) ? " selected='selected' " : "";
|
||||
$text .="<option value=\"$field_name\" $selected>".$field_name."</option>\n";
|
||||
|
@@ -94,6 +94,14 @@ class e_admin_log
|
||||
$this->_messages = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* BC Alias of add();
|
||||
*/
|
||||
public function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
|
||||
{
|
||||
return $this->add($event_title, $event_detail, $event_type, $event_code);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point.
|
||||
@@ -107,12 +115,12 @@ class e_admin_log
|
||||
* This is stored as 'LAN_AL_STRING_NN', and must be defined in a language file which is loaded during log display.
|
||||
*
|
||||
* @param string $event_title
|
||||
* @param mixed $event_detail
|
||||
* @param mixed $event_details
|
||||
* @param integer $event_type [optional] Log level
|
||||
* @param unknown $event_code [optional]
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
|
||||
public function add($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
|
||||
{
|
||||
if ($event_code == '')
|
||||
{
|
||||
|
@@ -237,7 +237,8 @@ class e107_user_extended
|
||||
// Return FALSE if acceptable, TRUE if fail , error message on regex fail if the message is defined
|
||||
function user_extended_validate_entry($val, $params)
|
||||
{
|
||||
global $tp;
|
||||
$tp = e107::getParser();
|
||||
|
||||
$parms = explode('^,^', $params['user_extended_struct_parms']);
|
||||
$requiredField = $params['user_extended_struct_required'] == 1;
|
||||
$regex = $tp->toText($parms[1]);
|
||||
@@ -278,7 +279,8 @@ class e107_user_extended
|
||||
*/
|
||||
public function userExtendedValidateAll($inArray, $hideArray, $isSignup=FALSE)
|
||||
{
|
||||
global $tp;
|
||||
$tp = e107::getParser();
|
||||
|
||||
$eufVals = array(); // 'Answer' array
|
||||
$hideFlags = array();
|
||||
|
||||
@@ -327,18 +329,26 @@ class e107_user_extended
|
||||
return $eufVals;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* BC Alias of getCategories();
|
||||
* @DEPRECATED
|
||||
*/
|
||||
function user_extended_get_categories($byID = TRUE)
|
||||
{
|
||||
return $this->getCategories($byID);
|
||||
}
|
||||
|
||||
|
||||
function getCategories($byID = TRUE)
|
||||
{
|
||||
$ret = array();
|
||||
global $sql;
|
||||
$sql = e107::getDb('ue');
|
||||
|
||||
if($sql->db_Select("user_extended_struct", "*", "user_extended_struct_type = 0 ORDER BY user_extended_struct_order ASC"))
|
||||
{
|
||||
if($byID == TRUE)
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
$ret[$row['user_extended_struct_id']][] = $row;
|
||||
}
|
||||
@@ -351,17 +361,26 @@ class e107_user_extended
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* BC Alias of getFields();
|
||||
* @DEPRECATED
|
||||
*/
|
||||
function user_extended_get_fields($cat = "")
|
||||
{
|
||||
return $this->getFields($cat);
|
||||
}
|
||||
|
||||
|
||||
// Get the definition of all fields, or those in a specific category, grouped by category ID
|
||||
// Reads non-system fields only
|
||||
function user_extended_get_fields($cat = "")
|
||||
function getFields($cat = "")
|
||||
{
|
||||
global $sql;
|
||||
$sql = e107::getDb('ue');
|
||||
$ret = array();
|
||||
$more = ($cat) ? " AND user_extended_struct_parent = ".intval($cat)." " : "";
|
||||
if($sql->db_Select("user_extended_struct", "*", "user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' {$more} ORDER BY user_extended_struct_order ASC"))
|
||||
if($sql->select("user_extended_struct", "*", "user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' {$more} ORDER BY user_extended_struct_order ASC"))
|
||||
{
|
||||
while($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
while($row = $sql->fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$ret[$row['user_extended_struct_parent']][] = $row;
|
||||
}
|
||||
@@ -369,7 +388,10 @@ class e107_user_extended
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// BC Alias of getFieldList().
|
||||
/**
|
||||
* BC Alias of getFieldList().
|
||||
* @DEPRECATED
|
||||
*/
|
||||
function user_extended_get_fieldList($cat = "", $indexField = 'user_extended_struct_id')
|
||||
{
|
||||
return $this->getFieldList($cat, $indexField);
|
||||
@@ -433,7 +455,8 @@ class e107_user_extended
|
||||
// Return the field creation text for a definition
|
||||
function user_extended_type_text($type, $default)
|
||||
{
|
||||
global $tp;
|
||||
$tp = e107::getParser();
|
||||
|
||||
if(!is_numeric($type))
|
||||
{
|
||||
return false;
|
||||
@@ -504,10 +527,11 @@ class e107_user_extended
|
||||
return $this->user_extended_add($name, '_system_', $type, $source, '', $default, 0, 255, 255, 255, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
function user_extended_add($name, $text, $type, $parms, $values, $default, $required, $read, $write, $applicable, $order='', $parent)
|
||||
{
|
||||
global $sql, $tp;
|
||||
|
||||
$sql = e107::getDb('ue');
|
||||
$tp = e107::getParser();
|
||||
|
||||
$this->clear_cache();
|
||||
|
||||
@@ -565,7 +589,9 @@ class e107_user_extended
|
||||
|
||||
function user_extended_modify($id, $name, $text, $type, $parms, $values, $default, $required, $read, $write, $applicable, $parent)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$sql = e107::getDb('ue');
|
||||
$tp = e107::getParser();
|
||||
|
||||
if ($this->user_extended_field_exist($name))
|
||||
{
|
||||
$field_info = $this->user_extended_type_text($type, $default);
|
||||
@@ -597,7 +623,9 @@ class e107_user_extended
|
||||
|
||||
function user_extended_remove($id, $name)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$sql = e107::getDb('ue');
|
||||
$tp = e107::getParser();
|
||||
|
||||
$this->clear_cache();
|
||||
if ($this->user_extended_field_exist($name))
|
||||
{
|
||||
@@ -774,7 +802,9 @@ class e107_user_extended
|
||||
return $ret;
|
||||
|
||||
case EUF_DB_FIELD : //db_field
|
||||
global $sql;
|
||||
|
||||
|
||||
$sql = e107::getDb('ue');
|
||||
$order = ($choices[3]) ? "ORDER BY ".$tp -> toDB($choices[3], true) : "";
|
||||
|
||||
if($sql->db_Select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){
|
||||
@@ -844,7 +874,8 @@ class e107_user_extended
|
||||
return $ueStruct;
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
$tp = e107::getParser();
|
||||
$sql_ue = e107::getDb('ue'); // new db; // Use our own db to avoid interference with other objects
|
||||
|
||||
$ret = array();
|
||||
$parms = "";
|
||||
@@ -854,7 +885,6 @@ class e107_user_extended
|
||||
$parms = "1 ORDER BY ".$tp -> toDB($orderby, true);
|
||||
}
|
||||
|
||||
$sql_ue = e107::getDb('ue'); // new db; // Use our own db to avoid interference with other objects
|
||||
if($sql_ue->select('user_extended_struct','*',$parms))
|
||||
{
|
||||
while($row = $sql_ue->fetch())
|
||||
@@ -862,6 +892,7 @@ class e107_user_extended
|
||||
$ret['user_'.$row['user_extended_struct_name']] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
cachevars('ue_struct',$ret);
|
||||
return $ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user