2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-29 16:11:02 +00:00
* e107 website system
*
2017-01-09 17:07:47 +00:00
* Copyright ( C ) 2008 - 2017 e107 Inc ( e107 . org )
2008-12-29 16:11:02 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Administration Area - User classes
*
2006-12-02 04:36:16 +00:00
*/
2007-12-22 12:39:27 +00:00
2010-01-16 19:54:04 +00:00
require_once ( '../class2.php' );
2017-01-17 01:33:03 +01:00
2010-01-16 19:54:04 +00:00
if ( ! getperms ( '4' ))
2007-12-22 12:39:27 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2007-12-22 12:39:27 +00:00
exit ;
2006-12-02 04:36:16 +00:00
}
2009-08-28 16:11:02 +00:00
2017-01-17 01:33:03 +01:00
e107 :: coreLan ( 'userclass2' , true );
2015-03-01 12:43:02 -08:00
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 ;
2015-03-01 21:34:57 -08:00
protected $batchCopy = false ; // no way to generate the non-incrementing primary key at the moment
2015-05-15 13:07:26 -07:00
// protected $listOrder = 'userclass_id DESC'; //XXX Make more intuitive.
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 " ;
2015-03-01 12:43:02 -08:00
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
2015-11-22 10:00:46 -08:00
protected $tabs = null ; // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
2015-03-01 12:43:02 -08:00
// 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' ),
2017-01-09 17:07:47 +00:00
'userclass_icon' => array ( 'title' => LAN_ICON , 'type' => 'icon' , 'tab' => 0 , 'data' => 'str' , 'width' => '5%' , 'thclass' => 'left' , 'class' => 'center' ),
'userclass_name' => array ( 'title' => LAN_NAME , 'type' => 'text' , 'tab' => 0 , 'data' => 'str' , 'inline' => true , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'text' , 'tab' => 0 , 'data' => 'str' , 'inline' => true , 'width' => 'auto' , 'thclass' => 'left' , 'writeParms' => array ( 'size' => 'xxlarge' )),
'userclass_type' => array ( 'title' => LAN_TYPE , 'type' => 'dropdown' , 'tab' => 0 , 'data' => 'int' , 'width' => '10%' , 'thclass' => 'left' , 'class' => 'left' ),
'userclass_editclass' => array ( 'title' => LAN_MANAGER , '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' => LAN_VISIBILITY , 'type' => 'userclass' , 'tab' => 0 , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_parent' => array ( 'title' => LAN_PARENT , 'type' => 'userclass' , 'tab' => 0 , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'left' , 'writeParms' => array ( 'classlist' => 'main,admin,nobody,public,classes,matchclass,member, no-excludes' )),
2015-11-22 10:00:46 -08:00
'userclass_perms' => array ( 'title' => " Perms " , 'type' => 'hidden' , 'tab' => 0 , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'left' ),
2015-03-01 12:43:02 -08:00
'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 ()
{
2015-11-22 10:00:46 -08:00
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 ;
}
2015-03-01 12:43:02 -08:00
// 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 )
{
2015-05-12 13:53:47 -07:00
e107 :: getUserClass () -> clearCache ();
2015-11-22 10:00:46 -08:00
$e_userclass = $this -> getUserClassAdmin ();
$e_userclass -> calc_tree ();
$e_userclass -> save_tree ();
2015-03-01 12:43:02 -08:00
}
public function beforeUpdate ( $new_data , $old_data , $id )
{
2015-11-22 10:00:46 -08:00
if ( ! empty ( $new_data [ 'perms' ]))
{
$new_data [ 'userclass_perms' ] = implode ( " . " , $new_data [ 'perms' ]);
}
e107 :: getMessage () -> addDebug ( print_a ( $new_data , true ));
2015-03-01 12:43:02 -08:00
return $new_data ;
}
public function afterUpdate ( $new_data , $old_data , $id )
{
2015-05-12 13:53:47 -07:00
e107 :: getUserClass () -> clearCache ();
2015-03-01 12:43:02 -08:00
}
2015-05-12 13:53:47 -07:00
public function afterDelete ( $data , $id )
{
e107 :: getUserClass () -> clearCache ();
}
2015-03-01 12:43:02 -08:00
public function onCreateError ( $new_data , $old_data )
{
// do something
}
public function onUpdateError ( $new_data , $old_data , $id )
{
// do something
}
2015-04-09 11:13:26 -07:00
function renderHelp ()
{
$e_userclass = e107 :: getSingleton ( 'user_class_admin' ); // Admin functions - should just obliterate any previous object created in class2.php
$e_userclass -> calc_tree ();
$text = " <div id='userclass-tree-structure'> " . $e_userclass -> show_graphical_tree () . " </div> " ;
2015-05-12 13:53:47 -07:00
return array ( 'caption' => 'Class Structure' , 'text' => $text ); //TODO LAN
2015-04-09 11:13:26 -07:00
// $text .= $e_userclass->show_graphical_tree();
}
2015-03-01 12:43:02 -08:00
public function optionsPage ()
{
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
2017-01-09 17:07:47 +00:00
$mes -> addWarning ( LAN_OPTIONS . " <br /><br /> " . UCSLAN_53 );
2015-03-01 12:43:02 -08:00
$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 )
{
2015-05-12 13:53:47 -07:00
if ( trim ( $i )) $icn [] = e107 :: getUserClass () -> getName ( $i );
2015-03-01 12:43:02 -08:00
}
2015-06-02 14:25:39 -07:00
$class_text = $frm -> userclass ( 'init_classes' , $initial_classes , 'checkbox' , array ( 'options' => 'classes,force' ));
2015-03-01 12:43:02 -08:00
// $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 );
2015-07-15 19:33:15 -07:00
$text = " <div>
2015-03-01 12:43:02 -08:00
< 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
{
2017-01-09 17:07:47 +00:00
$text .= LAN_NONE ;
2015-03-01 12:43:02 -08:00
}
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 >
2017-01-11 08:45:00 +00:00
< div class = 'buttons-bar center' > " . $frm->admin_button ('set_initial_classes','no-value','create',LAN_UPDATE). " </ div > " ;
2015-03-01 12:43:02 -08:00
}
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 )
{
2015-03-15 13:30:37 -07:00
2015-03-01 12:43:02 -08:00
$text = " " ;
2015-03-15 13:30:37 -07:00
$options = array ();
2015-03-01 12:43:02 -08:00
if ( $attributes [ 'mode' ] == 'read' )
{
$classID = $this -> getController () -> getListModel () -> get ( 'userclass_id' );
if ( ! $this -> getController () -> getUserClassAdmin () -> queryCanDeleteClass ( $classID ))
{
2015-03-15 13:30:37 -07:00
$options [ 'readParms' ][ 'deleteClass' ] = e_UC_NOBODY ;
}
if ( $classID == 0 )
{
$options [ 'readParms' ][ 'deleteClass' ] = e_UC_NOBODY ;
$options [ 'readParms' ][ 'editClass' ] = e_UC_NOBODY ;
2015-03-01 12:43:02 -08:00
}
$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 ;
}
2015-11-22 10:00:46 -08:00
2015-03-01 12:43:02 -08:00
}
2015-11-22 10:00:46 -08:00
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 );
}
}
2015-03-01 12:43:02 -08:00
}
2015-11-22 10:00:46 -08:00
2015-03-01 12:43:02 -08:00
new uclass_admin ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . " footer.php " );
exit ;
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'userclass' ;
2008-01-19 21:01:59 +00:00
//define('UC_DEBUG_OPTS',FALSE);
2008-11-09 20:31:10 +00:00
2009-08-22 21:27:34 +00:00
require_once ( e_HANDLER . 'userclass_class.php' ); // Modified class handler
2008-02-16 12:03:27 +00:00
$e_userclass = new user_class_admin ; // Admin functions - should just obliterate any previous object created in class2.php
2013-03-03 11:32:28 +00:00
// @TODO: Does core object manager need to know somehow?
2009-11-05 12:26:44 +00:00
2010-01-16 19:54:04 +00:00
require_once ( e_HANDLER . 'form_handler.php' );
2009-11-05 12:26:44 +00:00
2009-07-16 08:15:35 +00:00
$frm = new e_form ();
2015-03-01 12:43:02 -08:00
// $uc = new uclass_manager;
2012-11-30 13:47:06 -08:00
$mes = e107 :: getMessage ();
2009-11-05 12:26:44 +00:00
2007-12-22 12:39:27 +00:00
$message = '' ;
2010-03-11 11:56:23 +00:00
/**
2012-12-19 22:27:48 +00:00
* See whether a user class is editable .
*
* ( Note : On fixed classes , only some fields are editable )
2012-12-18 22:43:10 +00:00
*
2010-03-11 11:56:23 +00:00
* @ param integer $class_id
2012-12-19 22:27:48 +00:00
* @ param boolean $redirect - if TRUE , will redirect to site home page if class not editable .
* @ param boolean $fullEdit - set TRUE if full editing required , FALSE if some editing permitted
*
* @ return boolean - TRUE if class editable ( fully or partially ), FALSE if not .
2010-03-11 11:56:23 +00:00
*/
2012-12-19 22:27:48 +00:00
function checkAllowed ( $classID , $redirect = true , $fullEdit = FALSE )
2006-12-02 04:36:16 +00:00
{
2012-12-19 22:27:48 +00:00
global $e_userclass ; // TODO: Get rid of this (we need the system admin object; not the user-level object)
$editLevel = $fullEdit ? 2 : 1 ;
if ( $e_userclass -> queryCanEditClass ( $classID ) >= $editLevel )
{
return TRUE ;
}
if ( $redirect )
2008-12-29 16:11:02 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ();
2008-12-29 16:11:02 +00:00
exit ;
}
2010-03-11 11:56:23 +00:00
2012-12-19 22:27:48 +00:00
return FALSE ;
2012-12-18 22:43:10 +00:00
2012-12-19 22:27:48 +00:00
// Next bit probably redundant - editing of some parts of system class data is allowed.
2012-12-18 22:43:10 +00:00
if ( ! $uc -> isEditableClass ( $class_id ))
2008-12-29 16:11:02 +00:00
{
if ( ! $redirect ) return false ;
2012-12-19 22:27:48 +00:00
e107 :: getMessage () -> addSession ( UCSLAN_90 , E_MESSAGE_ERROR );
2010-03-11 11:56:23 +00:00
header ( 'location:' . e_SELF );
2008-12-29 16:11:02 +00:00
exit ;
}
2010-03-11 11:56:23 +00:00
2008-12-29 16:11:02 +00:00
return true ;
2006-12-02 04:36:16 +00:00
}
2008-12-29 16:11:02 +00:00
if ( e_QUERY )
2006-12-02 04:36:16 +00:00
{
2010-03-11 11:56:23 +00:00
// BC - SO MUCH BAD, never do this at home!!!
if ( isset ( $_GET [ 'action' ]))
{
$uc_qs = array ( $_GET [ 'action' ], $_GET [ 'id' ]);
}
2012-12-18 22:43:10 +00:00
else $uc_qs = explode ( '.' , e_QUERY );
2006-12-02 04:36:16 +00:00
}
2009-08-03 18:04:19 +00:00
$action = varset ( $uc_qs [ 0 ]);
2007-12-22 12:39:27 +00:00
$params = varset ( $uc_qs [ 1 ], '' );
2010-03-11 11:56:23 +00:00
e107 :: setRegistry ( 'pageParams' , $uc_qs );
2006-12-02 04:36:16 +00:00
2008-12-29 16:11:02 +00:00
//AJAX request check is already made by the API
2015-03-01 12:43:02 -08:00
/*
2008-12-29 16:11:02 +00:00
if ( e_AJAX_REQUEST )
{
2010-03-11 11:56:23 +00:00
$class_num = intval ( $params );
if ( $action == 'edit' )
2008-11-09 20:31:10 +00:00
{
require_once ( e_HANDLER . 'js_helper.php' );
$jshelper = new e_jshelper ();
2012-12-19 22:27:48 +00:00
if ( ! checkAllowed ( $class_num , false ))
2008-11-27 22:07:36 +00:00
{
//This will raise an error
2008-12-29 16:11:02 +00:00
//'Access denied' is the message which will be thrown
2008-11-27 22:07:36 +00:00
//by the JS AJAX handler
2010-03-11 11:56:23 +00:00
e_jshelper :: sendAjaxError ( '403' , 'Access denied. ' . UCSLAN_90 );
2008-11-27 22:07:36 +00:00
}
2009-11-01 17:19:27 +00:00
elseif ( $sql -> db_Select ( 'userclass_classes' , '*' , " userclass_id=' " . $class_num . " ' " ))
{
2016-02-14 12:15:55 -08:00
$row = $sql -> db_Fetch ();
2008-12-29 16:11:02 +00:00
2009-11-01 17:19:27 +00:00
//Response action - reset all group checkboxes
$jshelper -> addResponseAction ( 'reset-checked' , array ( 'group_classes_select' => '0' ));
2008-12-29 16:11:02 +00:00
2009-11-01 17:19:27 +00:00
//it's grouped userclass
if ( $row [ 'userclass_type' ] == UC_TYPE_GROUP )
{
//Response action - show group, hide standard
$jshelper -> addResponseAction ( 'element-invoke-by-id' , array ( 'show' => 'userclass_type_groups' , 'hide' => 'userclass_type_standard' ));
2008-12-29 16:11:02 +00:00
2009-11-01 17:19:27 +00:00
//fill in the classes array
$tmp = explode ( ',' , $row [ 'userclass_accum' ]);
2009-11-26 21:43:38 +00:00
foreach ( $tmp as $uid )
2009-11-01 17:19:27 +00:00
{
$row [ 'group_classes_select_' . $uid ] = $uid ;
}
2009-11-26 21:43:38 +00:00
}
else
2009-11-01 17:19:27 +00:00
{
//hide group, show standard rows
$jshelper -> addResponseAction ( 'element-invoke-by-id' , array ( 'hide' => 'userclass_type_groups' , 'show' => 'userclass_type_standard' ));
2008-11-29 17:35:38 +00:00
}
2009-11-01 17:19:27 +00:00
unset ( $row [ 'userclass_accum' ]);
2010-03-11 11:56:23 +00:00
2009-11-01 17:19:27 +00:00
$jshelper -> addResponseAction ( 'fill-form' , $row );
$jshelper -> sendResponse ( 'XML' );
2010-03-11 11:56:23 +00:00
// $jshelper->sendResponse('JSON'); - another option (tested) - faster transfer!
2009-11-01 17:19:27 +00:00
}
else
{
e_jshelper :: sendAjaxError ( '500' , 'Database read error!' );
2008-11-27 22:07:36 +00:00
}
2009-11-01 17:19:27 +00:00
2008-11-09 20:31:10 +00:00
}
2010-03-11 11:56:23 +00:00
exit ;
2008-11-09 20:31:10 +00:00
}
2007-12-22 12:39:27 +00:00
2010-03-11 12:49:05 +00:00
e107 :: getJs () -> headerCore ( 'core/admin.js' );
2015-03-01 12:43:02 -08:00
*/
2010-03-11 12:49:05 +00:00
2008-11-09 20:31:10 +00:00
/*
* Authorization should be done a bit later !
*/
require_once ( " auth.php " );
2010-03-11 12:49:05 +00:00
$emessage = e107 :: getMessage ();
2007-12-22 12:39:27 +00:00
//---------------------------------------------------
// Set Initial Classes
//---------------------------------------------------
2015-03-01 12:43:02 -08:00
/*
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'set_initial_classes' ]))
{
2009-07-14 19:26:24 +00:00
$changed = $pref [ 'init_class_stage' ] != intval ( $_POST [ 'init_class_stage' ]);
$pref [ 'init_class_stage' ] = intval ( $_POST [ 'init_class_stage' ]);
$temp = array ();
foreach ( $_POST [ 'init_classes' ] as $ic )
{
$temp [] = intval ( $ic );
}
$newval = implode ( ',' , $temp );
$temp = varset ( $pref [ 'initial_user_classes' ], '' );
if ( $temp != $newval ) $changed = TRUE ;
if ( $changed )
{
$pref [ 'initial_user_classes' ] = $newval ;
save_prefs ();
userclass2_adminlog ( " 05 " , " New: { $newval } , Old: { $temp } , Stage: " . $pref [ 'init_class_stage' ]);
$message = UCSLAN_41 ;
}
else
{
2017-01-09 17:24:52 +00:00
$message = LAN_NOCHANGE_NOTSAVED ;
2009-07-14 19:26:24 +00:00
}
2006-12-02 04:36:16 +00:00
}
2015-03-01 12:43:02 -08:00
*/
2007-12-22 12:39:27 +00:00
//---------------------------------------------------
// Delete existing class
//---------------------------------------------------
2015-03-01 12:43:02 -08:00
/*
2010-03-11 12:49:05 +00:00
if ( isset ( $_POST [ 'etrigger_delete' ]) && ! empty ( $_POST [ 'etrigger_delete' ]))
2006-12-02 04:36:16 +00:00
{
2012-12-19 22:27:48 +00:00
$classID = intval ( array_shift ( array_keys ( $_POST [ 'etrigger_delete' ])));
//checkAllowed($classID);
if ( $e_userclass -> queryCanDeleteClass ( $classID ))
2007-12-22 12:39:27 +00:00
{
2009-07-14 19:26:24 +00:00
if ( $e_userclass -> delete_class ( $class_id ) !== FALSE )
{
2012-12-19 22:27:48 +00:00
userclass2_adminlog ( " 02 " , " ID: { $class_id } ( " . $e_userclass -> uc_get_classname ( $classID ) . " ) " );
if ( $sql -> db_Select ( 'user' , 'user_id, user_class' , " user_class = ' { $classID } ' OR user_class REGEXP('^ { $classID } ,') OR user_class REGEXP(', { $classID } ,') OR user_class REGEXP(', { $classID } $ ') " ))
2009-07-14 19:26:24 +00:00
{ // Delete existing users from class
2016-02-14 12:15:55 -08:00
while ( $row = $sql -> db_Fetch ())
2009-07-14 19:26:24 +00:00
{
$uidList [ $row [ 'user_id' ]] = $row [ 'user_class' ];
}
2012-12-19 22:27:48 +00:00
$e_userclass -> class_remove ( $classID , $uidList );
2009-07-14 19:26:24 +00:00
}
2010-03-11 12:49:05 +00:00
$e_pref = e107 :: getConfig ();
2012-12-19 22:27:48 +00:00
if ( $e_pref -> isData ( 'frontpage/' . $classID ))
2010-03-11 12:49:05 +00:00
{
2012-12-19 22:27:48 +00:00
$e_pref -> removePref ( 'frontpage/' . $classID ) -> save ( false );
2010-03-11 12:49:05 +00:00
}
2015-03-01 12:43:02 -08:00
// if (isset($pref['frontpage'][$class_id]))
2006-12-02 04:36:16 +00:00
{
2015-03-01 12:43:02 -08:00
// unset($pref['frontpage'][$class_id]); // (Should work with both 0.7 and 0.8 front page methods)
// save_prefs();
}
2017-01-11 08:39:26 +00:00
$emessage -> add ( LAN_DELETED , E_MESSAGE_SUCCESS );
2006-12-02 04:36:16 +00:00
}
2009-07-14 19:26:24 +00:00
else
2006-12-02 04:36:16 +00:00
{
2017-01-11 08:31:55 +00:00
$emessage -> add ( UCSLAN_10 , E_MESSAGE_ERROR );
2006-12-02 04:36:16 +00:00
}
}
2012-12-19 22:27:48 +00:00
else
2006-12-02 04:36:16 +00:00
{
2017-01-11 08:31:55 +00:00
$emessage -> add ( UCSLAN_10 , E_MESSAGE_ERROR );
2012-12-19 22:27:48 +00:00
}
2015-03-01 12:43:02 -08:00
} */
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
//---------------------------------------------------
// Add/Edit class information
//---------------------------------------------------
2015-03-01 12:43:02 -08:00
/*
2009-08-03 18:04:19 +00:00
if ( isset ( $_POST [ 'createclass' ])) // Add or edit
2008-12-29 16:11:02 +00:00
{
2012-12-19 22:27:48 +00:00
$fullEdit = TRUE ; // Most of the time, we are allowed to edit everything
$do_tree = FALSE ; // Set flag to rebuild tree if no errors
$forwardVals = FALSE ; // Set to ripple through existing values to a subsequent pass
$tempID = intval ( varset ( $_POST [ 'userclass_id' ], - 1 ));
if (( $tempID < 0 ) && $e_userclass -> ucGetClassIDFromName ( $class_record [ 'userclass_name' ]))
{
$emessage -> add ( UCSLAN_63 , E_MESSAGE_WARNING ); // Duplicate name
$forwardVals = TRUE ;
}
if ( $tempID > 0 )
{
$fullEdit = $e_userclass -> queryCanEditClass ( $tempID ) == 2 ;
}
2008-11-29 21:16:54 +00:00
$class_record = array (
'userclass_description' => varset ( $tp -> toDB ( $_POST [ 'userclass_description' ]), '' ),
'userclass_editclass' => intval ( varset ( $_POST [ 'userclass_editclass' ], 0 )),
'userclass_parent' => intval ( varset ( $_POST [ 'userclass_parent' ], 0 )),
'userclass_visibility' => intval ( varset ( $_POST [ 'userclass_visibility' ], 0 )),
2012-12-19 22:27:48 +00:00
'userclass_icon' => $tp -> toDB ( varset ( $_POST [ 'userclass_icon' ], '' ))
2008-11-29 21:16:54 +00:00
);
2012-12-19 22:27:48 +00:00
if ( $fullEdit )
2008-11-27 22:07:36 +00:00
{
2012-12-19 22:27:48 +00:00
$class_record [ 'userclass_name' ] = varset ( $tp -> toDB ( $_POST [ 'userclass_name' ]), '' );
$class_record [ 'userclass_type' ] = intval ( varset ( $_POST [ 'userclass_type' ], UC_TYPE_STD ));
if ( $class_record [ 'userclass_type' ] == UC_TYPE_GROUP )
2008-11-27 22:07:36 +00:00
{
2012-12-19 22:27:48 +00:00
$temp = array ();
foreach ( $_POST [ 'group_classes_select' ] as $gc )
{
$temp [] = intval ( $gc );
}
$class_record [ 'userclass_accum' ] = implode ( ',' , $temp );
2008-11-27 22:07:36 +00:00
}
}
2007-12-22 12:39:27 +00:00
2012-12-19 22:27:48 +00:00
if ( $e_userclass -> checkAdminInfo ( $class_record , $tempID ) === FALSE )
2006-12-02 04:36:16 +00:00
{
2012-12-18 22:43:10 +00:00
$emessage -> add ( UCSLAN_86 ); // Some fixed values changed
2012-12-19 22:27:48 +00:00
$forwardVals = TRUE ;
2006-12-02 04:36:16 +00:00
}
2008-11-29 21:16:54 +00:00
if ( ! $forwardVals )
2007-12-22 12:39:27 +00:00
{
2008-11-29 21:16:54 +00:00
if ( $tempID > 0 )
{ // Editing existing class here
2012-12-19 22:27:48 +00:00
checkAllowed ( $tempID );
2008-11-29 21:16:54 +00:00
$class_record [ 'userclass_id' ] = $tempID ;
$e_userclass -> save_edited_class ( $class_record );
2012-12-19 22:27:48 +00:00
userclass2_adminlog ( '03' , " ID: { $class_record [ 'userclass_id' ] } ( " . $class_record [ 'userclass_name' ] . " ) " );
2008-11-29 21:16:54 +00:00
$do_tree = TRUE ;
2017-01-09 17:07:47 +00:00
//$message .= LAN_UPDATED.': '.LAN_USERCLASS;
$emessage -> add ( LAN_UPDATED . ': ' . LAN_USERCLASS , E_MESSAGE_SUCCESS );
2008-12-29 16:11:02 +00:00
}
2008-11-29 21:16:54 +00:00
else
{ // Creating new class
if ( $class_record [ 'userclass_name' ])
{
2008-12-29 16:11:02 +00:00
if ( getperms ( " 0 " ) || ( $class_record [ 'userclass_editclass' ] && check_class ( $class_record [ 'userclass_editclass' ])))
2008-11-29 21:16:54 +00:00
{
$i = $e_userclass -> findNewClassID ();
if ( $i === FALSE )
{
2010-03-11 12:49:05 +00:00
//$message = UCSLAN_85;
$emessage -> add ( UCSLAN_85 , E_MESSAGE_WARNING );
2008-11-29 21:16:54 +00:00
}
else
{
$class_record [ 'userclass_id' ] = $i ;
$e_userclass -> add_new_class ( $class_record );
userclass2_adminlog ( " 01 " , " ID: { $class_record [ 'userclass_id' ] } ( " . $class_record [ 'userclass_name' ] . " ) " );
$do_tree = TRUE ;
2017-01-09 17:07:47 +00:00
//$message .= LAN_UPDATED.': '.LAN_USERCLASS;
$emessage -> add ( LAN_UPDATED . ': ' . LAN_USERCLASS , E_MESSAGE_SUCCESS );
2008-11-29 21:16:54 +00:00
}
}
else
{
header ( " location: " . SITEURL );
exit ;
}
}
else
{
2010-03-11 12:49:05 +00:00
// Class name required
//$message = UCSLAN_37;
$emessage -> add ( UCSLAN_37 , E_MESSAGE_ERROR );
2008-11-29 21:16:54 +00:00
$forwardVals = TRUE ;
}
}
2007-12-22 12:39:27 +00:00
}
2006-12-02 04:36:16 +00:00
2012-12-19 22:27:48 +00:00
if ( $do_tree )
{
$e_userclass -> calc_tree ();
$e_userclass -> save_tree ();
}
2006-12-02 04:36:16 +00:00
}
2015-03-01 12:43:02 -08:00
*/
2006-12-02 04:36:16 +00:00
2015-03-01 12:43:02 -08:00
/*
2007-12-22 12:39:27 +00:00
if ( $message )
2006-12-02 04:36:16 +00:00
{
2010-03-11 12:49:05 +00:00
$emessage -> add ( $message );
2006-12-02 04:36:16 +00:00
}
2007-12-22 12:39:27 +00:00
2009-11-05 12:26:44 +00:00
class uclassFrm extends e_form
{
function userclass_type ( $curVal , $mode )
{
$types = array (
UC_TYPE_STD => UCSLAN_80 ,
UC_TYPE_GROUP => UCSLAN_81
);
2009-11-26 21:43:38 +00:00
2009-11-05 12:26:44 +00:00
return varset ( $types [ $curVal ]);
2009-11-26 21:43:38 +00:00
}
2009-11-05 12:26:44 +00:00
}
2015-03-01 12:43:02 -08:00
*/
2009-11-05 12:26:44 +00:00
2015-03-01 12:43:02 -08:00
/*
2009-08-22 21:27:34 +00:00
if ( ! e_QUERY || $action == 'list' )
2009-08-03 18:04:19 +00:00
{
2009-11-23 01:17:29 +00:00
$uc -> show_existing ();
2009-11-26 21:43:38 +00:00
2009-08-03 18:04:19 +00:00
}
2015-03-01 12:43:02 -08:00
*/
2010-03-11 11:56:23 +00:00
if ( isset ( $_GET [ 'id' ]) && $_GET [ 'action' ] == 'edit' )
2009-08-03 18:04:19 +00:00
{
2009-08-22 21:27:34 +00:00
$action = 'config' ;
2009-11-05 12:26:44 +00:00
$_POST [ 'existing' ] = $_GET [ 'id' ];
2009-08-03 18:04:19 +00:00
}
2007-12-22 12:39:27 +00:00
switch ( $action )
2006-12-02 04:36:16 +00:00
{
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
// Class management
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
case 'config' :
2012-12-19 22:27:48 +00:00
$fullEdit = TRUE ;
2009-08-03 18:04:19 +00:00
if ( isset ( $_POST [ 'existing' ]))
2006-12-02 04:36:16 +00:00
{
2008-11-27 22:07:36 +00:00
$params = 'edit' ;
$class_num = intval ( varset ( $_POST [ 'existing' ], 0 ));
2012-12-19 22:27:48 +00:00
$fullEdit = $e_userclass -> queryCanEditClass ( $class_num ) == 2 ;
2006-12-02 04:36:16 +00:00
}
2007-12-22 12:39:27 +00:00
else
{
2008-11-27 22:07:36 +00:00
$class_num = intval ( varset ( $uc_qs [ 2 ], 0 ));
2007-12-22 12:39:27 +00:00
}
2008-11-29 21:16:54 +00:00
2008-11-27 22:07:36 +00:00
$userclass_id = 0 ; // Set defaults for new class to start with
$userclass_name = '' ;
$userclass_description = '' ;
$userclass_editclass = e_UC_ADMIN ;
$userclass_visibility = e_UC_ADMIN ;
2008-12-07 16:37:37 +00:00
$userclass_parent = e_UC_NOBODY ;
2008-11-27 22:07:36 +00:00
$userclass_icon = '' ;
$userclass_type = UC_TYPE_STD ;
$userclass_groupclass = '' ;
2008-11-29 21:16:54 +00:00
if ( $params == 'edit' || $forwardVals )
2007-12-22 12:39:27 +00:00
{
2013-04-30 01:28:44 -07:00
if ( ! isset ( $forwardVals ))
2008-11-29 21:16:54 +00:00
{ // Get the values from DB (else just recycle data uer was trying to store)
2012-12-19 22:27:48 +00:00
checkAllowed ( $class_num );
2008-11-29 21:16:54 +00:00
$sql -> db_Select ( 'userclass_classes' , '*' , " userclass_id=' " . intval ( $class_num ) . " ' " );
$class_record = $sql -> db_Fetch ();
$userclass_id = $class_record [ 'userclass_id' ]; // Update fields from DB if editing
}
$userclass_name = $class_record [ 'userclass_name' ];
$userclass_description = $class_record [ 'userclass_description' ];
$userclass_editclass = $class_record [ 'userclass_editclass' ];
$userclass_visibility = $class_record [ 'userclass_visibility' ];
$userclass_parent = $class_record [ 'userclass_parent' ];
$userclass_icon = $class_record [ 'userclass_icon' ];
$userclass_type = $class_record [ 'userclass_type' ];
2008-11-27 22:07:36 +00:00
if ( $userclass_type == UC_TYPE_GROUP )
{
2008-11-29 21:16:54 +00:00
$userclass_groupclass = $class_record [ 'userclass_accum' ];
2008-11-27 22:07:36 +00:00
}
2007-12-22 12:39:27 +00:00
}
2008-11-27 22:07:36 +00:00
$class_total = $sql -> db_Count ( 'userclass_classes' , '(*)' );
2007-12-22 12:39:27 +00:00
$text = " <div style='text-align:center'>
< form method = 'post' action = '".e_SELF."' id = 'classForm' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-16 08:15:35 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
2009-07-21 07:13:42 +00:00
2009-08-03 18:04:19 +00:00
</ colgroup > " ;
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
$text .= "
< tr >
2017-01-09 17:07:47 +00:00
< td > " .LAN_NAME. " </ td >
2012-12-19 22:27:48 +00:00
< td > " ;
if ( $fullEdit )
{
$text .= " <input class='tbox' type='text' size='30' maxlength='25' name='userclass_name' value=' { $userclass_name } ' /> " ;
}
else
{
$text .= " { $userclass_name } <input type='hidden' name='userclass_name' value=' { $userclass_name } ' /> " ;
}
$text .= " <div class='field-help'> " . UCSLAN_30 . " </div></td>
2009-07-21 07:13:42 +00:00
2007-12-22 12:39:27 +00:00
</ tr >
< tr >
2017-01-09 17:07:47 +00:00
< td > " .LAN_DESCRIPTION. " </ td >
2009-07-21 07:13:42 +00:00
< td >< input class = 'tbox' type = 'text' size = '60' maxlength = '85' name = 'userclass_description' value = '{$userclass_description}' />
< div class = 'field-help' > " .UCSLAN_31. " </ div ></ td >
2007-12-22 12:39:27 +00:00
</ tr > " ;
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
// Userclass icon
$text .= "
< tr >
2017-01-09 17:07:47 +00:00
< td > " .LAN_ICON. " </ td >
2009-08-03 18:04:19 +00:00
< td > " . $frm->iconpicker ('userclass_icon', $userclass_icon , LAN_SELECT). "
2009-07-21 07:13:42 +00:00
< div class = 'field-help' > " .UCSLAN_69. " </ div ></ td >
</ tr >
2007-12-22 12:39:27 +00:00
" ;
$text .= "
< tr >
2017-01-09 17:07:47 +00:00
< td > " .LAN_TYPE. " </ td >
2012-12-19 22:27:48 +00:00
< td > " ;
$classTypes = array ( UC_TYPE_STD => UCSLAN_80 , UC_TYPE_GROUP => UCSLAN_81 );
if ( $fullEdit )
{
$text .= " \n
2008-11-27 22:07:36 +00:00
< select name = 'userclass_type' class = 'tbox' onchange = 'setGroupStatus(this)' >
< option value = '".UC_TYPE_STD."' " .(UC_TYPE_STD == $userclass_type ? " selected = 'selected' " : " " ). " > " .UCSLAN_80. " </ option > \n
< option value = '".UC_TYPE_GROUP."' " .(UC_TYPE_GROUP == $userclass_type ? " selected = 'selected' " : " " ). " > " .UCSLAN_81. " </ option > \n
2012-12-19 22:27:48 +00:00
</ select > \n " ;
}
else
{
$text .= $classTypes [ $userclass_type ] . " <input type='hidden' name='userclass_type' value=' { $userclass_type } ' /> " ;
}
$text .= " <div class='field-help'> " . UCSLAN_82 . " </div></td>
2009-07-21 07:13:42 +00:00
</ tr >
2008-11-27 22:07:36 +00:00
" ;
// Who can manage class
$text .= "
< tr id = 'userclass_type_standard' " .(UC_TYPE_GROUP == $userclass_type ? " style = 'display:none' " : " " ). " >
2017-01-09 17:07:47 +00:00
< td > " .LAN_MANAGER. " </ td >
2009-07-21 07:13:42 +00:00
< td > " ;
2013-03-03 11:32:28 +00:00
$text .= " <select name='userclass_editclass' class='tbox'> " . $e_userclass -> vetted_tree ( 'userclass_editclass' , array ( $e_userclass , 'select' ), $userclass_editclass , 'nobody,public,main,admin,classes,matchclass,member, no-excludes' ) . '</select>' ;
2009-07-21 07:13:42 +00:00
$text .= " <div class='field-help'> " . UCSLAN_32 . " </div></td>
</ tr >
2007-12-22 12:39:27 +00:00
" ;
2008-11-27 22:07:36 +00:00
// List of class checkboxes for grouping
$text .= "
< tr id = 'userclass_type_groups' " .(UC_TYPE_STD == $userclass_type ? " style = 'display:none' " : " " ). " >
2009-07-21 07:13:42 +00:00
< td > " .UCSLAN_83. " </ td >
< td > " ;
2008-11-27 22:07:36 +00:00
$text .= $e_userclass -> vetted_tree ( 'group_classes_select' , array ( $e_userclass , 'checkbox' ), $userclass_groupclass , " classes,matchclass " );
2009-11-01 17:19:27 +00:00
$text .= " <div class='field-help'> " . UCSLAN_89 . " </div></td>
2009-07-21 07:13:42 +00:00
</ tr >
2008-11-27 22:07:36 +00:00
" ;
2007-12-22 12:39:27 +00:00
$text .= "
< tr >
2017-01-09 17:07:47 +00:00
< td > " .LAN_VISIBILITY. " </ td >
2009-07-21 07:13:42 +00:00
< td > " ;
2009-02-01 15:18:30 +00:00
$text .= " <select name='userclass_visibility' class='tbox'> " . $e_userclass -> vetted_tree ( 'userclass_visibility' , array ( $e_userclass , 'select' ), $userclass_visibility , 'main,admin,classes,matchclass,public,member,nobody' ) . '</select>' ;
2009-07-21 07:13:42 +00:00
$text .= " <div class='field-help'> " . UCSLAN_33 . " </div></td>
</ tr >
2007-12-22 12:39:27 +00:00
" ;
$text .= "
< tr >
2017-01-09 17:07:47 +00:00
< td > " .LAN_PARENT. " </ td >
2009-07-21 07:13:42 +00:00
< td > " ;
2013-03-03 11:32:28 +00:00
$text .= " <select name='userclass_parent' class='tbox'> " . $e_userclass -> vetted_tree ( 'userclass_parent' , array ( $e_userclass , 'select' ), $userclass_parent , 'main,admin,nobody,public,classes,matchclass,member, no-excludes' ) . '</select>' ;
2007-12-22 12:39:27 +00:00
// .r_userclass("userclass_parent", $userclass_parent, "off", "admin,classes,matchclass,public,member").
2009-07-21 07:13:42 +00:00
$text .= " <div class='field-help'> " . UCSLAN_36 . " </div></td>
</ tr ></ table >
2007-12-22 12:39:27 +00:00
" ;
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
$text .= "
2009-07-21 07:13:42 +00:00
< div class = 'buttons-bar center' > " ;
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
if ( $params == 'edit' )
2006-12-02 04:36:16 +00:00
{
2017-01-09 17:07:47 +00:00
$text .= $frm -> admin_button ( 'createclass' , LAN_UPDATE , 'create' );
2012-11-26 14:41:32 -08:00
$text .= $frm -> admin_button ( 'updatecancel' , LAN_CANCEL , 'cancel' );
2017-01-09 17:07:47 +00:00
// $text .= "<input class='btn' type='submit' id='createclass' name='createclass' value='".LAN_UPDATE."' />";
2013-04-26 13:48:23 -07:00
// $text .= " <input class='btn' type='submit' id='updatecancel' name='updatecancel' value='".LAN_CANCEL."' />";
2009-07-21 07:13:42 +00:00
$text .= "
2008-11-09 20:31:10 +00:00
< input type = 'hidden' name = 'userclass_id' value = '{$userclass_id}' />
" ;
2006-12-02 04:36:16 +00:00
}
else
{
2017-01-09 17:07:47 +00:00
$text .= $frm -> admin_button ( 'createclass' , LAN_CREATE , 'create' );
2012-11-26 14:41:32 -08:00
$text .= $frm -> admin_button ( 'updatecancel' , LAN_CANCEL , 'cancel' );
2017-01-09 17:24:52 +00:00
// $text .= "<input class='btn' type='submit' id='createclass' name='createclass' value='".LAN_CREATE."' />
2013-04-26 13:48:23 -07:00
// <input class='btn' type='submit' id='updatecancel' name='updatecancel' value='".LAN_CANCEL."' />";
2009-07-21 07:13:42 +00:00
$text .= "
2008-11-09 20:31:10 +00:00
< input type = 'hidden' name = 'userclass_id' value = '0' /> " ;
2006-12-02 04:36:16 +00:00
}
2009-07-21 07:13:42 +00:00
$text .= " </div> " ;
2007-12-22 12:39:27 +00:00
$text .= " </form></div><br /><br /> " ;
2013-04-30 01:28:44 -07:00
// $text .= $e_userclass->show_graphical_tree();
2007-12-22 12:39:27 +00:00
2013-05-08 14:19:38 +03:00
$title = $params == 'edit' ? LAN_EDIT : LAN_CREATE ;
$ns -> tablerender ( ADLAN_38 . SEP . $title , $text );
unset ( $title );
2007-12-22 12:39:27 +00:00
break ; // End of 'config' option
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
// Initial User class(es)
//-----------------------------------
2015-03-01 12:43:02 -08:00
/*
2007-12-22 12:39:27 +00:00
case 'initial' :
2015-03-01 12:43:02 -08:00
2007-12-22 12:39:27 +00:00
$initial_classes = varset ( $pref [ 'initial_user_classes' ], '' );
$irc = explode ( ',' , $initial_classes );
$icn = array ();
foreach ( $irc as $i )
{
if ( trim ( $i )) $icn [] = $e_userclass -> uc_get_classname ( $i );
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
// $class_text = $e_userclass->uc_checkboxes('init_classes', $initial_classes, 'classes, force', TRUE);
2012-12-18 21:29:53 +00:00
$class_text = $e_userclass -> vetted_tree ( 'init_classes' , array ( $e_userclass , 'checkbox_desc' ), $initial_classes , 'classes, force, no-excludes' );
2007-12-22 12:39:27 +00:00
2012-11-30 13:47:06 -08:00
$mes -> addInfo ( UCSLAN_49 );
2007-12-22 12:39:27 +00:00
$text = " <div style='text-align:center'>
< form method = 'post' action = '".e_SELF."?initial' id = 'initialForm' >
2015-02-15 19:56:58 -08:00
< table class = 'table table-bordered adminform' >
< tr >< td > " .UCSLAN_43. " </ td >< td > " ;
2007-12-22 12:39:27 +00:00
if ( count ( $icn ) > 0 )
{
2015-02-15 19:56:58 -08:00
// $text .= implode(', ',$icn);
2007-12-22 12:39:27 +00:00
}
else
{
2017-01-09 17:07:47 +00:00
$text .= LAN_NONE ;
2007-12-22 12:39:27 +00:00
}
2015-02-15 19:56:58 -08:00
2007-12-22 12:39:27 +00:00
if ( $class_text )
{
2009-07-21 07:13:42 +00:00
$text .= $class_text . " </td></tr><tr><td> " ;
2007-12-22 12:39:27 +00:00
$sel_stage = varset ( $pref [ 'init_class_stage' ], 2 );
2015-02-15 19:56:58 -08:00
$text .= UCSLAN_45 . " <br /> </td>
2012-11-30 13:47:06 -08:00
< td >
2007-12-22 12:39:27 +00:00
< select class = 'tbox' name = 'init_class_stage' > \n
2007-12-26 16:32:05 +00:00
< option value = '1' " .( $sel_stage ==1 ? " selected = 'selected' " : " " ). " > " .UCSLAN_47. " </ option >
< option value = '2' " .( $sel_stage ==2 ? " selected = 'selected' " : " " ). " > " .UCSLAN_48. " </ option >
2012-11-30 13:47:06 -08:00
</ select >< span class = 'field-help' > " .UCSLAN_46. " </ span > " ;
2015-02-15 19:56:58 -08:00
$text .= " </td></tr></table>
< div class = 'buttons-bar' > " .
$frm -> admin_button ( 'set_initial_classes' , 'no-value' , 'create' , LAN_UPDATE )
. " </div> " ;
2007-12-22 12:39:27 +00:00
}
else
{
$text .= UCSLAN_39 ;
}
2015-02-15 19:56:58 -08:00
2007-12-22 12:39:27 +00:00
$text .= " </td></tr></table></form></div> " ;
2013-02-22 21:34:06 -08:00
$ns -> tablerender ( ADLAN_38 . SEP . UCSLAN_40 , $mes -> render () . $text );
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
break ; // End of 'initial'
2015-03-01 12:43:02 -08:00
*/
2007-12-22 12:39:27 +00:00
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
// Debug aids
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
case 'debug' :
// if (!check_class(e_UC_MAINADMIN)) break; // Let ordinary admins see this if they know enough to specify the URL
$text .= $e_userclass -> show_graphical_tree ( TRUE ); // Print with debug options
2017-01-09 17:07:47 +00:00
$ns -> tablerender ( LAN_SETTINGS , $text );
2008-12-29 16:11:02 +00:00
2012-11-26 14:41:32 -08:00
$text = " <table class='table adminlist'><tr><td colspan='5'>Class rights for first 20 users in database</td></tr>
2008-01-07 22:30:29 +00:00
< tr >< td > User ID </ td >< td > Disp Name </ td >< td > Raw classes </ td >< td > Inherited classes </ td >< td > Editable classes </ td ></ tr > " ;
2007-12-22 12:39:27 +00:00
$sql -> db_Select ( 'user' , 'user_id,user_name,user_class' , " ORDER BY user_id LIMIT 0,20 " , 'no_where' );
while ( $row = $sql -> db_Fetch ())
{
2008-01-07 22:30:29 +00:00
$inherit = $e_userclass -> get_all_user_classes ( $row [ 'user_class' ]);
$text .= " <tr><td> " . $row [ 'user_id' ] . " </td>
< td > " . $row['user_name'] . " </ td >< td > " . $row['user_class'] . " </ td >
< td > " . $inherit . " </ td >
< td > " . $e_userclass->get_editable_classes ( $inherit ). " </ td >
</ tr > " ;
2007-12-22 12:39:27 +00:00
}
$text .= " </table> " ;
2017-01-09 17:07:47 +00:00
$ns -> tablerender ( LAN_SETTINGS , $text );
2007-12-22 12:39:27 +00:00
break ; // End of 'debug'
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
// Configuration options
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
case 'options' :
2015-03-01 12:43:02 -08:00
/*
2007-12-22 12:39:27 +00:00
if ( ! check_class ( e_UC_MAINADMIN )) break ;
if ( isset ( $_POST [ 'add_class_tree' ]))
{ // Create a default tree
2008-11-29 21:16:54 +00:00
$message = UCSLAN_62 ;
2007-12-22 12:39:27 +00:00
$e_userclass -> set_default_structure ();
$e_userclass -> calc_tree ();
$e_userclass -> save_tree ();
2010-05-17 14:13:50 +00:00
$e_userclass -> readTree ( TRUE ); // Need to re-read the tree to show correct info
2007-12-22 12:39:27 +00:00
$message .= UCSLAN_64 ;
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'flatten_class_tree' ]))
{ // Remove the default tree
2012-12-29 12:12:51 +00:00
$message = UCSLAN_65 ;
$sql -> db_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 ;
2007-12-22 12:39:27 +00:00
}
if ( isset ( $_POST [ 'rebuild_tree' ]))
{
2012-12-29 12:12:51 +00:00
$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' ;
2007-12-22 12:39:27 +00:00
}
if ( $message )
{
2012-12-29 12:12:51 +00:00
$ns -> tablerender ( '' , " <div style='text-align:center'><b> " . $message . " </b></div> " );
2007-12-22 12:39:27 +00:00
}
2012-11-26 14:41:32 -08:00
$mes = e107 :: getMessage ();
2017-01-09 17:07:47 +00:00
$mes -> addWarning ( LAN_OPTIONS . " <br /> " . UCSLAN_53 );
2007-12-22 12:39:27 +00:00
2012-12-29 12:12:51 +00:00
$text = " <form method='post' action=' " . e_SELF . " ?options { $params } ' id='treesetForm'>
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2007-12-22 12:39:27 +00:00
< colgroup >
2012-11-26 14:41:32 -08:00
< col class = 'col-label' />
< col class = 'col-content' />
2007-12-22 12:39:27 +00:00
</ colgroup >
2012-11-26 14:41:32 -08:00
< 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). "
2007-12-22 12:39:27 +00:00
</ td >
2012-11-26 14:41:32 -08:00
</ 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 >
2012-12-29 12:12:51 +00:00
</ 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> " ;
2012-11-26 14:41:32 -08:00
2013-02-22 21:34:06 -08:00
$ns -> tablerender ( ADLAN_38 . SEP . LAN_PREFS , $mes -> render () . $text );
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
$text = " <form method='post' action=' " . e_SELF . " ?options' id='maintainForm'>
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2007-12-22 12:39:27 +00:00
< colgroup >
2012-11-26 14:41:32 -08:00
< col class = 'col-label' />
< col class = 'col-content' />
2007-12-22 12:39:27 +00:00
</ colgroup >
2012-11-26 14:41:32 -08:00
< 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 > " ;
2007-12-22 12:39:27 +00:00
$ns -> tablerender ( UCSLAN_71 , $text );
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
break ; // End of 'options'
2015-03-01 12:43:02 -08:00
*/
2007-12-22 12:39:27 +00:00
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
// Test options
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
case 'test' :
if ( ! check_class ( e_UC_MAINADMIN )) break ;
2012-12-18 21:21:05 +00:00
break ; // ...And disable for everyone at present
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'add_db_fields' ]))
{ // Add the extra DB fields
$message = " Add DB fields: " ;
$e_userclass -> update_db ( FALSE );
$message .= " Completed " ;
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'remove_db_fields' ]))
{ // Remove the DB fields
$message = " Remove DB fields: " ;
2016-02-15 00:14:45 -08:00
$sql -> gen ( " ALTER TABLE #userclass_classes DROP `userclass_parent`, DROP `userclass_accum`, DROP `userclass_visibility` " );
2007-12-22 12:39:27 +00:00
$message .= " Completed " ;
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'add_class_tree' ]))
{ // Create a default tree
$message = " Create default class tree: " ;
if ( ! $e_userclass -> update_db ( TRUE ))
{
$message .= " Must add new DB fields first " ;
}
else
{
$e_userclass -> set_default_structure ();
$e_userclass -> read_tree ( TRUE ); // Need to re-read the tree to show correct info
$message .= " Completed " ;
}
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'remove_class_tree' ]))
{ // Remove the default tree
$message = " Remove default class tree: " ;
$sql -> db_Delete ( " userclass_classes " , " `userclass_id` IN ( " . implode ( ',' , array ( e_UC_MAINADMIN , e_UC_MEMBER , e_UC_ADMIN , e_UC_ADMINMOD , e_UC_MODS , e_UC_USERS , e_UC_READONLY )) . " ) " );
$e_userclass -> read_tree ( TRUE ); // Need to re-read the tree to show correct info
$message .= " completed " ;
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
if ( isset ( $_POST [ 'rebuild_tree' ]))
{
$message = 'Rebuilding tree: ' ;
$e_userclass -> calc_tree ();
$e_userclass -> save_tree ();
$message .= " completed " ;
}
2008-12-29 16:11:02 +00:00
2007-12-22 12:39:27 +00:00
if ( $message )
{
$ns -> tablerender ( " " , " <div style='text-align:center'><b> " . $message . " </b></div> " );
}
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
$db_status = " Unknown " ;
$db_status = $e_userclass -> update_db ( TRUE ) ? " Updated " : " Original " ;
$text = " <div style='text-align:center'>
< form method = 'post' action = '".e_SELF."?test' id = 'testForm' >
2012-11-28 23:34:40 -08:00
< table class = 'table adminform' >
2007-12-22 12:39:27 +00:00
< tr >< td class = 'fcaption' style = 'text-align:center' colspan = '2' > Test Functions and Information </ td ></ tr > " ;
2009-07-21 07:13:42 +00:00
$text .= " <tr><td style='text-align:center' colspan='2'>DB Status: " . $db_status . " </td></tr> " ;
2015-07-13 19:09:30 -07:00
$text .= " <tr><td><input class='btn btn-default button' type='submit' name='add_db_fields' value='Add new DB fields' />First required step</td> " ;
$text .= " <td><input class='btn btn-default button' type='submit' name='remove_db_fields' value='Remove new DB fields' />Reverse the process</td></tr> " ;
$text .= " <tr><td><input class='btn btn-default button' type='submit' name='add_class_tree' value='Add class tree' />Optional default tree</td> " ;
$text .= " <td><input class='btn btn-default button' type='submit' name='remove_class_tree' value='Remove class tree' />Deletes the 'core' class entries</td></tr> " ;
$text .= " <tr><td><input class='btn btn-default button' type='submit' name='rebuild_tree' value='Rebuild class tree' />Sets up all the structures</td> " ;
$text .= " <td><input class='btn btn-default button' type='submit' name='' value='Spare' />Spare</td></tr> " ;
2009-07-21 07:13:42 +00:00
$text .= " <tr><td colspan='2'> </td></tr> " ;
$text .= " <tr><td colspan='2'> " . $e_userclass -> show_tree ( TRUE ) . " </td></tr> " ;
2007-12-22 12:39:27 +00:00
$text .= " </table> " ;
$text .= " </form>
</ div > " ;
$ns -> tablerender ( 'User classes - test features' , $text );
break ; // End of temporary test options
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
// Special fooling around
2008-12-29 16:11:02 +00:00
//-----------------------------------
2007-12-22 12:39:27 +00:00
case 'special' :
2009-07-14 19:26:24 +00:00
if ( ! check_class ( e_UC_MAINADMIN )) break ; // Let main admins see this if they know enough to specify the URL
2007-12-22 12:39:27 +00:00
$text = " <div style='text-align:center'>
< form method = 'post' action = '".e_SELF."?special' id = 'specialclassForm' > " ;
$text .= " <select name='class_select'> \n " ;
$text .= $e_userclass -> vetted_tree ( 'class_select' , array ( $e_userclass , 'select' ), $_POST [ 'class_select' ]);
$text .= " </select> \n " ;
$ns -> tablerender ( 'Select box with nested items' , $text );
$text = " <select multiple size='10' name='multi_class_select[]'> \n " ;
$text .= $e_userclass -> vetted_tree ( 'multi_class_select[]' , array ( $e_userclass , 'select' ), implode ( ',' , $_POST [ 'multi_class_select' ]));
$text .= " </select> \n " ;
$ns -> tablerender ( 'Multiple Select box with nested items' , $text );
$checked_class_list = implode ( ',' , $_POST [ 'classes_select' ]);
2008-02-16 12:03:27 +00:00
$text = " <table style=' " . ADMIN_WIDTH . " '><tr><td style='text-align:left'> " ;
2012-12-18 21:21:05 +00:00
$text .= $e_userclass -> vetted_tree ( 'classes_select' , array ( $e_userclass , 'checkbox' ), $checked_class_list , 'is-checkbox' );
2007-12-22 12:39:27 +00:00
$text .= " Classes: " . $checked_class_list ;
$text .= " </td><td style='text-align:left'> " ;
2012-12-18 21:21:05 +00:00
$text .= $e_userclass -> vetted_tree ( 'normalised_classes_select' , array ( $e_userclass , 'checkbox' ), $e_userclass -> normalise_classes ( $checked_class_list ), 'is-checkbox' );
2007-12-22 12:39:27 +00:00
$text .= " Normalised Classes: " . $e_userclass -> normalise_classes ( $checked_class_list );
$text .= " </td></tr></table> " ;
$ns -> tablerender ( 'Nested checkboxes, showing the effect of the normalise() routine' , $text );
$text = " Single class: " . $_POST [ 'class_select' ] . " <br />
Multi - select : " .implode(',', $_POST['multi_class_select'] ). " < br />
Check boxes : " .implode(',', $_POST['classes_select'] ). " < br /> " ;
2015-07-13 19:09:30 -07:00
$text .= " <input class='btn btn-default button' type='submit' value='Click to save' />
2007-12-22 12:39:27 +00:00
</ form > </ div > " ;
$ns -> tablerender ( 'Click on the button - the settings above should be remembered, and the $_POST values displayed' , $text );
break ; // End of 'debug'
} // End - switch ($action)
2008-02-16 12:03:27 +00:00
2010-02-07 19:42:07 +00:00
/**
* Log event to admin log
*
* @ param string $msg_num - 2 - digit event number ( MUST be as a string )
* @ param string $woffle - log detail
*
* @ return none
*/
2008-01-16 22:18:27 +00:00
function userclass2_adminlog ( $msg_num = '00' , $woffle = '' )
2007-01-20 15:59:42 +00:00
{
2010-02-07 19:42:07 +00:00
e107 :: getAdminLog () -> log_event ( 'UCLASS_' . $msg_num , $woffle , E_LOG_INFORMATIVE , '' );
2007-01-20 15:59:42 +00:00
}
2007-12-22 12:39:27 +00:00
2015-03-01 12:43:02 -08:00
/*
2007-12-22 12:39:27 +00:00
function userclass2_adminmenu ()
2007-01-20 15:59:42 +00:00
{
2010-03-11 11:56:23 +00:00
$tmp = array ();
if ( e_QUERY )
{
$tmp = explode ( " . " , e_QUERY );
}
$action = vartrue ( $tmp [ 0 ], 'list' );
2013-05-08 14:19:38 +03:00
if ( isset ( $_GET [ 'action' ]) && 'edit' == $_GET [ 'action' ]) $action = 'list' ;
2009-08-03 18:04:19 +00:00
$var [ 'list' ][ 'text' ] = LAN_MANAGE ;
$var [ 'list' ][ 'link' ] = 'userclass2.php' ;
2007-12-22 12:39:27 +00:00
2017-01-11 08:31:55 +00:00
$var [ 'config' ][ 'text' ] = LAN_CREATE ; // UCSLAN_25;
2009-08-03 18:04:19 +00:00
$var [ 'config' ][ 'link' ] = 'userclass2.php?config' ;
2007-12-22 12:39:27 +00:00
2009-11-26 21:43:38 +00:00
//DEPRECATED - use admin->users instead.
2015-03-01 12:43:02 -08:00
2017-01-11 08:31:55 +00:00
// $var['membs']['text'] = UCSLAN_26;
2015-03-01 12:43:02 -08:00
// $var['membs']['link'] ='userclass2.php?membs';
2007-12-22 12:39:27 +00:00
2009-08-03 18:04:19 +00:00
$var [ 'initial' ][ 'text' ] = UCSLAN_38 ;
$var [ 'initial' ][ 'link' ] = 'userclass2.php?initial' ;
2007-12-22 12:39:27 +00:00
2010-03-11 11:56:23 +00:00
if ( check_class ( e_UC_MAINADMIN ))
2007-01-20 15:59:42 +00:00
{
2017-01-11 08:31:55 +00:00
$var [ 'options' ][ 'text' ] = LAN_PREFS ; // UCSLAN_50;
2010-03-11 11:56:23 +00:00
$var [ 'options' ][ 'link' ] = 'userclass2.php?options' ;
2007-01-20 15:59:42 +00:00
2010-03-11 11:56:23 +00:00
if ( defined ( 'UC_DEBUG_OPTS' ))
{
2017-01-11 08:31:55 +00:00
$var [ 'debug' ][ 'text' ] = UCSLAN_27 ;
2010-03-11 11:56:23 +00:00
$var [ 'debug' ][ 'link' ] = 'userclass2.php?debug' ;
$var [ 'test' ][ 'text' ] = 'Test functions' ;
$var [ 'test' ][ 'link' ] = " userclass2.php?test " ;
2007-12-22 12:39:27 +00:00
2010-03-11 11:56:23 +00:00
$var [ 'specials' ][ 'text' ] = 'Special tests' ;
$var [ 'specials' ][ 'link' ] = " userclass2.php?special " ;
}
2007-01-20 15:59:42 +00:00
}
2013-02-22 21:34:06 -08:00
show_admin_menu ( ADLAN_38 , $action , $var );
2007-01-20 15:59:42 +00:00
}
2015-03-01 12:43:02 -08:00
*/
2007-01-20 15:59:42 +00:00
2009-11-05 12:26:44 +00:00
2015-03-01 12:43:02 -08:00
/*
2009-08-03 18:04:19 +00:00
class uclass_manager
{
2010-01-16 19:54:04 +00:00
public function __construct ()
2009-08-03 18:04:19 +00:00
{
global $user_pref ;
2009-11-05 17:32:19 +00:00
if ( isset ( $_POST [ 'etrigger_ecolumns' ]))
2009-08-03 18:04:19 +00:00
{
$user_pref [ 'admin_userclass_columns' ] = $_POST [ 'e-columns' ];
save_prefs ( 'user' );
}
2009-11-26 21:43:38 +00:00
$this -> fieldpref = ( varset ( $user_pref [ 'admin_userclass_columns' ])) ? $user_pref [ 'admin_userclass_columns' ] : array ( " userclass_id " , " userclass_name " , " userclass_description " );
2009-08-03 18:04:19 +00:00
$this -> fields = array (
2017-01-09 17:07:47 +00:00
'userclass_icon' => array ( 'title' => LAN_ICON , 'type' => 'icon' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' ),
2012-12-15 18:06:55 -08:00
'userclass_id' => array ( 'title' => LAN_ID , 'type' => 'int' , 'width' => '5%' , 'thclass' => 'left' ),
2017-01-09 17:07:47 +00:00
'userclass_name' => array ( 'title' => LAN_NAME , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_editclass' => array ( 'title' => LAN_MANAGER , 'type' => 'userclass' , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_parent' => array ( 'title' => LAN_PARENT , 'type' => 'userclass' , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_visibility' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclass' , 'width' => 'auto' , 'thclass' => 'left' ),
'userclass_type' => array ( 'title' => LAN_TYPE , 'type' => 'method' , 'width' => '10%' , 'thclass' => 'left' , 'class' => 'left' ),
2015-02-15 19:56:58 -08:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'width' => '10%' , 'thclass' => 'center last' , 'forced' => TRUE , 'class' => 'right' , 'readParms' => array ( 'deleteClass' => e_UC_NOBODY ))
2009-08-03 18:04:19 +00:00
);
}
2015-03-01 12:43:02 -08:00
// Show list of existing userclasses, followed by graphical tree of the hierarchy
2010-01-16 19:54:04 +00:00
public function show_existing ()
2009-08-03 18:04:19 +00:00
{
2009-11-05 12:26:44 +00:00
global $e_userclass ;
2009-11-26 21:43:38 +00:00
2009-11-05 12:26:44 +00:00
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$frm = new uclassFrm ;
2010-01-16 19:54:04 +00:00
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2009-11-26 21:43:38 +00:00
2009-11-05 12:26:44 +00:00
if ( ! $total = $sql -> db_Select ( 'userclass_classes' , '*' ))
2009-08-03 18:04:19 +00:00
{
2009-11-23 01:17:29 +00:00
$text = " " ;
2017-01-09 17:07:47 +00:00
$mes -> add ( LAN_NO_RECORDS_FOUND , E_MESSAGE_INFO );
2009-11-26 21:43:38 +00:00
2009-08-03 18:04:19 +00:00
}
else
{
2012-12-08 13:52:05 +01:00
$text = " <form method='post' action=' " . e_SELF . " ? " . e_QUERY . " '>
2009-08-03 18:04:19 +00:00
< fieldset id = 'core-userclass-list' >
2017-01-09 17:07:47 +00:00
< legend class = 'e-hideme' > " .LAN_UPDATED.': '.LAN_USERCLASS. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' > " .
2009-08-03 18:04:19 +00:00
$frm -> colGroup ( $this -> fields , $this -> fieldpref ) .
$frm -> thead ( $this -> fields , $this -> fieldpref ) .
" <tbody> " ;
$classes = $sql -> db_getList ( 'ALL' , FALSE , FALSE );
2009-10-21 07:31:07 +00:00
2009-08-03 18:04:19 +00:00
foreach ( $classes as $row )
2009-11-26 21:43:38 +00:00
{
2012-12-19 22:27:48 +00:00
$this -> fields [ 'options' ][ 'readParms' ][ 'deleteClass' ] = $e_userclass -> queryCanDeleteClass ( $row [ 'userclass_id' ]) ? '' : e_UC_NOBODY ;
$text .= $frm -> renderTableRow ( $this -> fields , $this -> fieldpref , $row , 'userclass_id' );
2009-08-03 18:04:19 +00:00
}
2009-11-26 21:43:38 +00:00
2009-11-23 01:17:29 +00:00
$text .= " </tbody></table></fieldset></form> " ;
2009-08-03 18:04:19 +00:00
}
2009-11-26 21:43:38 +00:00
2013-04-30 01:28:44 -07:00
// $text .= $e_userclass->show_graphical_tree(); // Show the tree as well - sometimes more useful
2010-01-16 19:54:04 +00:00
2013-05-08 14:19:38 +03:00
$ns -> tablerender ( ADLAN_38 , $mes -> render () . $text );
2009-08-03 18:04:19 +00:00
}
}
2010-01-16 19:54:04 +00:00
2010-07-23 23:21:48 +00:00
require_once ( e_ADMIN . 'footer.php' );
2015-03-01 12:43:02 -08:00
*/
2007-12-22 12:39:27 +00:00
2013-03-03 11:32:28 +00:00
// @TODO: Is this function still required? - Yes - setGroupStatus() used on class add/edit page
2006-12-02 04:36:16 +00:00
function headerjs ()
{
2010-03-11 11:56:23 +00:00
$params = e107 :: getRegistry ( 'pageParams' );
2008-11-09 20:31:10 +00:00
/*
2008-12-29 16:11:02 +00:00
* e107Ajax . fillForm demonstration
2008-11-09 20:31:10 +00:00
* Open Firebug console for Ajax transaction details
2008-12-29 16:11:02 +00:00
*
2008-11-09 20:31:10 +00:00
*/
$script_js = " <script type= \" text/javascript \" >
//<![CDATA[
2010-03-11 11:56:23 +00:00
" ;
2008-11-09 20:31:10 +00:00
2010-03-11 11:56:23 +00:00
// Edit mode only
if ( $params [ 0 ] == 'edit' )
{
$script_js .= "
e107 . runOnLoad ( function () {
document . observe ( 'click' , ( function ( event ){
var target = event . findElement ( 'a.userclass_edit' );
if ( target ) {
event . stop ();
// non-editable user class
if ( '#' == target . readAttribute ( 'href' )) return ;
//If link is clicked use it's href as a target
$ ( 'classForm' ) . fillForm ( $ ( document . body ), { handler : target . readAttribute ( 'href' ) });
2010-03-11 12:09:41 +00:00
new Effect . ScrollTo ( 'classForm' );
2010-03-11 11:56:23 +00:00
}
}));
});
//Observe fillForm errors
e107Event . register ( 'ajax_fillForm_error' , function ( transport ) {
//memo.error object contains the error message
//error handling will be extended in the near future
alert ( transport . memo . error . message );
});
/*// Click observer
document . observe ( 'click' , ( function ( event ){
var target = ( event . findElement ( 'a.userclass_edit' ) || event . findElement ( 'input#edit' ));
if ( target ) {
event . stop ();
//show cancel button in edit mod only
\ $ ( 'updatecancel' ) . show ();
//If link is clicked use it's href as a target
$ ( 'classForm' ) . fillForm ( $ ( document . body ), { handler : target . readAttribute ( 'href' ) });
}
}));
//run on e107 init finished (dom is loaded)
e107 . runOnLoad ( function () {
\ $ ( 'updatecancel' ) . hide (); //hide cancel button onload
});
//Observe fillForm errors
e107Event . register ( 'ajax_fillForm_error' , function ( transport ) {
//memo.error object contains the error message
//error handling will be extended in the near future
alert ( transport . memo . error . message );
}); */
" ;
}
2008-11-27 22:07:36 +00:00
2013-03-03 23:42:37 -08:00
//XXX FIXME Rewrite using jQuery selectors.
2010-03-11 11:56:23 +00:00
$script_js .= "
2008-11-27 22:07:36 +00:00
function setGroupStatus ( dropdown )
{
var temp1 = document . getElementById ( 'userclass_type_standard' );
var temp2 = document . getElementById ( 'userclass_type_groups' );
if ( ! temp1 || ! temp2 ) return ;
if ( dropdown . value == 0 )
{
temp1 . style . display = '' ;
temp2 . style . display = 'none' ;
}
else
{
temp2 . style . display = '' ;
temp1 . style . display = 'none' ;
}
2008-12-29 16:11:02 +00:00
}
2008-11-27 22:07:36 +00:00
2008-11-09 20:31:10 +00:00
//]]>
</ script > \n " ;
2010-03-11 11:56:23 +00:00
if ( $params [ 0 ] != 'membs' ) return $script_js ;
2006-12-02 04:36:16 +00:00
2010-03-11 11:56:23 +00:00
// We only want this JS on the class membership selection page
// XXX memebs action is deprecated now, remove this script?
2008-11-09 20:31:10 +00:00
$script_js .= " <script type= \" text/javascript \" >
2006-12-02 04:36:16 +00:00
//<![CDATA[
2008-12-29 16:11:02 +00:00
// Inspiration (and some of the code) from a script by Sean Geraty - Web Site: http://www.freewebs.com/sean_geraty/
2007-12-22 12:39:27 +00:00
// Script from: The JavaScript Source!! http://javascript.internet.com
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
// Control flags for list selection and sort sequence
// Sequence is on option value (first 2 chars - can be stripped off in form processing)
// It is assumed that the select list is in sort sequence initially
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
var singleSelect = true ; // Allows an item to be selected once only (i.e. in only one list at a time)
var sortSelect = true ; // Only effective if above flag set to true
var sortPick = true ; // Will order the picklist in sort sequence
2006-12-02 04:36:16 +00:00
2007-12-22 12:39:27 +00:00
// Initialise - invoked on load
2008-12-29 16:11:02 +00:00
function initIt ()
2007-12-22 12:39:27 +00:00
{
var selectList = document . getElementById ( \ " assignclass1 \" );
var pickList = document . getElementById ( \ " assignclass2 \" );
var pickOptions = pickList . options ;
pickOptions [ 0 ] = null ; // Remove initial entry from picklist (was only used to set default width)
selectList . focus (); // Set focus on the selectlist
}
// Adds a selected item into the picklist
2008-12-29 16:11:02 +00:00
function addIt ()
2007-12-22 12:39:27 +00:00
{
var selectList = document . getElementById ( \ " assignclass1 \" );
var selectIndex = selectList . selectedIndex ;
var selectOptions = selectList . options ;
var pickList = document . getElementById ( \ " assignclass2 \" );
var pickOptions = pickList . options ;
var pickOLength = pickOptions . length ;
// An item must be selected
2008-12-29 16:11:02 +00:00
if ( selectIndex > - 1 )
2007-12-22 12:39:27 +00:00
{
pickOptions [ pickOLength ] = new Option ( selectList [ selectIndex ] . text );
pickOptions [ pickOLength ] . value = selectList [ selectIndex ] . value ;
// If single selection, remove the item from the select list
2008-12-29 16:11:02 +00:00
if ( singleSelect )
2007-12-22 12:39:27 +00:00
{
selectOptions [ selectIndex ] = null ;
}
2008-12-29 16:11:02 +00:00
if ( sortPick )
2007-12-22 12:39:27 +00:00
{
var tempText ;
var tempValue ;
// Sort the pick list
2008-12-29 16:11:02 +00:00
// while (pickOLength > 0 && pickOptions[pickOLength].text < pickOptions[pickOLength-1].text)
while ( pickOLength > 0 && pickOptions [ pickOLength ] . text . toLowerCase () < pickOptions [ pickOLength - 1 ] . text . toLowerCase ())
2007-12-22 12:39:27 +00:00
{
tempText = pickOptions [ pickOLength - 1 ] . text ;
tempValue = pickOptions [ pickOLength - 1 ] . value ;
pickOptions [ pickOLength - 1 ] . text = pickOptions [ pickOLength ] . text ;
pickOptions [ pickOLength - 1 ] . value = pickOptions [ pickOLength ] . value ;
pickOptions [ pickOLength ] . text = tempText ;
pickOptions [ pickOLength ] . value = tempValue ;
pickOLength = pickOLength - 1 ;
}
}
}
}
// Deletes an item from the picklist
2008-12-29 16:11:02 +00:00
function delIt ()
2007-12-22 12:39:27 +00:00
{
var selectList = document . getElementById ( \ " assignclass1 \" );
var selectOptions = selectList . options ;
var selectOLength = selectOptions . length ;
var pickList = document . getElementById ( \ " assignclass2 \" );
var pickIndex = pickList . selectedIndex ;
var pickOptions = pickList . options ;
2006-12-02 04:36:16 +00:00
2008-12-29 16:11:02 +00:00
if ( pickIndex > - 1 )
2007-12-22 12:39:27 +00:00
{
// If single selection, replace the item in the select list
2008-12-29 16:11:02 +00:00
if ( singleSelect )
2007-12-22 12:39:27 +00:00
{
selectOptions [ selectOLength ] = new Option ( pickList [ pickIndex ] . text );
selectOptions [ selectOLength ] . value = pickList [ pickIndex ] . value ;
}
pickOptions [ pickIndex ] = null ;
2008-12-29 16:11:02 +00:00
if ( singleSelect && sortSelect )
2007-12-22 12:39:27 +00:00
{
var tempText ;
var tempValue ;
// Re-sort the select list - start from the bottom, swapping pairs, until the moved element is in the right place
// Commented out line sorts upper case first, then lower case. 'Active' line does case-insensitive sort
2008-12-29 16:11:02 +00:00
// while (selectOLength > 0 && selectOptions[selectOLength].text < selectOptions[selectOLength-1].text)
while ( selectOLength > 0 && selectOptions [ selectOLength ] . text . toLowerCase () < selectOptions [ selectOLength - 1 ] . text . toLowerCase ())
2007-12-22 12:39:27 +00:00
{
tempText = selectOptions [ selectOLength - 1 ] . text ;
tempValue = selectOptions [ selectOLength - 1 ] . value ;
selectOptions [ selectOLength - 1 ] . text = selectOptions [ selectOLength ] . text ;
selectOptions [ selectOLength - 1 ] . value = selectOptions [ selectOLength ] . value ;
selectOptions [ selectOLength ] . text = tempText ;
selectOptions [ selectOLength ] . value = tempValue ;
selectOLength = selectOLength - 1 ;
}
}
}
}
2008-12-29 16:11:02 +00:00
function clearMe ( clid )
2007-12-22 12:39:27 +00:00
{
location . href = document . location + \ " .clear. \" + clid;
}
2008-12-29 16:11:02 +00:00
function saveMe ( clid )
2007-12-22 12:39:27 +00:00
{
var strValues = \ " \" ;
var boxLength = document . getElementById ( 'assignclass2' ) . length ;
var count = 0 ;
2008-12-29 16:11:02 +00:00
if ( boxLength != 0 )
2007-12-22 12:39:27 +00:00
{
2008-12-29 16:11:02 +00:00
for ( i = 0 ; i < boxLength ; i ++ )
2007-12-22 12:39:27 +00:00
{
2008-12-29 16:11:02 +00:00
if ( count == 0 )
2007-12-22 12:39:27 +00:00
{
2006-12-02 04:36:16 +00:00
strValues = document . getElementById ( 'assignclass2' ) . options [ i ] . value ;
2008-12-29 16:11:02 +00:00
}
else
2007-12-22 12:39:27 +00:00
{
2006-12-02 04:36:16 +00:00
strValues = strValues + \ " , \" + document.getElementById('assignclass2').options[i].value;
2007-12-22 12:39:27 +00:00
}
count ++ ;
}
}
2008-12-29 16:11:02 +00:00
if ( strValues . length == 0 )
2007-12-22 12:39:27 +00:00
{
//alert(\"You have not made any selections\");
}
2008-12-29 16:11:02 +00:00
else
2007-12-22 12:39:27 +00:00
{
location . href = document . location + \ " . \" + clid + \" - \" + strValues;
}
}
//]]>
</ script > \n " ;
2006-12-02 04:36:16 +00:00
return $script_js ;
}
2007-12-22 12:39:27 +00:00
2006-12-02 04:36:16 +00:00
?>