<?php
/// LICENSE- A new license needs to put here
/* CHANGES
removed all header and footer calls
moved content over to GL template system
*/
# this is only required till we stop symbolic linking our development version
# in production it can be a relative link ../../lib-common.php
require_once('lib-common.php');
/* Disable access rights check
// Check user has rights to access this page
if (!SEC_hasRights('geekddb.view','geekddb.edit','geekddb.admin','OR')) {
// Someone is trying to illegally access this page
COM_errorLog("Someone has tried to illegally access the geekddb page. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: $REMOTE_ADDR",1);
$display = COM_siteHeader();
$display .= COM_startBlock($LANG_DB00['access_denied']);
$display .= $LANG_DB00['access_denied_msg'];
$display .= COM_endBlock();
$display .= COM_siteFooter(true);
echo $display;
exit;
}
// end disable access rights check */
$display = COM_siteHeader();
$T = new Template($_CONF['path'] . 'plugins/geekddb/templates');
$T->set_file('page', 'index.thtml');
$T->set_var('header', $LANG_DB00['plugin']);
$T->set_var('site_url',$_CONF['site_url']);
$T->set_var('plugin','geekddb');
include ($_CONF['path'] . 'plugins/geekddb/config.php');
include ($_CONF['path'] . 'plugins/geekddb/functions.php');
include ($_CONF['path'] . 'plugins/geekddb/common.php');
// Now handled in index.thml
//include ($_CONF['path'] . 'plugins/geekddb/templates/header.php');
include ($_CONF['path'] . "plugins/geekddb/check_table.php");
/***
* Check geekDDB user permissions for given table
*/
$gddb_access = gddb_access($_GET['table_name']);
phpblock_debugWrite(" User ID is: " . $_USER['uid']);
$debug_msg = "
Table name: $A[name_table]
Read: $gddb_access[read]
Edit: $gddb_access[edit]
User ID: $_USER[uid]
Username: $_USER[username]
enable edit: $enable_edit
enable insert: $enable_insert
enable delete: $enable_delete
enable details: $enable_details
";
// Make Values For Template
//DEV need to convert to template
/***
* if allowed to insert and user has edit rights...
*/
if (($enable_insert == "1") && ($gddb_access['edit'])) {
$link_link = '<a href="form.php?form_type=insert&table_name=' .
urlencode($table_name) . '">' .
$LANG_DB02['insert'] . '</a>' ;
} else {
$link_link = "" ; // blank value if insert is not allowed
}
/***
* if allowed update/delete and user has edit rights...
*/
//DEV need to do this using language system
$update_link_text = "Search";
if (($enable_edit) && ($gddb_access['edit'])) {
$update_link_text .= "/update";
}
if (($enable_delete) && ($gddb_access['edit'])) {
$update_link_text .= "/delete";
}
$update_link_text .= " records";
$update_link = '<a href="form.php?form_type=search&table_name=' .
urlencode($table_name). '">'.
// $LANG_DB02['search/update/delete']. '</a>' ;
$update_link_text. '</a>' ;
$show_all_records_link = '<a href="form.php?function=search&sql=&page=0&table_name=' . urlencode($table_name). '">' . $LANG_DB01['show_all_records'] . '</a>' ;
// get the number of contacts in the database
$sql = "select count(*) from ".$quote."$table_name".$quote."";
// select the database
select_db("$db_name", $conn);
// execute the select query
$res_count = execute_db("$sql", $conn);
$count_row = fetch_row_db($res_count) ;
$records_number = $count_row[0];
// DEV needs to be GL standard language implementation
$records_number_message = $LANG_DB01['records_in_database'].$records_number ;
// Build Drop Down List for Template
$change_table_select = build_change_table_select($conn, $db_name);
if ($change_table_select != "")
{
$change_table_form = '
<form method="get" action="'. $PHP_SELF. '">' .
$change_table_select . '
<input type="submit" value="' . $LANG_DB02['change_table'] .
'"></form>' ;
} else {
$change_table_form = '' ; // Blank value
}
## Fill in template
$T->set_var('insert_link',"$link_link");
$T->set_var('update_link',"$update_link");
$T->set_var('show_all_records_link',"$show_all_records_link");
$T->set_var('change_table_form',"$change_table_form");
$T->set_var('records_number_message',"$records_number_message");
// DEV this still needs to be dealt with in the template
if ($mail_feature == 1){
?>
<form method="post" action="mail.php"><input type="hidden" name="function" value="new_form"><input type="submit" value="<?php echo $LANG_DB02['new_mailing']; ?>"></form>
<?php
$sql = "select name_mailing from mailing_tab where sent_mailing = '0' order by date_created_mailing desc";
// select the database
select_db("$db_name", $conn);
// execute the query
$res_mailing = execute_db("$sql", $conn);
if (get_num_rows_db($res_mailing) > 0){ // at least one mailing created
$mailing_select = build_mailing_select($conn, $db_name, $res_mailing);
?>
<form method="post" action="mail.php"><input type="hidden" name="function" value="check_form"><input type="submit" value="<?php echo $LANG_DB02['check_existing_mailing']; ?>"><?php display_message($mailing_select, "", "", ""); ?></form>
<form method="post" action="mail.php"><input type="hidden" name="function" value="send"><input type="submit" value="<?php echo $LANG_DB02['send_mailing']; ?>"><?php display_message($mailing_select, "", "", ""); ?></form>
<?php
} // end if
} // end if
?>
<?php
// include footer
// The Template is no longer needed, it is handled in index.thtml
//include ($_CONF['path'] . "plugins/geekddb/templates/footer_index.php");
$T->parse('output','page');
$display .= $T->finish($T->get_var('output'));
//$display .= COM_siteFooter();
/* Display debugging info
$display .= "<HR>";
$display .= "<PRE>$debug_msg</PRE>";
$display .= "<HR>";
// end debugging info */
$display .= COM_siteFooter(true);
echo $display;
?>