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

Diff of /contributions/modules/restricted_content/restricted_content.module

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

revision 1.2, Sat Jan 3 04:09:13 2009 UTC revision 1.3, Sat Jan 3 04:25:12 2009 UTC
# Line 114  function restricted_content_nodeapi(&$no Line 114  function restricted_content_nodeapi(&$no
114      if ($rids && !array_intersect(unserialize($rids), array_keys($user->roles))) {      if ($rids && !array_intersect(unserialize($rids), array_keys($user->roles))) {
115    
116        $node_type = drupal_strtolower(node_get_types('name', $node));        $node_type = drupal_strtolower(node_get_types('name', $node));
117        $node->body = t('This @node-type has been restricted to certain users.', array('@node-type' => $node_type));        $node->body = strtr(restricted_content_var('message'), array('@node-type' => $node_type));
118          //$node->body = t('This @node-type has been restricted to certain users.', array('@node-type' => $node_type));
119        $node->restricted = TRUE;        $node->restricted = TRUE;
120        $node->comment = COMMENT_NODE_DISABLED;        $node->comment = COMMENT_NODE_DISABLED;
121    
122        // Add a register link of the user is anonymous and can register for an        // Add a register link of the user is anonymous and can register for an
123        // account.        // account.
124        if (!$user->uid && variable_get('user_register', 1)) {        if (!$user->uid && variable_get('user_register', 1)) {
125          $node->body .= ' '. t('Please <a href="@link-register">register for a user account</a> to view this @node-type.', array('@link-register' => url('user/register'), '@node-type' => $node_type));          //$node->body .= ' '. t('Please <a href="@link-register">register for a user account</a> to view this @node-type.', array('@link-register' => url('user/register'), '@node-type' => $node_type));
126            $node->body .= ' '. strtr(restricted_content_var('message_anon'), array('@link-register' => url('user/register'), '@node-type' => $node_type));
127        }        }
128    
129        $node->teaser = $node->body;        $node->teaser = $node->body;
# Line 139  function restricted_content_nodeapi(&$no Line 141  function restricted_content_nodeapi(&$no
141    }    }
142  }  }
143    
144    function restricted_content_variables() {
145      return array(
146        'restricted_content_message' => t('This @node-type has been restricted to certain users.'),
147        'restricted_content_message_anon' => t('Please <a href="@link-register">register for a user account</a> to view this @node-type.'),
148      );
149    }
150    
151    function restricted_content_var($name) {
152      static $defaults = NULL;
153      if (!isset($defaults)) {
154        $defaults = restricted_content_variables();
155      }
156    
157      $name = 'restricted_content_'. $name;
158    
159      return variable_get($name, $defaults[$name]);
160    }
161    
162  function restricted_content_preprocess_node(&$vars) {  function restricted_content_preprocess_node(&$vars) {
163    if (!empty($vars['node']->restricted)) {    if (!empty($vars['node']->restricted)) {
164    //echo "<pre>"; var_export($vars); echo "</pre>";// die();    //echo "<pre>"; var_export($vars); echo "</pre>";// die();

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2