/[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.7, Sat Jan 3 07:48:17 2009 UTC revision 1.8, Wed Jan 28 17:25:34 2009 UTC
# Line 31  function restricted_content_form_alter(& Line 31  function restricted_content_form_alter(&
31      //restricted_content_node_form($form);      //restricted_content_node_form($form);
32    }    }
33    elseif ($form['#id'] == 'node-form') {    elseif ($form['#id'] == 'node-form') {
34      $default = unserialize(db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $form['#node']->nid)));      $default = unserialize(db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $form['nid']['#value'])));
35      restricted_content_node_form($form, $default);      restricted_content_node_form($form, $default);
36      $form['#submit'][] = 'restricted_content_node_form_submit';      $form['#submit'][] = 'restricted_content_node_form_submit';
37    }    }
# Line 47  function restricted_content_node_form(&$ Line 47  function restricted_content_node_form(&$
47      '#collapsible' => TRUE,      '#collapsible' => TRUE,
48      '#collapsed' => TRUE,      '#collapsed' => TRUE,
49      '#tree' => TRUE,      '#tree' => TRUE,
50      '#access' => restricted_content_form_access($form['#node']),      '#access' => restricted_content_form_access($form['uid']['#value']),
51    );    );
52    $form['restricted_content']['rids'] = array(    $form['restricted_content']['rids'] = array(
53      '#type' => 'checkboxes',      '#type' => 'checkboxes',
# Line 68  function restricted_content_node_form_su Line 68  function restricted_content_node_form_su
68    }    }
69  }  }
70    
71  function restricted_content_form_access($node) {  function restricted_content_form_access($uid) {
72    global $user;    global $user;
73    return user_access('restrict content access') || ($node->nid == $user->uid && user_access('restrict own content access'));    return user_access('restrict content access') || ($uid == $user->uid && user_access('restrict own content access'));
74  }  }
75    
76  function restricted_content_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {  function restricted_content_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
# Line 79  function restricted_content_nodeapi(&$no Line 79  function restricted_content_nodeapi(&$no
79    if ($op == 'delete') {    if ($op == 'delete') {
80      db_query("DELETE FROM {restricted_content} WHERE nid = %d", $node->nid);      db_query("DELETE FROM {restricted_content} WHERE nid = %d", $node->nid);
81    }    }
82    elseif ($op == 'load' && !restricted_content_form_access($node)) {    elseif ($op == 'load' && !restricted_content_form_access($node->uid)) {
83      $rids = db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $node->nid));      $rids = db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $node->nid));
84      if ($rids && !array_intersect(unserialize($rids), array_keys($user->roles))) {      if ($rids && !array_intersect(unserialize($rids), array_keys($user->roles))) {
85    
# Line 169  function restricted_content_var($name) { Line 169  function restricted_content_var($name) {
169    
170    // @todo Remove when I stop making spelling errors in variable names.    // @todo Remove when I stop making spelling errors in variable names.
171    if (!isset($defaults[$name])) {    if (!isset($defaults[$name])) {
172      watchdog('restricted_conte', 'Default variable for %variable not found.', array('%variable' => $name));      watchdog('restricted_conte', 'Default variable for %variable not found.', array('%variable' => $name), WATCHDOG_WARNING);
173    }    }
174    
175    return variable_get($name, isset($defaults[$name]) ? $defaults[$name] : NULL);    return variable_get($name, isset($defaults[$name]) ? $defaults[$name] : NULL);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.2