<?php
################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- #
## --------------------------------------------------------------------------- #
## ApPHP AdminPanel Pro #
## Developed by: ApPHP <hide@address.com> #
## License: GNU LGPL v.3 #
## Site: http://www.apphp.com/php-adminpanel/ #
## Copyright: ApPHP AdminPanel (c) 2006-2011. All rights reserved. #
## #
################################################################################
// Initialize the session.
session_start();
require_once("../inc/classes/session.class.php");
require_once("../inc/checkAdminPagePermissions.php");
require_once("../inc/config.inc.php");
require_once("../inc/settings.inc.php");
require_once("../inc/functions.inc.php");
require_once("../inc/languages/".$SETTINGS['site_language'].".php");
if(!page_access_allowed($_SERVER['SCRIPT_NAME'])) redirect_to("access_denied.php");
//--------------------------------------------------------------------------
$aid = isset($_GET['aid']) ? (int)$_GET['aid'] : "0";
$user_type = isset($_GET['t']) ? $_GET['t'] : "admin";
$table_name = (($user_type == "admin") ? TABLE_ADMINS : TABLE_USERS);
$table_href = (($user_type == "admin") ? "admins" : "users");
$table_field_name = (($user_type == "admin") ? "admin_id" : "user_id");
$adm_status = isset($_SESSION['adm_status']) ? $_SESSION['adm_status'] : "";
$full_access = ($adm_status == "main admin") ? true : false;
$css_class = isset($SETTINGS['datagrid_css_style']) ? $SETTINGS['datagrid_css_style'] : "default";
$page_breadcrumbs = (($user_type == "admin") ? "admins.php" : "users.php");
$first_dg_mode = isset($_REQUEST['ar_mode']) ? $_REQUEST['ar_mode'] : "";
$first_dg_rid = isset($_REQUEST['ar_rid']) ? (int)$_REQUEST['ar_rid'] : "0";
$menu_id = "0";
$admin_id = "0";
$user_id = "0";
$user_name = "";
//--------------------------------------------------------------------------
// get user name
$sql = "SELECT * FROM ".(($user_type == "admin") ? TABLE_ADMINS : TABLE_USERS)." WHERE id = '".$aid."'";
$db->Query($sql);
if($row = $db->FetchArray()){
$user_name = $row['first_name']." ".$row['last_name'];
}
$sql = "SELECT admin_id, user_id, menu_id FROM ".TABLE_MENU_ACCESS_RIGHTS." WHERE id = '".$first_dg_rid."'";
$db->Query($sql);
if($row = $db->FetchArray()){
$menu_id = $row['menu_id'];
$admin_id = $row['admin_id'];
$user_id = $row['user_id'];
}
$sql = "SELECT ".TABLE_MENU.".id
FROM ".TABLE_MENU_ACCESS_RIGHTS."
INNER JOIN ".$table_name." ON ".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = ".$table_name.".id
INNER JOIN ".TABLE_MENU." ON ".TABLE_MENU_ACCESS_RIGHTS.".menu_id = ".TABLE_MENU.".id
WHERE
".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = '".$aid."' AND
".TABLE_MENU.".is_menu_group = 1 ";
$db->Query($sql);
$menu_ids = "-1";
while($row = $db->FetchArray()){
$menu_ids .= ", ".$row['id'];
}
$sql_parent_ids = "SELECT ".TABLE_MENU.".id
FROM ".TABLE_MENU_ACCESS_RIGHTS."
INNER JOIN ".$table_name." ON ".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = ".$table_name.".id
INNER JOIN ".TABLE_MENU." ON ".TABLE_MENU_ACCESS_RIGHTS.".menu_id = ".TABLE_MENU.".id
WHERE
".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = '".$aid."' AND
".TABLE_MENU.".is_menu_group = 0 AND
".TABLE_MENU.".parent_id ='".$menu_id."'";
$db->Query($sql_parent_ids);
$menu_ids2 = "-1";
while($row = $db->FetchArray()){
$menu_ids2 .= ", ".$row['id'];
}
//print_r($menu_ids);
//echo "<br>";
//print_r($menu_ids2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><?php echo $SETTINGS['site_name']; ?> :: <?php echo lang('admin_panel'); ?></title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link href="../styles/<?php echo $SETTINGS['css_style'];?>/style.css" type="text/css" rel="stylesheet">
</head>
<!-- BEGIN MAIN CONTENT ARE -->
<body dir="<?php echo $SETTINGS['language_dir'];?>">
<?php echo page_breadcrumbs($page_breadcrumbs); ?>
<br />
<?php
################################################################################
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling: |
## +---------------------------------------------------------------------------+
## *** define a relative (virtual) path to datagrid.class.php file and "pear"
## *** directory (relatively to the current file)
## *** RELATIVE PATH ONLY ***
//
define ("DATAGRID_DIR", "../modules/datagrid/"); /* Ex.: "datagrid/" */
define ("PEAR_DIR", "../modules/datagrid/pear/"); /* Ex.: "datagrid/pear/" */
require_once(DATAGRID_DIR.'datagrid.class.php');
require_once(PEAR_DIR.'PEAR.php');
require_once(PEAR_DIR.'DB.php');
## *** creating variables that we need for database connection
$config = new Config();
$DB_USER = $config->getUser();
$DB_PASS = $config->getPassword();
$DB_HOST = $config->getHost();
$DB_NAME = $config->getDatabase();
$DB_TYPE = $config->getDatabaseType();
ob_start();
$db_conn = DB::factory($DB_TYPE); /* don't forget to change on appropriate db type */
$result_conn = $db_conn->connect(DB::parseDSN($DB_TYPE.'://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }
## *** put a primary key on the first place
$sql = "SELECT
".TABLE_MENU_ACCESS_RIGHTS.".id,
".TABLE_MENU_ACCESS_RIGHTS.".admin_id,
".TABLE_MENU_ACCESS_RIGHTS.".user_id,
".TABLE_MENU_ACCESS_RIGHTS.".menu_id,
".TABLE_MENU.".name as menu_name,
IF(".TABLE_MENU_ACCESS_RIGHTS.".is_accessible = 1, 'Yes', 'No') as is_accessible
FROM ".TABLE_MENU_ACCESS_RIGHTS."
INNER JOIN ".TABLE_MENU." ON ".TABLE_MENU_ACCESS_RIGHTS.".menu_id = ".TABLE_MENU.".id
INNER JOIN ".$table_name." ON ".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = ".$table_name.".id
WHERE
".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = '".$aid."' AND
".TABLE_MENU.".is_menu_group = 1 ";
## *** set needed options and create a new class instance
$debug_mode = false; /* display SQL statements while processing */
$messaging = true; /* display system messages on a screen */
$unique_prefix = "ar_"; /* prevent overlays - must be started with a letter */
$dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
if(strtolower(_SITE_MODE) == "demo") $dgrid->isDemo = true;
## *** set data source with needed options
$default_order_field = "menu_id";
$default_order_type = "ASC";
$dgrid->dataSource($db_conn, $sql, $default_order_field, $default_order_type);
##
##
## +---------------------------------------------------------------------------+
## | 2. General Settings: |
## +---------------------------------------------------------------------------+
## *** set encoding and collation (default: utf8/utf8_unicode_ci)
/// $dg_encoding = "utf8";
/// $dg_collation = "utf8_unicode_ci";
/// $dgrid->SetEncoding($dg_encoding, $dg_collation);
## *** set interface language (default - English)
$dg_language = $SETTINGS['site_language'];
$dgrid->setInterfaceLang($dg_language);
## *** set direction: "ltr" or "rtr" (default - "ltr")
$direction = $SETTINGS['language_dir'];
$dgrid->SetDirection($direction);
## *** set layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - customized
$layouts = array("view"=>"0", "edit"=>"0", "details"=>"1", "filter"=>"1");
$dgrid->setLayouts($layouts);
/// $details_template = "<table><tr><td>{field_name_1}</td><td>{field_name_2}</td></tr>...</table>";
/// $dgrid->setTemplates("","",$details_template);
## *** set modes for operations ("type" => "link|button|image")
## *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
$modes = array(
"add" =>array("view"=>$full_access, "edit"=>false, "type"=>"link"),
"edit" =>array("view"=>$full_access, "edit"=>$full_access, "type"=>"link", "byFieldValue"=>""),
"cancel" =>array("view"=>true, "edit"=>true, "type"=>"link"),
"details" =>array("view"=>true, "edit"=>false, "type"=>"link"),
"delete" =>array("view"=>$full_access, "edit"=>false, "type"=>"image")
);
$dgrid->setModes($modes);
## *** allow scrolling on datagrid
/// $scrolling_option = false;
/// $dgrid->allowScrollingSettings($scrolling_option);
## *** set scrolling settings (optional)
/// $scrolling_width = "90%";
/// $scrolling_height = "100%";
/// $dgrid->setScrollingSettings($scrolling_width, $scrolling_height);
## *** allow mulirow operations
// $multirow_option = true;
// $dgrid->allowMultirowOperations($multirow_option);
/// $multirow_operations = array(
/// "delete" => array("view"=>true),
/// "details" => array("view"=>true),
/// "my_operation_name" => array("view"=>true, "flag_name"=>"my_flag_name", "flag_value"=>"my_flag_value", "tooltip"=>"Do something with selected", "image"=>"image.gif")
/// );
/// $dgrid->setMultirowOperations($multirow_operations);
## *** set CSS class for datagrid
## *** "default" or "blue" or "gray" or "green" or "pink" or your own css file
$dgrid->setCssClass($css_class);
## *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.)
$http_get_vars = array("t", "aid");
$dgrid->setHttpGetVars($http_get_vars);
## *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
## *** format (in which mode to allow processing of another datagrids)
## *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
$anotherDatagrids = array("armo_"=>array("view"=>false, "edit"=>false, "details"=>false));
$dgrid->setAnotherDatagrids($anotherDatagrids);
## *** set DataGrid caption
$dg_caption = "Access Rights for ".$user_name." (".$user_type.")";
$dgrid->setCaption($dg_caption);
$dgrid->navigationBar = "<a href='".$table_href.".php'>« Back to ".ucfirst($table_href)."</a>";
##
##
## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings: |
## +---------------------------------------------------------------------------+
## *** set printing option: true(default) or false
$printing_option = true;
$dgrid->allowPrinting($printing_option);
## *** set exporting option: true(default) or false and relative (virtual) path
## *** to export directory (relatively to datagrid.class.php file).
## *** Ex.: "" - if we use current datagrid folder
$exporting_option = false;
$exporting_directory = "../tmp/export/";
$dgrid->allowExporting($exporting_option, $exporting_directory);
##
##
## +---------------------------------------------------------------------------+
## | 4. Sorting & Paging Settings: |
## +---------------------------------------------------------------------------+
## *** set sorting option: true(default) or false
/// $sorting_option = true;
/// $dgrid->allowSorting($sorting_option);
## *** set paging option: true(default) or false
$paging_option = true;
$rows_numeration = false;
$numeration_sign = "N #";
$dgrid->allowPaging($paging_option, $rows_numeration, $numeration_sign);
## *** set paging settings
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$top_paging = array();
$pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
$default_page_size = 10;
$paging_arrows = array("first"=>"|<<", "previous"=>"<<", "next"=>">>", "last"=>">>|");
$dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);
## +---------------------------------------------------------------------------+
## | 5. Filter Settings: |
## +---------------------------------------------------------------------------+
## *** set filtering option: true or false(default)
# $filtering_option = true;
# $show_search_type = true;
# $dgrid->allowFiltering($filtering_option, $show_search_type);
## *** set aditional filtering settings
# //$fill_from_array = array("0"=>"No", "1"=>"Yes"); /* as "value"=>"option" */
# $filtering_fields = array(
# );
# $dgrid->setFieldsFiltering($filtering_fields);
## +---------------------------------------------------------------------------+
## | 6. View Mode Settings: |
## +---------------------------------------------------------------------------+
## *** set view mode table properties
$vm_table_properties = array("width"=>"70%");
$dgrid->setViewModeTableProperties($vm_table_properties);
## *** set columns in view mode
## *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
## *** "barchart" : number format in SELECT SQL must be equal with number format in max_value
$vm_colimns = array(
"menu_name" =>array("header"=>lang("menu"), "type"=>"label", "align"=>"left", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>true|false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
"is_accessible" =>array("header"=>"Accessible", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>true|false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
);
$dgrid->setColumnsInViewMode($vm_colimns);
## *** set auto-genereted columns in view mode
// $auto_column_in_view_mode = false;
// $dgrid->setAutoColumnsInViewMode($auto_column_in_view_mode);
## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode Settings: |
## +---------------------------------------------------------------------------+
## *** set add/edit mode table properties
$em_table_properties = array("width"=>"70%");
$dgrid->setEditModeTableProperties($em_table_properties);
## *** set details mode table properties
$dm_table_properties = array("width"=>"70%");
$dgrid->setDetailsModeTableProperties($dm_table_properties);
## *** set settings for add/edit/details modes
$table_name_ = TABLE_MENU_ACCESS_RIGHTS;
$primary_key = "id";
$condition = $table_field_name."='".$aid."' AND menu_id IN (".$menu_ids.")";
$dgrid->setTableEdit($table_name_, $primary_key, $condition);
## *** set columns in edit mode
$fill_from_array_accessible = array("0"=>"No", "1"=>"Yes"); /* as "value"=>"option" */
$em_columns = array(
"menu_id" => array("header"=>"Menu Name", "type"=>"textbox", "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>(($first_dg_mode == "edit") ? true : false), "maxlength"=>"-1", "default"=>"", "unique"=>true, "unique_condition"=>$table_field_name."='".$aid."'", "visible"=>"true", "on_js_event"=>""),
"is_accessible" => array("header"=>"Is Accessible?", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"0", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_accessible, "view_type"=>"dropdownlist(default)|radiobutton", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
$table_field_name => array("header"=>"", "type"=>"hidden", "req_type"=>"st", "default"=>$aid, "visible"=>"true", "unique"=>false),
);
$dgrid->setColumnsInEditMode($em_columns);
## *** set auto-genereted columns in edit mode
// $auto_column_in_edit_mode = false;
// $dgrid->setAutoColumnsInEditMode($auto_column_in_edit_mode);
## *** set foreign keys for add/edit/details modes (if there are linked tables)
$foreign_keys = array(
"menu_id"=>array("table"=>TABLE_MENU, "field_key"=>"id", "field_name"=>"name", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>TABLE_MENU.".is_menu_group = 1", "order_by_field"=>"order_index", "order_type"=>"ASC", "on_js_event"=>""),
);
$dgrid->setForeignKeysEdit($foreign_keys);
##
##
## +---------------------------------------------------------------------------+
## | 8. Bind the DataGrid: |
## +---------------------------------------------------------------------------+
## *** bind the DataGrid and draw it on the screen
$dgrid->bind();
ob_end_flush();
##
################################################################################
if($first_dg_mode == "delete"){
// delete all sub-menus
$sql = "DELETE
FROM ".TABLE_MENU_ACCESS_RIGHTS."
WHERE
".(($user_type == "admin") ? "admin_id = '".(int)$admin_id."'" : "user_id = '".(int)$user_id."'")." AND
menu_id IN (SELECT id FROM ".TABLE_MENU." WHERE parent_id='".(int)$menu_id."')";
$db->Exec($sql);
}else if($first_dg_mode == "edit" || $first_dg_mode == "details"){
echo "<br />";
################################################################################
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling: |
## +---------------------------------------------------------------------------+
$result_conn = $db_conn->connect(DB::parseDSN('mysql://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }
## *** put a primary key on the first place
$sql = "SELECT
".TABLE_MENU_ACCESS_RIGHTS.".id,
".TABLE_MENU_ACCESS_RIGHTS.".admin_id,
".TABLE_MENU_ACCESS_RIGHTS.".user_id,
".TABLE_MENU_ACCESS_RIGHTS.".menu_id,
".TABLE_MENU.".name as menu_name,
IF(".TABLE_MENU_ACCESS_RIGHTS.".is_accessible = 1, 'Yes', 'No') as is_accessible
FROM ".TABLE_MENU_ACCESS_RIGHTS."
INNER JOIN ".TABLE_MENU." ON ".TABLE_MENU_ACCESS_RIGHTS.".menu_id = ".TABLE_MENU.".id
INNER JOIN ".$table_name." ON ".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = ".$table_name.".id
WHERE
".TABLE_MENU_ACCESS_RIGHTS.".".$table_field_name." = '".$aid."' AND
".TABLE_MENU.".is_menu_group = 0 AND
".TABLE_MENU_ACCESS_RIGHTS.".menu_id IN (".$sql_parent_ids.")";
ob_start();
## *** set needed options and create a new class instance
$debug_mode = false; /* display SQL statements while processing */
$messaging = true; /* display system messages on a screen */
$unique_prefix = "armo_"; /* prevent overlays - must be started with a letter */
$dgrid1 = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
## *** set data source with needed options
$default_order_field = "menu_id";
$default_order_type = "ASC";
$dgrid1->dataSource($db_conn, $sql, $default_order_field, $default_order_type);
##
## +---------------------------------------------------------------------------+
## | 2. General Settings: |
## +---------------------------------------------------------------------------+
## *** set encoding and collation (default: utf8/utf8_unicode_ci)
/// $dg_encoding = "utf8";
/// $dg_collation = "utf8_unicode_ci";
/// $dgrid1->SetEncoding($dg_encoding, $dg_collation);
## *** set interface language (default - English)
## *** (en) - English (de) - German (se) - Swedish (hr) - Bosnian/Croatian
## *** (hu) - Hungarian (es) - Espanol (ca) - Catala (fr) - Francais
## *** (nl) - Netherlands/"Vlaams"(Flemish) (it) - Italiano (pl) - Polish
## *** (ch) - Chinese (sr) - Serbian (bg) - Bulgarian (pb) - Brazilian Portuguese
## *** (ar) - Arabic (tr) - Turkish (cz) - Czech
/// $dg_language = "en";
/// $dgrid1->setInterfaceLang($dg_language);
## *** set direction: "ltr" or "rtr" (default - "ltr")
/// $direction = "ltr";
/// $dgrid1->setDirection($direction);
## *** set layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - customized
$layouts = array("view"=>"0", "edit"=>"0", "details"=>"1", "filter"=>"1");
$dgrid1->setLayouts($layouts);
/// $details_template = "<table><tr><td>{field_name_1}</td><td>{field_name_2}</td></tr>...</table>";
/// $dgrid1->setTemplates("","",$details_template);
## *** set modes for operations ("type" => "link|button|image")
## *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
$modes = array(
"add" =>array("view"=>$full_access, "edit"=>false, "type"=>"link"),
"edit" =>array("view"=>$full_access, "edit"=>$full_access, "type"=>"link", "byFieldValue"=>""),
"cancel" =>array("view"=>true, "edit"=>true, "type"=>"link"),
"details" =>array("view"=>false, "edit"=>false, "type"=>"link"),
"delete" =>array("view"=>$full_access, "edit"=>false, "type"=>"image")
);
$dgrid1->setModes($modes);
## *** allow scrolling on datagrid
/// $scrolling_option = false;
/// $dgrid1->allowScrollingSettings($scrolling_option);
## *** set scrolling settings (optional)
/// $scrolling_width = "90%";
/// $scrolling_height = "100%";
/// $dgrid1->setScrollingSettings($scrolling_width, $scrolling_height);
## *** allow mulirow operations
// $multirow_option = true;
// $dgrid1->allowMultirowOperations($multirow_option);
/// $multirow_operations = array(
/// "delete" => array("view"=>true),
/// "details" => array("view"=>true),
/// "my_operation_name" => array("view"=>true, "flag_name"=>"my_flag_name", "flag_value"=>"my_flag_value", "tooltip"=>"Do something with selected", "image"=>"image.gif")
/// );
/// $dgrid1->setMultirowOperations($multirow_operations);
## *** set CSS class for datagrid
## *** "default" or "blue" or "gray" or "green" or "pink" or your own css file
$dgrid1->setCssClass($css_class);
## *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.)
$http_get_vars = array("t", "aid");
$dgrid1->setHttpGetVars($http_get_vars);
## *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
## *** format (in which mode to allow processing of another datagrids)
## *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
$anotherDatagrids = array("ar_"=>array("view"=>true, "edit"=>true, "details"=>false));
$dgrid1->setAnotherDatagrids($anotherDatagrids);
## *** set DataGrid caption
//$dg_caption = "Access Rights for menu options";
//$dgrid1->setCaption($dg_caption);
##
##
## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings: |
## +---------------------------------------------------------------------------+
## *** set printing option: true(default) or false
$printing_option = false;
$dgrid1->allowPrinting($printing_option);
## *** set exporting option: true(default) or false and relative (virtual) path
## *** to export directory (relatively to datagrid.class.php file).
## *** Ex.: "" - if we use current datagrid folder
$exporting_option = false;
$exporting_directory = "export/";
$dgrid1->allowExporting($exporting_option, $exporting_directory);
##
##
## +---------------------------------------------------------------------------+
## | 4. Sorting & Paging Settings: |
## +---------------------------------------------------------------------------+
## *** set sorting option: true(default) or false
/// $sorting_option = true;
/// $dgrid1->allowSorting($sorting_option);
## *** set paging option: true(default) or false
$paging_option = true;
$rows_numeration = false;
$numeration_sign = "N #";
$dgrid1->allowPaging($paging_option, $rows_numeration, $numeration_sign);
## *** set paging settings
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$top_paging = array();
$pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
$default_page_size = 10;
$paging_arrows = array("first"=>"|<<", "previous"=>"<<", "next"=>">>", "last"=>">>|");
$dgrid1->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);
##
##
## +---------------------------------------------------------------------------+
## | 5. Filter Settings: |
## +---------------------------------------------------------------------------+
## *** set filtering option: true or false(default)
# $filtering_option = true;
# $show_search_type = true;
# $dgrid1->allowFiltering($filtering_option, $show_search_type);
## *** set aditional filtering settings
# //$fill_from_array = array("0"=>"No", "1"=>"Yes"); /* as "value"=>"option" */
# $filtering_fields = array(
# );
# $dgrid1->setFieldsFiltering($filtering_fields);
##
##
## +---------------------------------------------------------------------------+
## | 6. View Mode Settings: |
## +---------------------------------------------------------------------------+
## *** set view mode table properties
$vm_table_properties = array("width"=>"70%");
$dgrid1->setViewModeTableProperties($vm_table_properties);
## *** set columns in view mode
$vm_colimns = array(
"menu_name" =>array("header"=>lang("menu"), "type"=>"label", "align"=>"left", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>true|false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
"is_accessible" =>array("header"=>"Accessible", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>true|false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
);
$dgrid1->setColumnsInViewMode($vm_colimns);
## *** set auto-genereted columns in view mode
// $auto_column_in_view_mode = false;
// $dgrid1->setAutoColumnsInViewMode($auto_column_in_view_mode);
##
##
## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode Settings: |
## +---------------------------------------------------------------------------+
## *** set add/edit mode table properties
$em_table_properties = array("width"=>"70%");
$dgrid1->setEditModeTableProperties($em_table_properties);
## *** set details mode table properties
/// $dm_table_properties = array("width"=>"70%");
/// $dgrid1->setDetailsModeTableProperties($dm_table_properties);
## *** set settings for add/edit/details modes
$table_name_ = TABLE_MENU_ACCESS_RIGHTS;
$primary_key = "id";
$condition = $table_field_name."='".$aid."' AND menu_id IN (".$menu_ids2.")";
$dgrid1->setTableEdit($table_name_, $primary_key, $condition);
## *** set columns in edit mode
$fill_from_array_accessible = array("0"=>"No", "1"=>"Yes"); /* as "value"=>"option" */
$em_columns = array(
"menu_id" => array("header"=>"Menu Name", "type"=>"textbox", "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>true, "unique_condition"=>$table_field_name."='".$aid."'", "visible"=>"true", "on_js_event"=>""),
"is_accessible" => array("header"=>"Is Accessible?", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"0", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_accessible, "view_type"=>"dropdownlist(default)|radiobutton", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
$table_field_name => array("header"=>"", "type"=>"hidden", "req_type"=>"st", "default"=>$aid, "visible"=>"true", "unique"=>false),
);
$dgrid1->setColumnsInEditMode($em_columns);
## *** set auto-genereted columns in edit mode
// $auto_column_in_edit_mode = false;
// $dgrid1->setAutoColumnsInEditMode($auto_column_in_edit_mode);
## *** set foreign keys for add/edit/details modes (if there are linked tables)
$foreign_keys = array(
"menu_id"=>array("table"=>TABLE_MENU, "field_key"=>"id", "field_name"=>"name", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>TABLE_MENU.".is_menu_group = 0 AND ".TABLE_MENU.".parent_id='".$menu_id."'", "order_by_field"=>"order_index", "order_type"=>"ASC", "on_js_event"=>""),
);
$dgrid1->setForeignKeysEdit($foreign_keys);
##
##
## +---------------------------------------------------------------------------+
## | 8. Bind the DataGrid: |
## +---------------------------------------------------------------------------+
## *** bind the DataGrid and draw it on the screen
$dgrid1->bind();
ob_end_flush();
##
################################################################################
}
?>
<br />
</body>
</html>