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,39 +11,34 @@ function stormnote_list() {
|
|||
|
||||
if (array_key_exists('organization_nid', $_GET)) {
|
||||
if ($_SESSION['stormnote_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
_storm_set_filter_param('note', 'organization_nid', $_GET['organization_nid']);
|
||||
}
|
||||
unset($_SESSION['stormnote_list_filter']['project_nid']);
|
||||
unset($_SESSION['stormnote_list_filter']['task_nid']);
|
||||
_storm_set_filter_param('note', 'project_nid');
|
||||
_storm_set_filter_param('note', 'task_nid');
|
||||
}
|
||||
if (array_key_exists('project_nid', $_GET)) {
|
||||
if ($_SESSION['stormnote_list_filter']['project_nid'] != $_GET['project_nid']) {
|
||||
$_SESSION['stormnote_list_filter']['project_nid'] = $_GET['project_nid'];
|
||||
_storm_set_filter_param('note', 'project_nid', $_GET['project_nid']);
|
||||
}
|
||||
$p = node_load($_GET['project_nid']);
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $p->organization_nid;
|
||||
unset($_SESSION['stormnote_list_filter']['task_nid']);
|
||||
_storm_set_filter_param('note', 'organization_nid', $p->organization_nid);
|
||||
_storm_set_filter_param('note', 'task_nid');
|
||||
}
|
||||
if (array_key_exists('task_nid', $_GET)) {
|
||||
if ($_SESSION['stormnote_list_filter']['task_nid'] != $_GET['task_nid']) {
|
||||
$_SESSION['stormnote_list_filter']['task_nid'] = $_GET['task_nid'];
|
||||
_storm_set_filter_param('note', 'task_nid', $_GET['task_nid']);
|
||||
}
|
||||
$t = node_load($_GET['task_nid']);
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $t->organization_nid;
|
||||
$_SESSION['stormnote_list_filter']['project_nid'] = $t->project_nid;
|
||||
_storm_set_filter_param('note', 'organization_nid', $t->organization_nid);
|
||||
_storm_set_filter_param('note', 'project_nid', $t->project_nid);
|
||||
}
|
||||
if (array_key_exists('view', $_GET) && $_GET['view'] == 'all') {
|
||||
$_SESSION['stormnote_list_filter']['title'] = '';
|
||||
_storm_set_filter_param('note', 'title', '');
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormnote';
|
||||
|
||||
$params = $_GET;
|
||||
if (isset($_SESSION['stormnote_list_filter']['organization_nid'])) {
|
||||
$params['organization_nid'] = $_SESSION['stormnote_list_filter']['organization_nid'];
|
||||
}
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Title') . ' / ' . t('Organization') . ' » ' . t('Project') . ' » ' . t('Task'),
|
||||
|
@ -69,44 +64,44 @@ function stormnote_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.*, sno.*, nre.format, fno.field_stormnote_attached_list AS clip FROM {node} AS n
|
||||
INNER JOIN {stormnote} AS sno ON n.vid=sno.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
LEFT JOIN {content_field_stormnote_attached} AS fno ON n.vid = fno.vid AND fno.field_stormnote_attached_list = 1 AND fno.delta = 0
|
||||
WHERE n.status=1 AND n.type='stormnote'";
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
if (isset($_SESSION['stormnote_list_filter']['organization_nid']) && $_SESSION['stormnote_list_filter']['organization_nid'] != 0) {
|
||||
$s = "SELECT n.*, sno.*, nre.format, fno.field_stormnote_attached_list AS clip FROM {node} AS n
|
||||
INNER JOIN {stormnote} AS sno ON n.vid=sno.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
LEFT JOIN {content_field_stormnote_attached} AS fno ON n.vid = fno.vid AND fno.field_stormnote_attached_list = 1 AND fno.delta = 0
|
||||
WHERE n.status=1 AND n.type='stormnote'";
|
||||
|
||||
if (_storm_isset_filter_param('note', 'organization_nid', 0)) {
|
||||
$where[] = 'sno.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormnote_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormnote_list_filter']['project_nid']) && $_SESSION['stormnote_list_filter']['project_nid'] != 0) {
|
||||
if (_storm_isset_filter_param('note', 'project_nid', 0)) {
|
||||
$where[] = 'sno.project_nid=%d';
|
||||
$args[] = $_SESSION['stormnote_list_filter']['project_nid'];
|
||||
$filterfields[] = t('Project');
|
||||
}
|
||||
if (isset($_SESSION['stormnote_list_filter']['task_nid']) && $_SESSION['stormnote_list_filter']['task_nid'] != 0) {
|
||||
if (_storm_isset_filter_param('note', 'task_nid', 0)) {
|
||||
$where[] = 'sno.task_nid=%d';
|
||||
$args[] = $_SESSION['stormnote_list_filter']['task_nid'];
|
||||
$filterfields[] = t('Task');
|
||||
}
|
||||
if (isset($_SESSION['stormnote_list_filter']['title']) && $_SESSION['stormnote_list_filter']['title'] != '') {
|
||||
|
||||
if (_storm_isset_filter_param('note', 'title', '')) {
|
||||
$where[] = "LOWER(n.title) LIKE CONCAT('%', LOWER('%s'), '%')";
|
||||
$args[] = $_SESSION['stormnote_list_filter']['title'];
|
||||
$filterfields[] = t('Title');
|
||||
}
|
||||
|
||||
// This section only provides the value for the fieldset label, doesn't control actual filter
|
||||
$itemsperpage = isset($_SESSION['stormnote_list_filter']['itemsperpage']) ? $_SESSION['stormnote_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$itemsperpage = _storm_get_filter_param('note', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
||||
|
||||
if (count($filterfields) == 0) {
|
||||
$filterdesc = t('Not filtered');
|
||||
|
@ -135,13 +130,14 @@ function stormnote_list() {
|
|||
}
|
||||
|
||||
function stormnote_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$organization_nid = isset($_SESSION['stormnote_list_filter']['organization_nid']) ? $_SESSION['stormnote_list_filter']['organization_nid'] : 0;
|
||||
$project_nid = isset($_SESSION['stormnote_list_filter']['project_nid']) ? $_SESSION['stormnote_list_filter']['project_nid'] : 0;
|
||||
$task_nid = isset($_SESSION['stormnote_list_filter']['task_nid']) ? $_SESSION['stormnote_list_filter']['task_nid'] : 0;
|
||||
$title = isset($_SESSION['stormnote_list_filter']['title']) ? $_SESSION['stormnote_list_filter']['title'] : '';
|
||||
$organization_nid = _storm_get_filter_param('note', 'organization_nid', 0);
|
||||
$project_nid = _storm_get_filter_param('note', 'project_nid', 0);
|
||||
$task_nid = _storm_get_filter_param('note', 'task_nid', 0);
|
||||
|
||||
$title = _storm_get_filter_param('note', 'title', '');
|
||||
|
||||
$itemsperpage = _storm_get_filter_param('note', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormnote_list_filter']['itemsperpage']) ? $_SESSION['stormnote_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormnote_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
|
|
Reference in a new issue