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

Contents of /contributions/modules/public_preview/public_preview.module

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


Revision 1.3 - (show annotations) (download) (as text)
Wed Aug 27 17:44:16 2008 UTC (15 months ago) by chrisyates
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +31 -31 lines
File MIME type: text/x-php
initial port to D6
1 <?php
2
3 /*
4 public_preview.module
5
6 Christian Yates
7 Mars Space Flight Facility
8 14 Jul 2008
9
10 Revised for Drupal 6.x 27 Aug 2008
11
12 */
13
14
15 function public_preview_perm() {
16 $perms = array_map( create_function('$t', 'return "preview ".strtolower($t->name)." content";'), node_get_types());
17 return $perms;
18 }
19
20 function public_preview_menu() {
21 $items['admin/content/preview'] = array(
22 'title' => 'Content Preview',
23 'description' => 'Settings to allow users access to unpublished content.',
24 'page callback' => 'drupal_get_form',
25 'page arguments' => array('public_preview_admin_settings'),
26 'access arguments' => array('administer site configuration'),
27 'type' => MENU_NORMAL_ITEM
28 );
29 $items['node/%node/%public_preview'] = array(
30 'page callback' => 'public_preview_preview_page',
31 'page arguments' => array(1),
32 'access callback' => 'public_preview_access',
33 'access arguments' => array(1),
34 'type' => MENU_CALLBACK
35 );
36 return $items;
37 }
38
39 function public_preview_admin_settings(){
40 $form['public_preview_suffix'] = array(
41 '#type' => 'textfield',
42 '#title' => t('Node preview suffix'),
43 '#default_value' => variable_get('public_preview_suffix', 'preview'),
44 '#size' => 30,
45 '#maxlength' => 100,
46 '#description' => t('Path to append to urls when public preview is enable for a specific node type')
47 );
48 return system_settings_form($form);
49 }
50
51 function public_preview_access($node) {
52 return user_access('preview '.strtolower($node->type).' content');
53 }
54
55 function public_preview_load($arg) {
56 if($arg != variable_get('public_preview_suffix', 'preview')) {
57 return FALSE;
58 }
59 }
60
61 function public_preview_preview_page($nid) {
62 if (!is_numeric($nid)) {
63 return FALSE;
64 }
65 $node = node_load($nid);
66 drupal_set_title(check_plain($node->title));
67 return node_show($node, NULL);
68 }
69 ?>

  ViewVC Help
Powered by ViewVC 1.1.2