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

Diff of /contributions/modules/shoutbox/shoutbox.module

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

revision 1.18.2.23, Sun Jul 13 09:59:58 2008 UTC revision 1.18.2.24, Tue Jul 29 09:05:00 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: shoutbox.module,v 1.18.2.22 2008/07/13 09:45:57 disterics Exp $  // $Id: shoutbox.module,v 1.18.2.23 2008/07/13 09:59:58 disterics Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 62  function shoutbox_menu($may_cache) { Line 62  function shoutbox_menu($may_cache) {
62        'title' => t('Edit Shout'),        'title' => t('Edit Shout'),
63        'callback' => 'shoutbox_callback',        'callback' => 'shoutbox_callback',
64        'callback arguments' => array(arg(1), 'edit'),        'callback arguments' => array(arg(1), 'edit'),
65        'access' => user_access('edit own shouts'),        'access' => shoutbox_access_callback('edit own shouts', arg(1)),
66        'type' => MENU_CALLBACK);        'type' => MENU_CALLBACK);
67      $items[] = array(      $items[] = array(
68        'path' => 'shoutbox/'. arg(1) .'/delete',        'path' => 'shoutbox/'. arg(1) .'/delete',
# Line 70  function shoutbox_menu($may_cache) { Line 70  function shoutbox_menu($may_cache) {
70        'callback' => 'shoutbox_callback',        'callback' => 'shoutbox_callback',
71        'callback arguments' => array(arg(1), 'delete'),        'callback arguments' => array(arg(1), 'delete'),
72        // BUGBUG - what should the access be        // BUGBUG - what should the access be
73        'access' => user_access('delete own shouts'),        'access' => shoutbox_access_callback('delete own shouts', arg(1)),
74        'type' => MENU_CALLBACK);        'type' => MENU_CALLBACK);
75      $items[] = array(      $items[] = array(
76        'path' => 'shoutbox/'. arg(1) .'/publish',        'path' => 'shoutbox/'. arg(1) .'/publish',
77        'title' => t('Publish Shout'),        'title' => t('Publish Shout'),
78        'callback' => 'shoutbox_callback',        'callback' => 'shoutbox_callback',
79        'callback arguments' => array(arg(1), 'publish'),        'callback arguments' => array(arg(1), 'publish'),
80        'access' => user_access('moderate shoutbox'),        'access' => shoutbox_access_callback('moderate shoutbox', arg(1)),
81        'type' => MENU_CALLBACK);        'type' => MENU_CALLBACK);
82      $items[] = array(      $items[] = array(
83        'path' => 'shoutbox/'. arg(1) .'/unpublish',        'path' => 'shoutbox/'. arg(1) .'/unpublish',
84        'title' => t('Unpublish Shout'),        'title' => t('Unpublish Shout'),
85        'callback' => 'shoutbox_callback',        'callback' => 'shoutbox_callback',
86        'callback arguments' => array(arg(1), 'unpublish'),        'callback arguments' => array(arg(1), 'unpublish'),
87        'access' => user_access('moderate shoutbox'),        'access' => shoutbox_access_callback('moderate shoutbox', arg(1)),
88        'type' => MENU_CALLBACK);        'type' => MENU_CALLBACK);
89    }    }
90    
# Line 252  function shoutbox_callback($shout_id, $c Line 252  function shoutbox_callback($shout_id, $c
252  }  }
253    
254    
255    /**
256     * Function to handle shoutbox access callbacks that
257     * require a shout_id. Does some sanity checking on
258     * on the id and loads the shout before calling
259     * _shoutbox_user_access.
260     *
261     * @param shout_id
262     *   The shout id the action is being performed on.
263     * @param permission
264     *   The permission that we want to check
265     * @return
266     *   Returns 1 if user should have accces, 0 otherwise.
267     *
268     */
269    function shoutbox_access_callback($permission, $shout_id) {
270      $access = FALSE;
271    
272      if (is_numeric($shout_id)) {
273        $shout = db_fetch_object(db_query('SELECT * FROM {shoutbox} WHERE shout_id = %d', $shout_id));
274        $access = _shoutbox_user_access($permission, $shout);
275      }
276      return $access;
277    }
278    
279    
280  // THEMES.  // THEMES.
281    
282  /**  /**
# Line 835  function _shoutbox_block_view() { Line 860  function _shoutbox_block_view() {
860    
861    
862    // Output the shoutbox form.    // Output the shoutbox form.
863    if (user_access('post shouts') || user_access('post shouts without approval')) {    if (_shoutbox_user_access('post shouts') || _shoutbox_user_access('post shouts without approval')) {
864      $output .= drupal_get_form('shoutbox_add_form');      $output .= drupal_get_form('shoutbox_add_form');
865    }    }
866    else {    else {

Legend:
Removed from v.1.18.2.23  
changed lines
  Added in v.1.18.2.24

  ViewVC Help
Powered by ViewVC 1.1.2