Súbor: [Platon] / Metafox / admin / inc-db / polls.inc.php (stiahnutie)
Revízia 1.11, Tue Nov 7 08:43:23 2017 UTC (6 years, 4 months ago) by nepto
Zmeny od 1.10: +1 -1 [lines]
Reuse existing DB handle in $ezin_db_handle variable instead of creating
a new one. Not only this needs more resources, but also newly created
handle does not have proper encoding initialized via SET NAMES query
(for example default UTF-8 vs required LATIN2)
|
<?php
// Authentification
if (@file_exists('inc/auth.inc.php') && @include_once 'inc/auth.inc.php');
else exit;
// General options
$ezin_opts['dbh'] = $ezin_db_handle;
$ezin_opts['key'] = 'id';
$ezin_opts['key_type'] = 'int';
$ezin_opts['inc'] = -1;
$ezin_opts['options'] = $ezin_user['role_polls'];
$ezin_opts['multiple'] = '4';
$ezin_opts['navigation'] = $ezin_cfg['admin_navigation'].$ezin_cfg['admin_buttons_pos'];
$ezin_opts['display'] = array('query' => false, 'sort' => false, 'time' => false);
$ezin_opts['url'] = array('images' => 'icons/');
$ezin_opts['language'] = 'EN';
$ezin_opts['encoding'] = $ezin_cfg['encoding'];
$ezin_opts['ext_hsc'] = false;
$poll_id = intval($_REQUEST['poll_id']);
if ($poll_id > 0) { /* {{{ */
// General options
$ezin_opts['tb'] = $ezin_sys['db']['tables']['poll_answers'];
$ezin_opts['sort_field'] = array('-votes', 'id');
$ezin_opts['filters'] = 'poll_id = '.$poll_id;
$ezin_opts['cgi']['persist'] = array('poll_id' => $poll_id);
// Triggers
$ezin_opts['triggers']['insert']['after'] = 'inc-db/triggers/polls.after';
$ezin_opts['triggers']['update']['after'] = 'inc-db/triggers/polls.after';
$ezin_opts['triggers']['delete']['after'] = 'inc-db/triggers/polls.after';
// Field definitions
$ezin_opts['fdd']['id'] = array(
'name'=>Platon::htmlspecialchars2('Answer ID'),
'select'=>'T',
'sort'=>true,
'size'=>5,
'default'=>'',
'options'=>'LDVFPCR',
'mask'=>'%03d',
'escape' => false,
'colattrs|LF'=>'align="center"',
);
$ezin_opts['fdd']['poll_id'] = array(
'name'=>'Poll',
'select'=>'D',
'options'=>'ALDVFPCR',
'sqlw'=>$poll_id,
'sort'=>true,
'required'=>true,
'strip_tags'=>true,
'values'=>array(
'table' => $ezin_sys['db']['tables']['polls'],
'column' => 'id',
'description' => array(
'columns' => array('question', 'id'),
'divs' => array(' (POLL #', ')')))
);
$ezin_opts['fdd']['answer'] = array(
'name'=>'Answer',
'select'=>'T',
'maxlen'=>255,
'sort'=>true,
'js'=>array('required' => true)
);
$ezin_opts['fdd']['votes'] = array(
'name'=>'Votes',
'select'=>'T',
'default'=>'0',
'maxlen'=>5,
'sort'=>true
);
} /* }}} */
else { /* {{{ */
// General options
$ezin_opts['tb'] = $ezin_sys['db']['tables']['polls'];
$ezin_opts['sort_field'] = array('-dt_valid_from', '-id');
// Triggers
// Field definitions
$ezin_opts['fdd']['id'] = array(
'name'=>Platon::htmlspecialchars2('Poll ID'),
'select'=>'T',
'sort'=>true,
'size'=>5,
'default'=>'',
'options'=>'LDVFPCR',
'mask'=>'%03d',
'escape' => false,
'URLprefix' => '?poll_id=',
'colattrs|LF'=>'align="center"',
);
$ezin_opts['fdd']['section_id'] = array(
'name'=>'Section',
'select'=>'D',
'sort'=>true,
'required'=>true,
'strip_tags'=>true,
'values'=>array(
'table' => $ezin_sys['db']['tables']['sections'],
'column' => 'id',
'description' => array(
'columns' => array('name', 'id', 'type'),
'divs' => array(' (SECTION #', '; ', ')')))
);
$ezin_opts['fdd']['dt_valid_from'] = array(
'name'=>Platon::htmlspecialchars2('Valid From'),
'select'=>'T',
'sort'=>true,
'required'=>true,
'mask'=>'%.10s',
'default'=>date('Y-m-d'),
'colattrs|LF'=>'align="center"',
);
$ezin_opts['fdd']['dt_valid_to'] = array(
'name'=>Platon::htmlspecialchars2('Valid To'),
'select'=>'T',
'sort'=>true,
'required'=>true,
'mask'=>'%.10s',
'default'=>date('Y-m-d', time() + 2592000),
'colattrs|LF'=>'align="center"',
);
$ezin_opts['fdd']['votes'] = array(
'name'=>'Votes',
'options'=>'ALDVFPCR',
'select'=>'T',
'default'=>'0',
'maxlen'=>5,
'sort'=>true
);
$ezin_opts['fdd']['answers'] = array(
'name'=>'Answers',
'options'=>'ALDVFPCR',
'select'=>'T',
'default'=>'0',
'maxlen'=>5,
'sort'=>true
);
$ezin_opts['fdd']['question'] = array(
'name'=>'Question',
'select'=>'T',
'maxlen'=>255,
'sort'=>true,
//'trimlen|LF'=>35,
'sql|LFVD' => "CONCAT('<a href=\"?poll_id=', PMEtable0.id, '\">', question, '</a>')",
'escape'=>false,
'js'=>array('required' => true)
);
$ezin_opts['fdd']['description'] = array(
'name'=>'Description',
'select'=>'T',
'textarea'=>array(
'rows'=>8,
'cols'=>65,
),
'options'=>'ACPV',
);
include dirname(__FILE__).'/_credentials.inc.php';
} /* }}} */
// Execution code
if (! ezin_admin_check_list_privileges($ezin_opts['options'])) {
require 'inc-html/permdenied.html';
} else {
require_once 'phpMyEdit/phpMyEdit.class.php';
new phpMyEdit($ezin_opts);
}
/* Modeline for ViM {{{
* vim: set ts=4:
* vim600: fdm=marker fdl=0 fdc=0:
* }}} */
?>
Platon Group <platon@platon.sk> http://platon.sk/
|