'inc-db/triggers/bindings.before',
'after' => 'inc-db/triggers/bindings.after',
); /* }}} */
/*
* ezin_admin_bindings_main()
*/
function ezin_admin_bindings_main($perm_articles, $perm_sections, $perm_authors) /* {{{ */
{
global $ezin_sys;
global $ezin_cfg;
global $ezin_db_handle;
$op_list = array(
'article_bind_theme' => strstr($perm_articles, 'a'),
'article_bind_lang' => strstr($perm_articles, 'a'),
'page_bind_lang' => strstr($perm_articles, 'a'),
'section_bind_lang' => strstr($perm_sections, 's'),
'author_bind' => strstr($perm_authors, 't'));
$op_change = array(
'article_bind_theme' => strstr($perm_articles, 'A'),
'article_bind_lang' => strstr($perm_articles, 'A'),
'page_bind_lang' => strstr($perm_articles, 'A'),
'section_bind_lang' => strstr($perm_sections, 'S'),
'author_bind' => strstr($perm_authors, 'T'));
echo '
',"\n";
return;
} /* }}} */
function ezin_admin_bindings_buttons($f_multilng, $f_change, $type, $op_list) /* {{{ */
{
echo '',"\n";
} /* }}} */
function ezin_admin_bindings_save($type, $action) /* {{{ */
{
global $ezin_sys;
global $ezin_db_handle;
global $ezin_admin_bindings_triggers;
$ar_rec = @$_POST['record'];
$ar_bind = @$_POST['binding'];
is_array($ar_rec) || $ar_rec = array();
is_array($ar_bind) || $ar_bind = array();
for ($i = 0; $i < count($ar_rec); $i++) {
if (($ar_rec[$i] = intval($ar_rec[$i])) == 0)
unset($ar_rec[$i]);
}
for ($i = 0; $i < count($ar_bind); $i++) {
if (($ar_bind[$i] = intval($ar_bind[$i])) == 0)
unset($ar_bind[$i]);
}
if (count($ar_rec) + count($ar_bind) <= 0)
return false;
$update_value = 0;
$update_field = $type == 'article_bind_theme' ? 'bind_theme' : 'bind_lang';
$update_field = $type == 'author_bind' ? 'bind' : $update_field;
$update_table = $type == 'section_bind_lang'
? $ezin_sys['db']['tables']['sections']
: $ezin_sys['db']['tables']['articles'];
$update_table = $type == 'author_bind'
? $ezin_sys['db']['tables']['authors']
: $update_table;
if ($action == 'create') {
if (count($ar_bind) > 0) {
sort($ar_bind);
$update_value = intval($ar_bind[0]);
}
if (! $update_value) {
//$update_value = "MAX($update_field) + 1";
$query = sprintf('SELECT MAX(IFNULL(%s, 0)) + 1 FROM %s',
$update_field, $update_table);
if ($result = mysqli_query($ezin_db_handle, $query)) {
$row = mysqli_fetch_array($result, MYSQLI_NUM);
mysqli_free_result($result);
$update_value = $row[0];
}
}
if (! $update_value) {
return false;
}
}
$query = sprintf('UPDATE %s SET %s = %s',
$update_table, $update_field, $update_value);
$query_add = '';
if (count($ar_rec) > 0) {
$query_add .= 'id IN ('.join(', ', $ar_rec).')'; // )
}
if (count($ar_bind) > 0) {
$query_add != '' && $query_add .=' OR ';
$query_add .= $update_field.' IN ('.join(', ', $ar_bind).')'; // )
}
$query_add != '' && $query .=' WHERE '.$query_add;
if (0) { // DEBUG
echo 'type = '.$type.'
';
echo 'action = '.$action.'
';
echo 'update_table = '.$update_table.'
';
echo 'update_field = '.$update_field.'
';
echo 'update_value = '.$update_value.'
';
echo 'query
'.htmlspecialchars($query).'
';
}
if (file_exists($ezin_admin_bindings_triggers['before'])) {
$trigger_ret = include $ezin_admin_bindings_triggers['before'];
if ($trigger_ret == false) {
return -1;
}
}
if (mysqli_query($ezin_db_handle, $query) == false) {
return false;
}
if (file_exists($ezin_admin_bindings_triggers['after'])) {
$trigger_ret = include $ezin_admin_bindings_triggers['after'];
if ($trigger_ret == false) {
return false;
}
}
return true;
} /* }}} */
/*
* main stuff
*/
$ezin_perm_articles = '';
$ezin_perm_sections = '';
$ezin_perm_authors = '';
ezin_admin_check_full_list_privileges($ezin_user['role_articles']) && $ezin_perm_articles .= 'a';
ezin_admin_check_full_list_privileges($ezin_user['role_sections']) && $ezin_perm_sections .= 's';
ezin_admin_check_full_list_privileges($ezin_user['role_authors']) && $ezin_perm_authors .= 't';
strstr($ezin_perm_articles, 'a') && stristr($ezin_user['role_articles'], 'C') && $ezin_perm_articles .= 'A';
strstr($ezin_perm_sections, 's') && stristr($ezin_user['role_sections'], 'C') && $ezin_perm_sections .= 'S';
strstr($ezin_perm_authors, 't') && stristr($ezin_user['role_authors'], 'C') && $ezin_perm_authors .= 'T';
if (strlen($ezin_perm_articles) > 0 || strlen($ezin_perm_sections) > 0 || strlen($ezin_perm_authors) > 0) {
ezin_check_db_handle();
ezin_admin_bindings_main($ezin_perm_articles, $ezin_perm_sections, $ezin_perm_authors);
ezin_close_db_connection();
} else {
require 'inc-html/permdenied.html';
}
/* Modeline for ViM {{{
* vim: set ts=4:
* vim600: fdm=marker fdl=0 fdc=0:
* }}} */
?>