/[drupal]/contributions/modules/nodetypeviews/nodetypeviews.module
ViewVC logotype

Contents of /contributions/modules/nodetypeviews/nodetypeviews.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Wed May 27 11:07:12 2009 UTC (5 months, 4 weeks ago) by yaph
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA3, HEAD
Changes since 1.3: +20 -1 lines
File MIME type: text/x-php
Before node list and feed display check whether node type actually exists, though a manipulated path should return a 404 error. In node list view added call to db_rewrite_sql to allow node access modules to add restrictions.
1 <?php
2 // $Id: nodetypeviews.module,v 1.3 2008/08/30 22:54:39 yaph Exp $
3
4 /**
5 * @file
6 * Creates teaser views and RSS feeds for published content by node type.
7 */
8
9 /**
10 * Implemetation of hook_menu().
11 */
12 function nodetypeviews_menu() {
13 $items = array();
14 $items['admin/content/nodetypeviews'] = array(
15 'title' => 'Node Type Views',
16 'description' => 'Enable the node types to generate views for.',
17 'page callback' => 'drupal_get_form',
18 'page arguments' => array('nodetypeviews_admin_settings'),
19 'access arguments' => array('administer site configuration'),
20 'type' => MENU_NORMAL_ITEM,
21 'file' => 'nodetypeviews.admin.inc'
22 );
23 $node_types = variable_get('nodetypeviews_node_types', array());
24 if (is_array($node_types)) {
25 foreach ($node_types as $type => $isset) {
26 if ($isset) {
27 $path = str_replace('_', '-', $type);
28 $title = ucfirst($type);
29 $items[$path] = array(
30 'title' => $title,
31 'access arguments' => array('access content'),
32 'type' => MENU_NORMAL_ITEM,
33 'page callback' => 'nodetypeviews_type_teaser_view',
34 'page arguments' => array($type),
35 'file' => 'nodetypeviews.pages.inc'
36 );
37 $items[$path .'/feed'] = array(
38 'title' => $title,
39 'access arguments' => array('access content'),
40 'type' => MENU_CALLBACK,
41 'page callback' => 'nodetypeviews_type_teaser_feed',
42 'page arguments' => array($type),
43 'file' => 'nodetypeviews.pages.inc'
44 );
45 }
46 }
47 }
48 return $items;
49 }
50
51 /**
52 * Check whether the given node type exists
53 *
54 * @param String $type
55 * @return Boolean
56 */
57 function nodetypeviews_check_type($type) {
58 $node_types = node_get_types();
59 if (isset($node_types[$type])) {
60 return TRUE;
61 }
62
63 $msg = 'Content type %type does not exist.';
64 $placeholder = array('%type' => $type);
65 watchdog('security', $msg, $placeholder, WATCHDOG_ALERT);
66 drupal_set_message(t($msg, $placeholder));
67 return false;
68 }

  ViewVC Help
Powered by ViewVC 1.1.2