New way to initialize and modify filter parameters
This commit is contained in:
parent
ce5f89b38f
commit
6b9f1ad9d5
14 changed files with 541 additions and 526 deletions
|
@ -11,45 +11,40 @@ function stormevent_list() {
|
|||
|
||||
if (array_key_exists('organization_nid', $_GET)) {
|
||||
if ($_SESSION['stormevent_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
||||
$_SESSION['stormevent_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
_storm_set_filter_param('event', 'organization_nid', $_GET['organization_nid']);
|
||||
}
|
||||
unset($_SESSION['stormevent_list_filter']['project_nid']);
|
||||
unset($_SESSION['stormevent_list_filter']['task_nid']);
|
||||
_storm_set_filter_param('event', 'project_nid');
|
||||
_storm_set_filter_param('event', 'task_nid');
|
||||
}
|
||||
if (array_key_exists('project_nid', $_GET)) {
|
||||
if ($_SESSION['stormevent_list_filter']['project_nid'] != $_GET['project_nid']) {
|
||||
$_SESSION['stormevent_list_filter']['project_nid'] = $_GET['project_nid'];
|
||||
_storm_set_filter_param('event', 'project_nid', $_GET['project_nid']);
|
||||
}
|
||||
$p = node_load($_GET['project_nid']);
|
||||
$_SESSION['stormevent_list_filter']['organization_nid'] = $p->organization_nid;
|
||||
unset($_SESSION['stormevent_list_filter']['task_nid']);
|
||||
_storm_set_filter_param('event', 'organization_nid', $p->organization_nid);
|
||||
_storm_set_filter_param('event', 'task_nid');
|
||||
}
|
||||
if (array_key_exists('task_nid', $_GET)) {
|
||||
if ($_SESSION['stormevent_list_filter']['task_nid'] != $_GET['task_nid']) {
|
||||
$_SESSION['stormevent_list_filter']['task_nid'] = $_GET['task_nid'];
|
||||
_storm_set_filter_param('event', 'task_nid', $_GET['task_nid']);
|
||||
}
|
||||
$t = node_load($_GET['task_nid']);
|
||||
$_SESSION['stormevent_list_filter']['organization_nid'] = $t->organization_nid;
|
||||
$_SESSION['stormevent_list_filter']['project_nid'] = $t->project_nid;
|
||||
_storm_set_filter_param('event', 'organization_nid', $t->organization_nid);
|
||||
_storm_set_filter_param('event', 'project_nid', $t->project_nid);
|
||||
}
|
||||
if (array_key_exists('view', $_GET) && $_GET['view'] == 'all') {
|
||||
$_SESSION['stormevent_list_filter']['eventtype'] = '-';
|
||||
$_SESSION['stormevent_list_filter']['title'] = '';
|
||||
_storm_set_filter_param('event', 'eventtype', '-');
|
||||
_storm_set_filter_param('event', 'title', '');
|
||||
|
||||
unset($_SESSION['stormevent_list_filter']['datebeginfrom']);
|
||||
unset($_SESSION['stormevent_list_filter']['datebeginto']);
|
||||
unset($_SESSION['stormevent_list_filter']['dateendfrom']);
|
||||
unset($_SESSION['stormevent_list_filter']['dateendto']);
|
||||
_storm_set_filter_param('event', 'datebeginfrom');
|
||||
_storm_set_filter_param('event', 'datebeginto');
|
||||
_storm_set_filter_param('event', 'dateendfrom');
|
||||
_storm_set_filter_param('event', 'dateendto');
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormevent';
|
||||
|
||||
$params = $_GET;
|
||||
if (isset($_SESSION['stormevent_list_filter']['organization_nid'])) {
|
||||
$params['organization_nid'] = $_SESSION['stormevent_list_filter']['organization_nid'];
|
||||
}
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => ' ',
|
||||
|
@ -78,12 +73,16 @@ function stormevent_list() {
|
|||
'class' => 'storm_list_version',
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_add_node($i, $params),
|
||||
'data' => storm_icon_add_node($i, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$s = "SELECT n.*, sev.*, nre.format, tev.*,
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
$s = "SELECT n.*, sev.*, nre.format, tev.*,
|
||||
fda.field_stormevent_date_value AS dini,
|
||||
fda.field_stormevent_date_value2 AS dend,
|
||||
fda.field_stormevent_date_rrule AS drule,
|
||||
|
@ -95,43 +94,36 @@ function stormevent_list() {
|
|||
LEFT JOIN {content_field_stormevent_attach} AS fev ON n.vid = fev.vid AND fev.field_stormevent_attach_list = 1 AND fev.delta = 0
|
||||
WHERE n.status=1 AND n.type='stormevent'";
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
if (isset($_SESSION['stormevent_list_filter']['organization_nid']) && $_SESSION['stormevent_list_filter']['organization_nid'] != 0) {
|
||||
if (_storm_isset_filter_param('event', 'organization_nid', 0)) {
|
||||
$where[] = 'sev.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormevent_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormevent_list_filter']['project_nid']) && $_SESSION['stormevent_list_filter']['project_nid'] != 0) {
|
||||
if (_storm_isset_filter_param('event', 'project_nid', 0)) {
|
||||
$where[] = 'sev.project_nid=%d';
|
||||
$args[] = $_SESSION['stormevent_list_filter']['project_nid'];
|
||||
$filterfields[] = t('Project');
|
||||
}
|
||||
if (isset($_SESSION['stormevent_list_filter']['task_nid']) && $_SESSION['stormevent_list_filter']['task_nid'] != 0) {
|
||||
if (_storm_isset_filter_param('event', 'task_nid', 0)) {
|
||||
$where[] = 'sev.task_nid=%d';
|
||||
$args[] = $_SESSION['stormevent_list_filter']['task_nid'];
|
||||
$filterfields[] = t('Task');
|
||||
}
|
||||
|
||||
$type_list = storm_attributes_bydomain('event type search');
|
||||
$eventtype = isset($_SESSION['stormevent_list_filter']['eventtype']) ? $_SESSION['stormevent_list_filter']['eventtype'] : $type_list['default'];
|
||||
$_SESSION['stormevent_list_filter']['eventtype'] = $eventtype;
|
||||
|
||||
if ($eventtype != '-') {
|
||||
$type_list = storm_attributes_bydomain('Event type search');
|
||||
if (_storm_isset_filter_param('event', 'eventtype', $type_list['default'], '-')) {
|
||||
$where[] = "sev.eventtype='%s'";
|
||||
$args[] = $eventtype;
|
||||
$args[] = $_SESSION['stormevent_list_filter']['eventtype'];
|
||||
$filterfields[] = t('Type');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormevent_list_filter']['title']) && $_SESSION['stormevent_list_filter']['title'] != '') {
|
||||
if (_storm_isset_filter_param('event', 'title', '')) {
|
||||
$where[] = "LOWER(n.title) LIKE LOWER('%s')";
|
||||
$args[] = $_SESSION['stormevent_list_filter']['title'];
|
||||
$filterfields[] = t('Title');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormevent_list_filter']['datebeginfrom'])) {
|
||||
if (_storm_isset_filter_param('event', 'datebeginfrom')) {
|
||||
$datebeginfrom = $_SESSION['stormevent_list_filter']['datebeginfrom'];
|
||||
$datebeginfrom['hour'] = 0;
|
||||
$datebeginfrom['minute'] = 0;
|
||||
|
@ -142,7 +134,7 @@ function stormevent_list() {
|
|||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
if (isset($_SESSION['stormevent_list_filter']['datebeginto'])) {
|
||||
if (_storm_isset_filter_param('event', 'datebeginto')) {
|
||||
$datebeginto = $_SESSION['stormevent_list_filter']['datebeginto'];
|
||||
$datebeginto['hour'] = 23;
|
||||
$datebeginto['minute'] = 59;
|
||||
|
@ -153,7 +145,7 @@ function stormevent_list() {
|
|||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
if (isset($_SESSION['stormevent_list_filter']['dateendfrom'])) {
|
||||
if (_storm_isset_filter_param('event', 'dateendfrom')) {
|
||||
$dateendfrom = $_SESSION['stormevent_list_filter']['dateendfrom'];
|
||||
$dateendfrom['hour'] = 0;
|
||||
$dateendfrom['minute'] = 0;
|
||||
|
@ -164,7 +156,7 @@ function stormevent_list() {
|
|||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
if (isset($_SESSION['stormevent_list_filter']['dateendto'])) {
|
||||
if (_storm_isset_filter_param('event', 'dateendto')) {
|
||||
$dateendto = $_SESSION['stormevent_list_filter']['dateendto'];
|
||||
$dateendto['hour'] = 23;
|
||||
$dateendto['minute'] = 59;
|
||||
|
@ -184,8 +176,7 @@ function stormevent_list() {
|
|||
$where[] = "EXISTS ($wheredate)";
|
||||
}
|
||||
|
||||
// This section only provides the value for the fieldset label, doesn't control actual filter
|
||||
$itemsperpage = isset($_SESSION['stormevent_list_filter']['itemsperpage']) ? $_SESSION['stormevent_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$itemsperpage = _storm_get_filter_param('event', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
||||
|
||||
if (count($filterfields) == 0) {
|
||||
$filterdesc = t('Not filtered');
|
||||
|
@ -214,22 +205,22 @@ function stormevent_list() {
|
|||
}
|
||||
|
||||
function stormevent_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$organization_nid = isset($_SESSION['stormevent_list_filter']['organization_nid']) ? $_SESSION['stormevent_list_filter']['organization_nid'] : 0;
|
||||
$project_nid = isset($_SESSION['stormevent_list_filter']['project_nid']) ? $_SESSION['stormevent_list_filter']['project_nid'] : 0;
|
||||
$task_nid = isset($_SESSION['stormevent_list_filter']['task_nid']) ? $_SESSION['stormevent_list_filter']['task_nid'] : 0;
|
||||
$organization_nid = _storm_get_filter_param('event', 'organization_nid', 0);
|
||||
$project_nid = _storm_get_filter_param('event', 'project_nid', 0);
|
||||
$task_nid = _storm_get_filter_param('event', 'task_nid', 0);
|
||||
|
||||
$type_list = storm_attributes_bydomain('event type search');
|
||||
$eventtype = isset($_SESSION['stormevent_list_filter']['eventtype']) ? $_SESSION['stormevent_list_filter']['eventtype'] : $type_list['default'];
|
||||
$type_list = storm_attributes_bydomain('Event type search');
|
||||
$eventtype = _storm_get_filter_param('event', 'eventtype', $type_list['default']);
|
||||
|
||||
$title = isset($_SESSION['stormevent_list_filter']['title']) ? $_SESSION['stormevent_list_filter']['title'] : '';
|
||||
$title = _storm_get_filter_param('event', 'title', '');
|
||||
|
||||
$datebeginfrom = isset($_SESSION['stormevent_list_filter']['datebeginfrom']) ? $_SESSION['stormevent_list_filter']['datebeginfrom'] : NULL;
|
||||
$datebeginto = isset($_SESSION['stormevent_list_filter']['datebeginto']) ? $_SESSION['stormevent_list_filter']['datebeginto'] : NULL;
|
||||
$dateendfrom = isset($_SESSION['stormevent_list_filter']['dateendfrom']) ? $_SESSION['stormevent_list_filter']['dateendfrom'] : NULL;
|
||||
$dateendto = isset($_SESSION['stormevent_list_filter']['dateendto']) ? $_SESSION['stormevent_list_filter']['dateendto'] : NULL;
|
||||
$datebeginfrom = _storm_get_filter_param('event', 'datebeginfrom');
|
||||
$datebeginto = _storm_get_filter_param('event', 'datebeginto');
|
||||
$dateendfrom = _storm_get_filter_param('event', 'dateendfrom');
|
||||
$dateendto = _storm_get_filter_param('event', 'dateendto');
|
||||
|
||||
$itemsperpage = _storm_get_filter_param('event', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormevent_list_filter']['itemsperpage']) ? $_SESSION['stormevent_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormevent_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
|
|
Reference in a new issue