1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

Should fix #1229 - Rebuild userclass tree after adding new class.

This commit is contained in:
Cameron
2015-11-22 10:00:46 -08:00
parent a047757fef
commit 6db8c7ddeb
5 changed files with 91 additions and 13 deletions

View File

@@ -82,7 +82,7 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
protected $listOrder = "CASE WHEN userclass_id = 250 THEN 1 WHEN userclass_id =254 THEN 2 WHEN userclass_id = 253 THEN 3 WHEN userclass_id < 250 THEN 4 END, 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 $tabs = null;// 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.
@@ -93,13 +93,14 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
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', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left'),
'userclass_description' => array('title'=> UCSLAN_13, 'type' => 'text', 'data'=>'str', 'inline'=>true,'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')),
'userclass_icon' => array('title'=> UCSLAN_68, 'type' => 'icon', 'tab'=>0, 'data'=>'str', 'width' => '5%', 'thclass' => 'left', 'class' => 'center'),
'userclass_name' => array('title'=> UCSLAN_12, 'type' => 'text', 'tab'=>0,'data'=>'str', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left'),
'userclass_description' => array('title'=> UCSLAN_13, 'type' => 'text', 'tab'=>0,'data'=>'str', 'inline'=>true,'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('size'=>'xxlarge')),
'userclass_type' => array('title'=> UCSLAN_79, 'type' => 'dropdown', 'tab'=>0,'data'=>'int', 'width' => '10%', 'thclass' => 'left', 'class'=>'left' ),
'userclass_editclass' => array('title'=> UCSLAN_24, 'type' => 'userclass', 'tab'=>0,'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', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left'),
'userclass_parent' => array('title'=> UCSLAN_35, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'main,admin,nobody,public,classes,matchclass,member, no-excludes')),
'userclass_perms' => array('title'=> "Perms", 'type' => 'hidden', 'tab'=>0,'data'=>'str', 'width' => 'auto', 'thclass' => 'left'),
'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'width' => '10%', 'thclass' => 'center last', 'forced'=>TRUE, 'class'=>'right', 'readParms' => array('deleteClass' => e_UC_NOBODY))
);
@@ -113,6 +114,15 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
public function init()
{
if(E107_DBG_BASIC && intval($_GET['id']) === 254) // Experimental
{
e107::getMessage()->addDebug("Experimental Feature active");
$this->tabs = array(LAN_GENERAL,"Administrator Permissions");
$this->fields['userclass_perms']['type'] = 'method';
$this->fields['userclass_perms']['tab'] = 1;
}
// Listen for submitted data.
$this->initialPageSubmit();
$this->optionsPageSubmit();
@@ -144,10 +154,22 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
public function afterCreate($new_data, $old_data, $id)
{
e107::getUserClass()->clearCache();
$e_userclass = $this->getUserClassAdmin();
$e_userclass->calc_tree();
$e_userclass->save_tree();
}
public function beforeUpdate($new_data, $old_data, $id)
{
if(!empty($new_data['perms']))
{
$new_data['userclass_perms'] = implode(".",$new_data['perms']);
}
e107::getMessage()->addDebug(print_a($new_data,true));
return $new_data;
}
@@ -461,11 +483,31 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
return $text;
}
}
function userclass_perms($curVal,$mode)
{
if($mode == 'read')
{
// $uid = $this->getController()->getModel()->get('user_id');
// return e107::getUserPerms()->renderPerms($curVal,$uid);
}
if($mode == 'write')
{
$prm = e107::getUserPerms();
return $prm->renderPermTable('tabs',$curVal);
}
}
}
new uclass_admin();
require_once(e_ADMIN."auth.php");

View File

@@ -2706,6 +2706,7 @@ class e_front_model extends e_model
if(!$this->data_has_changed && !$force)
{
$this->addMessageInfo(LAN_NO_CHANGE);
return 0;
}
$sql = e107::getDb();

View File

@@ -1245,7 +1245,7 @@ class e_userperms
protected $full_perms = array();
protected $permSectionDiz = array(
'core' => ADMSLAN_74,
'core' => LAN_GENERAL,
'plugin' => ADLAN_CL_7,
'language' => ADLAN_132,
'main' => ADMSLAN_58
@@ -1446,8 +1446,10 @@ class e_userperms
$icon_16 = "";
$icon_32 = "";
}
$par = "<tr>
$class = getperms($arg, $perms) ? 'active' : '';
$par = "<tr class='{$class}'>
<td style='text-align:center'>".$icon_16."</td>
<td style='text-align:center'>".$frm->checkbox('perms[]', $arg, getperms($arg, $perms))."</td>
<td>".$frm->label($label,'perms[]', $arg)."</td>
@@ -1618,6 +1620,40 @@ class e_userperms
function renderPermTable($type,$a_perms='')
{
if($type == 'tabs')
{
$groupedList = $this->getPermList('grouped');
$tab = array();
foreach($groupedList as $section=>$list)
{
$text = '';
// $text .= "\t\t<div class='field-section'><h4>".$prm->renderSectionDiz($section)."</h4>"; //XXX Lan - General
$text .= "\t\t<table class='table adminlist'>
<colgroup>
<col class='center' style='width:50px' />
<col style='width:50px' />
<col />
</colgroup>
<tbody>";
foreach($list as $key=>$diz)
{
$text .= $this->checkb($key, $a_perms, $diz);
}
$text .= "</tbody></table>";
$tab[] = array('caption'=>$this->renderSectionDiz($section), 'text'=>$text);
}
// return print_a($groupedList);
return e107::getForm()->tabs($tab);
}
$groupedList = $this->getPermList($type);
if($type != 'grouped')

View File

@@ -414,6 +414,6 @@ define("LAN_CONTROL_PANEL", "[x]'s Control Panel");
define("LAN_CUSTOM_URL", "Custom URL");
define("LAN_CUSTOM_URL_DISABLED", "Disabled or Enter Custom URL");
define("LAN_GENERAL", "General");
// TODO - move e_form related LANS below, add new lan_form.php file (for both front/back-end)

View File

@@ -79,7 +79,6 @@ define("ADMSLAN_71", "Click here to display privileges");
define("ADMSLAN_72", "Admin ID: --ID-- name: --NAME-- new permissions: ");
define("ADMSLAN_73", "Admin ID: --ID-- name: --NAME--");
define("ADMSLAN_74", "General");
// define("ADMSLAN_75", "");
//define("ADMSLAN_76", "Manage language-packs");//ADLAN_132