-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwn_admin.module
79 lines (70 loc) · 2.49 KB
/
wn_admin.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
include_once('wn_admin.features.inc');
/**
* Implmentation of hook_init().
*/
function wn_admin_init() {
// Load wn_helper's css and javascript.
drupal_add_css((drupal_get_path('module', 'wn_admin')) . '/css/wn_admin.css');
drupal_add_js((drupal_get_path('module', 'wn_admin')) . '/js/wn_admin.js');
}
/**
* Implementation of Hook_perm().
* Provides permission for accessing WN's custom dashboard.
*/
function wn_admin_perm() {
return array('access wn dashboard');
}
/**
* Implementation of hook_help().
*
* Adds a help message our our custom dashboard.
*/
function wn_admin_help($path, $arg) {
switch ($path) {
case 'admin/dashboard':
return 'Welcome to the Watershed Now Dashboard. Here you will find quick links and other tools for managing your site. If you get stuck, consider reaching out to <a href="http://thinkshout.com/contact" target="_blank">ThinkShout.com</a>, the maintainers of the <a href="http://drupal.org/project/watershednow" target="_blank">Watershed Now</a> Drupal distribution.';
}
}
/**
* Implementation of hook_menu().
*
* Adds a customized dashboard menu item and page.
*/
function wn_admin_menu() {
$items = array();
$items['admin/dashboard'] = array(
'title' => 'Watershed Now Dashboard',
'page callback' => 'wn_admin_dashboard',
'access arguments' => array('access wn dashboard'),
'type' => MENU_NORMAL_ITEM,
'file' => 'wn_admin.admin.inc',
'weight' => -20,
);
return $items;
}
/**
* Implementation of hook_views_pre_render(&$view).
* Add content creation links at the top of the content listing.
*/
function wn_admin_views_pre_render(&$view) {
if (($view->name == 'all_content') && ($view->current_display == 'page_1')) {
$view->exposed_widgets = _wn_admin_create_links() . $view->exposed_widgets;
}
}
/**
* Helper function for adding create content links.
*/
function _wn_admin_create_links() {
$types = node_get_types();
$links = array();
foreach ($types as $key => $type) {
if (node_access('create', $type)) {
$links[] = array('title' => 'Create ' . $type->name, 'href' => 'node/add/' . str_replace('_', '-', $key)); // Create a collection of "create content" links.
}
}
$output = 'Use the form below to query all content posted on this site. You can also create content using the quick links here, or <a href="/node/add">learn more</a> about the types of content you can create.';
$output .= theme_links($links);
$output = '<div class="messages">' . $output . '</div>';
return $output;
}