- ".$obj->get('title')." |
+/**
+ * @package Multimenu
+ * @version 2.3.1
+ * @author Gigamaster, 2020 XCL PHP7
+ * @author Domifara
+ * @author Tom Hayakawa
+ * @copyright Copyright 2005-2021 XOOPSCube Project
+ * @license https://github.com/xoopscube/xcl/blob/master/docs/GPL_V2.txt
+ */
+
+if ( ! defined( 'XOOPS_ROOT_PATH' ) ) {
+ exit();
+}
+
+class multimenu {
+
+ private $mnum;
+
+ private $db;
+
+ private $root;
+
+ public $menu_num;
+
+ public function __construct( $menu_num = '01' ) {
+
+ $this->root = XCube_Root::getSingleton();
+ $this->mnum = $menu_num;
+ $this->db = XoopsDatabaseFactory::getDatabaseConnection();
+ }
+
+ public function mm_admin_menu( $currentoption = 0, $breadcrumb = "" ) {
+ $tblColors = array();
+ $tblColors[0] = $tblColors[1] = $tblColors[2] = $tblColors[3] = $tblColors[4] = $tblColors[5] = $tblColors[6] = $tblColors[7] = $tblColors[8] = $tblColors[99] = 'unselected';
+ $tblColors[ $currentoption ] = 'selected';
+
+ echo '
+
+ ' . $this->root->mContext->mModule->mXoopsModule->getShow( 'name' ) . ' : ' . $breadcrumb . '
+ |
';
+
+ echo '';
+ }
+
+ private function im_admin_clean() {
+ global $xoopsDB;
+ $i = 0;
+ $db = $xoopsDB->prefix( "multimenu" . $this->menu_num );
+ $result = $xoopsDB->query( "SELECT id FROM " . $db . " ORDER BY weight ASC" );
+ while ( list( $id ) = $xoopsDB->fetchrow( $result ) ) {
+ $xoopsDB->queryF( "UPDATE " . $db . " SET weight='$i' WHERE id=$id" );
+ $i ++;
+ }
+ }
+
+ public function im_admin_list() {
+ xoops_cp_header();
+ $this->mm_admin_menu( (int) $this->mnum, _AD_MULTIMENU_ADMIN . $this->mnum );
+
+ echo '' . _AD_MULTIMENU_ADMIN . $this->mnum . '
';
+ echo '";
- echo "
";
- xoops_cp_footer();
- }
- public function im_admin_new() {
- if ( ! $GLOBALS['xoopsGTicket']->check() ) {
- redirect_header('index.php',3,$GLOBALS['xoopsGTicket']->getErrors());
+
+ xoops_cp_footer();
}
- global $xoopsDB;
- xoops_cp_header();
- $this->mm_admin_menu(intval($this->mnum), _AD_MULTIMENU_ADMIN.$this->mnum );
- echo "
";
- xoops_cp_footer();
- }
-/*
- private function im_admin_update_flow(&$obj){
- $block_id = isset($_POST['block_id']) ? intval($_POST['block_id']) : 0;
- $parent_id = isset($_POST['parent_id']) ? intval($_POST['parent_id']) : 0;
- $title = isset($_POST['title']) ? $_POST['title'] : 'NoTitle';
- $link = isset($_POST['link']) ? $_POST['link'] : 'http://www.google.co.jp/';
- $hide = empty($_POST['hide']) ? 0 : 1;
- $groups = isset($_POST['groups']) ? $_POST['groups'] : '';
- $groups = (is_array($groups)) ? implode(" ", $groups) : '';
- $target = isset($_POST['target']) ? $_POST['target'] : '_self';
-
- $obj->set('block_id', $block_id);
- $obj->set('parent_id', $parent_id);
- $obj->set('title', $title);
- $obj->set('hide', $hide);
- $obj->set('link', $link);
- $obj->set('weight', 255);
- $obj->set('target', $target);
- $obj->set('groups', $groups);
- }
-*/
- private function im_admin_update_menu(&$obj){
- $title = isset($_POST['title']) ? $this->root->mContext->mRequest->getRequest('title') : 'NoTitle';
- $link = isset($_POST['link']) ? $this->root->mContext->mRequest->getRequest('link') : 'http://www.google.co.jp/';
- $hide = empty($_POST['hide']) ? 0 : 1;
- $groups = isset($_POST['groups']) ? $this->root->mContext->mRequest->getRequest('groups') : '';
- $groups = (is_array($groups)) ? implode(" ", array_map( 'intval' , $groups ) ) : '';
- $target = isset($_POST['target']) ? $this->root->mContext->mRequest->getRequest('target') : '_self';
- //$obj->set('id', $id);
- $obj->set('title', $title);
- $obj->set('hide', $hide);
- $obj->set('link', $link);
- $obj->set('target', $target);
- $obj->set('groups', $groups);
- }
- public function im_admin_update(){
- if ( ! $GLOBALS['xoopsGTicket']->check() ) {
- redirect_header('index.php',3,$GLOBALS['xoopsGTicket']->getErrors());
+ $GLOBALS['xoopsGTicket']->addTicketXoopsFormElement( $form, __LINE__ );
+
+ $form->display();
+
+ xoops_cp_footer();
+ }
+
+ private function im_admin_update_menu( &$obj ) {
+ $title = isset( $_POST['title'] ) ? $this->root->mContext->mRequest->getRequest( 'title' ) : 'NoTitle';
+ $link = isset( $_POST['link'] ) ? $this->root->mContext->mRequest->getRequest( 'link' ) : 'https://github.com/xoopscube/xcl';
+ $hide = empty( $_POST['hide'] ) ? 0 : 1;
+ $groups = isset( $_POST['groups'] ) ? $this->root->mContext->mRequest->getRequest( 'groups' ) : '';
+ $groups = ( is_array( $groups ) ) ? implode( " ", array_map( 'intval', $groups ) ) : '';
+ $target = isset( $_POST['target'] ) ? $this->root->mContext->mRequest->getRequest( 'target' ) : '_self';
+ //$obj->set('id', $id);
+ $obj->set( 'title', $title );
+ $obj->set( 'hide', $hide );
+ $obj->set( 'link', $link );
+ $obj->set( 'target', $target );
+ $obj->set( 'groups', $groups );
+ }
+
+ public function im_admin_update() {
+ if ( ! $GLOBALS['xoopsGTicket']->check() ) {
+ redirect_header( 'index.php', 3, $GLOBALS['xoopsGTicket']->getErrors() );
+ }
+ $modhand = xoops_getmodulehandler( 'menu' );
+ $modhand->setTable( $this->mnum );
+ $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
+ if ( $id == 0 ) {
+ $obj = $modhand->create();
+ } else {
+ $obj = $modhand->get( $id );
+ }
+ $this->im_admin_update_menu( $obj );
+ $success = $modhand->insert( $obj );
+ if ( ! $success ) {
+ redirect_header( "index.php?mnum=" . $this->mnum, 2, _AD_MULTIMENU_UPDATED );
+ } else {
+ $modhand->im_admin_clean();
+ redirect_header( "index.php?mnum=" . $this->mnum, 2, _AD_MULTIMENU_UPDATED );
+ }
+ exit();
}
- $modhand = xoops_getmodulehandler('menu');
- $modhand->setTable($this->mnum);
- $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
- if ( $id == 0 ) {
- $obj = $modhand->create();
- } else {
- $obj = $modhand->get($id);
- }
- $this->im_admin_update_menu($obj);
- $success = $modhand->insert($obj);
- if ( !$success ) {
- redirect_header("index.php?mnum=".$this->mnum,2,_AD_MULTIMENU_UPDATED);
- }else {
- $modhand->im_admin_clean();
- redirect_header("index.php?mnum=".$this->mnum,2,_AD_MULTIMENU_UPDATED);
- }
- exit();
- }
- public function im_admin_edit () {
- xoops_cp_header();
- $this->mm_admin_menu(intval($this->mnum), _AD_MULTIMENU_ADMIN.$this->mnum );
- echo "
";
- xoops_cp_footer();
- }
- public function im_admin_del () {
- $del = isset($_POST['del']) ? 1 : 0;
- $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
+ $form->display();
- if ( $del == 1 ) {
- if ( ! $GLOBALS['xoopsGTicket']->check() ) {
- redirect_header('index.php',3,$GLOBALS['xoopsGTicket']->getErrors());
+ xoops_cp_footer();
+ }
+
+ public function im_admin_del() {
+ $del = isset( $_POST['del'] ) ? 1 : 0;
+ $id = isset( $_GET['id'] ) ? (int) $_GET['id'] : 0;
+
+ if ( $del == 1 ) {
+ if ( ! $GLOBALS['xoopsGTicket']->check() ) {
+ redirect_header( 'index.php', 3, $GLOBALS['xoopsGTicket']->getErrors() );
+ }
+ $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : $id;
+ $modhand = xoops_getmodulehandler( 'menu' );
+ $modhand->setTable( $this->mnum );
+ $obj = $modhand->get( $id );
+
+ if ( $modhand->delete( $obj ) ) {
+ $modhand->im_admin_clean( $this->mnum );
+ redirect_header( "index.php?mnum=" . $this->mnum, 2, _AD_MULTIMENU_UPDATED );
+ } else {
+ redirect_header( "index.php?mnum=" . $this->mnum, 2, _AD_MULTIMENU_NOTUPDATED );
+ }
+ exit();
+ } else {
+ xoops_cp_header();
+ echo "" . _AD_MULTIMENU_ADMIN . $this->mnum . "
";
+ xoops_confirm( array(
+ 'op' => 'del',
+ 'id' => $id,
+ 'del' => 1
+ ) + $GLOBALS['xoopsGTicket']->getTicketArray( __LINE__ ), 'index.php?op=del&mnum=' . $this->mnum, _AD_MULTIMENU_SUREDELETE );
+ xoops_cp_footer();
}
- $id = isset($_POST['id']) ? intval($_POST['id']) : $id;
- $modhand = xoops_getmodulehandler('menu');
- $modhand->setTable($this->mnum);
- $obj = $modhand->get($id);
-
- if ( $modhand->delete($obj) ) {
- $modhand->im_admin_clean($this->mnum);
- redirect_header("index.php?mnum=".$this->mnum, 2, _AD_MULTIMENU_UPDATED);
- } else {
- redirect_header("index.php?mnum=".$this->mnum, 2, _AD_MULTIMENU_NOTUPDATED);
- }
- exit();
- } else {
- xoops_cp_header();
- echo ""._AD_MULTIMENU_ADMIN.$this->mnum."
";
- xoops_confirm(array('op' => 'del', 'id' => $id, 'del' => 1) + $GLOBALS['xoopsGTicket']->getTicketArray( __LINE__ ), 'index.php?op=del&mnum='.$this->mnum, _AD_MULTIMENU_SUREDELETE);
- xoops_cp_footer();
- }
- }
- public function im_admin_move () {
- $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
- $weight = isset($_GET['weight']) ? intval($_GET['weight']) : 0;
- $db = $this->db->prefix( "multimenu".$this->mnum );
- $this->db->queryF("UPDATE `".$db."` SET `weight` = `weight` + 1 WHERE `weight` >= ".$weight." AND `id` <> ".$id);
- $this->db->queryF("UPDATE `".$db."` SET `weight` = ".$weight." WHERE `id` = ".$id);
- $modhand = xoops_getmodulehandler('menu');
- $modhand->im_admin_clean($this->mnum);
- }
+ }
+
+ public function im_admin_move() {
+ $id = isset( $_GET['id'] ) ? (int) $_GET['id'] : 0;
+ $weight = isset( $_GET['weight'] ) ? (int) $_GET['weight'] : 0;
+ $db = $this->db->prefix( "multimenu" . $this->mnum );
+ $this->db->queryF( "UPDATE `" . $db . "` SET `weight` = `weight` + 1 WHERE `weight` >= " . $weight . " AND `id` <> " . $id );
+ $this->db->queryF( "UPDATE `" . $db . "` SET `weight` = " . $weight . " WHERE `id` = " . $id );
+ $modhand = xoops_getmodulehandler( 'menu' );
+ $modhand->im_admin_clean( $this->mnum );
+ }
}
-?>
\ No newline at end of file
+
diff --git a/html/modules/multiMenu/admin/index.php b/html/modules/multiMenu/admin/index.php
index 9272783..d7df9c9 100644
--- a/html/modules/multiMenu/admin/index.php
+++ b/html/modules/multiMenu/admin/index.php
@@ -1,9 +1,8 @@
\ No newline at end of file
diff --git a/html/modules/multiMenu/admin/menu.php b/html/modules/multiMenu/admin/menu.php
index 3939598..b578f04 100644
--- a/html/modules/multiMenu/admin/menu.php
+++ b/html/modules/multiMenu/admin/menu.php
@@ -1,28 +1,36 @@
\ No newline at end of file
+$adminmenu[9]['link'] = "admin/myblocksadmin.php";
diff --git a/html/modules/multiMenu/admin/myblocksadmin.php b/html/modules/multiMenu/admin/myblocksadmin.php
index 631a09d..51be22f 100644
--- a/html/modules/multiMenu/admin/myblocksadmin.php
+++ b/html/modules/multiMenu/admin/myblocksadmin.php
@@ -1,71 +1,72 @@
//
-// ------------------------------------------------------------------------- //
-
-include_once( '../../../include/cp_header.php' ) ;
-include_once( 'mygrouppermform.php' ) ;
-include_once( XOOPS_ROOT_PATH.'/class/xoopsblock.php' ) ;
-
-
-$xoops_system_url = XOOPS_URL . '/modules/system' ;
-
-if( !defined( 'XOOPS_CUBE_LEGACY' ) ) {
- $xoops_system_path = XOOPS_ROOT_PATH . '/modules/system' ;
-
- // language files
- $language = $xoopsConfig['language'] ;
- if( ! file_exists( "$xoops_system_path/language/$language/admin/blocksadmin.php") ) $language = 'english' ;
-
- include_once( "$xoops_system_path/language/$language/admin.php" ) ;
- include_once( "$xoops_system_path/language/$language/admin/blocksadmin.php" ) ;
- $group_defs = file( "$xoops_system_path/language/$language/admin/groups.php" ) ;
- foreach( $group_defs as $def ) {
- if( strstr( $def , '_AM_ACCESSRIGHTS' ) || strstr( $def , '_AM_ACTIVERIGHTS' ) ) eval( $def ) ;
- }
-}
+/**
+ * @package Multimenu
+ * @version 2.3.1
+ * @author Gigamaster, 2020 XCL PHP7
+ * @author Tom Hayakawa
+ * @copyright Copyright 2005-2021 XOOPSCube Project
+ * @license https://github.com/xoopscube/xcl/blob/master/docs/GPL_V2.txt
+ */
+
+include_once( '../../../include/cp_header.php' );
+include_once( 'mygrouppermform.php' );
+include_once( XOOPS_ROOT_PATH . '/class/xoopsblock.php' );
// check $xoopsModule
-if( ! is_object( $xoopsModule ) ) redirect_header( XOOPS_URL.'/user.php' , 1 , _NOPERM ) ;
+if ( ! is_object( $xoopsModule ) ) {
+ redirect_header( XOOPS_URL . '/user.php', 1, _NOPERM );
+}
// get blocks owned by the module
-$block_arr =& XoopsBlock::getByModule( $xoopsModule->mid() ) ;
+// $block_arr =& XoopsBlock::getByModule( $xoopsModule->mid() ) ; @gigamaster make call dynamic
+$block_arr =& (new XoopsBlock)->getByModule( $xoopsModule->mid() ) ;
// add by Tom
-sort ($block_arr);
-reset ($block_arr);
+sort( $block_arr );
+reset( $block_arr );
-function list_blocks()
-{
- global $xoopsUser , $xoopsConfig , $xoopsDB ;
- global $block_arr , $xoops_system_url ;
+function list_blocks() {
+ global $xoopsUser, $xoopsConfig, $xoopsDB;
+ global $block_arr;
- $side_descs = array( 0 => _AM_SBLEFT, 1 => _AM_SBRIGHT, 3 => _AM_CBLEFT, 4 => _AM_CBRIGHT, 5 => _AM_CBCENTER ) ;
+ $side_descs = array( 0 => _AM_SBLEFT, 1 => _AM_SBRIGHT, 3 => _AM_CBLEFT, 4 => _AM_CBRIGHT, 5 => _AM_CBCENTER );
// displaying TH
echo "
-
- "._AM_BLKDESC." | "._AM_TITLE." | "._AM_SIDE." | "._AM_WEIGHT." | "._AM_VISIBLE." | "._AM_ACTION." |
+
+
+ " . _AM_BLKDESC . " |
+ " . _AM_TITLE . " |
+ " . _AM_SIDE . " |
+ " . _AM_WEIGHT . " |
+ " . _AM_VISIBLE . " |
+ " . _AM_ACTION . " |
+
";
// blocks displaying loop
- if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
- $blockAdmin = XOOPS_URL."/modules/legacy/admin/index.php?action=BlockEdit&bid=";
- $blockInstallAdmin = XOOPS_URL."/modules/legacy/admin/index.php?action=BlockInstallEdit&bid=";
- }else{
- $blockAdmin = $xoops_system_url."/admin.php?fct=blocksadmin&op=edit&bid=";
+ if ( defined( 'XOOPS_CUBE_LEGACY' ) ) {
+ $blockAdmin = XOOPS_URL . "/modules/legacy/admin/index.php?action=BlockEdit&bid=";
+ $blockInstallAdmin = XOOPS_URL . "/modules/legacy/admin/index.php?action=BlockInstallEdit&bid=";
}
- $class = 'even' ;
- foreach( array_keys( $block_arr ) as $i ) {
- $visible = ( $block_arr[$i]->getVar("visible") == 1 ) ? _YES : _NO ;
- $weight = $block_arr[$i]->getVar("weight") ;
- $side_desc = $side_descs[ $block_arr[$i]->getVar("side") ] ;
- $title = $block_arr[$i]->getVar("title") ;
- if( $title == '' ) $title = " " ;
- $name = $block_arr[$i]->getVar("name") ;
- $bid = $block_arr[$i]->getVar("bid") ;
+ $iconVisible = '';
+ $iconInvisible = '';
+
+
+ $mBlockEdit = '';
+ $mBlockInstall = '';
+
+ $class = 'even';
+ foreach ( array_keys( $block_arr ) as $i ) {
+ $visible = ( $block_arr[ $i ]->getVar( "visible" ) == 1 ) ? $iconVisible : $iconInvisible;
+ $weight = $block_arr[ $i ]->getVar( "weight" );
+ $side_desc = $side_descs[ $block_arr[ $i ]->getVar( "side" ) ];
+ $title = $block_arr[ $i ]->getVar( "title" );
+ if ( $title == '' ) {
+ $title = " ";
+ }
+ $name = $block_arr[ $i ]->getVar( "name" );
+ $bid = $block_arr[ $i ]->getVar( "bid" );
echo "
$name |
@@ -74,60 +75,53 @@ function list_blocks()
$weight |
$visible |
";
- if ($visible === _YES) {
- echo ""._EDIT."";
+ if ( $visible === $iconVisible ) {
+ echo "$mBlockEdit";
} else {
- echo ""._INSTALL."";
+ echo "$mBlockInstall";
}
echo " |
-
\n" ;
-
- $class = ( $class == 'even' ) ? 'odd' : 'even' ;
+ \n";
+
+ $class = ( $class == 'even' ) ? 'odd' : 'even';
}
echo "|
\n" ;
+
\n";
}
-function list_groups()
-{
- global $xoopsUser , $xoopsConfig , $xoopsDB ;
- global $xoopsModule , $block_arr , $xoops_system_url ;
+function list_groups() {
+ global $xoopsUser, $xoopsConfig, $xoopsDB;
+ global $xoopsModule, $block_arr;
- foreach( array_keys( $block_arr ) as $i ) {
- $item_list[ $block_arr[$i]->getVar("bid") ] = $block_arr[$i]->getVar("title") ;
+ foreach ( array_keys( $block_arr ) as $i ) {
+ $item_list[ $block_arr[ $i ]->getVar( "bid" ) ] = $block_arr[ $i ]->getVar( "title" );
}
- $form = new MyXoopsGroupPermForm( '' , 1 , 'block_read' , _MD_AM_ADGS ) ;
- $form->addAppendix('module_admin',$xoopsModule->mid(),$xoopsModule->name().' '._AM_ACTIVERIGHTS);
- $form->addAppendix('module_read',$xoopsModule->mid(),$xoopsModule->name().' '._AM_ACCESSRIGHTS);
- foreach( $item_list as $item_id => $item_name) {
- $form->addItem( $item_id , $item_name ) ;
+ $form = new MyXoopsGroupPermForm( '', 1, 'block_read', _MD_AM_ADGS );
+ $form->addAppendix( 'module_admin', $xoopsModule->mid(), $xoopsModule->name() . ' ' . _AM_ACTIVERIGHTS );
+ $form->addAppendix( 'module_read', $xoopsModule->mid(), $xoopsModule->name() . ' ' . _AM_ACCESSRIGHTS );
+ foreach ( $item_list as $item_id => $item_name ) {
+ $form->addItem( $item_id, $item_name );
}
- echo $form->render() ;
+ echo $form->render();
}
-
-if( ! empty( $_POST['submit'] ) ) {
- include( "mygroupperm.php" ) ;
- redirect_header( XOOPS_URL."/modules/".$xoopsModule->dirname()."/admin/myblocksadmin.php" , 1 , _MD_AM_DBUPDATED );
+if ( ! empty( $_POST['submit'] ) ) {
+ include( "mygroupperm.php" );
+ redirect_header( XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/admin/myblocksadmin.php", 1, _MD_AM_DBUPDATED );
}
-xoops_cp_header() ;
+xoops_cp_header();
+
-// for multimenu admin menu
-//echo "".$xoopsModule->name()."
\n" ;
require 'admin_function.php';
-$class = new multimenu($menu_num);
-$class->mm_admin_menu(0, _AM_BADMIN );
+$class = new multimenu( $menu_num );
-//echo ""._AM_BADMIN."
\n" ;
-list_blocks() ;
-if( !defined( 'XOOPS_CUBE_LEGACY' ) ) {
- list_groups() ;
-}
-xoops_cp_footer() ;
+$class->mm_admin_menu( 0, _AM_BADMIN );
+
+list_blocks();
-?>
\ No newline at end of file
+xoops_cp_footer();
diff --git a/html/modules/multiMenu/admin/myblocksadmin.txt b/html/modules/multiMenu/admin/myblocksadmin.txt
deleted file mode 100644
index cdae53c..0000000
--- a/html/modules/multiMenu/admin/myblocksadmin.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-- myblocksadmin -
-
-
-SUMMARY:
-
-This files add blocks admin into your module.
-
-
-BACKGROUND:
-
-XOOPS's admin of blocks and groups will be hard to use,
-when many modules is installed.
-If each module has the block management screen for itself,
-webmasters using XOOPS will feel it easy, I think.
-I will recommend it to the module developers by all means.
-
-
-HOW TO USE:
-
-1) copy these 3 files into XOOPS_ROOT_PATH./modules/(your module)/admin/
-2) edit admin/menu.php and add a menu item like this:
-
- $adminmenu[] = array( 'title' => _MI_SYSTEM_ADMENU2 ,
- 'link' => "admin/myblocksadmin.php" ) ;
-
-That's all !
-
-
-
-CHANGELOG:
-
-2003-12-18 0.03 for XOOPS <= 2.0.3 patch
- (gperm_handler->deleteByModule() has only 1 parameter)
-2003-12-12 0.02 'module_read' and 'module_admin' to be able to change
-2003-12-4 0.01 first release
-
-
-
-COPYRIGHT:
-
-I do not insist on the right of these codes, and don't guarantee.
-
diff --git a/html/modules/multiMenu/admin/mygroupperm.php b/html/modules/multiMenu/admin/mygroupperm.php
index d767bd4..0ea8ab2 100644
--- a/html/modules/multiMenu/admin/mygroupperm.php
+++ b/html/modules/multiMenu/admin/mygroupperm.php
@@ -1,59 +1,70 @@
add(new Criteria('gperm_name', $gperm_name));
- if (isset($gperm_itemid)) {
- $criteria->add(new Criteria('gperm_itemid', intval($gperm_itemid)));
+function myDeleteByModule( $DB, $gperm_modid, $gperm_name = null, $gperm_itemid = null ) {
+ $criteria = new CriteriaCompo( new Criteria( 'gperm_modid', (int) $gperm_modid ) );
+ if ( isset( $gperm_name ) ) {
+ $criteria->add( new Criteria( 'gperm_name', $gperm_name ) );
+ if ( isset( $gperm_itemid ) ) {
+ $criteria->add( new Criteria( 'gperm_itemid', (int) $gperm_itemid ) );
}
}
- $sql = "DELETE FROM ".$DB->prefix('group_permission').' '.$criteria->renderWhere();
- if (!$result = $DB->query($sql)) {
+ $sql = "DELETE FROM " . $DB->prefix( 'group_permission' ) . ' ' . $criteria->renderWhere();
+ if ( ! $result = $DB->query( $sql ) ) {
return false;
}
+
return true;
}
-
// include '../../../include/cp_header.php'; GIJ
-$modid = isset($HTTP_POST_VARS['modid']) ? intval($HTTP_POST_VARS['modid']) : 1;
+$modid = isset( $HTTP_POST_VARS['modid'] ) ? (int) $HTTP_POST_VARS['modid'] : 1;
// we dont want system module permissions to be changed here ( 1 -> 0 GIJ)
-if ($modid <= 0 || !is_object($xoopsUser) || !$xoopsUser->isAdmin($modid)) {
- redirect_header(XOOPS_URL.'/index.php', 1, _NOPERM);
+if ( $modid <= 0 || ! is_object( $xoopsUser ) || ! $xoopsUser->isAdmin( $modid ) ) {
+ redirect_header( XOOPS_URL . '/index.php', 1, _NOPERM );
exit();
}
-$module_handler =& xoops_gethandler('module');
-$module =& $module_handler->get($modid);
-if (!is_object($module) || !$module->getVar('isactive')) {
- redirect_header(XOOPS_URL.'/admin.php', 1, _MODULENOEXIST);
+$module_handler =& xoops_gethandler( 'module' );
+$module =& $module_handler->get( $modid );
+if ( ! is_object( $module ) || ! $module->getVar( 'isactive' ) ) {
+ redirect_header( XOOPS_URL . '/admin.php', 1, _MODULENOEXIST );
exit();
}
-$member_handler =& xoops_gethandler('member');
-$group_list =& $member_handler->getGroupList();
-if (is_array($HTTP_POST_VARS['perms']) && !empty($HTTP_POST_VARS['perms'])) {
- $gperm_handler = xoops_gethandler('groupperm');
- foreach ($HTTP_POST_VARS['perms'] as $perm_name => $perm_data) {
- foreach( $perm_data['itemname' ] as $item_id => $item_name ) {
+$member_handler =& xoops_gethandler( 'member' );
+$group_list =& $member_handler->getGroupList();
+if ( is_array( $HTTP_POST_VARS['perms'] ) && ! empty( $HTTP_POST_VARS['perms'] ) ) {
+ $gperm_handler = xoops_gethandler( 'groupperm' );
+ foreach ( $HTTP_POST_VARS['perms'] as $perm_name => $perm_data ) {
+ foreach ( $perm_data['itemname'] as $item_id => $item_name ) {
// checking code
// echo "" ;
// var_dump( $HTTP_POST_VARS['perms'] ) ;
// exit ;
- if (false != myDeleteByModule($gperm_handler->db,$modid,$perm_name,$item_id)) {
- if( empty( $perm_data['groups'] ) ) continue ;
- foreach ($perm_data['groups'] as $group_id => $item_ids) {
- // foreach ($item_ids as $item_id => $selected) {
- $selected = isset( $item_ids[ $item_id ] ) ? $item_ids[ $item_id ] : 0 ;
- if ($selected == 1) {
+ if ( false != myDeleteByModule( $gperm_handler->db, $modid, $perm_name, $item_id ) ) {
+ if ( empty( $perm_data['groups'] ) ) {
+ continue;
+ }
+ foreach ( $perm_data['groups'] as $group_id => $item_ids ) {
+ // foreach ($item_ids as $item_id => $selected) {
+ $selected = isset( $item_ids[ $item_id ] ) ? $item_ids[ $item_id ] : 0;
+ if ( $selected == 1 ) {
// make sure that all parent ids are selected as well
- if ($perm_data['parents'][$item_id] != '') {
- $parent_ids = explode(':', $perm_data['parents'][$item_id]);
- foreach ($parent_ids as $pid) {
- if ($pid != 0 && !in_array($pid, array_keys($item_ids))) {
+ if ( $perm_data['parents'][ $item_id ] != '' ) {
+ $parent_ids = explode( ':', $perm_data['parents'][ $item_id ] );
+ foreach ( $parent_ids as $pid ) {
+ if ( $pid != 0 && ! in_array( $pid, array_keys( $item_ids ) ) ) {
// one of the parent items were not selected, so skip this item
- $msg[] = sprintf(_MD_AM_PERMADDNG, ''.$perm_name.'', ''.$perm_data['itemname'][$item_id].'', ''.$group_list[$group_id].'').' ('._MD_AM_PERMADDNGP.')';
+ $msg[] = sprintf(_MD_AM_PERMADDNG, ''.$perm_name.'',
+ ''.$perm_data['itemname'][$item_id].'',
+ ''.$group_list[$group_id].'').' ('._MD_AM_PERMADDNGP.')';
continue 2;
}
}
@@ -64,30 +75,20 @@ function myDeleteByModule($DB, $gperm_modid, $gperm_name = null, $gperm_itemid =
$gperm->setVar('gperm_modid', $modid);
$gperm->setVar('gperm_itemid', $item_id);
if (!$gperm_handler->insert($gperm)) {
- $msg[] = sprintf(_MD_AM_PERMADDNG, ''.$perm_name.'', ''.$perm_data['itemname'][$item_id].'', ''.$group_list[$group_id].'');
+ $msg[] = sprintf(_MD_AM_PERMADDNG, ''.$perm_name.'',
+ ''.$perm_data['itemname'][$item_id].'',
+ ''.$group_list[$group_id].'');
} else {
- $msg[] = sprintf(_MD_AM_PERMADDOK, ''.$perm_name.'', ''.$perm_data['itemname'][$item_id].'', ''.$group_list[$group_id].'');
+ $msg[] = sprintf(_MD_AM_PERMADDOK, ''.$perm_name.'',
+ ''.$perm_data['itemname'][$item_id].'',
+ ''.$group_list[$group_id].'');
}
unset($gperm);
}
}
} else {
- $msg[] = sprintf(_MD_AM_PERMRESETNG, $module->getVar('name'));
+ $msg[] = sprintf( _MD_AM_PERMRESETNG, $module->getVar( 'name' ) );
}
}
}
}
-/*
-$backlink = XOOPS_URL.'/admin.php';
-if ($module->getVar('hasadmin')) {
- $adminindex = $module->getInfo('adminindex');
- if ($adminindex) {
- $backlink = XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$adminindex;
- }
-}
-
-$msg[] = '
'._BACK.'';
-xoops_cp_header();
-xoops_result($msg);
-xoops_cp_footer(); GIJ */
-?>
\ No newline at end of file
diff --git a/html/modules/multiMenu/admin/mygrouppermform.php b/html/modules/multiMenu/admin/mygrouppermform.php
index 8440278..f989448 100644
--- a/html/modules/multiMenu/admin/mygrouppermform.php
+++ b/html/modules/multiMenu/admin/mygrouppermform.php
@@ -1,89 +1,63 @@
//
-// ------------------------------------------------------------------------ //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// You may not change or alter any portion of this comment or credits //
-// of supporting developers from this source code or any supporting //
-// source code which is considered copyrighted (c) material of the //
-// original comment or credit authors. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details. //
-// //
-// You should have received a copy of the GNU General Public License //
-// along with this program; if not, write to the Free Software //
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
-// ------------------------------------------------------------------------ //
-// Author: Kazumi Ono (AKA onokazu) //
-// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
-// Project: The XOOPS Project //
-// ------------------------------------------------------------------------- //
+/**
+ * @package Multimenu
+ * @version 2.3.1
+ * @author Gigamaster, 2020 XCL PHP7
+ * @author Other : Kazumi Ono (AKA onokazu), grouppermform.php v 1.4
+ * @copyright Copyright 2005-2021 XOOPSCube Project
+ * @license https://github.com/xoopscube/xcl/blob/master/docs/GPL_V2.txt
+ */
-require_once XOOPS_ROOT_PATH.'/class/xoopsform/formelement.php';
-require_once XOOPS_ROOT_PATH.'/class/xoopsform/formhidden.php';
-require_once XOOPS_ROOT_PATH.'/class/xoopsform/formbutton.php';
-require_once XOOPS_ROOT_PATH.'/class/xoopsform/formelementtray.php';
-require_once XOOPS_ROOT_PATH.'/class/xoopsform/form.php';
+require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelement.php';
+require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhidden.php';
+require_once XOOPS_ROOT_PATH . '/class/xoopsform/formbutton.php';
+require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelementtray.php';
+require_once XOOPS_ROOT_PATH . '/class/xoopsform/form.php';
/**
* Renders a form for setting module specific group permissions
- *
- * @author Kazumi Ono
- * @copyright copyright (c) 2000-2003 XOOPS.org
- *
+ * @author Kazumi Ono
+ * @copyright copyright (c) 2000-2021
* @package kernel
* @subpackage form
*/
-class MyXoopsGroupPermForm extends XoopsForm
-{
+class MyXoopsGroupPermForm extends XoopsForm {
/**
* Module ID
* @var int
*/
- var $_modid;
+ public $_modid;
/**
* Tree structure of items
* @var array
*/
- var $_itemTree;
+ public $_itemTree;
/**
* Name of permission
* @var string
*/
- var $_permName;
+ public $_permName;
/**
* Description of permission
* @var string
*/
- var $_permDesc;
+ public $_permDesc;
/**
* Appendix
* @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
*/
- var $_appendix = array() ;
+ public $_appendix = array();
/**
* Constructor
*/
- function MyXoopsGroupPermForm($title, $modid, $permname, $permdesc)
- {
-// $this->XoopsForm($title, 'groupperm_form', XOOPS_URL.'/modules/system/admin/groupperm.php', 'post'); GIJ
- $this->XoopsForm($title, 'groupperm_form', '' , 'post');
- $this->_modid = intval($modid);
+ public function __construct( $title, $modid, $permname, $permdesc ) {
+ $this->XoopsForm( $title, 'groupperm_form', '', 'post' );
+ $this->_modid = (int) $modid;
$this->_permName = $permname;
$this->_permDesc = $permdesc;
- $this->addElement(new XoopsFormHidden('modid', $this->_modid));
+ $this->addElement( new XoopsFormHidden( 'modid', $this->_modid ) );
}
/**
@@ -92,14 +66,14 @@ function MyXoopsGroupPermForm($title, $modid, $permname, $permdesc)
* @param string $itemName
* @param int $itemId
* @param int $itemParent
+ *
* @access public
*/
- function addItem($itemId, $itemName, $itemParent = 0)
- {
- $this->_itemTree[$itemParent]['children'][] = $itemId;
- $this->_itemTree[$itemId]['parent'] = $itemParent;
- $this->_itemTree[$itemId]['name'] = $itemName;
- $this->_itemTree[$itemId]['id'] = $itemId;
+ function addItem( $itemId, $itemName, $itemParent = 0 ) {
+ $this->_itemTree[ $itemParent ]['children'][] = $itemId;
+ $this->_itemTree[ $itemId ]['parent'] = $itemParent;
+ $this->_itemTree[ $itemId ]['name'] = $itemName;
+ $this->_itemTree[ $itemId ]['id'] = $itemId;
}
/**
@@ -107,9 +81,13 @@ function addItem($itemId, $itemName, $itemParent = 0)
*
* @access public
*/
- function addAppendix($permName,$itemId,$itemName)
- {
- $this->_appendix[] = array('permname'=>$permName,'itemid'=>$itemId,'itemname'=>$itemName,'selected'=>false);
+ function addAppendix( $permName, $itemId, $itemName ) {
+ $this->_appendix[] = array(
+ 'permname' => $permName,
+ 'itemid' => $itemId,
+ 'itemname' => $itemName,
+ 'selected' => false
+ );
}
/**
@@ -117,18 +95,18 @@ function addAppendix($permName,$itemId,$itemName)
*
* @param int $itemId
* @param array $childIds
+ *
* @access private
*/
- function _loadAllChildItemIds($itemId, &$childIds)
- {
- if (!empty($this->_itemTree[$itemId]['children'])) {
- $first_child = $this->_itemTree[$itemId]['children'];
- foreach ($first_child as $fcid) {
- array_push($childIds, $fcid);
- if (!empty($this->_itemTree[$fcid]['children'])) {
- foreach ($this->_itemTree[$fcid]['children'] as $_fcid) {
- array_push($childIds, $_fcid);
- $this->_loadAllChildItemIds($_fcid, $childIds);
+ function _loadAllChildItemIds( $itemId, &$childIds ) {
+ if ( ! empty( $this->_itemTree[ $itemId ]['children'] ) ) {
+ $first_child = $this->_itemTree[ $itemId ]['children'];
+ foreach ( $first_child as $fcid ) {
+ array_push( $childIds, $fcid );
+ if ( ! empty( $this->_itemTree[ $fcid ]['children'] ) ) {
+ foreach ( $this->_itemTree[ $fcid ]['children'] as $_fcid ) {
+ array_push( $childIds, $_fcid );
+ $this->_loadAllChildItemIds( $_fcid, $childIds );
}
}
}
@@ -141,109 +119,113 @@ function _loadAllChildItemIds($itemId, &$childIds)
* @return string
* @access public
*/
- function render()
- {
+ function render() {
// load all child ids for javascript codes
- foreach (array_keys($this->_itemTree) as $item_id) {
- $this->_itemTree[$item_id]['allchild'] = array();
- $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']);
+ foreach ( array_keys( $this->_itemTree ) as $item_id ) {
+ $this->_itemTree[ $item_id ]['allchild'] = array();
+ $this->_loadAllChildItemIds( $item_id, $this->_itemTree[ $item_id ]['allchild'] );
}
- $gperm_handler =& xoops_gethandler('groupperm');
- $member_handler =& xoops_gethandler('member');
- $glist =& $member_handler->getGroupList();
- foreach (array_keys($glist) as $i) {
+ $gperm_handler =& xoops_gethandler( 'groupperm' );
+ $member_handler =& xoops_gethandler( 'member' );
+ $glist =& $member_handler->getGroupList();
+ foreach ( array_keys( $glist ) as $i ) {
// get selected item id(s) for each group
- $selected = $gperm_handler->getItemIds($this->_permName, $i, $this->_modid);
- $ele = new MyXoopsGroupFormCheckBox($glist[$i], 'perms['.$this->_permName.']', $i, $selected);
- $ele->setOptionTree($this->_itemTree);
+ $selected = $gperm_handler->getItemIds( $this->_permName, $i, $this->_modid );
+ $ele = new MyXoopsGroupFormCheckBox( $glist[ $i ], 'perms[' . $this->_permName . ']', $i, $selected );
+ $ele->setOptionTree( $this->_itemTree );
- foreach( $this->_appendix as $key => $append ) {
- $this->_appendix[$key]['selected'] = $gperm_handler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid ) ;
+ foreach ( $this->_appendix as $key => $append ) {
+ $this->_appendix[ $key ]['selected'] = $gperm_handler->checkRight( $append['permname'], $append['itemid'], $i, $this->_modid );
}
- $ele->setAppendix($this->_appendix);
- $this->addElement($ele);
- unset($ele);
+ $ele->setAppendix( $this->_appendix );
+ $this->addElement( $ele );
+ unset( $ele );
}
// GIJ start
- $jstray = new XoopsFormElementTray(' ');
- $jsuncheckbutton = new XoopsFormButton('', 'none', _NONE, 'button');
- $jsuncheckbutton->setExtra( "onclick=\"with(document.groupperm_form){for(i=0;isetExtra( "onclick=\"with(document.groupperm_form){for(i=0;iaddElement( $jsuncheckbutton ) ;
- $jstray->addElement( $jscheckbutton ) ;
- $this->addElement($jstray);
+ $jstray = new XoopsFormElementTray( ' ' );
+ $jsuncheckbutton = new XoopsFormButton( '', 'none', _NONE, 'button' );
+ $jsuncheckbutton->setExtra( "onclick=\"with(document.groupperm_form){for(i=0;isetExtra( "onclick=\"with(document.groupperm_form){for(i=0;iaddElement( $jsuncheckbutton );
+ $jstray->addElement( $jscheckbutton );
+ $this->addElement( $jstray );
// GIJ end
- $tray = new XoopsFormElementTray('');
- $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset'));
- $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
- $this->addElement($tray);
+ $tray = new XoopsFormElementTray( '' );
+
+ $buttonCancel = new XoopsFormButton( '', 'reset', _CANCEL, 'reset' );
+ $tray->addElement( $buttonCancel );
+
+ $buttonSubmit = new XoopsFormButton( '', 'submit', _SUBMIT, 'submit' );
+ $tray->addElement( $buttonSubmit );
+
+ $this->addElement( $tray );
+
+ $ret = '' . $this->getTitle() . '
' . $this->_permDesc . '
';
+ $ret .= "