268 lines
8.8 KiB
PHP
268 lines
8.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
*/
|
|
|
|
function stormdok_list() {
|
|
$breadcrumb = array();
|
|
$breadcrumb[] = l(t('Home'), '<front>');
|
|
drupal_set_breadcrumb($breadcrumb);
|
|
|
|
if (array_key_exists('organization_nid', $_GET)) {
|
|
if ($_SESSION['stormdok_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
|
_storm_set_filter_param('dok', 'organization_nid', $_GET['organization_nid']);
|
|
}
|
|
_storm_set_filter_param('dok', 'project_nid');
|
|
_storm_set_filter_param('dok', 'task_nid');
|
|
}
|
|
if (array_key_exists('project_nid', $_GET)) {
|
|
if ($_SESSION['stormdok_list_filter']['project_nid'] != $_GET['project_nid']) {
|
|
_storm_set_filter_param('dok', 'project_nid', $_GET['project_nid']);
|
|
}
|
|
$p = node_load($_GET['project_nid']);
|
|
_storm_set_filter_param('dok', 'organization_nid', $p->organization_nid);
|
|
_storm_set_filter_param('dok', 'task_nid');
|
|
}
|
|
if (array_key_exists('task_nid', $_GET)) {
|
|
if ($_SESSION['stormdok_list_filter']['task_nid'] != $_GET['task_nid']) {
|
|
_storm_set_filter_param('dok', 'task_nid', $_GET['task_nid']);
|
|
}
|
|
$t = node_load($_GET['task_nid']);
|
|
_storm_set_filter_param('dok', 'organization_nid', $t->organization_nid);
|
|
_storm_set_filter_param('dok', 'project_nid', $t->project_nid);
|
|
}
|
|
if (array_key_exists('view', $_GET) && $_GET['view'] == 'all') {
|
|
_storm_set_filter_param('dok', 'title', '');
|
|
}
|
|
|
|
$i = new stdClass();
|
|
$i->type = 'stormdok';
|
|
|
|
$header = array(
|
|
array(
|
|
'data' => ' ',
|
|
),
|
|
array(
|
|
'data' => ' ',
|
|
'field' => 'tdo.field_stormdok_status_value',
|
|
),
|
|
array(
|
|
'data' => t('Title') . ' / ' . t('Organization') . ' » ' . t('Project') . ' » ' . t('Task'),
|
|
'field' => 'n.title',
|
|
),
|
|
array(
|
|
'data' => ' ',
|
|
),
|
|
array(
|
|
'data' => t('Created'),
|
|
'field' => 'n.created',
|
|
'class' => 'storm_list_date',
|
|
),
|
|
array(
|
|
'data' => t('Modified'),
|
|
'field' => 'n.changed',
|
|
'class' => 'storm_list_date',
|
|
'sort' => 'desc',
|
|
),
|
|
array(
|
|
'data' => t('Rev.'),
|
|
'field' => 'sdo.version',
|
|
'class' => 'storm_list_version',
|
|
),
|
|
array(
|
|
'data' => storm_icon_add_node($i, $_GET),
|
|
'class' => 'storm_list_operations',
|
|
),
|
|
);
|
|
|
|
$where = array();
|
|
$args = array();
|
|
$filterfields = array();
|
|
|
|
$s = "SELECT n.*, sdo.*, nre.format, tdo.*, fdo.field_stormdok_attach_list AS clip FROM {node} AS n
|
|
INNER JOIN {stormdok} AS sdo ON n.vid=sdo.vid
|
|
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
|
INNER JOIN {content_type_stormdok} AS tdo ON n.vid = tdo.vid
|
|
LEFT JOIN {content_field_stormdok_attach} AS fdo ON n.vid = fdo.vid AND fdo.field_stormdok_attach_list = 1 AND fdo.delta = 0
|
|
WHERE n.status=1 AND n.type='stormdok'";
|
|
|
|
if (_storm_isset_filter_param('dok', 'organization_nid', 0)) {
|
|
$where[] = 'sdo.organization_nid=%d';
|
|
$args[] = $_SESSION['stormdok_list_filter']['organization_nid'];
|
|
$filterfields[] = t('Organization');
|
|
}
|
|
if (_storm_isset_filter_param('dok', 'project_nid', 0)) {
|
|
$where[] = 'sdo.project_nid=%d';
|
|
$args[] = $_SESSION['stormdok_list_filter']['project_nid'];
|
|
$filterfields[] = t('Project');
|
|
}
|
|
if (_storm_isset_filter_param('dok', 'task_nid', 0)) {
|
|
$where[] = 'sdo.task_nid=%d';
|
|
$args[] = $_SESSION['stormdok_list_filter']['task_nid'];
|
|
$filterfields[] = t('Task');
|
|
}
|
|
|
|
if (_storm_isset_filter_param('dok', 'title', '')) {
|
|
$where[] = "LOWER(n.title) LIKE LOWER('%s')";
|
|
$args[] = $_SESSION['stormdok_list_filter']['title'];
|
|
$filterfields[] = t('Title');
|
|
}
|
|
|
|
$itemsperpage = _storm_get_filter_param('dok', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
|
|
|
if (count($filterfields) == 0) {
|
|
$filterdesc = t('Not filtered');
|
|
}
|
|
else {
|
|
$filterdesc = t('Filtered by !fields', array('!fields' => implode(", ", array_unique($filterfields))));
|
|
}
|
|
$filterdesc .= ' | '. t('!items items per page', array('!items' => $itemsperpage));
|
|
|
|
$o = drupal_get_form('stormdok_list_filter', $filterdesc);
|
|
|
|
$s = stormdok_access_sql($s, $where);
|
|
$s = db_rewrite_sql($s);
|
|
$tablesort = tablesort_sql($header);
|
|
|
|
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
|
|
|
$doks = array();
|
|
while ($item = db_fetch_object($r)) {
|
|
$doks[] = $item;
|
|
}
|
|
|
|
$o .= theme('stormdok_list', $header, $doks);
|
|
$o .= theme('pager', NULL, $itemsperpage, 0);
|
|
print theme('page', $o);
|
|
}
|
|
|
|
function stormdok_list_filter(&$form_state, $filterdesc = 'Filter') {
|
|
$organization_nid = _storm_get_filter_param('dok', 'organization_nid', 0);
|
|
$project_nid = _storm_get_filter_param('dok', 'project_nid', 0);
|
|
$task_nid = _storm_get_filter_param('dok', 'task_nid', 0);
|
|
|
|
$title = _storm_get_filter_param('dok', 'title', '');
|
|
|
|
$itemsperpage = _storm_get_filter_param('dok', 'itemsperpage', variable_get('storm_default_items_per_page', 10));
|
|
|
|
|
|
$form = array();
|
|
|
|
$form['filter'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => $filterdesc,
|
|
'#collapsible' => TRUE,
|
|
'#collapsed' => TRUE,
|
|
);
|
|
|
|
$form['filter']['group1'] = array(
|
|
'#type' => 'markup',
|
|
'#theme' => 'storm_form_group',
|
|
);
|
|
|
|
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormorganization} AS sor ON sor.vid=n.vid WHERE n.status=1 AND n.type='stormorganization' ORDER BY n.title";
|
|
$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;
|
|
}
|
|
$organizations = array(0 => t('All')) + $organizations;
|
|
$form['filter']['group1']['organization_nid'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Organization'),
|
|
'#default_value' => $organization_nid,
|
|
'#options' => $organizations,
|
|
'#attributes' => array('onchange' => "stormtask_organization_project_tasks(this, 'edit-project-nid', 'edit-task-nid', '', true, '" . t('All') . "')"),
|
|
);
|
|
|
|
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormproject} AS spr ON spr.vid=n.vid
|
|
WHERE n.status=1 AND spr.organization_nid=%d AND n.type='stormproject' ORDER BY n.title";
|
|
$s = stormproject_access_sql($s);
|
|
$s = db_rewrite_sql($s);
|
|
$r = db_query($s, $organization_nid);
|
|
$projects = array();
|
|
while ($project = db_fetch_object($r)) {
|
|
$projects[$project->nid] = $project->title;
|
|
}
|
|
$projects = array(0 => t('All')) + $projects;
|
|
$form['filter']['group1']['project_nid'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Project'),
|
|
'#default_value' => $project_nid,
|
|
'#options' => $projects,
|
|
'#process' => array('storm_dependent_select_process'),
|
|
'#attributes' => array('onchange' => "stormtask_project_tasks('edit-organization-nid', this, 'edit-task-nid', '', true, '" . t('All') . "')"),
|
|
);
|
|
|
|
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormtask} AS sta ON sta.nid=n.nid WHERE n.status=1 AND n.type='stormtask' AND sta.project_nid=%d ORDER BY title ";
|
|
$s = stormtask_access_sql($s);
|
|
$s = db_rewrite_sql($s);
|
|
$r = db_query($s, $project_nid);
|
|
$tasks = array();
|
|
while ($task = db_fetch_object($r)) {
|
|
$tasks[$task->nid] = $task->title;
|
|
}
|
|
$tasks = array(0 => t('All')) + $tasks;
|
|
$form['filter']['group1']['task_nid'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Task'),
|
|
'#default_value' => $task_nid,
|
|
'#options' => $tasks,
|
|
);
|
|
|
|
$form['filter']['group2'] = array(
|
|
'#type' => 'markup',
|
|
'#theme' => 'storm_form_group',
|
|
);
|
|
|
|
$form['filter']['group2']['title'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Title'),
|
|
'#default_value' => $title,
|
|
);
|
|
|
|
$form['filter']['group3'] = array(
|
|
'#type' => 'markup',
|
|
'#theme' => 'storm_form_group',
|
|
'#attributes' => array('class' => 'formgroup-submit'),
|
|
);
|
|
|
|
$form['filter']['group3']['submit'] = array(
|
|
'#type' => 'submit',
|
|
'#value' => t('Filter'),
|
|
'#submit' => array('stormdok_list_filter_filter'),
|
|
);
|
|
|
|
$form['filter']['group3']['reset'] = array(
|
|
'#type' => 'submit',
|
|
'#value' => t('Reset'),
|
|
'#submit' => array('stormdok_list_filter_reset'),
|
|
);
|
|
|
|
$form['filter']['group3']['itemsperpage'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Items'),
|
|
'#size' => 10,
|
|
'#default_value' => $itemsperpage,
|
|
'#prefix' => '<div class="container-inline">',
|
|
'#suffix' => '</div>',
|
|
);
|
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
function stormdok_list_filter_reset($form, &$form_state) {
|
|
unset($_SESSION['stormdok_list_filter']);
|
|
}
|
|
|
|
function stormdok_list_filter_filter($form, &$form_state) {
|
|
$_SESSION['stormdok_list_filter']['organization_nid'] = $form_state['values']['organization_nid'];
|
|
$_SESSION['stormdok_list_filter']['project_nid'] = $form_state['values']['project_nid'];
|
|
$_SESSION['stormdok_list_filter']['task_nid'] = $form_state['values']['task_nid'];
|
|
$_SESSION['stormdok_list_filter']['title'] = $form_state['values']['title'];
|
|
$_SESSION['stormdok_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
|
}
|