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
141
modules/storm/stormidea/stormidea.admin.inc
Normal file
141
modules/storm/stormidea/stormidea.admin.inc
Normal file
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormidea_list() {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormidea';
|
||||
|
||||
$params = $_GET;
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Idea'),
|
||||
'field' => 'n.title',
|
||||
),
|
||||
array(
|
||||
'data' => t('Date'),
|
||||
'field' => 'n.changed',
|
||||
'class' => 'storm_list_date',
|
||||
'sort' => 'desc',
|
||||
),
|
||||
array(
|
||||
'data' => ' ',
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$s = "SELECT n.*, nre.format FROM {node} AS n
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
WHERE n.status=1 AND n.type='stormidea'";
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
if (isset($_SESSION['stormidea_list_filter']['title']) && $_SESSION['stormidea_list_filter']['title'] != '') {
|
||||
$where[] = "LOWER(n.title) LIKE CONCAT('%', LOWER('%s'), '%')";
|
||||
$args[] = $_SESSION['stormidea_list_filter']['title'];
|
||||
$filterfields[] = t('Title');
|
||||
}
|
||||
|
||||
// This section only provides the value for the fieldset label, doesn't control actual filter
|
||||
$itemsperpage = isset($_SESSION['stormidea_list_filter']['itemsperpage']) ? $_SESSION['stormidea_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('stormidea_list_filter', $filterdesc);
|
||||
|
||||
$s = stormidea_access_sql($s, $where);
|
||||
$s = db_rewrite_sql($s);
|
||||
$tablesort = tablesort_sql($header);
|
||||
|
||||
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
||||
|
||||
$ideas = array();
|
||||
while ($item = db_fetch_object($r)) {
|
||||
$ideas[] = $item;
|
||||
}
|
||||
|
||||
$o .= theme('stormidea_list', $header, $ideas);
|
||||
$o .= theme('pager', NULL, $itemsperpage, 0);
|
||||
print theme('page', $o);
|
||||
}
|
||||
|
||||
function stormidea_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$title = isset($_SESSION['stormidea_list_filter']['title']) ? $_SESSION['stormidea_list_filter']['title'] : '';
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormidea_list_filter']['itemsperpage']) ? $_SESSION['stormidea_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormidea_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
$form['filter'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $filterdesc,
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$form['filter']['group2'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
);
|
||||
|
||||
$form['filter']['group2']['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Idea'),
|
||||
'#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('stormidea_list_filter_filter'),
|
||||
);
|
||||
|
||||
$form['filter']['group3']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Reset'),
|
||||
'#submit' => array('stormidea_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 stormidea_list_filter_reset($form, &$form_state) {
|
||||
unset($_SESSION['stormidea_list_filter']);
|
||||
}
|
||||
|
||||
function stormidea_list_filter_filter($form, &$form_state) {
|
||||
$_SESSION['stormidea_list_filter']['title'] = $form_state['values']['title'];
|
||||
$_SESSION['stormidea_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
||||
}
|
11
modules/storm/stormidea/stormidea.info
Normal file
11
modules/storm/stormidea/stormidea.info
Normal file
|
@ -0,0 +1,11 @@
|
|||
name = Storm Idea
|
||||
description = "Allows creation of personal quick notes."
|
||||
dependencies[] = storm
|
||||
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"
|
13
modules/storm/stormidea/stormidea.install
Normal file
13
modules/storm/stormidea/stormidea.install
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormidea_install() {
|
||||
variable_set('node_options_stormidea', array('status'));
|
||||
}
|
||||
|
||||
function stormidea_disable() {
|
||||
drupal_set_message(t('Nodes of type "Idea" have not been deleted on disabling SuiteDesk Idea. Please note that they will now have reduced functionality, and will not be protected by SuiteDesk Idea access controls.'), 'warning');
|
||||
}
|
223
modules/storm/stormidea/stormidea.module
Normal file
223
modules/storm/stormidea/stormidea.module
Normal file
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormidea_help($path, $arg) {
|
||||
$o = '';
|
||||
|
||||
switch ($path) {
|
||||
case "admin/help#stormidea":
|
||||
$o = '<p>'. t("Provides quick notes support for SuiteDesk") .'</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function stormidea_perm() {
|
||||
return array(
|
||||
'Storm idea: access',
|
||||
'Storm idea: add',
|
||||
'Storm idea: delete all',
|
||||
'Storm idea: delete own',
|
||||
'Storm idea: edit all',
|
||||
'Storm idea: edit own',
|
||||
'Storm idea: view all',
|
||||
'Storm idea: view own',
|
||||
);
|
||||
}
|
||||
|
||||
function stormidea_access($op, $node, $account = NULL) {
|
||||
if (empty($account)) {
|
||||
global $user;
|
||||
$account = $user;
|
||||
}
|
||||
|
||||
if ($op == 'create') {
|
||||
return user_access('Storm idea: add');
|
||||
}
|
||||
|
||||
if (is_numeric($node)) {
|
||||
$node = node_load($node);
|
||||
}
|
||||
|
||||
if ($op == 'delete') {
|
||||
if (user_access('Storm idea: delete all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm idea: delete own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'update') {
|
||||
if (user_access('Storm idea: edit all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm idea: edit own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'view') {
|
||||
if (user_access('Storm idea: view all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm idea: view own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function stormidea_access_sql($sql, $where = array()) {
|
||||
if (!user_access('Storm idea: view all')) {
|
||||
global $user;
|
||||
|
||||
$cond = '';
|
||||
if (user_access('Storm idea: view own')) {
|
||||
$cond .= 'n.uid = ' . $user->uid;
|
||||
}
|
||||
$where[] = empty($cond) ? '0 = 1' : $cond;
|
||||
}
|
||||
|
||||
$where[] = "'storm_access' = 'storm_access'";
|
||||
return storm_rewrite_sql($sql, $where);
|
||||
}
|
||||
|
||||
function stormidea_storm_rewrite_where_sql_old($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 idea: view all', $account)) {
|
||||
return '';
|
||||
}
|
||||
if (user_access('Storm idea: view own', $account)) {
|
||||
$cond .= "${primary_table}.uid = " . $account->uid;
|
||||
}
|
||||
if ($cond) {
|
||||
$cond = " WHEN 'stormidea' THEN (SELECT IF($cond, 1, 0) FROM {stormidea} sno1 WHERE sno1.vid = ${primary_table}.vid) ";
|
||||
}
|
||||
else {
|
||||
$cond = " WHEN 'stormidea' THEN 0 ";
|
||||
}
|
||||
}
|
||||
$conds[$primary_table][$account->uid] = $cond;
|
||||
return $cond;
|
||||
}
|
||||
|
||||
function stormidea_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['ideas'] = array(
|
||||
'title' => 'My ideas',
|
||||
'description' => 'SuiteDesk ideas',
|
||||
'page callback' => 'stormidea_list',
|
||||
'access arguments' => array('Storm idea: access'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'file' => 'stormidea.admin.inc',
|
||||
'weight' => 7,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function stormidea_theme() {
|
||||
return array(
|
||||
'stormidea_list' => array(
|
||||
'file' => 'stormidea.theme.inc',
|
||||
'arguments' => array('header', 'ideas'),
|
||||
),
|
||||
'stormidea_view' => array(
|
||||
'file' => 'stormidea.theme.inc',
|
||||
'arguments' => array('node', 'teaser', 'page'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormidea_node_info() {
|
||||
return array(
|
||||
'stormidea' => array(
|
||||
'name' => t('Idea'),
|
||||
'module' => 'stormidea',
|
||||
'description' => t("A quick note for SuiteDesk."),
|
||||
'has_body' => TRUE,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function stormidea_form(&$node) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('My ideas'), 'ideas');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
$type = node_get_types('type', $node);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormidea_form_alter(&$form, $form_state, $form_id) {
|
||||
if (isset($form['#node']) && $form['#node']->type == 'stormidea') {
|
||||
if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
|
||||
$form['buttons']['preview']['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stormidea_nodeapi($node, $op, $a3 = NULL, $a4 = NULL) {
|
||||
if ($node->type == 'stormidea' && $op == 'insert') {
|
||||
$_REQUEST['destination'] = $_GET['q'];
|
||||
}
|
||||
}
|
||||
|
||||
function stormidea_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('My ideas'), 'ideas');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
return theme('stormidea_view', $node, $teaser, $page);
|
||||
}
|
||||
|
||||
function stormidea_views_api() {
|
||||
return array(
|
||||
'api' => 2,
|
||||
'path' => drupal_get_path('module', 'stormidea'),
|
||||
);
|
||||
}
|
||||
|
||||
function stormidea_storm_dashboard_links($type) {
|
||||
$links = array();
|
||||
if ($type == 'page' || $type == 'block') {
|
||||
$links[] = array(
|
||||
'theme' => 'storm_dashboard_link',
|
||||
'title' => t('My ideas'),
|
||||
'icon' => 'stormidea-item',
|
||||
'path' => 'ideas',
|
||||
'params' => array(),
|
||||
'access_arguments' => 'Storm idea: access',
|
||||
'node_type' => 'stormidea',
|
||||
'add_type' => 'stormidea',
|
||||
'map' => array(),
|
||||
'weight' => 9,
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
58
modules/storm/stormidea/stormidea.theme.inc
Normal file
58
modules/storm/stormidea/stormidea.theme.inc
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function theme_stormidea_list($header, $ideas) {
|
||||
$rows = array();
|
||||
|
||||
foreach ($ideas as $idea) {
|
||||
$rows[] = array(
|
||||
'<span class="idea-title">' . l($idea->title, 'node/'. $idea->nid) . theme('mark', node_mark($idea->nid, $idea->changed)) . '</span>',
|
||||
format_date($idea->changed, 'small'),
|
||||
array(
|
||||
'data' => storm_icon_edit_node($idea, $_GET) . storm_icon_delete_node($idea, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
}
|
||||
$o = theme('table', $header, $rows, array('id' => 'stormideas'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
function theme_stormidea_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,
|
||||
);
|
||||
$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,
|
||||
);
|
||||
}
|
||||
|
||||
unset($node->content['body']);
|
||||
|
||||
return $node;
|
||||
}
|
42
modules/storm/stormidea/stormidea.views.inc
Normal file
42
modules/storm/stormidea/stormidea.views.inc
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions to expose storm quick note module data to views
|
||||
*/
|
||||
function stormidea_views_data() {
|
||||
$data['stormidea']['table']['group'] = t('SuiteDesk Quick Note');
|
||||
$data['stormidea']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormidea']['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' => 'stormidea',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function stormidea_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