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
|
@ -511,7 +511,6 @@ function _stormtask_project_assignments_js($organization_nid, $project_nid) {
|
|||
}
|
||||
|
||||
function stormtask_list() {
|
||||
|
||||
global $user;
|
||||
|
||||
$breadcrumb = array();
|
||||
|
@ -520,30 +519,31 @@ function stormtask_list() {
|
|||
|
||||
if (array_key_exists('organization_nid', $_GET)) {
|
||||
if ($_SESSION['stormtask_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
||||
$_SESSION['stormtask_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
_storm_set_filter_param('task', 'organization_nid', $_GET['organization_nid']);
|
||||
}
|
||||
unset($_SESSION['stormtask_list_filter']['project_nid']);
|
||||
_storm_set_filter_param('task', 'project_nid');
|
||||
}
|
||||
if (array_key_exists('project_nid', $_GET)) {
|
||||
if ($_SESSION['stormtask_list_filter']['project_nid'] != $_GET['project_nid']) {
|
||||
$_SESSION['stormtask_list_filter']['project_nid'] = $_GET['project_nid'];
|
||||
_storm_set_filter_param('task', 'project_nid', $_GET['project_nid']);
|
||||
}
|
||||
$p = node_load($_GET['project_nid']);
|
||||
$_SESSION['stormtask_list_filter']['organization_nid'] = $p->organization_nid;
|
||||
_storm_set_filter_param('task', 'organization_nid', $p->organization_nid);
|
||||
}
|
||||
if (array_key_exists('view', $_GET) && $_GET['view'] == 'all') {
|
||||
$_SESSION['stormtask_list_filter']['taskcategory'] = '-';
|
||||
$_SESSION['stormtask_list_filter']['taskstatus'] = '-';
|
||||
$_SESSION['stormtask_list_filter']['taskpriority'] = '-';
|
||||
_storm_set_filter_param('task', 'taskcategory', '-');
|
||||
_storm_set_filter_param('task', 'taskstatus', '-');
|
||||
_storm_set_filter_param('task', 'taskpriority', '-');
|
||||
|
||||
unset($_SESSION['stormtask_list_filter']['datebeginfrom']);
|
||||
unset($_SESSION['stormtask_list_filter']['datebeginto']);
|
||||
unset($_SESSION['stormtask_list_filter']['dateendfrom']);
|
||||
unset($_SESSION['stormtask_list_filter']['dateendto']);
|
||||
unset($_SESSION['stormtask_list_filter']['assigned_to']);
|
||||
_storm_set_filter_param('task', 'datebeginfrom');
|
||||
_storm_set_filter_param('task', 'datebeginto');
|
||||
_storm_set_filter_param('task', 'dateendfrom');
|
||||
_storm_set_filter_param('task', 'dateendto');
|
||||
|
||||
$_SESSION['stormtask_list_filter']['billable'] = '-';
|
||||
$_SESSION['stormtask_list_filter']['billed'] = '-';
|
||||
_storm_set_filter_param('task', 'assigned_to');
|
||||
|
||||
_storm_set_filter_param('task', 'billable', '-');
|
||||
_storm_set_filter_param('task', 'billed', '-');
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
|
@ -591,24 +591,26 @@ function stormtask_list() {
|
|||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
$s = "SELECT n.*, sta.*, nre.format, fta.field_stormtask_attached_list AS clip, ncs.comment_count FROM {node} AS n
|
||||
$s = "SELECT n.*, sta.*, nre.format, fta.field_stormtask_attached_list AS clip, ncs.comment_count FROM {node} AS n
|
||||
INNER JOIN {stormtask} AS sta ON n.vid=sta.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
LEFT JOIN {content_field_stormtask_attached} AS fta ON n.vid = fta.vid AND fta.field_stormtask_attached_list = 1 AND fta.delta = 0
|
||||
LEFT JOIN {node_comment_statistics} AS ncs ON n.nid = ncs.nid
|
||||
WHERE n.status=1 AND n.type='stormtask' ";
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['organization_nid']) && ($_SESSION['stormtask_list_filter']['organization_nid'] != 0)) {
|
||||
if (_storm_isset_filter_param('task', 'organization_nid', 0)) {
|
||||
$where[] = 'sta.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormtask_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormtask_list_filter']['project_nid']) && ($_SESSION['stormtask_list_filter']['project_nid'] != 0)) {
|
||||
if (_storm_isset_filter_param('task', 'project_nid', 0)) {
|
||||
$where[] = 'sta.project_nid=%d';
|
||||
$args[] = $_SESSION['stormtask_list_filter']['project_nid'];
|
||||
$filterfields[] = t('Project');
|
||||
}
|
||||
if (isset($_SESSION['stormtask_list_filter']['taskcategory']) && $_SESSION['stormtask_list_filter']['taskcategory'] != '-') {
|
||||
|
||||
$category_list = storm_attributes_bydomain('Task category search');
|
||||
if (_storm_isset_filter_param('task', 'taskcategory', $category_list['default'], '-')) {
|
||||
$category = split(',', $_SESSION['stormtask_list_filter']['taskcategory']);
|
||||
$v = array();
|
||||
foreach ($category as $item) $v[] = '%s';
|
||||
|
@ -618,7 +620,8 @@ function stormtask_list() {
|
|||
}
|
||||
$filterfields[] = t('Category');
|
||||
}
|
||||
if (isset($_SESSION['stormtask_list_filter']['taskstatus']) && $_SESSION['stormtask_list_filter']['taskstatus'] != '-') {
|
||||
$status_list = storm_attributes_bydomain('Task status search');
|
||||
if (_storm_isset_filter_param('task', 'taskstatus', $status_list['default'], '-')) {
|
||||
$status = split(',', $_SESSION['stormtask_list_filter']['taskstatus']);
|
||||
$v = array();
|
||||
foreach ($status as $item) $v[] = '%s';
|
||||
|
@ -628,7 +631,8 @@ function stormtask_list() {
|
|||
}
|
||||
$filterfields[] = t('Status');
|
||||
}
|
||||
if (isset($_SESSION['stormtask_list_filter']['taskpriority']) && $_SESSION['stormtask_list_filter']['taskpriority'] != '-') {
|
||||
$priority_list = storm_attributes_bydomain('Task priority search');
|
||||
if (_storm_isset_filter_param('task', 'taskpriority', $priority_list['default'], '-')) {
|
||||
$priority = split(',', $_SESSION['stormtask_list_filter']['taskpriority']);
|
||||
$v = array();
|
||||
foreach ($priority as $item) $v[] = '%s';
|
||||
|
@ -639,7 +643,7 @@ function stormtask_list() {
|
|||
$filterfields[] = t('Priority');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['datebeginfrom'])) {
|
||||
if (_storm_isset_filter_param('task', 'datebeginfrom')) {
|
||||
$datebeginfrom = $_SESSION['stormtask_list_filter']['datebeginfrom'];
|
||||
$datebeginfrom['hour'] = 0;
|
||||
$datebeginfrom['minute'] = 0;
|
||||
|
@ -650,8 +654,7 @@ function stormtask_list() {
|
|||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['datebeginto'])) {
|
||||
if (_storm_isset_filter_param('task', 'datebeginto')) {
|
||||
$datebeginto = $_SESSION['stormtask_list_filter']['datebeginto'];
|
||||
$datebeginto['hour'] = 23;
|
||||
$datebeginto['minute'] = 59;
|
||||
|
@ -662,8 +665,7 @@ function stormtask_list() {
|
|||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['dateendfrom'])) {
|
||||
if (_storm_isset_filter_param('task', 'dateendfrom')) {
|
||||
$dateendfrom = $_SESSION['stormtask_list_filter']['dateendfrom'];
|
||||
$dateendfrom['hour'] = 0;
|
||||
$dateendfrom['minute'] = 0;
|
||||
|
@ -674,8 +676,7 @@ function stormtask_list() {
|
|||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['dateendto'])) {
|
||||
if (_storm_isset_filter_param('task', 'dateendto')) {
|
||||
$dateendto = $_SESSION['stormtask_list_filter']['dateendto'];
|
||||
$dateendto['hour'] = 23;
|
||||
$dateendto['minute'] = 59;
|
||||
|
@ -687,7 +688,7 @@ function stormtask_list() {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['assigned_to'])) {
|
||||
if (_storm_isset_filter_param('task', 'assigned_to')) {
|
||||
if (!is_numeric($_SESSION['stormtask_list_filter']['assigned_to'])) {
|
||||
switch ($_SESSION['stormtask_list_filter']['assigned_to']) {
|
||||
|
||||
|
@ -718,19 +719,18 @@ function stormtask_list() {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['billable']) && $_SESSION['stormtask_list_filter']['billable'] != '-') {
|
||||
if (_storm_isset_filter_param('task', 'billable', '-')) {
|
||||
$where[] = 'sta.billable=%d';
|
||||
$args[] = $_SESSION['stormtask_list_filter']['billable'];
|
||||
$filterfields[] = t('Billable');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormtask_list_filter']['billed']) && $_SESSION['stormtask_list_filter']['billed'] != '-') {
|
||||
if (_storm_isset_filter_param('task', 'billed', '-')) {
|
||||
$where[] = 'sta.billed=%d';
|
||||
$args[] = $_SESSION['stormtask_list_filter']['billed'];
|
||||
$filterfields[] = t('Billed');
|
||||
}
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormtask_list_filter']['itemsperpage']) ? $_SESSION['stormtask_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$itemsperpage = _storm_get_filter_param('task', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
||||
|
||||
if (count($filterfields) == 0) {
|
||||
$filterdesc = t('Not filtered');
|
||||
|
@ -759,30 +759,30 @@ function stormtask_list() {
|
|||
}
|
||||
|
||||
function stormtask_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$organization_nid = _storm_get_filter_param('task', 'organization_nid', 0);
|
||||
$project_nid = _storm_get_filter_param('task', 'project_nid', 0);
|
||||
|
||||
$category_list = storm_attributes_bydomain('Task category search');
|
||||
$taskcategory = isset($_SESSION['stormtask_list_filter']['taskcategory']) ? $_SESSION['stormtask_list_filter']['taskcategory'] : $taskcategory = $category_list['default'];
|
||||
$_SESSION['stormtask_list_filter']['taskcategory'] = $taskcategory;
|
||||
$taskcategory = _storm_get_filter_param('task', 'taskcategory', $category_list['default']);
|
||||
|
||||
$status_list = storm_attributes_bydomain('Task status search');
|
||||
$taskstatus = isset($_SESSION['stormtask_list_filter']['taskstatus']) ? $_SESSION['stormtask_list_filter']['taskstatus'] : $status_list['default'];
|
||||
$_SESSION['stormtask_list_filter']['taskstatus'] = $taskstatus;
|
||||
$taskstatus = _storm_get_filter_param('task', 'taskstatus', $status_list['default']);
|
||||
|
||||
$priority_list = storm_attributes_bydomain('Task priority search');
|
||||
$taskpriority = isset($_SESSION['stormtask_list_filter']['taskpriority']) ? $_SESSION['stormtask_list_filter']['taskpriority'] : $priority_list['default'];
|
||||
$_SESSION['stormtask_list_filter']['taskpriority'] = $taskpriority;
|
||||
$taskpriority = _storm_get_filter_param('task', 'taskpriority', $priority_list['default']);
|
||||
|
||||
$organization_nid = isset($_SESSION['stormtask_list_filter']['organization_nid']) ? $_SESSION['stormtask_list_filter']['organization_nid'] : 0;
|
||||
$project_nid = isset($_SESSION['stormtask_list_filter']['project_nid']) ? $_SESSION['stormtask_list_filter']['project_nid'] : 0;
|
||||
$datebeginfrom = _storm_get_filter_param('task', 'datebeginfrom');
|
||||
$datebeginto = _storm_get_filter_param('task', 'datebeginto');
|
||||
$dateendfrom = _storm_get_filter_param('task', 'dateendfrom');
|
||||
$dateendto = _storm_get_filter_param('task', 'dateendto');
|
||||
|
||||
$datebeginfrom = isset($_SESSION['stormtask_list_filter']['datebeginfrom']) ? $_SESSION['stormtask_list_filter']['datebeginfrom'] : NULL;
|
||||
$datebeginto = isset($_SESSION['stormtask_list_filter']['datebeginto']) ? $_SESSION['stormtask_list_filter']['datebeginto'] : NULL;
|
||||
$dateendfrom = isset($_SESSION['stormtask_list_filter']['dateendfrom']) ? $_SESSION['stormtask_list_filter']['dateendfrom'] : NULL;
|
||||
$dateendto = isset($_SESSION['stormtask_list_filter']['dateendto']) ? $_SESSION['stormtask_list_filter']['dateendfrom'] : NULL;
|
||||
$assigned_to = _storm_get_filter_param('task', 'assigned_to');
|
||||
|
||||
$assigned_to = isset($_SESSION['stormtask_list_filter']['assigned_to']) ? $_SESSION['stormtask_list_filter']['assigned_to'] : NULL;
|
||||
$billable = _storm_get_filter_param('task', 'billable', '-');
|
||||
$billed = _storm_get_filter_param('task', 'billed', '-');
|
||||
|
||||
$itemsperpage = _storm_get_filter_param('task', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormtask_list_filter']['itemsperpage']) ? $_SESSION['stormtask_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormtask_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
|
@ -803,6 +803,7 @@ function stormtask_list_filter(&$form_state, $filterdesc = 'Filter') {
|
|||
$s = stormorganization_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s);
|
||||
|
||||
$organizations = array();
|
||||
while ($organization = db_fetch_object($r)) {
|
||||
$organizations[$organization->nid] = $organization->title;
|
||||
|
@ -916,14 +917,14 @@ function stormtask_list_filter(&$form_state, $filterdesc = 'Filter') {
|
|||
'#type' => 'select',
|
||||
'#title' => t('Billable'),
|
||||
'#options' => array('-' => t('all'), '1' => t('billable'), '0' => t('not billable')),
|
||||
'#default_value' => isset($_SESSION['stormtask_list_filter']['billable']) ? $_SESSION['stormtask_list_filter']['billable'] : '-',
|
||||
'#default_value' => $billable,
|
||||
);
|
||||
|
||||
$form['filter']['group4_1']['billed'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Billed'),
|
||||
'#options' => array('-' => t('all'), '1' => t('billed'), '0' => t('not billed')),
|
||||
'#default_value' => isset($_SESSION['stormtask_list_filter']['billed']) ? $_SESSION['stormtask_list_filter']['billed'] : '-',
|
||||
'#default_value' => $billed,
|
||||
);
|
||||
|
||||
$form['filter']['group5'] = array(
|
||||
|
|
Reference in a new issue