'. t("Provides knowledgebase support for Storm") .'

'; break; } return $o; } function stormknowledgebase_perm() { return array( 'Storm knowledgebase: access', 'Storm knowledgebase: add', 'Storm knowledgebase: delete all', 'Storm knowledgebase: delete own', 'Storm knowledgebase: edit all', 'Storm knowledgebase: edit own', 'Storm knowledgebase: view all', 'Storm knowledgebase: view own', ); } function stormknowledgebase_access($op, $node) { global $user; $account = $user; if ($op == 'create') { return user_access('Storm knowledgebase: add'); } if (is_numeric($node)) $node = node_load($node); if ($op == 'delete') { if (user_access('Storm knowledgebase: delete all')) { return TRUE; } else if (user_access('Storm knowledgebase: delete own') && ($account->uid == $node->uid)) { return TRUE; } } if ($op == 'update') { if (user_access('Storm knowledgebase: edit all')) { return TRUE; } else if (user_access('Storm knowledgebase: edit own') && ($account->uid == $node->uid)) { return TRUE; } } if ($op == 'view') { if (user_access('Storm knowledgebase: view all')) { return TRUE; } else if (user_access('Storm knowledgebase: view own') && ($account->uid == $node->uid)) { return TRUE; } } return FALSE; } function stormknowledgebase_access_sql($sql, $where = array()) { if (user_access('Storm knowledgebase: view all')) { $where[] = "'storm_access'='storm_access'"; return storm_rewrite_sql($sql, $where); } global $user; $cond = ''; if (user_access('Storm knowledgebase: view own')) { $cond .= 'n.uid='. $user->uid; } if (empty($cond)) $cond = '0=1'; $where[] = $cond; $where[] = "'storm_access'='storm_access'"; return storm_rewrite_sql($sql, $where); } function stormknowledgebase_storm_rewrite_where_sql($query, $primary_table, $account) { static $conds = array(); if ($conds[$account->uid]) { return $conds[$account->uid]; } if (preg_match("/'storm_access'='storm_access'/", $query)) { $cond = ''; } else { if (user_access('Storm knowledgebase: view all', $account)) { return ''; } $cond = ''; if (user_access('Storm knowledgebase: view own', $account)) { $cond .= " ${primary_table}.uid=". $account->uid; } if ($cond) { $cond = " WHEN 'stormknowledgebase' THEN IF($cond,1,0) "; } else { $cond = " WHEN 'stormknowledgebase' THEN 0 "; } } $conds[$account->uid] = $cond; return $cond; } function stormknowledgebase_menu($may_cache) { $items = array(); if (!$may_cache) { if (arg(0)=='storm' && arg(1)=='knowledgebase') { require_once(drupal_get_path('module', 'stormknowledgebase') .'/stormknowledgebase.admin.inc'); require_once(drupal_get_path('module', 'stormknowledgebase') .'/stormknowledgebase.theme.inc'); } $items[] = array( 'path' => 'storm/knowledgebase', 'title' => t('Knowledge base'), 'description' => t('Storm Knowledge base'), 'callback' => 'stormknowledgebase_list', 'access' => user_access('Storm knowledgebase: access'), 'type' => MENU_NORMAL_ITEM ); } return $items; } function stormknowledgebase_node_info() { return array( 'stormknowledgebase' => array( 'name' => t('Knowledge base'), 'module' => 'stormknowledgebase', 'description' => t("A knowledge base for Storm."), 'has_body' => true, ) ); } function stormknowledgebase_form(&$node) { $type = node_get_types('type', $node); $form['title'] = array( '#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -49, ); if ($type->has_body) { $form['body_filter']['#weight'] = -48; $form['body_filter']['body'] = array( '#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => $node->body, '#rows' => 20, '#required' => ($type->min_word_count > 0)); $form['body_filter']['format'] = filter_form($node->format); } return $form; }