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

Diff of /contributions/modules/tac_lite/tac_lite.module

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

revision 1.9.2.4, Tue Dec 9 20:00:28 2008 UTC revision 1.9.2.5, Tue Dec 9 21:39:10 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id: tac_lite.module,v 1.9.2.3 2008/12/09 19:47:53 yogadex Exp $    // $Id: tac_lite.module,v 1.9.2.4 2008/12/09 20:00:28 yogadex Exp $
3  /**  /**
4   * @file   * @file
5   * Control access to site content based on taxonomy, roles and users.   *   Control access to site content based on taxonomy, roles and users.
6   *   *
7   *   *
8   */   */
9    
10  /**  /**
11   * Implementation of hook_help   * Implementation of hook_help().
12   */   */
13  function tac_lite_help($section) {  function tac_lite_help($section) {
14    switch ($section) {    switch ($section) {
# Line 33  function tac_lite_help($section) { Line 33  function tac_lite_help($section) {
33   * Implementation of hook_perm().   * Implementation of hook_perm().
34   */   */
35  function tac_lite_perm() {  function tac_lite_perm() {
36    return array('administer_tac_lite');    return array('administer tac_lite');
37  }  }
38    
39  /**  /**
# Line 50  function tac_lite_menu() { Line 50  function tac_lite_menu() {
50            'page arguments' => array('tac_lite_admin_settings'),            'page arguments' => array('tac_lite_admin_settings'),
51            'type' => MENU_NORMAL_ITEM,            'type' => MENU_NORMAL_ITEM,
52            'weight' => 1, // after 'roles' tab            'weight' => 1, // after 'roles' tab
53            'access arguments' => array('administer_tac_lite'),            'access arguments' => array('administer tac_lite'),
54      );      );
55    
56    $items['admin/user/access/tac_lite/settings'] =    $items['admin/user/access/tac_lite/settings'] =
57      array('title' => 'Settings',      array('title' => 'Settings',
58            'type' => MENU_DEFAULT_LOCAL_TASK,            'type' => MENU_DEFAULT_LOCAL_TASK,
59            'weight' => -1,            'weight' => -1,
60            'access arguments' => array('administer_tac_lite'),            'access arguments' => array('administer tac_lite'),
61      );      );
62    
63    $schemes = variable_get('tac_lite_schemes', 1);    $schemes = variable_get('tac_lite_schemes', 1);
# Line 67  function tac_lite_menu() { Line 67  function tac_lite_menu() {
67              'page callback' => 'tac_lite_admin_settings_scheme',              'page callback' => 'tac_lite_admin_settings_scheme',
68              'page arguments' => array((string)$i),              'page arguments' => array((string)$i),
69              'type' => MENU_LOCAL_TASK,              'type' => MENU_LOCAL_TASK,
70              'access arguments' => array('administer_tac_lite'),              'access arguments' => array('administer tac_lite'),
71        );        );
72    }    }
73    
# Line 233  function tac_lite_admin_scheme_form($for Line 233  function tac_lite_admin_scheme_form($for
233                                    '#value' => t('First select vocabularies on the <a href=!url>settings page</a>.', array('!url' => url('admin/user/access/tac_lite'))))));                                    '#value' => t('First select vocabularies on the <a href=!url>settings page</a>.', array('!url' => url('admin/user/access/tac_lite'))))));
234    }    }
235  }  }
236    
237  /**  /**
238   * Implementation of hook_user().   * Implementation of hook_user().
239   */   */
   
240  function tac_lite_user($op, $edit, $account, $category = null) {  function tac_lite_user($op, $edit, $account, $category = null) {
   //drupal_set_message("tac_lite_user($op) called."); // debug  
241    
242    // only for administrators    if (!user_access('administer tac_lite')) {
243    global $user;      // Only for tac_lite administrators.
244    if (!user_access('administer_tac_lite'))      return;
245          return;    }
246    
247    switch ($op) {    switch ($op) {
248    case 'categories':    case 'categories':
249      return array(array('name' => 'tac_lite',      return array(array('name' => 'tac_lite',
250                         'title' => 'Taxonomy-based access',                         'title' => t('Taxonomy-based access'),
                        'access callback' => 'user_access',  
                        'access arguments' => array('administer_tac_lite'),  
251                         'weight' => 5,                         'weight' => 5,
252                   ),                   ),
253      );      );
# Line 463  function tac_lite_node_grants(&$account, Line 460  function tac_lite_node_grants(&$account,
460  function tac_lite_db_rewrite_sql($query, $primary_table, $primary_field, $args) {  function tac_lite_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
461    global $user;    global $user;
462    
463    // if administrator, give all access    if (user_access('administer tac_lite')) {
464    if (user_access('administer_tac_lite')) {      // Only for tac_lite administrators.
465          return;      return;
466    }    }
467    
468    // the vocabularies containing protected info.    // the vocabularies containing protected info.

Legend:
Removed from v.1.9.2.4  
changed lines
  Added in v.1.9.2.5

  ViewVC Help
Powered by ViewVC 1.1.2