<?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/functions.inc.php");
require_once("../inc/config.inc.php");
require_once("../inc/settings.inc.php");
require_once("../modules/phpmailer/class.phpmailer.php");
require_once("../inc/languages/".$SETTINGS['site_language'].".php");
if(!module_istalled('users')) redirect_to("access_denied.php");
if(!page_access_allowed($_SERVER['SCRIPT_NAME'])) redirect_to("access_denied.php");
$unique_prefix = "usr_"; /* prevent overlays - must be started with a letter */
$mode = isset($_REQUEST[$unique_prefix.'mode']) ? $_REQUEST[$unique_prefix.'mode'] : "";
$rid = isset($_REQUEST[$unique_prefix.'rid']) ? $_REQUEST[$unique_prefix.'rid'] : "";
$adm_status = (isset($_SESSION['adm_status'])) ? $_SESSION['adm_status'] : "";
$old_password = "";
if(strtolower(_SITE_MODE) != "demo" && $mode == "update" && $rid != "-1"){
// save old password
$sql = "SELECT password FROM ".TABLE_USERS." WHERE id = ".(int)$rid;
$db->Query($sql);
if($row = $db->FetchArray()){
$old_password = $row['password'];
}
}
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling: |
## +---------------------------------------------------------------------------+
## *** define a relative (virtual) path to datagrid.class.php file (relatively to the current file)
## *** RELATIVE PATH ONLY ***
## Ex.: "datagrid/datagrid.class.php" or "datagrid.class.php" etc.
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()); }
## *** write down the primary key in the first place (MUST BE AUTO-INCREMENT NUMERIC!)
$sql = "SELECT
".TABLE_USERS.".id,
".TABLE_USERS.".username,
".TABLE_USERS.".password,
".TABLE_USERS.".last_name,
".TABLE_USERS.".first_name,
CONCAT(".TABLE_USERS.".first_name, ' ', ".TABLE_USERS.".last_name) as full_name,
".TABLE_USERS.".email,
".TABLE_USERS.".status,
".TABLE_USERS.".newsletter,
".TABLE_USERS.".newsletter_sent,
".TABLE_USERS.".date_created,
IF(".TABLE_USERS.".is_active = '1', '<img src=../images/yes.gif>', '<img src=../images/no.gif>') as is_active,
".TABLE_USERS.".group_id,
IF(".TABLE_USERS.".last_login = '0000-00-00 00:00:00', 'Never', ".TABLE_USERS.".last_login) as last_login,
".TABLE_USERS.".logins_count,
".TABLE_COUNTRIES.".name as country_name,
".TABLE_USERS_GROUPS.".group_name,
'[Set Access Rights]' as menu_access_rights
FROM ".TABLE_USERS."
LEFT OUTER JOIN ".TABLE_USERS_GROUPS." ON ".TABLE_USERS.".group_id = ".TABLE_USERS_GROUPS.".id
LEFT OUTER JOIN ".TABLE_COUNTRIES." ON ".TABLE_USERS.".country = ".TABLE_COUNTRIES.".abbrv";
## *** 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 */
$dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
if(strtolower(_SITE_MODE) == "demo") $dgrid->isDemo = true;
$dgrid->firstFieldFocusAllowed = true;
if($adm_status == "main admin") $dgrid->navigationBar = "<a href='mod_users_groups_manager.php' class='x-blue_dg_a'>[Manage User Groups]</a>";
## *** set encoding and collation (default: utf8/utf8_unicode_ci)
/// $dg_encoding = "utf8";
/// $dg_collation = "utf8_unicode_ci";
/// $dgrid->SetEncoding($dg_encoding, $dg_collation);
## *** set data source with needed options
$default_order_field = TABLE_USERS.".username";
$default_order_type = "ASC";
$dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);
?>
<!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">
<?php
## call of this method between HTML <HEAD> tags
//$dgrid->WriteCssClass();
?>
</head>
<body dir="<?php echo $SETTINGS['language_dir'];?>">
<?php echo page_breadcrumbs(); ?>
<br />
<?php
## +---------------------------------------------------------------------------+
## | 2. General Settings: |
## +---------------------------------------------------------------------------+
## *** 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
## *** use "view"=>"0" and "edit"=>"0" only if you work on the same tables
$layouts = array("view"=>"0", "edit"=>"1", "details"=>"1", "filter"=>"1");
$dgrid->SetLayouts($layouts);
/// $mode_template = array("header"=>"", "body"=>"", "footer"=>"");
/// $details_template['body'] = "<table><tr><td>{field_name_1}</td><td>{field_name_2}</td></tr>...[ADD/EDIT/DELETE/BACK]</table>";
/// $dgrid->SetTemplates("","",$details_template);
## *** set modes for operations ("type" => "link|button|image")
## *** "view" - view mode | "edit" - add/edit/details modes
## *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
$modes = array(
"add" =>array("view"=>true, "edit"=>false, "type"=>"link", "show_add_button"=>"inside|outside"),
"edit" =>array("view"=>true, "edit"=>true, "type"=>"link", "byFieldValue"=>""),
"cancel" =>array("view"=>true, "edit"=>true, "type"=>"link"),
"details" =>array("view"=>true, "edit"=>false, "type"=>"link"),
"delete" =>array("view"=>true, "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 multirow operations
$multirow_option = true;
$dgrid->AllowMultirowOperations($multirow_option);
$multirow_operations = array(
"delete" => array("view"=>false),
"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", "blue", "x-blue", "gray", "green" or "pink" or your own css file
$css_class = $SETTINGS['datagrid_css_style'];
$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("act", "id");
/// $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("abcd_"=>array("view"=>true, "edit"=>true, "details"=>true));
/// $dgrid->SetAnotherDatagrids($anotherDatagrids);
## *** set DataGrid caption
$dg_caption = "Users Management";
$dgrid->SetCaption($dg_caption);
##
##
## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings: |
## +---------------------------------------------------------------------------+
## *** set printing option: true(default) or false
$printing_option = false;
$dgrid->AllowPrinting($printing_option);
## *** set exporting option: true(default) or false and relative (virtual) path
## *** to export directory (relatively to datagrid.class.php file).
## *** Add 744 access permissions for this folder. Ex.: "" - if we use current datagrid folder
## *** Change $file_path = "../../".$dir.$file; in scripts/download.php on appropriate path relatively to download.php
$exporting_option = true;
$exporting_directory = "../tmp/export/";
$export_all = false;
$dgrid->AllowExporting($exporting_option, $exporting_directory, $export_all);
$exporting_types = array("excel"=>"true", "pdf"=>"true", "xml"=>"true");
$dgrid->AllowExportingTypes($exporting_types);
## +---------------------------------------------------------------------------+
## | 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("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
/// $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 additional filtering settings
/// $fill_from_array = array("0"=>"No", "1"=>"Yes"); /* as "value"=>"option" */
$filtering_fields = array(
"Username"=>array("type"=>"textbox", "table"=>TABLE_USERS, "field"=>"username", "filter_condition"=>"", "show_operator"=>"false", "default_operator"=>"like%", "case_sensitive"=>"false", "comparison_type"=>"string", "width"=>"", "on_js_event"=>""),
"Group"=>array("type"=>"dropdownlist", "table"=>TABLE_USERS_GROUPS, "field"=>"group_name", "filter_condition"=>"", "order"=>"ASC", "source"=>"self", "show"=>"", "condition"=>"", "show_operator"=>"false", "default_operator"=>"=", "case_sensitive"=>"false", "comparison_type"=>"string", "width"=>"", "multiple"=>"false", "multiple_size"=>"4", "on_js_event"=>""),
"Country"=>array("type"=>"dropdownlist", "table"=>TABLE_COUNTRIES, "field"=>"name", "filter_condition"=>"", "order"=>"ASC", "source"=>"self", "show"=>"", "condition"=>"is_active=1", "show_operator"=>"false", "default_operator"=>"=", "case_sensitive"=>"false", "comparison_type"=>"string", "width"=>"", "multiple"=>"false", "multiple_size"=>"4", "on_js_event"=>""),
"Registered (from)"=>array("type"=>"calendar", "calendar_type"=>"floating", "date_format"=>"date", "table"=>TABLE_USERS, "field"=>"date_created", "filter_condition"=>"", "field_type"=>"from", "show_operator"=>"false", "default_operator"=>">=", "case_sensitive"=>"false", "comparison_type"=>"string", "width"=>"80px", "on_js_event"=>""),
"Registered (to)"=>array("type"=>"calendar", "calendar_type"=>"floating", "date_format"=>"date", "table"=>TABLE_USERS, "field"=>"date_created", "filter_condition"=>"", "field_type"=>"to", "show_operator"=>"false", "default_operator"=>"<=", "case_sensitive"=>"false", "comparison_type"=>"string", "width"=>"80px", "on_js_event"=>""),
);
$dgrid->SetFieldsFiltering($filtering_fields);
## +---------------------------------------------------------------------------+
## | 6. View Mode Settings: |
## +---------------------------------------------------------------------------+
## *** set view mode table properties
$vm_table_properties = array("width"=>"90%");
$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
/// $fill_from_array = array("0"=>"Banned", "1"=>"Active", "2"=>"Closed", "3"=>"Removed"); /* as "value"=>"option" */
$vm_colimns = array(
"full_name" =>array("header"=>lang("name"), "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"=>""),
"username" =>array("header"=>"Username", "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"=>""),
"email" =>array("header"=>"Email", "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"=>""),
"group_name" =>array("header"=>"Group", "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"=>""),
//"logins_count" =>array("header"=>"Logins", "type"=>"label", "align"=>"right", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>true|false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
//"last_login" =>array("header"=>"Last Login", "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"=>"", "on_item_created"=>"my_date_format"),
"status" =>array("header"=>"Status", "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"=>""),
"is_active" =>array("header"=>"Active", "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"=>""),
"menu_access_rights" =>array("header"=>"Menu Access", "type"=>"link", "sortable"=>"false", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>true|false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"id", "field_data"=>"category_access_rights", "rel"=>"", "title"=>"", "target"=>"", "href"=>"user_menu_access_rights.php?t=user&aid={0}"),
);
$dgrid->SetColumnsInViewMode($vm_colimns);
## *** set auto-generated 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_USERS;
$primary_key = "id";
// for ex.: "table_name.field = ".$_REQUEST['abc_rid'];
$condition = "";
$dgrid->SetTableEdit($table_name, $primary_key, $condition);
## *** set columns in edit mode
$fill_from_array_yes_no = array("0"=>lang("no"), "1"=>lang("yes"));
$fill_from_array_languages = $config->langsArray();
$em_columns = array(
"delimiter_personal" =>array("inner_html"=>"<font style='font-size:13px; font-weight:bold; color:#336699'><i>Personal Information:</i></font><br />"),
"first_name" =>array("header"=>"First Name", "type"=>"textbox", "req_type"=>"ry", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
"last_name" =>array("header"=>"Last Name", "type"=>"textbox", "req_type"=>"ry", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
"email" =>array("header"=>"Email", "type"=>"textbox", "req_type"=>"re", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>true, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
"country" =>array("header"=>"Country", "type"=>"foreign_key","req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true"),
);
if($mode == "add"){
$em_columns['date_created'] = array("header"=>"", "type"=>"hidden", "req_type"=>"st", "default"=>date("Y-m-d H:i:s"), "unique"=>"false");
$em_columns['last_login'] = array("header"=>"", "type"=>"hidden", "req_type"=>"st", "default"=>"0000-00-00 00:00:00", "unique"=>"false");
$em_columns['logins_count'] = array("header"=>"", "type"=>"hidden", "req_type"=>"st", "default"=>"0", "unique"=>"false");
$em_columns['delimiter_2'] = array("inner_html"=>"<font style='font-size:13px;font-weight:bold;color:#336699'><i>Account & Login Info:</i></font><br />");
$em_columns["username"] = array("header"=>"Username", "type"=>"textbox", "req_type"=>"rl", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>true, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"");
$em_columns["password"] = array("header"=>"Password", "type"=>"password", "req_type"=>((strtolower($SETTINGS['passwords_encryption_type']) == "md5") ? "sp" : "rp"), "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>(($mode == "add" || $SETTINGS['user_password_editing']) ? true : false), "on_js_event"=>"", "generate"=>"true", "cryptography"=>$SETTINGS['passwords_encryption'], "cryptography_type"=>strtolower($SETTINGS['passwords_encryption_type']), "aes_password"=>$SETTINGS['passwords_encrypt_key']);
$em_columns["status"] = array("header"=>"Status", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"user", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>"self", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4");
$em_columns["group_id"] = array("header"=>"Group", "type"=>"foreign_key","req_type"=>"si", "width"=>"210px", "title"=>"", "readonly"=>"false", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true");
$em_columns['preferred_language'] = array("header"=>"Language", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>$SETTINGS['site_language'], "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_languages, "view_type"=>"dropdownlist");
$em_columns["is_active"] = array("header"=>"Active", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"1", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_yes_no, "view_type"=>"dropdownlist");
}else{
$em_columns['delimiter_2'] = array("inner_html"=>"<font style='font-size:13px;font-weight:bold;color:#336699'><i>Account & Login Info:</i></font><br />");
$em_columns["username"] = array("header"=>"Username", "type"=>"textbox", "req_type"=>"rl", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>true, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"");
$em_columns["password"] = array("header"=>"Password", "type"=>"password", "req_type"=>((strtolower($SETTINGS['passwords_encryption_type']) == "md5") ? "sp" : "rp"), "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>(($mode == "add" || $SETTINGS['user_password_editing']) ? true : false), "on_js_event"=>"", "generate"=>"true", "cryptography"=>$SETTINGS['passwords_encryption'], "cryptography_type"=>strtolower($SETTINGS['passwords_encryption_type']), "aes_password"=>$SETTINGS['passwords_encrypt_key']);
$em_columns["status"] = array("header"=>"Status", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"user", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>"self", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4");
$em_columns["group_id"] = array("header"=>"Group", "type"=>"foreign_key","req_type"=>"si", "width"=>"210px", "title"=>"", "readonly"=>"false", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true");
$em_columns['preferred_language'] = array("header"=>"Language", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>$SETTINGS['site_language'], "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_languages, "view_type"=>"dropdownlist");
$em_columns["is_active"] = array("header"=>"Active", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"1", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_yes_no, "view_type"=>"dropdownlist");
$em_columns['date_created'] = array("header"=>"Date Created", "type"=>"label", "req_type"=>"st", "title"=>"", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "on_item_created"=>"my_date_format");
$em_columns['last_login'] = array("header"=>"Last Login", "type"=>"label", "req_type"=>"st", "title"=>"", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "on_item_created"=>"my_date_format");
$em_columns['logins_count'] = array("header"=>"Logins Count", "type"=>"label", "req_type"=>"st", "title"=>"", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"");
$em_columns['logins_attempts'] = array("header"=>"Logins Attempts", "type"=>"label", "title"=>"", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>(($adm_status == "main admin") ? "true" : "false"), "on_js_event"=>"");
}
$em_columns["delimiter_news"] = array("inner_html"=>"<font style='font-size:13px; font-weight:bold; color:#336699'><i>Newsletter & Notifications:</i></font><br />");
$em_columns["newsletter"] = array("header"=>"Newsletter", "type"=>"checkbox", "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "true_value"=>1, "false_value"=>0);
$em_columns["newsletter_sent"] = array("header"=>"Newsletter Sent", "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_yes_no, "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4");
$dgrid->SetColumnsInEditMode($em_columns);
## *** set auto-generated 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(
"country"=>array("table"=>TABLE_COUNTRIES, "field_key"=>"abbrv", "field_name"=>"name", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"is_active=1", "order_by_field"=>"priority", "order_type"=>"DESC", "on_js_event"=>""),
"group_id"=>array("table"=>TABLE_USERS_GROUPS, "field_key"=>"id", "field_name"=>"group_name", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"", "order_by_field"=>"group_name", "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();
################################################################################
//--------------------------------------------------------------------------
// user was deleted - remove access rights
//--------------------------------------------------------------------------
if((strtolower(_SITE_MODE) != "demo") && $mode == "delete" && $dgrid->IsOperationCompleted())
{
$sql = "DELETE FROM ".TABLE_MENU_ACCESS_RIGHTS." WHERE user_id = ".(int)$rid;
$db->Exec($sql);
}
//--------------------------------------------------------------------------
// user was added - send notifacation email
//--------------------------------------------------------------------------
if((strtolower(_SITE_MODE) != "demo") && $mode == "update" && $rid == "-1" && $dgrid->IsOperationCompleted())
{
$rid = $dgrid->GetCurrentId();
$pswd_prefix = ((strtolower($SETTINGS['passwords_encryption_type']) == "md5") ? "sp" : "rp");
$password_new = isset($_POST[$pswd_prefix.'ypassword']) ? $_POST[$pswd_prefix.'ypassword'] : "";
send_email_on_account_created("users", $rid, $password_new);
}
//--------------------------------------------------------------------------
// check if password was changed and send email
//--------------------------------------------------------------------------
if(strtolower(_SITE_MODE) != "demo" && $mode == "update" && $rid != "-1"){
send_email_on_password_changed("users", $rid, $old_password);
}
?>
<br /><br />
</body>
</html>