Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
520
modules/storm/stormticket/stormticket.admin.inc
Normal file
520
modules/storm/stormticket/stormticket.admin.inc
Normal file
|
@ -0,0 +1,520 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormticket_list() {
|
||||
|
||||
global $user;
|
||||
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (array_key_exists('organization_nid', $_GET)) {
|
||||
if ($_SESSION['stormticket_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
||||
$_SESSION['stormticket_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
}
|
||||
unset($_SESSION['stormticket_list_filter']['project_nid']);
|
||||
unset($_SESSION['stormticket_list_filter']['task_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('project_nid', $_GET)) {
|
||||
if ($_SESSION['stormticket_list_filter']['project_nid'] != $_GET['project_nid']) {
|
||||
$_SESSION['stormticket_list_filter']['project_nid'] = $_GET['project_nid'];
|
||||
}
|
||||
$p = node_load($_GET['project_nid']);
|
||||
$_SESSION['stormticket_list_filter']['organization_nid'] = $p->organization_nid;
|
||||
|
||||
unset($_SESSION['stormticket_list_filter']['task_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('task_nid', $_GET)) {
|
||||
if ($_SESSION['stormticket_list_filter']['task_nid'] != $_GET['task_nid']) {
|
||||
$_SESSION['stormticket_list_filter']['task_nid'] = $_GET['task_nid'];
|
||||
}
|
||||
|
||||
$t = node_load($_GET['task_nid']);
|
||||
$_SESSION['stormticket_list_filter']['organization_nid'] = $t->organization_nid;
|
||||
$_SESSION['stormticket_list_filter']['project_nid'] = $t->project_nid;
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormticket';
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => ' ',
|
||||
),
|
||||
array(
|
||||
'data' => ' ',
|
||||
'field' => 'sti.ticketstatus',
|
||||
),
|
||||
array(
|
||||
'data' => t('Title') . ' / ' . t('Organization') . ' » ' . t('Project'),
|
||||
'field' => 'n.title',
|
||||
),
|
||||
array(
|
||||
'data' => ' ',
|
||||
),
|
||||
array(
|
||||
'data' => t('Date'),
|
||||
'field' => 'n.changed',
|
||||
'sort' => 'desc',
|
||||
),
|
||||
array(
|
||||
'data' => t('Pr.'),
|
||||
'field' => 'sti.ticketpriority',
|
||||
),
|
||||
array(
|
||||
'data' => t('Co.'),
|
||||
'field' => 'ncs.comment_count',
|
||||
'class' => 'storm_list_comments',
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_add_node($i, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
$s = "SELECT n.*, sti.*, nre.format, fta.field_stormticket_attached_list AS clip, ncs.comment_count FROM {node} AS n
|
||||
INNER JOIN {stormticket} AS sti ON n.vid=sti.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
LEFT JOIN {content_field_stormticket_attached} AS fta ON n.vid = fta.vid AND fta.field_stormticket_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='stormticket' ";
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['organization_nid']) && ($_SESSION['stormticket_list_filter']['organization_nid'] != 0)) {
|
||||
$where[] = 'sti.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormticket_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormticket_list_filter']['project_nid']) && ($_SESSION['stormticket_list_filter']['project_nid'] != 0)) {
|
||||
$where[] = 'sti.project_nid=%d';
|
||||
$args[] = $_SESSION['stormticket_list_filter']['project_nid'];
|
||||
$filterfields[] = t('Project');
|
||||
}
|
||||
if (isset($_SESSION['stormticket_list_filter']['task_nid']) && ($_SESSION['stormticket_list_filter']['task_nid'] != 0)) {
|
||||
$where[] = 'sti.task_nid=%d';
|
||||
$args[] = $_SESSION['stormticket_list_filter']['task_nid'];
|
||||
$filterfields[] = t('Task');
|
||||
}
|
||||
|
||||
$category_list = storm_attributes_bydomain('ticket category search');
|
||||
$ticketcategory = isset($_SESSION['stormticket_list_filter']['ticketcategory']) ? $_SESSION['stormticket_list_filter']['ticketcategory'] : $category_list['default'];
|
||||
$_SESSION['stormticket_list_filter']['ticketcategory'] = $ticketcategory;
|
||||
|
||||
if ($ticketcategory != '-') {
|
||||
$category = split(',', $ticketcategory);
|
||||
$v = array();
|
||||
foreach ($category as $item) $v[] = '%s';
|
||||
$where[] = "sti.ticketcategory IN ('". implode("','", $v) ."')";
|
||||
foreach ($category as $key => $value) {
|
||||
$args[] = $value;
|
||||
}
|
||||
$filterfields[] = t('Category');
|
||||
}
|
||||
|
||||
$status_list = storm_attributes_bydomain('ticket status search');
|
||||
$ticketstatus = isset($_SESSION['stormticket_list_filter']['ticketstatus']) ? $_SESSION['stormticket_list_filter']['ticketstatus'] : $status_list['default'];
|
||||
$_SESSION['stormticket_list_filter']['ticketstatus'] = $ticketstatus;
|
||||
|
||||
if ($ticketstatus != '-') {
|
||||
$status = split(',', $ticketstatus);
|
||||
$v = array();
|
||||
foreach ($status as $item) $v[] = '%s';
|
||||
$where[] = "sti.ticketstatus IN ('". implode("','", $v) ."')";
|
||||
foreach ($status as $key => $value) {
|
||||
$args[] = $value;
|
||||
}
|
||||
$filterfields[] = t('Status');
|
||||
}
|
||||
|
||||
$priority_list = storm_attributes_bydomain('ticket priority search');
|
||||
$ticketpriority = isset($_SESSION['stormticket_list_filter']['ticketpriority']) ? $_SESSION['stormticket_list_filter']['ticketpriority'] : $priority_list['default'];
|
||||
$_SESSION['stormticket_list_filter']['ticketpriority'] = $ticketpriority;
|
||||
|
||||
if ($ticketpriority != '-') {
|
||||
$priority = split(',', $ticketpriority);
|
||||
$v = array();
|
||||
foreach ($priority as $item) $v[] = '%s';
|
||||
$where[] = "sti.ticketpriority IN ('". implode("','", $v) ."')";
|
||||
foreach ($priority as $key => $value) {
|
||||
$args[] = $value;
|
||||
}
|
||||
$filterfields[] = t('Priority');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['datebeginfrom'])) {
|
||||
$datebeginfrom = $_SESSION['stormticket_list_filter']['datebeginfrom'];
|
||||
$datebeginfrom['hour'] = 0;
|
||||
$datebeginfrom['minute'] = 0;
|
||||
$t = _storm_datetime_to_gmtimestamp($datebeginfrom);
|
||||
if ($datebeginfrom['year']>0 && $t>=0) {
|
||||
$where[] = 'sti.datebegin>=%d';
|
||||
$args[] = $t;
|
||||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['datebeginto'])) {
|
||||
$datebeginto = $_SESSION['stormticket_list_filter']['datebeginto'];
|
||||
$datebeginto['hour'] = 23;
|
||||
$datebeginto['minute'] = 59;
|
||||
$t = _storm_datetime_to_gmtimestamp($datebeginto);
|
||||
if ($datebeginto['year']>0 && $t>=0) {
|
||||
$where[] = 'sti.datebegin<=%d';
|
||||
$args[] = $t;
|
||||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['dateendfrom'])) {
|
||||
$dateendfrom = $_SESSION['stormticket_list_filter']['dateendfrom'];
|
||||
$dateendfrom['hour'] = 0;
|
||||
$dateendfrom['minute'] = 0;
|
||||
$t = _storm_datetime_to_gmtimestamp($dateendfrom);
|
||||
if ($dateendfrom['year']>0 && $t>=0) {
|
||||
$where[] = 'sti.dateend>=%d';
|
||||
$args[] = $t;
|
||||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['dateendto'])) {
|
||||
$dateendto = $_SESSION['stormticket_list_filter']['dateendto'];
|
||||
$dateendto['hour'] = 23;
|
||||
$dateendto['minute'] = 59;
|
||||
$t = _storm_datetime_to_gmtimestamp($dateendto);
|
||||
if ($dateendto['year']>0 && $t>=0) {
|
||||
$where[] = 'sti.dateend<=%d';
|
||||
$args[] = $t;
|
||||
$filterfields[] = t('Date');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['assigned_to'])) {
|
||||
if (!is_numeric($_SESSION['stormticket_list_filter']['assigned_to'])) {
|
||||
switch ($_SESSION['stormticket_list_filter']['assigned_to']) {
|
||||
case 'all':
|
||||
// NO FILTER
|
||||
break;
|
||||
case 'mine':
|
||||
// CURRENT USER
|
||||
if (!empty($user->stormperson_nid) && is_numeric($user->stormperson_nid)) {
|
||||
$assigned_to_nid = $user->stormperson_nid;
|
||||
}
|
||||
break;
|
||||
case 'none':
|
||||
$where[] = '(sti.assigned_nid IS NULL OR sti.assigned_nid = 0) ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$assigned_to_nid = $_SESSION['stormticket_list_filter']['assigned_to'];
|
||||
}
|
||||
if (!empty($assigned_to_nid) && is_numeric($assigned_to_nid)) {
|
||||
$where[] = 'sti.assigned_nid=%d';
|
||||
$args[] = $assigned_to_nid;
|
||||
$filterfields[] = t('Assigned to');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['billable']) && $_SESSION['stormticket_list_filter']['billable'] != '-') {
|
||||
$where[] = 'sti.billable=%d';
|
||||
$args[] = $_SESSION['stormticket_list_filter']['billable'];
|
||||
$filterfields[] = t('Billable');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormticket_list_filter']['billed']) && $_SESSION['stormticket_list_filter']['billed'] != '-') {
|
||||
$where[] = 'sti.billed=%d';
|
||||
$args[] = $_SESSION['stormticket_list_filter']['billed'];
|
||||
$filterfields[] = t('Billed');
|
||||
}
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormticket_list_filter']['itemsperpage']) ? $_SESSION['stormticket_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormticket_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
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' => $_SESSION['stormticket_list_filter']['itemsperpage']));
|
||||
|
||||
$o = drupal_get_form('stormticket_list_filter', $filterdesc);
|
||||
|
||||
$s = stormticket_access_sql($s, $where);
|
||||
$s = db_rewrite_sql($s);
|
||||
|
||||
$tablesort = tablesort_sql($header);
|
||||
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
||||
|
||||
$tickets = array();
|
||||
while ($item = db_fetch_object($r)) {
|
||||
$tickets[] = $item;
|
||||
}
|
||||
|
||||
$o .= theme('stormticket_list', $header, $tickets);
|
||||
$o .= theme('pager', NULL, $itemsperpage, 0);
|
||||
print theme('page', $o);
|
||||
}
|
||||
|
||||
function stormticket_list_filter(&$form_state, $filterdesc='Filter') {
|
||||
$organization_nid = isset($_SESSION['stormticket_list_filter']['organization_nid']) ? $_SESSION['stormticket_list_filter']['organization_nid'] : 0;
|
||||
$project_nid = isset($_SESSION['stormticket_list_filter']['project_nid']) ? $_SESSION['stormticket_list_filter']['project_nid'] : 0;
|
||||
$task_nid = isset($_SESSION['stormticket_list_filter']['task_nid']) ? $_SESSION['stormticket_list_filter']['task_nid'] : 0;
|
||||
|
||||
$category_list = storm_attributes_bydomain('ticket category search');
|
||||
$ticketcategory = isset($_SESSION['stormticket_list_filter']['ticketcategory']) ? $_SESSION['stormticket_list_filter']['ticketcategory'] : $category_list['default'];
|
||||
|
||||
$status_list = storm_attributes_bydomain('ticket status search');
|
||||
$ticketstatus = isset($_SESSION['stormticket_list_filter']['ticketstatus']) ? $_SESSION['stormticket_list_filter']['ticketstatus'] : $status_list['default'];
|
||||
|
||||
$priority_list = storm_attributes_bydomain('ticket priority search');
|
||||
$ticketpriority = isset($_SESSION['stormticket_list_filter']['ticketpriority']) ? $_SESSION['stormticket_list_filter']['ticketpriority'] : $priority_list['default'];
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormticket_list_filter']['itemsperpage']) ? $_SESSION['stormticket_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormticket_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$datebeginfrom = isset($_SESSION['stormticket_list_filter']['datebeginfrom']) ? $_SESSION['stormticket_list_filter']['datebeginfrom'] : NULL;
|
||||
$datebeginto = isset($_SESSION['stormticket_list_filter']['datebeginto']) ? $_SESSION['stormticket_list_filter']['datebeginto'] : NULL;
|
||||
$dateendfrom = isset($_SESSION['stormticket_list_filter']['dateendfrom']) ? $_SESSION['stormticket_list_filter']['dateendfrom'] : NULL;
|
||||
$dateendto = isset($_SESSION['stormticket_list_filter']['dateendto']) ? $_SESSION['stormticket_list_filter']['dateendto'] : NULL;
|
||||
|
||||
$assigned_to = isset($_SESSION['stormticket_list_filter']['assigned_to']) ? $_SESSION['stormticket_list_filter']['assigned_to'] : NULL;
|
||||
|
||||
$form = array();
|
||||
|
||||
$form['filter'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $filterdesc,
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#theme' => 'stormticket_list_filter',
|
||||
);
|
||||
|
||||
$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', 'edit-assigned-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', 'edit-assigned-nid', true, '" . t('All') . "')"),
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormtask} AS sta
|
||||
ON sta.vid=n.vid 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']['ticketcategory'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Category'),
|
||||
'#default_value' => $ticketcategory,
|
||||
'#options' => $category_list['values'],
|
||||
);
|
||||
|
||||
$form['filter']['group2']['ticketstatus'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Status'),
|
||||
'#default_value' => $ticketstatus,
|
||||
'#options' => $status_list['values'],
|
||||
);
|
||||
|
||||
$form['filter']['group2']['ticketpriority'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Priority'),
|
||||
'#default_value' => $ticketpriority,
|
||||
'#options' => $priority_list['values'],
|
||||
);
|
||||
|
||||
$form['filter']['group3'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
);
|
||||
|
||||
$form['filter']['group3']['datebeginfrom'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#withnull' => 'true',
|
||||
'#title' => t('Date begin from'),
|
||||
'#default_value' => $datebeginfrom,
|
||||
);
|
||||
|
||||
$form['filter']['group3']['datebeginto'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#withnull' => 'true',
|
||||
'#title' => t('Date begin to'),
|
||||
'#default_value' => $datebeginto,
|
||||
);
|
||||
|
||||
$form['filter']['group4'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
);
|
||||
|
||||
$form['filter']['group4']['dateendfrom'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#withnull' => 'true',
|
||||
'#title' => t('Date end from'),
|
||||
'#default_value' => $dateendfrom,
|
||||
);
|
||||
|
||||
$form['filter']['group4']['dateendto'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#withnull' => 'true',
|
||||
'#title' => t('Date end to'),
|
||||
'#default_value' => $dateendto,
|
||||
);
|
||||
|
||||
$form['filter']['group4_1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
);
|
||||
|
||||
// ASSIGNED TO
|
||||
$options = storm_get_assignment_options(0, 0);
|
||||
$form['filter']['group4_1']['assigned_to'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Assigned to'),
|
||||
'#default_value' => $assigned_to,
|
||||
'#options' => $options,
|
||||
);
|
||||
|
||||
$form['filter']['group4_1']['billable'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Billable'),
|
||||
'#options' => array('-' => t('all'), '1' => t('billable'), '0' => t('not billable')),
|
||||
'#default_value' => isset($_SESSION['stormticket_list_filter']['billable']) ? $_SESSION['stormticket_list_filter']['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['stormticket_list_filter']['billed']) ? $_SESSION['stormticket_list_filter']['billed'] : '-',
|
||||
);
|
||||
|
||||
$form['filter']['group5'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#attributes' => array('class' => 'formgroup-submit'),
|
||||
);
|
||||
|
||||
$form['filter']['group5']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Filter'),
|
||||
'#submit' => array('stormticket_list_filter_filter'),
|
||||
);
|
||||
|
||||
$form['filter']['group5']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Reset'),
|
||||
'#submit' => array('stormticket_list_filter_reset'),
|
||||
);
|
||||
|
||||
$form['filter']['group5']['itemsperpage'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Items'),
|
||||
'#size' => 10,
|
||||
'#default_value' => $itemsperpage,
|
||||
'#prefix' => '<div class="container-inline">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormticket_list_filter_filter($form, &$form_state) {
|
||||
$_SESSION['stormticket_list_filter']['organization_nid'] = $form_state['values']['organization_nid'];
|
||||
$_SESSION['stormticket_list_filter']['project_nid'] = $form_state['values']['project_nid'];
|
||||
$_SESSION['stormticket_list_filter']['task_nid'] = $form_state['values']['task_nid'];
|
||||
$_SESSION['stormticket_list_filter']['ticketcategory'] = $form_state['values']['ticketcategory'];
|
||||
$_SESSION['stormticket_list_filter']['ticketstatus'] = $form_state['values']['ticketstatus'];
|
||||
$_SESSION['stormticket_list_filter']['ticketpriority'] = $form_state['values']['ticketpriority'];
|
||||
$_SESSION['stormticket_list_filter']['datebeginfrom'] = $form_state['values']['datebeginfrom'];
|
||||
$_SESSION['stormticket_list_filter']['datebeginto'] = $form_state['values']['datebeginto'];
|
||||
$_SESSION['stormticket_list_filter']['dateendfrom'] = $form_state['values']['dateendfrom'];
|
||||
$_SESSION['stormticket_list_filter']['dateendto'] = $form_state['values']['dateendto'];
|
||||
$_SESSION['stormticket_list_filter']['assigned_to'] = $form_state['values']['assigned_to'];
|
||||
$_SESSION['stormticket_list_filter']['billable'] = $form_state['values']['billable'];
|
||||
$_SESSION['stormticket_list_filter']['billed'] = $form_state['values']['billed'];
|
||||
$_SESSION['stormticket_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
||||
}
|
||||
|
||||
function stormticket_list_filter_reset($form, &$form_state) {
|
||||
unset($_SESSION['stormticket_list_filter']);
|
||||
}
|
||||
|
||||
function _stormticket_task_tickets_js($organization_nid=0, $project_nid=0, $task_nid=0) {
|
||||
$tickets = array();
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} n INNER JOIN {stormticket} sti
|
||||
ON n.vid=sti.vid WHERE n.status=1 AND n.type='stormticket' AND sti.organization_nid=%d AND sti.project_nid=%d
|
||||
AND sti.task_nid=%d ORDER BY n.title";
|
||||
|
||||
$s = stormticket_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $organization_nid, $project_nid, $task_nid);
|
||||
while ($item = db_fetch_object($r)) {
|
||||
$nid = $item->nid;
|
||||
$tickets[$nid] = check_plain($item->title);
|
||||
}
|
||||
print drupal_to_js($tickets);
|
||||
exit();
|
||||
}
|
14
modules/storm/stormticket/stormticket.info
Normal file
14
modules/storm/stormticket/stormticket.info
Normal file
|
@ -0,0 +1,14 @@
|
|||
name = Storm Ticket
|
||||
description = "Allows creation of tickets for SuiteDesk Projects and Tasks"
|
||||
dependencies[] = storm
|
||||
dependencies[] = stormorganization
|
||||
dependencies[] = stormproject
|
||||
dependencies[] = stormtask
|
||||
package = Storm
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-05
|
||||
version = "6.x-2.2"
|
||||
core = "6.x"
|
||||
project = "storm"
|
||||
datestamp = "1375697500"
|
240
modules/storm/stormticket/stormticket.install
Normal file
240
modules/storm/stormticket/stormticket.install
Normal file
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormticket_install() {
|
||||
drupal_install_schema('stormticket');
|
||||
variable_set('node_options_stormticket', array('status'));
|
||||
|
||||
$attributes = array();
|
||||
|
||||
$attributes['Ticket status'] = array(
|
||||
'inserted' => 'inserted',
|
||||
'in progress' => 'in progress',
|
||||
'on hold' => 'on hold',
|
||||
'completed' => 'completed'
|
||||
);
|
||||
|
||||
$attributes['Ticket status search'] = array(
|
||||
'-' => 'all',
|
||||
'inserted,in progress,on hold' => 'open',
|
||||
'inserted' => '-- inserted',
|
||||
'in progress' => '-- in progress',
|
||||
'on hold' => '-- on hold',
|
||||
'completed' => 'completed'
|
||||
);
|
||||
|
||||
$attributes['Ticket category'] = array(
|
||||
'estimate' => 'estimate',
|
||||
'bug' => 'bug',
|
||||
'feature request' => 'feature request',
|
||||
'support' => 'support',
|
||||
'task' => 'task'
|
||||
);
|
||||
|
||||
$attributes['Ticket category search'] = array(
|
||||
'-' => 'all',
|
||||
'estimate' => 'estimate',
|
||||
'bug' => 'bug',
|
||||
'feature request' => 'feature request',
|
||||
'support' => 'support',
|
||||
'task' => 'task'
|
||||
);
|
||||
|
||||
$attributes['Ticket priority'] = array(
|
||||
'1-low' => 'low',
|
||||
'2-normal' => 'normal',
|
||||
'3-high' => 'high',
|
||||
'4-urgent' => 'urgent'
|
||||
);
|
||||
|
||||
$attributes['Ticket priority search'] = array(
|
||||
'-' => 'all',
|
||||
'1-low' => 'low',
|
||||
'2-normal' => 'normal',
|
||||
'3-high' => 'high',
|
||||
'4-urgent' => 'urgent'
|
||||
);
|
||||
|
||||
$s = "INSERT INTO {stormattribute} (domain, akey, avalue, weight) VALUES ('%s', '%s', '%s', %d)";
|
||||
$prevdomain = '';
|
||||
$weight = 0;
|
||||
foreach ($attributes as $domain => $attribute) {
|
||||
if ($domain != $prevdomain) $weight=0;
|
||||
foreach ($attribute as $key => $value) {
|
||||
db_query($s, $domain, $key, $value, $weight);
|
||||
$weight++;
|
||||
}
|
||||
$prevdomain = $domain;
|
||||
}
|
||||
}
|
||||
|
||||
function stormticket_disable() {
|
||||
drupal_set_message(t('Nodes of type "Ticket" have not been deleted on disabling SuiteDesk Ticket. Please note that they will now have reduced functionality, and will not be protected by SuiteDesk Ticket access controls.'), 'warning');
|
||||
}
|
||||
|
||||
function stormticket_uninstall() {
|
||||
drupal_uninstall_schema('stormticket');
|
||||
|
||||
db_query($s = "DELETE FROM {stormattribute} WHERE domain IN ('Ticket status', 'Ticket status search', 'Ticket priority', 'Ticket priority search', 'Ticket category', 'Ticket category search')");
|
||||
}
|
||||
|
||||
function stormticket_schema() {
|
||||
$schema['stormticket'] = array(
|
||||
'fields' => array(
|
||||
'vid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'organization_nid' => array('type' => 'int'),
|
||||
'organization_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'project_nid' => array('type' => 'int'),
|
||||
'project_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'task_nid' => array('type' => 'int'),
|
||||
'task_stepno' => array('type' => 'varchar', 'length' => 128),
|
||||
'task_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'ticketcategory' => array('type' => 'varchar', 'length' => 100),
|
||||
'ticketstatus' => array('type' => 'varchar', 'length' => 100),
|
||||
'ticketpriority' => array('type' => 'varchar', 'length' => 100),
|
||||
'pricemode' => array('type' => 'varchar', 'length' => 100),
|
||||
'price' => array('type' => 'float'),
|
||||
'currency' => array('type' => 'varchar', 'length' => 100),
|
||||
'datebegin' => array('type' => 'int', 'default' => 0),
|
||||
'dateend' => array('type' => 'int', 'default' => 0),
|
||||
'durationunit' => array('type' => 'varchar', 'length' => 100),
|
||||
'duration' => array('type' => 'float', 'default' => 0),
|
||||
'assigned_nid' => array('type' => 'int'),
|
||||
'assigned_title' => array('type' => 'varchar', 'length' => 100),
|
||||
'billable' => array('type' => 'int', 'default' => 0),
|
||||
'billed' => array('type' => 'int', 'default' => 0),
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'project_nid' => array('project_nid'),
|
||||
'task_nid' => array('task_nid'),
|
||||
'assigned_nid' => array('assigned_nid'),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
function stormticket_update_1() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormticket', 'datebegin', array('type' => 'int', 'default' => 0));
|
||||
db_add_field($ret, 'stormticket', 'dateend', array('type' => 'int', 'default' => 0));
|
||||
db_add_field($ret, 'stormticket', 'durationunit', array('type' => 'varchar', 'length' => 20));
|
||||
db_add_field($ret, 'stormticket', 'duration', array('type' => 'float', 'default' => 0));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function stormticket_update_2() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormticket', 'pricemode', array('type' => 'varchar', 'length' => 20));
|
||||
db_add_field($ret, 'stormticket', 'price', array('type' => 'float'));
|
||||
db_add_field($ret, 'stormticket', 'currency', array('type' => 'varchar', 'length' => 20));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
* Implementation of hook_update_N: Adds assigned_nid and assigned_title fields
|
||||
*/
|
||||
function stormticket_update_6103() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormticket', 'assigned_nid', array('type' => 'int'));
|
||||
db_add_field($ret, 'stormticket', 'assigned_title', array('type' => 'varchar', 'length' => 100));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added billable and billed fields to stormticket table for issue 567558
|
||||
*/
|
||||
function stormticket_update_6106() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormticket', 'billable', array('type' => 'int', 'default' => 0));
|
||||
db_add_field($ret, 'stormticket', 'billed', array('type' => 'int', 'default' => 0));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @function
|
||||
* Database update for issue #899970
|
||||
*/
|
||||
function stormticket_update_6107() {
|
||||
$ret = array();
|
||||
|
||||
db_change_field($ret, 'stormticket', 'ticketcategory', 'ticketcategory', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormticket', 'ticketstatus', 'ticketstatus', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormticket', 'ticketpriority', 'ticketpriority', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormticket', 'pricemode', 'pricemode', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormticket', 'currency', 'currency', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormticket', 'durationunit', 'durationunit', array('type' => 'varchar', 'length' => 100));
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Improve primary keys and indexes
|
||||
*/
|
||||
function stormticket_update_6201() {
|
||||
$return = array();
|
||||
db_drop_primary_key($return, 'stormticket');
|
||||
db_add_primary_key($return, 'stormticket', array('vid'));
|
||||
$indexes = array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'project_nid' => array('project_nid'),
|
||||
'task_nid' => array('task_nid'),
|
||||
'assigned_nid' => array('assigned_nid'),
|
||||
);
|
||||
foreach ($indexes as $name => $fields) {
|
||||
db_add_index($return, 'stormticket', $name, $fields);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move SuiteDesk Attribute module into component modules
|
||||
*/
|
||||
function stormticket_update_6202() {
|
||||
$attributes = array();
|
||||
|
||||
if (db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'stormattribute'")) < 5) {
|
||||
$attributes['Ticket category search'] = array(
|
||||
'bug' => 'bug',
|
||||
'feature request' => 'feature request',
|
||||
'support' => 'support',
|
||||
'task' => 'task'
|
||||
);
|
||||
}
|
||||
|
||||
if (db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'stormattribute'")) < 6) {
|
||||
$attributes['Ticket status search'] = array('-' => 'all');
|
||||
$attributes['Ticket category search'] = array('-' => 'all');
|
||||
$attributes['Ticket priority search'] = array('-' => 'all');
|
||||
}
|
||||
|
||||
$s = "INSERT INTO {stormattribute} (domain, akey, avalue, weight, isactive) VALUES ('%s', '%s', '%s', %d, 1)";
|
||||
$prevdomain = '';
|
||||
$weight = 0;
|
||||
foreach ($attributes as $domain => $attribute) {
|
||||
if ($domain != $prevdomain) $weight=0;
|
||||
foreach ($attribute as $key => $value) {
|
||||
db_query($s, $domain, $key, $value, $weight);
|
||||
$weight++;
|
||||
}
|
||||
$prevdomain = $domain;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
|
||||
if (db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'stormattribute'")) < 6112) {
|
||||
$ret[] = update_sql("UPDATE {stormticket} set pricemode='fixed_price' where pricemode='fixed_timetracking'");
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
42
modules/storm/stormticket/stormticket.js
Normal file
42
modules/storm/stormticket/stormticket.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
function stormticket_task_tickets(_task_select, _organization_select_id, _project_select_id, _ticket_select_id, _with_all_option, _all_text) {
|
||||
var ticket_select = $("#" + _ticket_select_id).get(0);
|
||||
storm_empty_select(ticket_select);
|
||||
|
||||
var organization_select = $("#" + _organization_select_id).get(0);
|
||||
var organization_nid = organization_select.value;
|
||||
if (!organization_nid) organization_nid=0;
|
||||
|
||||
var project_select = $("#" + _project_select_id).get(0);
|
||||
var project_nid = project_select.value;
|
||||
if (!project_nid) project_nid=0;
|
||||
|
||||
var task_nid = _task_select.value;
|
||||
if (!task_nid) task_nid=0;
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
async: true,
|
||||
url: Drupal.settings.storm.task_tickets_url + Drupal.encodeURIComponent(organization_nid) +
|
||||
'/' + Drupal.encodeURIComponent(project_nid) +
|
||||
'/' + Drupal.encodeURIComponent(task_nid),
|
||||
dataType: "string",
|
||||
success: function (data) {
|
||||
var items = Drupal.parseJson(data);
|
||||
storm_fill_select(ticket_select, items, _with_all_option, _all_text);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function stormticket_project_task_tickets(_project_select, _organization_select_id, _task_select_id, _ticket_select_id, _with_all_option, _all_text) {
|
||||
stormtask_project_tasks(_organization_select_id, _project_select, _task_select_id, '', _with_all_option, _all_text);
|
||||
var task_select = $("#" + _task_select_id).get(0);
|
||||
stormticket_task_tickets(task_select, _organization_select_id, _project_select.id, _ticket_select_id, _with_all_option, _all_text);
|
||||
};
|
||||
|
||||
function stormticket_organization_project_task_tickets(_organization_select, _project_select_id, _task_select_id, _ticket_select_id, _with_all_option, _all_text) {
|
||||
stormproject_organization_projects(_organization_select, _project_select_id, _with_all_option, _all_text);
|
||||
var project_select = $("#" + _project_select_id).get(0);
|
||||
stormticket_project_task_tickets(project_select, _organization_select.id, _task_select_id, _ticket_select_id, _with_all_option, _all_text);
|
||||
};
|
||||
|
1090
modules/storm/stormticket/stormticket.module
Normal file
1090
modules/storm/stormticket/stormticket.module
Normal file
File diff suppressed because it is too large
Load diff
344
modules/storm/stormticket/stormticket.test
Normal file
344
modules/storm/stormticket/stormticket.test
Normal file
|
@ -0,0 +1,344 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Ticket module.
|
||||
*/
|
||||
class StormticketTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Ticket Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Ticket module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormticket', 'stormperson', 'stormteam');
|
||||
}
|
||||
|
||||
public function testStormticketAccess() {
|
||||
$this->drupalGet('tickets');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Tickets list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('tickets');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Tickets list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm ticket: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('tickets');
|
||||
$this->assertText(t('Tickets'), t('Make sure the correct page has been displayed by checking that the title is "Tickets".'));
|
||||
}
|
||||
|
||||
public function testStormticketCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm ticket: add', 'Storm ticket: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$ticket = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormticket', $ticket, t('Save'));
|
||||
|
||||
$this->assertText(t('Ticket @title has been created.', array('@title' => $ticket['title'])));;
|
||||
}
|
||||
|
||||
public function testStormticketList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view all', 'Storm ticket: edit all', 'Storm ticket: delete all', 'Storm person: add', 'Storm team: add', 'Storm person: view all', 'Storm team: view all', 'Storm project: add', 'Storm project: view all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view of user organization', 'Storm ticket: edit of user organization', 'Storm ticket: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view own', 'Storm ticket: edit own', 'Storm ticket: delete own', 'Storm project: view all'));
|
||||
$userAssigned = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view if assigned to ticket', 'Storm ticket: edit if assigned to ticket', 'Storm ticket: delete if assigned to ticket'));
|
||||
$userAssignedTeam = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view if assigned to ticket', 'Storm ticket: edit if assigned to ticket', 'Storm ticket: delete if assigned to ticket'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view all', 'Storm ticket: edit own', 'Storm ticket: delete own', 'Storm project: view all'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssigned->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPerson = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssignedTeam->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPersonTeam = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$team = array(
|
||||
'title' => $this->randomName(32),
|
||||
'members_array_1' => $assignedPersonTeam->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team, t('Save'));
|
||||
$team = node_load(array('title' => $team['title']));
|
||||
|
||||
// Create project foreach organization
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectOrg = node_load(array('title' => $prj['title']));
|
||||
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectTeam = node_load(array('title' => $prj['title']));
|
||||
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org2->nid,
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectOrg2 = node_load(array('title' => $prj['title']));
|
||||
|
||||
// Create tickets
|
||||
$ticket1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticket1, t('Save'), array('query' => 'organization_nid='.$org->nid));
|
||||
$ticket1 = node_load(array('title' => $ticket1['title']));
|
||||
|
||||
$ticketAssigned = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $assignedPerson->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticketAssigned, t('Save'), array('query' => 'organization_nid='.$org->nid.'&project_nid='.$projectOrg->nid));
|
||||
$ticketAssigned = node_load(array('title' => $ticketAssigned['title']));
|
||||
|
||||
$ticketAssignedTeam = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectTeam->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticketAssignedTeam, t('Save'), array('query' => 'organization_nid='.$org->nid.'&project_nid='.$projectTeam->nid));
|
||||
$ticketAssignedTeam = node_load(array('title' => $ticketAssignedTeam['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$ticket2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticket2, t('Save'), array('query' => 'organization_nid='.$org->nid));
|
||||
$ticket2 = node_load(array('title' => $ticket2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$ticket3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
'project_nid' => $projectOrg2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticket3, t('Save'), array('query' => 'organization_nid='.$org2->nid));
|
||||
$ticket3 = node_load(array('title' => $ticket3['title']));
|
||||
|
||||
// Test for 'Storm ticket: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertLink($ticket1->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticket3->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm ticket: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertLink($ticket1->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm ticket: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertNoLink($ticket1->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssigned->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssignedTeam->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm ticket: view all', 'Storm ticket: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertLink($ticket1->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticket3->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm ticket: view if assigned to ticket'
|
||||
$this->drupalLogin($userAssigned);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertNoLink($ticket1->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket2->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssignedTeam->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm ticket: view if assigned to ticket' (using team)
|
||||
$this->drupalLogin($userAssignedTeam);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertNoLink($ticket1->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket2->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssigned->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
}
|
||||
}
|
155
modules/storm/stormticket/stormticket.theme.inc
Normal file
155
modules/storm/stormticket/stormticket.theme.inc
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function theme_stormticket_list($header, $tickets) {
|
||||
|
||||
$rows = array();
|
||||
foreach ($tickets as $ticket) {
|
||||
$rows[] = array(
|
||||
storm_icon('category_'. $ticket->ticketcategory, storm_attribute_value('Ticket category', $ticket->ticketcategory)),
|
||||
storm_icon('status_'. $ticket->ticketstatus, storm_attribute_value('Ticket status', $ticket->ticketstatus)),
|
||||
'<span class="ticket-title status_' . str_replace(' ', '_', $ticket->ticketstatus) . '">' . l($ticket->title, 'node/'. $ticket->nid) . theme('mark', node_mark($ticket->nid, $ticket->changed)) . '</span><br />' .
|
||||
l($ticket->organization_title, 'node/'. $ticket->organization_nid) .
|
||||
(!empty($ticket->project_title) ? ' » ' . l($ticket->project_title, 'node/'. $ticket->project_nid) : '' ),
|
||||
$ticket->clip ? storm_icon('attached', t('Has attached files')) : ' ',
|
||||
format_date($ticket->changed, 'small'),
|
||||
storm_icon('priority_'. $ticket->ticketpriority, storm_attribute_value('Ticket priority', $ticket->ticketpriority)),
|
||||
array(
|
||||
'data' => $ticket->comment_count,
|
||||
'class' => 'storm_list_comments',
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_comment_node($ticket, $_GET) . storm_icon_edit_node($ticket, $_GET) . storm_icon_delete_node($ticket, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
}
|
||||
$o = theme('table', $header, $rows, array('id' => 'stormtickets'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
function theme_stormticket_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');
|
||||
|
||||
$node = node_prepare($node, $teaser);
|
||||
|
||||
$node->content['links'] = array(
|
||||
'#prefix' => '<div class="stormlinks"><dl>',
|
||||
'#suffix' => '</dl></div>',
|
||||
'#weight' => -25,
|
||||
);
|
||||
|
||||
$node->content['links']['expenses'] = theme('storm_link', 'stormticket', 'stormexpense', $node->nid, 1);
|
||||
$node->content['links']['timetrackings'] = theme('storm_link', 'stormticket', 'stormtimetracking', $node->nid, 2);
|
||||
|
||||
// Code to create invoice auto_add link
|
||||
if (module_exists('storminvoice')) {
|
||||
|
||||
$node->content['links']['auto_invoice'] = array(
|
||||
'#prefix' => variable_get('storm_icons_display', TRUE) ? '<dt id="storminvoice-item" class="stormcomponent">' : '<dt class="stormcomponent">',
|
||||
'#suffix' => '</dt>',
|
||||
'#value' => theme('storminvoice_autoadd_links', $node->nid, $node->billable, $node->billed),
|
||||
'#weight' => 3,
|
||||
);
|
||||
}
|
||||
|
||||
$node->content['group1'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$node->content['group1']['organization'] = array(
|
||||
'#prefix' => '<div class="organization">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Organization'), l($node->organization_title, 'node/'. $node->organization_nid)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group1']['project_nid'] = array(
|
||||
'#prefix' => '<div class="project">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Project'), l($node->project_title, 'node/'. $node->project_nid)),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group1']['task_nid'] = array(
|
||||
'#prefix' => '<div class="task">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Task'), l($node->task_title, 'node/'. $node->task_nid)),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$node->content['group1']['author'] = array(
|
||||
'#prefix' => '<div class="author">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Submitted by'), theme('username', $node)),
|
||||
'#weight' => 11,
|
||||
);
|
||||
$node->content['group1']['created'] = array(
|
||||
'#prefix' => '<div class="created">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Created'), format_date($node->created, 'small')),
|
||||
'#weight' => 12,
|
||||
);
|
||||
if ($node->changed != $node->created) {
|
||||
$node->content['group1']['modified'] = array(
|
||||
'#prefix' => '<div class="modified">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Modified'), format_date($node->changed, 'small')),
|
||||
'#weight' => 13,
|
||||
);
|
||||
}
|
||||
|
||||
$node->content['group2'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
|
||||
);
|
||||
|
||||
$node->content['group2']['category'] = array(
|
||||
'#prefix' => '<div class="category">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Category'), check_plain(storm_attribute_value('Ticket category', $node->ticketcategory))),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group2']['status'] = array(
|
||||
'#prefix' => '<div class="storm_status">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Status'), check_plain(storm_attribute_value('Ticket status', $node->ticketstatus))),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group2']['priority'] = array(
|
||||
'#prefix' => '<div class="priority">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Priority'), check_plain(storm_attribute_value('Ticket priority', $node->ticketpriority))),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$node->content['group5'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -16,
|
||||
);
|
||||
|
||||
$node->content['group5']['assigned'] = array(
|
||||
'#prefix' => '<div class="assigned">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Assigned to'), l($node->assigned_title, 'node/'. $node->assigned_nid)),
|
||||
);
|
||||
|
||||
$node->content['body_field'] = array(
|
||||
'#prefix' => '<div class="stormbody">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Description'), $node->content['body']['#value']),
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'body_field') : -15,
|
||||
);
|
||||
unset($node->content['body']);
|
||||
|
||||
return $node;
|
||||
}
|
322
modules/storm/stormticket/stormticket.views.inc
Normal file
322
modules/storm/stormticket/stormticket.views.inc
Normal file
|
@ -0,0 +1,322 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions to expose SuiteDesk Ticket module data to the Views module.
|
||||
*/
|
||||
function stormticket_views_data() {
|
||||
$data['stormticket']['table']['group'] = 'SuiteDesk Ticket';
|
||||
$data['stormticket']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['organization_nid'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('Ticket -> Organization'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Ticket -> Organization'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['organization_title'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('SuiteDesk Ticket Organization (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['project_nid'] = array(
|
||||
'title' => t('Project'),
|
||||
'help' => t('Ticket -> Project'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Ticket -> Project'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['project_title'] = array(
|
||||
'title' => t('Project'),
|
||||
'help' => t('SuiteDesk Ticket Project (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['task_nid'] = array(
|
||||
'title' => t('Task'),
|
||||
'help' => t('Ticket -> Task'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Ticket -> Task'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['ticketcategory'] = array(
|
||||
'title' => t('Category'),
|
||||
'help' => t('SuiteDesk Ticket category'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'storm_handler_field_attributes_domain',
|
||||
'domain' => 'Ticket Category',
|
||||
'icon' => 'category',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'storm_handler_filter_attributes_domain',
|
||||
'domain' => 'Ticket Category',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['ticketstatus'] = array(
|
||||
'title' => t('Status'),
|
||||
'help' => t('SuiteDesk Ticket Status'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'storm_handler_field_attributes_domain',
|
||||
'domain' => 'Ticket Status',
|
||||
'icon' => 'status',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'storm_handler_filter_attributes_domain',
|
||||
'domain' => 'Ticket Status',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['ticketpriority'] = array(
|
||||
'title' => t('Priority'),
|
||||
'help' => t('SuiteDesk Ticket priority'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'storm_handler_field_attributes_domain',
|
||||
'domain' => 'Ticket Priority',
|
||||
'icon' => 'priority',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'storm_handler_filter_attributes_domain',
|
||||
'domain' => 'Ticket Priority',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['task_title'] = array(
|
||||
'title' => t('Task'),
|
||||
'help' => t('SuiteDesk Ticket Task (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['datebegin'] = array(
|
||||
'title' => t('Date begin'),
|
||||
'help' => t('SuiteDesk Ticket begin date'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'views_handler_field_date',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['dateend'] = array(
|
||||
'title' => t('Date end'),
|
||||
'help' => t('SuiteDesk Ticket end date'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'views_handler_field_date',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['durationunit'] = array(
|
||||
'title' => t('Duration unit'),
|
||||
'help' => t('SuiteDesk Ticket duration unit'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'storm_handler_field_attributes_domain',
|
||||
'domain' => 'Duration unit',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'storm_handler_filter_attributes_domain',
|
||||
'domain' => 'Duration unit',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['duration'] = array(
|
||||
'title' => t('Duration'),
|
||||
'help' => t('SuiteDesk Ticket duration'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['assigned_nid'] = array(
|
||||
'title' => t('Assigned'),
|
||||
'help' => t('Ticket -> Assigned'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Ticket -> Assigned'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['assigned_title'] = array(
|
||||
'title' => t('Assigned'),
|
||||
'help' => t('SuiteDesk Ticket Assigned (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['billable'] = array(
|
||||
'title' => t('Ticket billable'),
|
||||
'help' => t('SuiteDesk Ticket Billable'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['billed'] = array(
|
||||
'title' => t('Ticket billed'),
|
||||
'help' => t('SuiteDesk Ticket Billed'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormticket']['operation'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Edit/Delete link'),
|
||||
'help' => t('Provide a simple link to edit and delete the node.'),
|
||||
'handler' => 'storm_handler_field_operation',
|
||||
'type' => 'stormticket',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function stormticket_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
'handlers' => array(
|
||||
'storm_handler_field_attributes_domain' => array(
|
||||
'parent' => 'views_handler_field',
|
||||
),
|
||||
'storm_handler_filter_attributes_domain' => array(
|
||||
'parent' => 'views_handler_filter_in_operator',
|
||||
),
|
||||
'storm_handler_field_operation' => array(
|
||||
'parent' => 'views_handler_field_node_link',
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormticket_date_api_fields($field) {
|
||||
$values = array(
|
||||
'sql_type' => DATE_UNIX,
|
||||
'tz_handling' => 'site',
|
||||
'timezone_field' => '',
|
||||
'offset_field' => '',
|
||||
'related_fields' => array(),
|
||||
'granularity' => array('year', 'month', 'day', 'hour', 'minute', 'second'),
|
||||
);
|
||||
|
||||
switch ($field) {
|
||||
case 'stormticket.datebegin':
|
||||
case 'stormticket.dateend':
|
||||
return $values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function stormticket_date_api_tables() {
|
||||
return array('stormticket');
|
||||
}
|
7
modules/storm/stormticket/stormticket.views_default.inc
Normal file
7
modules/storm/stormticket/stormticket.views_default.inc
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* This file will contain default views for the SuiteDesk Ticket module.
|
||||
*/
|
||||
|
||||
|
Reference in a new issue