mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Admin->Userclasses now using the Admin-UI. Admin-UI now supports non-incrementing primary fields being set manually using a hidden form field. Form handler for userclass with checkboxes now working correctly.
This commit is contained in:
@@ -2,15 +2,12 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
* Copyright (C) 2008-2015 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* Administration Area - User classes
|
* Administration Area - User classes
|
||||||
*
|
*
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -31,6 +28,430 @@ if (!getperms('4'))
|
|||||||
|
|
||||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
|
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class uclass_admin extends e_admin_dispatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $modes = array(
|
||||||
|
|
||||||
|
'main' => array(
|
||||||
|
'controller' => 'uclass_ui',
|
||||||
|
'path' => null,
|
||||||
|
'ui' => 'uclass_ui_form',
|
||||||
|
'uipath' => null
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
protected $adminMenu = array(
|
||||||
|
|
||||||
|
'main/list' => array('caption'=> LAN_MANAGE, 'perm' => '4'),
|
||||||
|
'main/create' => array('caption'=> LAN_CREATE, 'perm' => '4'),
|
||||||
|
'main/initial' => array('caption'=> UCSLAN_38, 'perm' => '4'),
|
||||||
|
'main/options' => array('caption'=> LAN_OPTIONS, 'perm' => '4'),
|
||||||
|
|
||||||
|
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $adminMenuAliases = array(
|
||||||
|
'main/edit' => 'main/list'
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $menuTitle = ADLAN_38;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class uclass_ui extends e_admin_ui
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $pluginTitle = ADLAN_38;
|
||||||
|
protected $pluginName = 'core';
|
||||||
|
// protected $eventName = 'userclass';
|
||||||
|
protected $table = 'userclass_classes';
|
||||||
|
protected $pid = 'userclass_id';
|
||||||
|
protected $perPage = 10;
|
||||||
|
protected $batchDelete = true;
|
||||||
|
protected $batchCopy = true;
|
||||||
|
protected $listOrder = 'userclass_id DESC';
|
||||||
|
// protected $sortField = 'somefield_order';
|
||||||
|
// protected $orderStep = 10;
|
||||||
|
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
|
||||||
|
|
||||||
|
// protected $listQry = "SELECT * FROM `#generic` WHERE gen_type='wmessage' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
|
||||||
|
|
||||||
|
// protected $listOrder = 'gen_id DESC';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected $fields = array(
|
||||||
|
'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
|
||||||
|
'userclass_id' => array('title'=> LAN_ID, 'type' =>'hidden', 'data'=>'int', 'width' => '5%', 'thclass' => 'left'),
|
||||||
|
'userclass_icon' => array('title'=> UCSLAN_68, 'type' => 'icon', 'data'=>'str', 'width' => '5%', 'thclass' => 'left', 'class' => 'center'),
|
||||||
|
'userclass_name' => array('title'=> UCSLAN_12, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left'),
|
||||||
|
'userclass_description' => array('title'=> UCSLAN_13, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('size'=>'xxlarge')),
|
||||||
|
'userclass_type' => array('title'=> UCSLAN_79, 'type' => 'dropdown', 'data'=>'int', 'width' => '10%', 'thclass' => 'left', 'class'=>'left' ),
|
||||||
|
'userclass_editclass' => array('title'=> UCSLAN_24, 'type' => 'userclass', 'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'nobody,public,main,admin,classes,matchclass,member, no-excludes')),
|
||||||
|
'userclass_visibility' => array('title'=> UCSLAN_34, 'type' => 'userclass', 'data'=>'int', 'width' => 'auto', 'thclass' => 'left'),
|
||||||
|
'userclass_parent' => array('title'=> UCSLAN_35, 'type' => 'userclass', 'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'main,admin,nobody,public,classes,matchclass,member, no-excludes')),
|
||||||
|
|
||||||
|
'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'width' => '10%', 'thclass' => 'center last', 'forced'=>TRUE, 'class'=>'right', 'readParms' => array('deleteClass' => e_UC_NOBODY))
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $fieldpref = array('userclass_icon', 'userclass_name', 'userclass_description');
|
||||||
|
|
||||||
|
/*
|
||||||
|
protected $prefs = array(
|
||||||
|
'wm_enclose' => array('title'=> WMLAN_05, 'type'=>'boolean', 'data' => 'int','help'=> WMLAN_06), );*/
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Listen for submitted data.
|
||||||
|
$this->initialPageSubmit();
|
||||||
|
$this->optionsPageSubmit();
|
||||||
|
|
||||||
|
if($this->getAction() == 'list')
|
||||||
|
{
|
||||||
|
$this->fields['userclass_id']['type'] = 'number';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set Defaults for when creating new records.
|
||||||
|
$this->fields['userclass_type']['writeParms'] = array(UC_TYPE_STD => UCSLAN_80, UC_TYPE_GROUP => UCSLAN_81);
|
||||||
|
$this->fields['userclass_editclass']['writeParms']['default'] = e_UC_ADMIN;
|
||||||
|
$this->fields['userclass_parent']['writeParms']['default'] = e_UC_NOBODY;
|
||||||
|
$this->fields['userclass_visibility']['writeParms']['default'] = e_UC_ADMIN;
|
||||||
|
$this->fields['userclass_id']['writeParms']['default'] =$this->getUserClassAdmin()->findNewClassID();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserClassAdmin()
|
||||||
|
{
|
||||||
|
return e107::getSingleton('user_class_admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function beforeCreate($new_data)
|
||||||
|
{
|
||||||
|
return $new_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterCreate($new_data, $old_data, $id)
|
||||||
|
{
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
|
||||||
|
public function beforeUpdate($new_data, $old_data, $id)
|
||||||
|
{
|
||||||
|
return $new_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterUpdate($new_data, $old_data, $id)
|
||||||
|
{
|
||||||
|
// e107::getCache()->clear("wmessage");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onCreateError($new_data, $old_data)
|
||||||
|
{
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onUpdateError($new_data, $old_data, $id)
|
||||||
|
{
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function optionsPage()
|
||||||
|
{
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
|
||||||
|
|
||||||
|
$mes->addWarning(UCSLAN_52."<br />".UCSLAN_53);
|
||||||
|
|
||||||
|
$text = "<h4>".LAN_PREFS."</h4>
|
||||||
|
<form method='post' action='".e_SELF."?mode=main&action=options' id='treesetForm'>
|
||||||
|
<table class='table adminform'>
|
||||||
|
<colgroup>
|
||||||
|
<col class='col-label' />
|
||||||
|
<col class='col-content' />
|
||||||
|
</colgroup>
|
||||||
|
<tr><td >".UCSLAN_54."<br /><span class='smalltext'>".UCSLAN_57."</span><br />
|
||||||
|
</td><td>
|
||||||
|
".$frm->admin_button('add_class_tree','no-value','delete', UCSLAN_58)."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>".UCSLAN_55."<br /><span class='smalltext'>".UCSLAN_56."</span><br />
|
||||||
|
</td><td>
|
||||||
|
".$frm->admin_button('flatten_class_tree','no-value','delete', UCSLAN_58)."
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ($params == '.xml')
|
||||||
|
{
|
||||||
|
$text .= "<tr>
|
||||||
|
<td>".'Create XML file of DB'."<br /><span class='smalltext'>".'Dev aid to set initial values'."</span><br />
|
||||||
|
</td><td>
|
||||||
|
".$frm->admin_button('create_xml_db','no-value','create', 'Create')."
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$text .= "</table></form>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// $ns->tablerender(ADLAN_38.SEP.LAN_PREFS, $mes->render().$text);
|
||||||
|
|
||||||
|
|
||||||
|
$text .= "
|
||||||
|
<h4>".UCSLAN_71."</h4><form method='post' action='".e_SELF."?options' id='maintainForm'>
|
||||||
|
<table class='table adminform'>
|
||||||
|
<colgroup>
|
||||||
|
<col class='col-label' />
|
||||||
|
<col class='col-content' />
|
||||||
|
</colgroup>
|
||||||
|
<tr>
|
||||||
|
<td>".UCSLAN_72."<br />
|
||||||
|
<span class='smalltext'>".UCSLAN_73."</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
".$frm->admin_button('rebuild_tree','no-value','delete', UCSLAN_58)."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>";
|
||||||
|
|
||||||
|
// $ns->tablerender(UCSLAN_71, $text);
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function optionsPageSubmit()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!check_class(e_UC_MAINADMIN))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ns = e107::getRender();
|
||||||
|
$sql = e107::getDb();
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
$e_userclass = $this->getUserClassAdmin();
|
||||||
|
|
||||||
|
if (isset($_POST['add_class_tree'])) // Create a default tree
|
||||||
|
{
|
||||||
|
$message = UCSLAN_62;
|
||||||
|
$e_userclass->set_default_structure();
|
||||||
|
$e_userclass->calc_tree();
|
||||||
|
$e_userclass->save_tree();
|
||||||
|
$e_userclass->readTree(TRUE); // Need to re-read the tree to show correct info
|
||||||
|
$message .= UCSLAN_64;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['flatten_class_tree'])) // Remove the default tree
|
||||||
|
{
|
||||||
|
$message = UCSLAN_65;
|
||||||
|
$sql->update('userclass_classes', "userclass_parent='0'");
|
||||||
|
$e_userclass->calc_tree();
|
||||||
|
$e_userclass->save_tree();
|
||||||
|
$e_userclass->readTree(TRUE); // Need to re-read the tree to show correct info
|
||||||
|
$message .= UCSLAN_64;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['rebuild_tree']))
|
||||||
|
{
|
||||||
|
$message = UCSLAN_70;
|
||||||
|
$e_userclass->calc_tree();
|
||||||
|
$e_userclass->save_tree();
|
||||||
|
$message .= UCSLAN_64;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ($params == 'xml') $params = '.xml'; else $params = '';
|
||||||
|
|
||||||
|
if (isset($_POST['create_xml_db']) && ($params == '.xml'))
|
||||||
|
{
|
||||||
|
$message = $e_userclass->makeXMLFile() ? 'XML file created' : 'Error creating XML file';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($message)
|
||||||
|
{
|
||||||
|
$mes->addSuccess($message);
|
||||||
|
// $ns->tablerender('', "<div style='text-align:center'><b>".$message."</b></div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function initialPage()
|
||||||
|
{
|
||||||
|
|
||||||
|
$pref = e107::pref('core');
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
$ns = e107::getRender();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
// $e_userclass = $this->getUserClassAdmin();
|
||||||
|
|
||||||
|
$text = "";
|
||||||
|
|
||||||
|
$initial_classes = varset($pref['initial_user_classes'],'');
|
||||||
|
|
||||||
|
$irc = explode(',',$initial_classes);
|
||||||
|
$icn = array();
|
||||||
|
|
||||||
|
foreach ($irc as $i)
|
||||||
|
{
|
||||||
|
if (trim($i)) $icn[] = e107::getUserClass()->uc_get_classname($i);
|
||||||
|
}
|
||||||
|
|
||||||
|
$class_text = $frm->userclass('init_classes',$initial_classes, 'checkbox', 'classes,force');
|
||||||
|
|
||||||
|
// $class_text = e107::getUserClass()->uc_checkboxes('init_classes', $initial_classes, 'classes, force', TRUE);
|
||||||
|
// $class_text = e107::getUserClass()->vetted_tree('init_classes',array($e_userclass,'checkbox_desc'), $initial_classes, 'classes, force, no-excludes');
|
||||||
|
|
||||||
|
$mes->addInfo(UCSLAN_49);
|
||||||
|
|
||||||
|
$text = "<div style='text-align:center'>
|
||||||
|
<form method='post' action='".e_SELF."?mode=main&action=initial' id='initialForm'>
|
||||||
|
<table class='table table-bordered adminform'>
|
||||||
|
<tr><td>".UCSLAN_43."</td><td>";
|
||||||
|
|
||||||
|
if (count($icn) > 0)
|
||||||
|
{
|
||||||
|
// $text .= implode(', ',$icn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= UCSLAN_44;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($class_text)
|
||||||
|
{
|
||||||
|
$text .= $class_text."</td></tr><tr><td>";
|
||||||
|
$sel_stage = varset($pref['init_class_stage'],2);
|
||||||
|
|
||||||
|
$initClassStages = array(1 =>UCSLAN_47, 2=>UCSLAN_48);
|
||||||
|
|
||||||
|
$text .= UCSLAN_45."<br /> </td>
|
||||||
|
<td>".$frm->select('init_class_stage', $initClassStages, $sel_stage)."<span class='field-help'>".UCSLAN_46."</span>
|
||||||
|
|
||||||
|
</td></tr></table>
|
||||||
|
<div class='buttons-bar'>". $frm->admin_button('set_initial_classes','no-value','create',LAN_UPDATE)."</div>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= UCSLAN_39;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</td></tr></table></form></div>";
|
||||||
|
return $mes->render() . $text;
|
||||||
|
// $ns->tablerender(ADLAN_38.SEP.UCSLAN_40, $mes->render() . $text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function initialPageSubmit()
|
||||||
|
{
|
||||||
|
if(empty($_POST['set_initial_classes']))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pref['init_class_stage'] = intval($_POST['init_class_stage']);
|
||||||
|
|
||||||
|
$temp = array();
|
||||||
|
|
||||||
|
foreach ($_POST['init_classes'] as $ic)
|
||||||
|
{
|
||||||
|
$temp[] = intval($ic);
|
||||||
|
}
|
||||||
|
|
||||||
|
$newval = implode(',', $temp);
|
||||||
|
|
||||||
|
$pref['initial_user_classes'] = $newval;
|
||||||
|
|
||||||
|
e107::getConfig()->setPref($pref)->save(true,true,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class uclass_ui_form extends e_admin_form_ui
|
||||||
|
{
|
||||||
|
function userclass_type($curVal,$mode)
|
||||||
|
{
|
||||||
|
$types = array(
|
||||||
|
UC_TYPE_STD => UCSLAN_80,
|
||||||
|
UC_TYPE_GROUP => UCSLAN_81
|
||||||
|
);
|
||||||
|
|
||||||
|
return varset($types[$curVal]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function options($parms, $value, $id, $attributes)
|
||||||
|
{
|
||||||
|
|
||||||
|
$text = "";
|
||||||
|
|
||||||
|
if($attributes['mode'] == 'read')
|
||||||
|
{
|
||||||
|
|
||||||
|
$classID = $this->getController()->getListModel()->get('userclass_id');
|
||||||
|
|
||||||
|
if(!$this->getController()->getUserClassAdmin()->queryCanDeleteClass($classID))
|
||||||
|
{
|
||||||
|
$options = array('deleteClass' => e_UC_NOBODY);
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= $this->renderValue('options',$value, $options,$id);
|
||||||
|
|
||||||
|
// if($parent != 0)
|
||||||
|
{
|
||||||
|
// $link = e_SELF."?searchquery=&filter_options=page_chapter__".$id."&mode=page&action=list";
|
||||||
|
// $text .= "<a href='".$link."' class='btn' title='View Pages in this chapter'>".E_32_CUST."</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
new uclass_admin();
|
||||||
|
|
||||||
|
require_once(e_ADMIN."auth.php");
|
||||||
|
|
||||||
|
e107::getAdminUI()->runPage();
|
||||||
|
|
||||||
|
require_once(e_ADMIN."footer.php");
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$e_sub_cat = 'userclass';
|
$e_sub_cat = 'userclass';
|
||||||
//define('UC_DEBUG_OPTS',FALSE);
|
//define('UC_DEBUG_OPTS',FALSE);
|
||||||
|
|
||||||
@@ -42,7 +463,7 @@ require_once(e_HANDLER.'form_handler.php');
|
|||||||
|
|
||||||
|
|
||||||
$frm = new e_form();
|
$frm = new e_form();
|
||||||
$uc = new uclass_manager;
|
// $uc = new uclass_manager;
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
|
||||||
@@ -102,6 +523,7 @@ $params = varset($uc_qs[1],'');
|
|||||||
e107::setRegistry('pageParams', $uc_qs);
|
e107::setRegistry('pageParams', $uc_qs);
|
||||||
|
|
||||||
//AJAX request check is already made by the API
|
//AJAX request check is already made by the API
|
||||||
|
/*
|
||||||
if(e_AJAX_REQUEST)
|
if(e_AJAX_REQUEST)
|
||||||
{
|
{
|
||||||
$class_num = intval($params);
|
$class_num = intval($params);
|
||||||
@@ -157,6 +579,7 @@ if(e_AJAX_REQUEST)
|
|||||||
}
|
}
|
||||||
|
|
||||||
e107::getJs()->headerCore('core/admin.js');
|
e107::getJs()->headerCore('core/admin.js');
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Authorization should be done a bit later!
|
* Authorization should be done a bit later!
|
||||||
@@ -167,6 +590,7 @@ $emessage = e107::getMessage();
|
|||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// Set Initial Classes
|
// Set Initial Classes
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
/*
|
||||||
if (isset($_POST['set_initial_classes']))
|
if (isset($_POST['set_initial_classes']))
|
||||||
{
|
{
|
||||||
$changed = $pref['init_class_stage'] != intval($_POST['init_class_stage']);
|
$changed = $pref['init_class_stage'] != intval($_POST['init_class_stage']);
|
||||||
@@ -191,11 +615,13 @@ if (isset($_POST['set_initial_classes']))
|
|||||||
$message = UCSLAN_42;
|
$message = UCSLAN_42;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// Delete existing class
|
// Delete existing class
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
if (isset($_POST['etrigger_delete']) && !empty($_POST['etrigger_delete']))
|
if (isset($_POST['etrigger_delete']) && !empty($_POST['etrigger_delete']))
|
||||||
{
|
{
|
||||||
$classID = intval(array_shift(array_keys($_POST['etrigger_delete'])));
|
$classID = intval(array_shift(array_keys($_POST['etrigger_delete'])));
|
||||||
@@ -219,11 +645,11 @@ if (isset($_POST['etrigger_delete']) && !empty($_POST['etrigger_delete']))
|
|||||||
{
|
{
|
||||||
$e_pref->removePref('frontpage/'.$classID)->save(false);
|
$e_pref->removePref('frontpage/'.$classID)->save(false);
|
||||||
}
|
}
|
||||||
/*if (isset($pref['frontpage'][$class_id]))
|
// if (isset($pref['frontpage'][$class_id]))
|
||||||
{
|
{
|
||||||
unset($pref['frontpage'][$class_id]); // (Should work with both 0.7 and 0.8 front page methods)
|
// unset($pref['frontpage'][$class_id]); // (Should work with both 0.7 and 0.8 front page methods)
|
||||||
save_prefs();
|
// save_prefs();
|
||||||
}*/
|
}
|
||||||
$emessage->add(UCSLAN_3, E_MESSAGE_SUCCESS);
|
$emessage->add(UCSLAN_3, E_MESSAGE_SUCCESS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -235,13 +661,15 @@ if (isset($_POST['etrigger_delete']) && !empty($_POST['etrigger_delete']))
|
|||||||
{
|
{
|
||||||
$emessage->add(UCSLAN_10, E_MESSAGE_ERROR);
|
$emessage->add(UCSLAN_10, E_MESSAGE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// Add/Edit class information
|
// Add/Edit class information
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
/*
|
||||||
|
|
||||||
if (isset($_POST['createclass'])) // Add or edit
|
if (isset($_POST['createclass'])) // Add or edit
|
||||||
{
|
{
|
||||||
$fullEdit = TRUE; // Most of the time, we are allowed to edit everything
|
$fullEdit = TRUE; // Most of the time, we are allowed to edit everything
|
||||||
@@ -345,9 +773,9 @@ if (isset($_POST['createclass'])) // Add or edit
|
|||||||
$e_userclass->save_tree();
|
$e_userclass->save_tree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
if ($message)
|
if ($message)
|
||||||
{
|
{
|
||||||
$emessage->add($message);
|
$emessage->add($message);
|
||||||
@@ -365,15 +793,16 @@ class uclassFrm extends e_form
|
|||||||
return varset($types[$curVal]);
|
return varset($types[$curVal]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
if(!e_QUERY || $action == 'list')
|
if(!e_QUERY || $action == 'list')
|
||||||
{
|
{
|
||||||
$uc->show_existing();
|
$uc->show_existing();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if(isset($_GET['id']) && $_GET['action'] == 'edit')
|
if(isset($_GET['id']) && $_GET['action'] == 'edit')
|
||||||
{
|
{
|
||||||
$action = 'config';
|
$action = 'config';
|
||||||
@@ -573,7 +1002,9 @@ unset($title);
|
|||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// Initial User class(es)
|
// Initial User class(es)
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
|
/*
|
||||||
case 'initial' :
|
case 'initial' :
|
||||||
|
|
||||||
$initial_classes = varset($pref['initial_user_classes'],'');
|
$initial_classes = varset($pref['initial_user_classes'],'');
|
||||||
$irc = explode(',',$initial_classes);
|
$irc = explode(',',$initial_classes);
|
||||||
$icn = array();
|
$icn = array();
|
||||||
@@ -626,7 +1057,7 @@ unset($title);
|
|||||||
$ns->tablerender(ADLAN_38.SEP.UCSLAN_40, $mes->render() . $text);
|
$ns->tablerender(ADLAN_38.SEP.UCSLAN_40, $mes->render() . $text);
|
||||||
|
|
||||||
break; // End of 'initial'
|
break; // End of 'initial'
|
||||||
|
*/
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// Debug aids
|
// Debug aids
|
||||||
@@ -657,6 +1088,7 @@ unset($title);
|
|||||||
// Configuration options
|
// Configuration options
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
case 'options' :
|
case 'options' :
|
||||||
|
/*
|
||||||
if (!check_class(e_UC_MAINADMIN)) break;
|
if (!check_class(e_UC_MAINADMIN)) break;
|
||||||
|
|
||||||
if (isset($_POST['add_class_tree']))
|
if (isset($_POST['add_class_tree']))
|
||||||
@@ -755,7 +1187,7 @@ unset($title);
|
|||||||
$ns->tablerender(UCSLAN_71, $text);
|
$ns->tablerender(UCSLAN_71, $text);
|
||||||
|
|
||||||
break; // End of 'options'
|
break; // End of 'options'
|
||||||
|
*/
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// Test options
|
// Test options
|
||||||
@@ -893,7 +1325,7 @@ function userclass2_adminlog($msg_num='00', $woffle='')
|
|||||||
e107::getAdminLog()->log_event('UCLASS_'.$msg_num,$woffle,E_LOG_INFORMATIVE,'');
|
e107::getAdminLog()->log_event('UCLASS_'.$msg_num,$woffle,E_LOG_INFORMATIVE,'');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
function userclass2_adminmenu()
|
function userclass2_adminmenu()
|
||||||
{
|
{
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
@@ -912,10 +1344,10 @@ function userclass2_adminmenu()
|
|||||||
$var['config']['link'] = 'userclass2.php?config';
|
$var['config']['link'] = 'userclass2.php?config';
|
||||||
|
|
||||||
//DEPRECATED - use admin->users instead.
|
//DEPRECATED - use admin->users instead.
|
||||||
/*
|
|
||||||
$var['membs']['text'] = UCSLAN_26;
|
// $var['membs']['text'] = UCSLAN_26;
|
||||||
$var['membs']['link'] ='userclass2.php?membs';
|
// $var['membs']['link'] ='userclass2.php?membs';
|
||||||
*/
|
|
||||||
|
|
||||||
$var['initial']['text'] = UCSLAN_38;
|
$var['initial']['text'] = UCSLAN_38;
|
||||||
$var['initial']['link'] ='userclass2.php?initial';
|
$var['initial']['link'] ='userclass2.php?initial';
|
||||||
@@ -939,11 +1371,16 @@ function userclass2_adminmenu()
|
|||||||
}
|
}
|
||||||
show_admin_menu(ADLAN_38, $action, $var);
|
show_admin_menu(ADLAN_38, $action, $var);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
function e_help()
|
function e_help()
|
||||||
{
|
{
|
||||||
|
// require_once(e_HANDLER.'userclass_class.php'); // Modified class handler
|
||||||
|
// $e_userclass = new user_class_admin;
|
||||||
|
$e_userclass = e107::getSingleton('user_class_admin'); // Admin functions - should just obliterate any previous object created in class2.php
|
||||||
|
|
||||||
global $e_userclass;
|
$e_userclass->calc_tree();
|
||||||
$text2 = "<div id='userclass-tree-structure'>".$e_userclass->show_graphical_tree()."</div>";
|
$text2 = "<div id='userclass-tree-structure'>".$e_userclass->show_graphical_tree()."</div>";
|
||||||
|
|
||||||
$help = e_LANGUAGEDIR.e_LANGUAGE.'/admin/help/userclass2.php';
|
$help = e_LANGUAGEDIR.e_LANGUAGE.'/admin/help/userclass2.php';
|
||||||
@@ -960,6 +1397,9 @@ function e_help()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
class uclass_manager
|
class uclass_manager
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -988,9 +1428,9 @@ class uclass_manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show list of existing userclasses, followed by graphical tree of the hierarchy
|
// Show list of existing userclasses, followed by graphical tree of the hierarchy
|
||||||
*/
|
|
||||||
public function show_existing()
|
public function show_existing()
|
||||||
{
|
{
|
||||||
global $e_userclass;
|
global $e_userclass;
|
||||||
@@ -1037,7 +1477,7 @@ class uclass_manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
require_once(e_ADMIN.'footer.php');
|
require_once(e_ADMIN.'footer.php');
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// @TODO: Is this function still required? - Yes - setGroupStatus() used on class add/edit page
|
// @TODO: Is this function still required? - Yes - setGroupStatus() used on class add/edit page
|
||||||
|
@@ -3975,7 +3975,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
$id = $model->getId();
|
$id = $model->getId();
|
||||||
|
|
||||||
// Trigger Admin-ui event. 'post'
|
// Trigger Admin-ui event. 'post'
|
||||||
if($triggerName = $this->getEventTriggerName($_posted['etrigger_submit']).'d') // 'created' or 'updated';
|
if($triggerName = $this->getEventTriggerName($_posted['etrigger_submit'],'after')) // 'created' or 'updated';
|
||||||
{
|
{
|
||||||
$eventData = array('newData'=>$_posted,'oldData'=>$old_data,'id'=> $id);
|
$eventData = array('newData'=>$_posted,'oldData'=>$old_data,'id'=> $id);
|
||||||
$model->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
$model->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||||
@@ -4006,16 +4006,26 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a custom event trigger name
|
|
||||||
|
/**
|
||||||
|
* Return a custom event trigger name
|
||||||
|
* @param null $type Usually 'Create' or 'Update'
|
||||||
|
* @param string $when ' before or after
|
||||||
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public function getEventTriggerName($type=null)
|
public function getEventTriggerName($type=null, $when='before')
|
||||||
{
|
{
|
||||||
$plug = $this->getEventName();
|
$plug = $this->getEventName();
|
||||||
|
|
||||||
if(empty($plug) || empty($type))
|
if(empty($plug) || empty($type))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($when == 'after')
|
||||||
|
{
|
||||||
|
$type .= 'd'; // ie. 'created' or 'updated'.
|
||||||
|
}
|
||||||
|
|
||||||
return 'admin_'.strtolower($plug).'_'.strtolower($type);
|
return 'admin_'.strtolower($plug).'_'.strtolower($type);
|
||||||
|
|
||||||
@@ -4231,7 +4241,7 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
// send messages to session
|
// send messages to session
|
||||||
e107::getMessage()->moveToSession();
|
e107::getMessage()->moveToSession();
|
||||||
// redirect
|
// redirect
|
||||||
$this->redirect();
|
$this->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -208,6 +208,7 @@ class e107
|
|||||||
'sitelinks' => '{e_HANDLER}sitelinks_class.php',
|
'sitelinks' => '{e_HANDLER}sitelinks_class.php',
|
||||||
'themeHandler' => '{e_HANDLER}theme_handler.php',
|
'themeHandler' => '{e_HANDLER}theme_handler.php',
|
||||||
'user_class' => '{e_HANDLER}userclass_class.php',
|
'user_class' => '{e_HANDLER}userclass_class.php',
|
||||||
|
'user_class_admin' => '{e_HANDLER}userclass_class.php',
|
||||||
'userlogin' => '{e_HANDLER}login.php',
|
'userlogin' => '{e_HANDLER}login.php',
|
||||||
'validatorClass' => '{e_HANDLER}validator_class.php',
|
'validatorClass' => '{e_HANDLER}validator_class.php',
|
||||||
'xmlClass' => '{e_HANDLER}xml_class.php',
|
'xmlClass' => '{e_HANDLER}xml_class.php',
|
||||||
|
@@ -1683,7 +1683,7 @@ class e_form
|
|||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
return e107::getUserClass()->uc_checkboxes($name,$curval,$options,null,true);
|
return e107::getUserClass()->uc_checkboxes($name,$curval,$options,null,false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
|
@@ -92,9 +92,10 @@ class e_object
|
|||||||
*/
|
*/
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->getFieldIdName())
|
if ($this->getFieldIdName())
|
||||||
{
|
{
|
||||||
return $this->get($this->getFieldIdName(), null);
|
return $this->get($this->getFieldIdName(), 0); // default of NULL will break MySQL strict in most cases.
|
||||||
}
|
}
|
||||||
return $this->get('id', 0);
|
return $this->get('id', 0);
|
||||||
}
|
}
|
||||||
@@ -2596,7 +2597,7 @@ class e_front_model extends e_model
|
|||||||
|
|
||||||
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
||||||
{
|
{
|
||||||
$this->addMessageDebug('SQL Qry: '.print_a($qry,true), $session_messages);
|
$this->addMessageDebug('SQL Qry: '.print_a($qry,true), null);
|
||||||
}
|
}
|
||||||
return $qry;
|
return $qry;
|
||||||
}
|
}
|
||||||
@@ -2853,7 +2854,7 @@ class e_admin_model extends e_front_model
|
|||||||
$this->mergePostedData(false, true, true);
|
$this->mergePostedData(false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->getId())
|
if($this->getId() && $this->getPostedData('etrigger_submit') !='Create') // Additional Check to allow primary ID to be manually set when auto-increment PID is not used. @see userclass2.php
|
||||||
{
|
{
|
||||||
return $this->dbUpdate($force, $session_messages);
|
return $this->dbUpdate($force, $session_messages);
|
||||||
}
|
}
|
||||||
|
@@ -1932,7 +1932,8 @@ class e_db_mysql
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->gen("INSERT INTO #".$table."(".$fieldList.") SELECT ".$fieldList." FROM #".$table." WHERE ".$args);
|
$id = $this->gen("INSERT INTO #".$table."(".$fieldList.") SELECT ".$fieldList." FROM #".$table." WHERE ".$args);
|
||||||
return $this->lastInsertId();
|
$lastInsertId = $this->lastInsertId();
|
||||||
|
return ($id && $lastInsertId) ? $lastInsertId : false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -570,8 +570,8 @@ class user_class
|
|||||||
$c = (in_array($k,$curArray)) ? true : false;
|
$c = (in_array($k,$curArray)) ? true : false;
|
||||||
if ($showdescription) $v .= ' ('.$this->uc_get_classdescription($k).')';
|
if ($showdescription) $v .= ' ('.$this->uc_get_classdescription($k).')';
|
||||||
//$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
|
//$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
|
||||||
|
$name = $fieldname.'['.$k.']';
|
||||||
$ret[] = $frm->checkbox($fieldname[$k],$k,$c,$v);
|
$ret[] = $frm->checkbox($name,$k,$c,$v);
|
||||||
//$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
|
//$ret[] = "<div class='field-spacer'><input type='checkbox' class='checkbox' name='{$fieldname}[{$k}]' id='{$fieldname}-{$k}' value='{$k}'{$c} /><label for='{$fieldname}-{$k}'>".$v."</label></div>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1193,6 +1193,7 @@ class user_class_admin extends user_class
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal function, called recursively to rebuild the permissions tree where rights increase going down the tree
|
* Internal function, called recursively to rebuild the permissions tree where rights increase going down the tree
|
||||||
* If the permissions change, sets the 'change_flag' to force rewrite to DB (by other code)
|
* If the permissions change, sets the 'change_flag' to force rewrite to DB (by other code)
|
||||||
@@ -1542,7 +1543,8 @@ class user_class_admin extends user_class
|
|||||||
{
|
{
|
||||||
if (!$classrec['userclass_id'])
|
if (!$classrec['userclass_id'])
|
||||||
{
|
{
|
||||||
echo 'Programming bungle on save - no ID field<br />';
|
e107::getMessage()->addDebug('Programming bungle on save - no ID field');
|
||||||
|
// echo 'Programming bungle on save - no ID field<br />';
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
$qry = '';
|
$qry = '';
|
||||||
@@ -1813,9 +1815,9 @@ class user_class_admin extends user_class
|
|||||||
|
|
||||||
foreach ($init_list as $entry)
|
foreach ($init_list as $entry)
|
||||||
{
|
{
|
||||||
if ($this->sql_r->db_Select('userclass_classes','*',"userclass_id='".$entry['userclass_id']."' "))
|
if ($this->sql_r->select('userclass_classes','*',"userclass_id='".$entry['userclass_id']."' "))
|
||||||
{
|
{
|
||||||
$this->sql_r->db_Update('userclass_classes', "userclass_parent='".$entry['userclass_parent']."', userclass_visibility='".$entry['userclass_visibility']."' WHERE userclass_id='".$entry['userclass_id']."'");
|
$this->sql_r->update('userclass_classes', "userclass_parent='".$entry['userclass_parent']."', userclass_visibility='".$entry['userclass_visibility']."' WHERE userclass_id='".$entry['userclass_id']."'");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user