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
265
modules/storm/stormnote/stormnote.admin.inc
Normal file
265
modules/storm/stormnote/stormnote.admin.inc
Normal file
|
@ -0,0 +1,265 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormnote_list() {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (array_key_exists('organization_nid', $_GET)) {
|
||||
if ($_SESSION['stormnote_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
}
|
||||
unset($_SESSION['stormnote_list_filter']['project_nid']);
|
||||
unset($_SESSION['stormnote_list_filter']['task_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('project_nid', $_GET)) {
|
||||
if ($_SESSION['stormnote_list_filter']['project_nid'] != $_GET['project_nid']) {
|
||||
$_SESSION['stormnote_list_filter']['project_nid'] = $_GET['project_nid'];
|
||||
}
|
||||
$p = node_load($_GET['project_nid']);
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $p->organization_nid;
|
||||
|
||||
unset($_SESSION['stormnote_list_filter']['task_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('task_nid', $_GET)) {
|
||||
if ($_SESSION['stormnote_list_filter']['task_nid'] != $_GET['task_nid']) {
|
||||
$_SESSION['stormnote_list_filter']['task_nid'] = $_GET['task_nid'];
|
||||
}
|
||||
|
||||
$t = node_load($_GET['task_nid']);
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $t->organization_nid;
|
||||
$_SESSION['stormnote_list_filter']['project_nid'] = $t->project_nid;
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormnote';
|
||||
|
||||
$params = $_GET;
|
||||
if (isset($_SESSION['stormnote_list_filter']['organization_nid'])) {
|
||||
$params['organization_nid'] = $_SESSION['stormnote_list_filter']['organization_nid'];
|
||||
}
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Title') . ' / ' . t('Organization') . ' » ' . t('Project') . ' » ' . t('Task'),
|
||||
'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' => 'sno.version',
|
||||
'class' => 'storm_list_version',
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_add_node($i, $params),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$s = "SELECT n.*, sno.*, nre.format, fno.field_stormnote_attached_list AS clip FROM {node} AS n
|
||||
INNER JOIN {stormnote} AS sno ON n.vid=sno.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
LEFT JOIN {content_field_stormnote_attached} AS fno ON n.vid = fno.vid AND fno.field_stormnote_attached_list = 1 AND fno.delta = 0
|
||||
WHERE n.status=1 AND n.type='stormnote'";
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
if (isset($_SESSION['stormnote_list_filter']['organization_nid']) && $_SESSION['stormnote_list_filter']['organization_nid'] != 0) {
|
||||
$where[] = 'sno.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormnote_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormnote_list_filter']['project_nid']) && $_SESSION['stormnote_list_filter']['project_nid'] != 0) {
|
||||
$where[] = 'sno.project_nid=%d';
|
||||
$args[] = $_SESSION['stormnote_list_filter']['project_nid'];
|
||||
$filterfields[] = t('Project');
|
||||
}
|
||||
if (isset($_SESSION['stormnote_list_filter']['task_nid']) && $_SESSION['stormnote_list_filter']['task_nid'] != 0) {
|
||||
$where[] = 'sno.task_nid=%d';
|
||||
$args[] = $_SESSION['stormnote_list_filter']['task_nid'];
|
||||
$filterfields[] = t('Task');
|
||||
}
|
||||
if (isset($_SESSION['stormnote_list_filter']['title']) && $_SESSION['stormnote_list_filter']['title'] != '') {
|
||||
$where[] = "LOWER(n.title) LIKE CONCAT('%', LOWER('%s'), '%')";
|
||||
$args[] = $_SESSION['stormnote_list_filter']['title'];
|
||||
$filterfields[] = t('Title');
|
||||
}
|
||||
|
||||
// This section only provides the value for the fieldset label, doesn't control actual filter
|
||||
$itemsperpage = isset($_SESSION['stormnote_list_filter']['itemsperpage']) ? $_SESSION['stormnote_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
|
||||
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('stormnote_list_filter', $filterdesc);
|
||||
|
||||
$s = stormnote_access_sql($s, $where);
|
||||
$s = db_rewrite_sql($s);
|
||||
$tablesort = tablesort_sql($header);
|
||||
|
||||
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
||||
|
||||
$notes = array();
|
||||
while ($item = db_fetch_object($r)) {
|
||||
$notes[] = $item;
|
||||
}
|
||||
|
||||
$o .= theme('stormnote_list', $header, $notes);
|
||||
$o .= theme('pager', NULL, $itemsperpage, 0);
|
||||
print theme('page', $o);
|
||||
}
|
||||
|
||||
function stormnote_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$organization_nid = isset($_SESSION['stormnote_list_filter']['organization_nid']) ? $_SESSION['stormnote_list_filter']['organization_nid'] : 0;
|
||||
$project_nid = isset($_SESSION['stormnote_list_filter']['project_nid']) ? $_SESSION['stormnote_list_filter']['project_nid'] : 0;
|
||||
$task_nid = isset($_SESSION['stormnote_list_filter']['task_nid']) ? $_SESSION['stormnote_list_filter']['task_nid'] : 0;
|
||||
$title = isset($_SESSION['stormnote_list_filter']['title']) ? $_SESSION['stormnote_list_filter']['title'] : '';
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormnote_list_filter']['itemsperpage']) ? $_SESSION['stormnote_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormnote_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
$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('stormnote_list_filter_filter'),
|
||||
);
|
||||
|
||||
$form['filter']['group3']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Reset'),
|
||||
'#submit' => array('stormnote_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 stormnote_list_filter_reset($form, &$form_state) {
|
||||
unset($_SESSION['stormnote_list_filter']);
|
||||
}
|
||||
|
||||
function stormnote_list_filter_filter($form, &$form_state) {
|
||||
$_SESSION['stormnote_list_filter']['organization_nid'] = $form_state['values']['organization_nid'];
|
||||
$_SESSION['stormnote_list_filter']['project_nid'] = $form_state['values']['project_nid'];
|
||||
$_SESSION['stormnote_list_filter']['task_nid'] = $form_state['values']['task_nid'];
|
||||
$_SESSION['stormnote_list_filter']['title'] = $form_state['values']['title'];
|
||||
$_SESSION['stormnote_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
||||
}
|
14
modules/storm/stormnote/stormnote.info
Normal file
14
modules/storm/stormnote/stormnote.info
Normal file
|
@ -0,0 +1,14 @@
|
|||
name = Storm Note
|
||||
description = "Allows creation of notes about organizations, projects or 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"
|
76
modules/storm/stormnote/stormnote.install
Normal file
76
modules/storm/stormnote/stormnote.install
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormnote_install() {
|
||||
drupal_install_schema('stormnote');
|
||||
variable_set('node_options_stormnote', array('status'));
|
||||
}
|
||||
|
||||
function stormnote_disable() {
|
||||
drupal_set_message(t('Nodes of type "Note" have not been deleted on disabling SuiteDesk Note. Please note that they will now have reduced functionality, and will not be protected by SuiteDesk Note access controls.'), 'warning');
|
||||
}
|
||||
|
||||
function stormnote_uninstall() {
|
||||
drupal_uninstall_schema('stormnote');
|
||||
}
|
||||
|
||||
function stormnote_schema() {
|
||||
$schema['stormnote'] = 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_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'version' => array('type' => 'varchar', 'length' => 12),
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'project_nid' => array('project_nid'),
|
||||
'task_nid' => array('task_nid'),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
* Update function to remove task_stepno field from stormnote table
|
||||
*/
|
||||
function stormnote_update_6101() {
|
||||
$ret = array();
|
||||
|
||||
db_drop_field($ret, 'stormnote', 'task_stepno');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Improve primary keys and indexes
|
||||
*/
|
||||
function stormnote_update_6201() {
|
||||
$return = array();
|
||||
db_drop_primary_key($return, 'stormnote');
|
||||
db_add_primary_key($return, 'stormnote', array('vid'));
|
||||
|
||||
$indexes = array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'project_nid' => array('project_nid'),
|
||||
'task_nid' => array('task_nid'),
|
||||
);
|
||||
foreach ($indexes as $name => $fields) {
|
||||
db_add_index($return, 'stormnote', $name, $fields);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
478
modules/storm/stormnote/stormnote.module
Normal file
478
modules/storm/stormnote/stormnote.module
Normal file
|
@ -0,0 +1,478 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormnote_help($path, $arg) {
|
||||
$o = '';
|
||||
|
||||
switch ($path) {
|
||||
case "admin/help#stormnote":
|
||||
$o = '<p>'. t("Provides note support for SuiteDesk") .'</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function stormnote_perm() {
|
||||
return array(
|
||||
'Storm note: access',
|
||||
'Storm note: add',
|
||||
'Storm note: delete all',
|
||||
'Storm note: delete own',
|
||||
'Storm note: delete of user organization',
|
||||
'Storm note: edit all',
|
||||
'Storm note: edit own',
|
||||
'Storm note: edit of user organization',
|
||||
'Storm note: view all',
|
||||
'Storm note: view own',
|
||||
'Storm note: view of user organization',
|
||||
);
|
||||
}
|
||||
|
||||
function stormnote_access($op, $node, $account = NULL) {
|
||||
if (empty($account)) {
|
||||
global $user;
|
||||
$account = $user;
|
||||
}
|
||||
|
||||
if ($op == 'create') {
|
||||
return user_access('Storm note: add');
|
||||
}
|
||||
|
||||
if (is_numeric($node)) {
|
||||
$node = node_load($node);
|
||||
}
|
||||
|
||||
if ($op == 'delete') {
|
||||
if (user_access('Storm note: delete all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm note: delete own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm note: delete of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'update') {
|
||||
if (user_access('Storm note: edit all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm note: edit own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm note: edit of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'view') {
|
||||
if (user_access('Storm note: view all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm note: view own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm note: view of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function stormnote_access_sql($sql, $where = array()) {
|
||||
if (!user_access('Storm note: view all')) {
|
||||
global $user;
|
||||
|
||||
$cond = '';
|
||||
if (user_access('Storm note: view own')) {
|
||||
$cond .= 'n.uid = ' . $user->uid;
|
||||
}
|
||||
if (user_access('Storm note: view of user organization')) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'sno.organization_nid = ' . $user->stormorganization_nid;
|
||||
}
|
||||
$where[] = empty($cond) ? '0 = 1' : $cond;
|
||||
}
|
||||
|
||||
$where[] = "'storm_access' = 'storm_access'";
|
||||
return storm_rewrite_sql($sql, $where);
|
||||
}
|
||||
|
||||
function stormnote_storm_rewrite_where_sql($query, $primary_table, $account) {
|
||||
static $conds = array();
|
||||
|
||||
if (isset($conds[$primary_table][$account->uid])) {
|
||||
return $conds[$primary_table][$account->uid];
|
||||
}
|
||||
|
||||
$cond = '';
|
||||
if (!preg_match("/'storm_access' = 'storm_access'/", $query)) {
|
||||
if (user_access('Storm note: view all', $account)) {
|
||||
return '';
|
||||
}
|
||||
if (user_access('Storm note: view own', $account)) {
|
||||
$cond .= "${primary_table}.uid = " . $account->uid;
|
||||
}
|
||||
if (user_access('Storm note: view of user organization', $account)) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
# If function is called without viewing an organization, this variable
|
||||
# may not be set. These lines check for that and set the organization
|
||||
# node id to zero if not otherwise set.
|
||||
if (!isset($account->stormorganization_nid)) {
|
||||
$account->stormorganization_nid = 0;
|
||||
}
|
||||
$cond .= ' sno1.organization_nid = ' . $account->stormorganization_nid;
|
||||
}
|
||||
if ($cond) {
|
||||
$cond = " WHEN 'stormnote' THEN (SELECT IF($cond, 1, 0) FROM {stormnote} sno1 WHERE sno1.vid = ${primary_table}.vid) ";
|
||||
}
|
||||
else {
|
||||
$cond = " WHEN 'stormnote' THEN 0 ";
|
||||
}
|
||||
}
|
||||
$conds[$primary_table][$account->uid] = $cond;
|
||||
return $cond;
|
||||
}
|
||||
|
||||
function stormnote_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['notes'] = array(
|
||||
'title' => 'Notes',
|
||||
'description' => 'SuiteDesk notes',
|
||||
'page callback' => 'stormnote_list',
|
||||
'access arguments' => array('Storm note: access'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'file' => 'stormnote.admin.inc',
|
||||
'weight' => 7,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function stormnote_theme() {
|
||||
return array(
|
||||
'stormnote_list' => array(
|
||||
'file' => 'stormnote.theme.inc',
|
||||
'arguments' => array('header', 'notes'),
|
||||
),
|
||||
'stormnote_view' => array(
|
||||
'file' => 'stormnote.theme.inc',
|
||||
'arguments' => array('node', 'teaser', 'page'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormnote_node_info() {
|
||||
return array(
|
||||
'stormnote' => array(
|
||||
'name' => t('Note'),
|
||||
'module' => 'stormnote',
|
||||
'description' => t("A note for SuiteDesk."),
|
||||
'has_body' => TRUE,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function stormnote_content_extra_fields($type_name) {
|
||||
if ($type_name == 'stormnote') {
|
||||
return array(
|
||||
'group1' => array('label' => 'Organization/Project/Task Group', 'weight' => -20),
|
||||
'groupv' => array('label' => 'New revision', 'weight' => -12),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function stormnote_stormorganization_change($organization_nid, $organization_title) {
|
||||
$s = "UPDATE {stormnote} SET organization_title='%s' WHERE organization_nid=%d AND organization_title <> '%s'";
|
||||
db_query($s, $organization_title, $organization_nid, $organization_title);
|
||||
}
|
||||
|
||||
function stormnote_stormproject_change($project_nid, $project_title) {
|
||||
$s = "UPDATE {stormnote} SET project_title='%s' WHERE project_nid=%d AND project_title <> '%s'";
|
||||
db_query($s, $project_title, $project_nid, $project_title);
|
||||
}
|
||||
|
||||
function stormnote_stormtask_change($task_nid, $task_title, $task_stepno) {
|
||||
$s = "UPDATE {stormnote} SET task_title='%s' WHERE task_nid=%d AND task_title<>'%s'";
|
||||
db_query($s, $task_title, $task_nid, $task_title);
|
||||
}
|
||||
|
||||
function stormnote_stormproject_change_hierarchy($project_nid, $organization_nid, $organization_title) {
|
||||
$s = "UPDATE {stormnote} SET organization_nid=%d, organization_title='%s' WHERE project_nid=%d";
|
||||
db_query($s, $organization_nid, $organization_title, $project_nid);
|
||||
}
|
||||
|
||||
function stormnote_stormtask_change_hierarchy($task_nid, $organization_nid, $organization_title, $project_nid, $project_title) {
|
||||
$s = "UPDATE {stormnote} SET organization_nid=%d, organization_title='%s', project_nid=%d, project_title='%s' WHERE task_nid=%d";
|
||||
db_query($s, $organization_nid, $organization_title, $project_nid, $project_title, $task_nid);
|
||||
}
|
||||
|
||||
function stormnote_form(&$node) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('Notes'), 'notes');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (arg(1)=='add') {
|
||||
if (array_key_exists('organization_nid', $_GET) && !$node->organization_nid) {
|
||||
$node->organization_nid = $_GET['organization_nid'];
|
||||
}
|
||||
if (array_key_exists('project_nid', $_GET) && !$node->project_nid) {
|
||||
$node->project_nid = $_GET['project_nid'];
|
||||
$p = node_load($node->project_nid);
|
||||
$node->organization_nid = $p->organization_nid;
|
||||
if (!stormorganization_access('view', $node->organization_nid)) {
|
||||
drupal_set_message(t("You cannot add a note for this project, as you do not have access to view the organization's profile"));
|
||||
drupal_goto('node/'. $node->project_nid);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('task_nid', $_GET) && !$node->task_nid) {
|
||||
$node->task_nid = $_GET['task_nid'];
|
||||
$t = node_load($node->task_nid);
|
||||
$node->organization_nid = $t->organization_nid;
|
||||
$node->project_nid = $t->project_nid;
|
||||
// $project_access deals with the case whereby the project could be blank, hence access rules not required
|
||||
$project_access = $node->project_nid ? stormproject_access('view', $node->project_nid) : TRUE;
|
||||
if (!stormorganization_access('view', $node->organization_nid) || !stormproject_access('view', $node->project_nid)) {
|
||||
drupal_set_message(t("You cannot add a note for this task, as you do not have access to view the both the organization and project's profile"));
|
||||
drupal_goto('node/'. $node->task_nid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['stormnote_list_filter']['organization_nid']) && !$node->organization_nid) {
|
||||
$node->organization_nid = $_SESSION['stormnote_list_filter']['organization_nid'];
|
||||
}
|
||||
if (!empty($_SESSION['stormnote_list_filter']['project_nid']) && !$node->project_nid) {
|
||||
$node->project_nid = $_SESSION['stormnote_list_filter']['project_nid'];
|
||||
}
|
||||
if (!empty($_SESSION['stormnote_list_filter']['task_nid']) && !$node->task_nid) {
|
||||
$node->task_nid = $_SESSION['stormnote_list_filter']['task_nid'];
|
||||
}
|
||||
$s_org = "SELECT n.nid, n.title FROM {stormorganization} so INNER JOIN {node} n
|
||||
ON so.nid=n.nid WHERE n.status=1 AND so.isactive=1 AND n.type='stormorganization' ORDER BY n.title";
|
||||
}
|
||||
else {
|
||||
$s_org = "SELECT n.nid, n.title FROM {stormorganization} so INNER JOIN {node} n
|
||||
ON so.nid=n.nid WHERE n.status=1 AND n.type='stormorganization' ORDER BY n.title";
|
||||
}
|
||||
|
||||
$type = node_get_types('type', $node);
|
||||
|
||||
$form['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$s_org = stormorganization_access_sql($s_org);
|
||||
$s_org = db_rewrite_sql($s_org);
|
||||
$r = db_query($s_org);
|
||||
$organizations = array();
|
||||
while ($organization = db_fetch_object($r)) {
|
||||
$organizations[$organization->nid] = $organization->title;
|
||||
/* if (!isset($node->organization_nid)) {
|
||||
$node->organization_nid = $organization->nid;
|
||||
} */
|
||||
}
|
||||
$form['group1']['organization_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Organization'),
|
||||
'#default_value' => $node->organization_nid,
|
||||
'#options' => array(0 => '-') + $organizations,
|
||||
'#attributes' => array('onchange' => "stormtask_organization_project_tasks(this, 'edit-project-nid', 'edit-parent-nid', '', true, '-')"),
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} n INNER JOIN {stormproject} spr ON spr.vid=n.vid WHERE spr.organization_nid=%d AND n.status=1 AND n.type='stormproject' ORDER BY n.title";
|
||||
$s = stormproject_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $node->organization_nid);
|
||||
$projects = array();
|
||||
while ($project = db_fetch_object($r)) {
|
||||
$projects[$project->nid] = $project->title;
|
||||
}
|
||||
$form['group1']['project_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Project'),
|
||||
'#default_value' => isset($node->project_nid) ? $node->project_nid : NULL,
|
||||
'#options' => array(0 => '-') + $projects,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#attributes' => array('onchange' => "stormtask_project_tasks('edit-organization-nid', this, 'edit-task-nid', '', true, '-')"),
|
||||
);
|
||||
|
||||
$tree = isset($node->project_nid) ? _stormtask_get_tree($node->project_nid) : array();
|
||||
$tasks = _stormtask_plain_tree($tree);
|
||||
$form['group1']['task_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Task'),
|
||||
'#default_value' => isset($node->task_nid) ? $node->task_nid : NULL,
|
||||
'#options' => array(0 => '-') + $tasks,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
);
|
||||
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => check_plain($type->title_label),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => $node->title,
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'title') : -16,
|
||||
);
|
||||
|
||||
$form['groupv'] = array(
|
||||
'#type' => 'markup',
|
||||
'#title' => t('New review'),
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'groupv') : -12,
|
||||
);
|
||||
|
||||
$options = array();
|
||||
$options['no review'] = t('Don\'t create any revision (change the current)');
|
||||
$options['minor review'] = t('Create a new review due to a minor modification');
|
||||
$options['major review'] = t('Create a new version by a major modification');
|
||||
$form['groupv']['review'] = array(
|
||||
'#type' => 'radios',
|
||||
'#options' => $options,
|
||||
'#default_value' => 'no review',
|
||||
);
|
||||
|
||||
$form['groupv']['reviewlog'] = array(
|
||||
'#title' => t('Log message'),
|
||||
'#type' => 'textfield',
|
||||
'#size' => 255,
|
||||
'#default_value' => NULL,
|
||||
);
|
||||
|
||||
if ($type->has_body) {
|
||||
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormnote_insert($node) {
|
||||
_stormnote_beforesave($node);
|
||||
|
||||
db_query("INSERT INTO {stormnote}
|
||||
(vid, nid,
|
||||
organization_nid, organization_title,
|
||||
project_nid, project_title,
|
||||
task_nid, task_title,
|
||||
version
|
||||
) VALUES
|
||||
(%d, %d,
|
||||
%d, '%s',
|
||||
%d, '%s',
|
||||
%d, '%s',
|
||||
'%s'
|
||||
)",
|
||||
$node->vid, $node->nid,
|
||||
$node->organization_nid, $node->organization_title,
|
||||
$node->project_nid, $node->project_title,
|
||||
$node->task_nid, $node->task_title,
|
||||
$node->version
|
||||
);
|
||||
}
|
||||
|
||||
function stormnote_update($node) {
|
||||
_stormnote_beforesave($node);
|
||||
|
||||
if ($node->revision) {
|
||||
stormnote_insert($node);
|
||||
}
|
||||
else {
|
||||
db_query("UPDATE {stormnote} SET
|
||||
organization_nid=%d, organization_title='%s',
|
||||
project_nid=%d, project_title='%s',
|
||||
task_nid=%d, task_title='%s',
|
||||
version='%s'
|
||||
WHERE vid = %d",
|
||||
$node->organization_nid, $node->organization_title,
|
||||
$node->project_nid, $node->project_title,
|
||||
$node->task_nid, $node->task_title,
|
||||
$node->version,
|
||||
$node->vid);
|
||||
}
|
||||
}
|
||||
|
||||
function _stormnote_beforesave(&$node) {
|
||||
$s = "SELECT n.title FROM {node} n INNER JOIN {stormorganization} o ON n.nid=o.nid
|
||||
WHERE type='stormorganization' AND n.nid=%d";
|
||||
$r = db_query($s, $node->organization_nid);
|
||||
$o = db_fetch_object($r);
|
||||
$node->organization_title = $o->title;
|
||||
|
||||
$s = "SELECT n.title FROM {node} n INNER JOIN {stormproject} p ON n.nid=p.nid
|
||||
WHERE type='stormproject' AND n.nid=%d";
|
||||
$r = db_query($s, $node->project_nid);
|
||||
$p = db_fetch_object($r);
|
||||
$node->project_title = isset($p->title) ? $p->title : '';
|
||||
|
||||
$s = "SELECT n.title FROM {node} n INNER JOIN {stormtask} p ON n.nid=p.nid
|
||||
WHERE type='stormtask' AND n.nid=%d";
|
||||
$r = db_query($s, $node->task_nid);
|
||||
$t = db_fetch_object($r);
|
||||
$node->task_title = isset($t->title) ? $t->title : '';
|
||||
}
|
||||
|
||||
function stormnote_nodeapi(&$node, $op, $teaser, $page) {
|
||||
if ($node->type != 'stormnote') {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($op) {
|
||||
case 'delete revision':
|
||||
// Notice that we're matching a single revision based on the node's vid.
|
||||
db_query('DELETE FROM {stormnote} WHERE vid = %d', $node->vid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function stormnote_delete($node) {
|
||||
db_query('DELETE FROM {stormnote} WHERE nid = %d', $node->nid);
|
||||
}
|
||||
|
||||
function stormnote_load($node) {
|
||||
$additions = db_fetch_object(db_query('SELECT * FROM {stormnote} WHERE vid = %d', $node->vid));
|
||||
return $additions;
|
||||
}
|
||||
|
||||
function stormnote_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('Notes'), 'notes');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
return theme('stormnote_view', $node, $teaser, $page);
|
||||
}
|
||||
|
||||
function stormnote_views_api() {
|
||||
return array(
|
||||
'api' => 2,
|
||||
'path' => drupal_get_path('module', 'stormnote'),
|
||||
);
|
||||
}
|
||||
|
||||
function stormnote_storm_dashboard_links($type) {
|
||||
$links = array();
|
||||
if ($type == 'page' || $type == 'block') {
|
||||
$links[] = array(
|
||||
'theme' => 'storm_dashboard_link',
|
||||
'title' => t('My notes'),
|
||||
'icon' => 'stormnote-item',
|
||||
'path' => 'notes',
|
||||
'params' => array(),
|
||||
'access_arguments' => 'Storm note: access',
|
||||
'node_type' => 'stormnote',
|
||||
'add_type' => 'stormnote',
|
||||
'map' => array(),
|
||||
'weight' => 9,
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
192
modules/storm/stormnote/stormnote.test
Normal file
192
modules/storm/stormnote/stormnote.test
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk note module
|
||||
*/
|
||||
class StormnoteTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Note Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Note module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormnote', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormnoteAccess() {
|
||||
$this->drupalGet('notes');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Notes list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('notes');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Notes list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm note: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('notes');
|
||||
$this->assertText(t('Notes'), t('Make sure the correct page has been displayed by checking that the title is "Notes".'));
|
||||
}
|
||||
|
||||
public function testStormnoteCreate() {
|
||||
// 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 note: add', 'Storm note: 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),
|
||||
);
|
||||
$note = 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/stormnote', $note, t('Save'));
|
||||
|
||||
$this->assertText(t('Note @title has been created.', array('@title' => $note['title'])));;
|
||||
}
|
||||
|
||||
public function testStormnoteList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view all', 'Storm note: edit all', 'Storm note: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view of user organization', 'Storm note: edit of user organization', 'Storm note: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view own', 'Storm note: edit own', 'Storm note: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view all', 'Storm note: edit own', 'Storm note: delete own'));
|
||||
|
||||
$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'));
|
||||
|
||||
// Create notes
|
||||
$note1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormnote', $note1, t('Save'));
|
||||
$note1 = node_load(array('title' => $note1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$note2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormnote', $note2, t('Save'));
|
||||
$note2 = node_load(array('title' => $note2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$note3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormnote', $note3, t('Save'));
|
||||
$note3 = node_load(array('title' => $note3['title']));
|
||||
|
||||
// Test for 'Storm note: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertLink($note1->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertLink($note3->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm note: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertLink($note1->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($note3->title, 'The Note does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm note: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertNoLink($note1->title, 'The Note does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($note3->title, 'The Note does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm note: view all', 'Storm note: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertLink($note1->title, 0, 'The Note appears on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/delete', 'The Note edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertNoRaw('node/'. $note2->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note2->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($note3->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
100
modules/storm/stormnote/stormnote.theme.inc
Normal file
100
modules/storm/stormnote/stormnote.theme.inc
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function theme_stormnote_list($header, $notes) {
|
||||
$rows = array();
|
||||
|
||||
foreach ($notes as $note) {
|
||||
$rows[] = array(
|
||||
'<span class="note-title">' . l($note->title, 'node/'. $note->nid) . theme('mark', node_mark($note->nid, $note->changed)) . '</span><br />' .
|
||||
l($note->organization_title, 'node/'. $note->organization_nid) .
|
||||
(!empty($note->project_title) ? ' » ' . l($note->project_title, 'node/'. $note->project_nid) : '' ) .
|
||||
(!empty($note->task_title) ? ' » ' . l($note->task_title, 'node/'. $note->task_nid) : '' ),
|
||||
$note->clip ? storm_icon('attached', t('Has attached files')) : ' ',
|
||||
format_date($note->created, 'small'),
|
||||
format_date($note->changed, 'small'),
|
||||
$note->version,
|
||||
array(
|
||||
'data' => storm_icon_edit_node($note, $_GET) . storm_icon_delete_node($note, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
}
|
||||
$o = theme('table', $header, $rows, array('id' => 'stormnotes'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
function theme_stormnote_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');
|
||||
|
||||
$node = node_prepare($node, $teaser);
|
||||
$l_pos = 1; // Used to increase the link position number (see issue 814820)
|
||||
|
||||
$node->content['links'] = array(
|
||||
'#prefix' => '<div class="stormlinks"><dl>',
|
||||
'#suffix' => '</dl></div>',
|
||||
'#weight' => $l_pos++,
|
||||
);
|
||||
$node->content['group1'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
if (!empty($node->organization_nid)) {
|
||||
$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' => 3,
|
||||
);
|
||||
}
|
||||
if (!empty($node->project_nid)) {
|
||||
$node->content['group1']['project'] = array(
|
||||
'#prefix' => '<div class="project">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Project'), l($node->project_title, 'node/' . $node->project_nid)),
|
||||
'#weight' => 4,
|
||||
);
|
||||
}
|
||||
if (!empty($node->task_nid)) {
|
||||
$node->content['group1']['task'] = array(
|
||||
'#prefix' => '<div class="task">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Task'), l($node->task_title, 'node/' . $node->task_nid)),
|
||||
'#weight' => 5,
|
||||
);
|
||||
}
|
||||
$node->content['group1']['created'] = array(
|
||||
'#prefix' => '<div class="created">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Note created'), format_date($node->created, 'small')),
|
||||
'#weight' => 12,
|
||||
);
|
||||
if ($node->changed != $node->created) {
|
||||
$node->content['group1']['modified'] = array(
|
||||
'#prefix' => '<div class="created">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Note updated'), format_date($node->changed, 'small')),
|
||||
'#weight' => 13,
|
||||
);
|
||||
}
|
||||
$node->content['group1']['version'] = array(
|
||||
'#prefix' => '<div class="version">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Revision'), $node->version),
|
||||
'#weight' => 14,
|
||||
);
|
||||
|
||||
$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') : -16,
|
||||
);
|
||||
unset($node->content['body']);
|
||||
|
||||
return $node;
|
||||
}
|
143
modules/storm/stormnote/stormnote.views.inc
Normal file
143
modules/storm/stormnote/stormnote.views.inc
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions to expose storm note module data to views
|
||||
*/
|
||||
function stormnote_views_data() {
|
||||
$data['stormnote']['table']['group'] = t('SuiteDesk Note');
|
||||
$data['stormnote']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormnote']['organization_nid'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('Note -> Organization'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Note -> Organization'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormnote']['organization_title'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('SuiteDesk Note 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['stormnote']['project_nid'] = array(
|
||||
'title' => t('Project'),
|
||||
'help' => t('Note -> Project'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Note -> Project'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormnote']['project_title'] = array(
|
||||
'title' => t('Project'),
|
||||
'help' => t('SuiteDesk Note 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['stormnote']['task_nid'] = array(
|
||||
'title' => t('Task'),
|
||||
'help' => t('Note -> Task'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Note -> Task'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormnote']['task_stepno'] = array(
|
||||
'title' => t('Task step number'),
|
||||
'help' => t('SuiteDesk Note Task Step Number'),
|
||||
'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['stormnote']['task_title'] = array(
|
||||
'title' => t('Task'),
|
||||
'help' => t('SuiteDesk Note 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['stormnote']['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' => 'stormnote',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function stormnote_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
'handlers' => array(
|
||||
'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'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
Reference in a new issue