Projet

Général

Profil

Révision 0695d136

Ajouté par Assos Assos il y a plus de 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/calendar/CHANGELOG.txt
5 5
Version 7.x-3.x-dev
6 6
===================
7 7

  
8
======================
9
Version 7.x-3.5
10
======================
11

  
12
- Issue #1729884 by lund.mikkel: Translations of max items collide with other translations.
13
- Issue #1734858 by Jaws, pc-wurm: Create localized_options array in calendar_menu_local_tasks_alter() if it does not exist.
14
- Issue #2008554 by coredumperror: Properly display week numbers in mini calendar view.
15
- Issue #1471400 by RoSk0, Garrett Albright: Fix illegal offset in template_preprocess_calendar_month().
16
- Issue #1792368 by rdela, Day template missing % after $first_column_width
17

  
8 18
======================
9 19
Version 7.x-3.4
10 20
======================
drupal7/sites/all/modules/calendar/calendar.info
16 16
files[] = theme/theme.inc
17 17
files[] = theme/calendar-style.tpl.php
18 18

  
19
; Information added by drupal.org packaging script on 2012-05-19
20
version = "7.x-3.4"
19
; Information added by Drupal.org packaging script on 2014-10-14
20
version = "7.x-3.5"
21 21
core = "7.x"
22 22
project = "calendar"
23
datestamp = "1337429753"
23
datestamp = "1413299943"
24 24

  
drupal7/sites/all/modules/calendar/calendar.module
169 169
        // The add new content page would redirect to the new event
170 170
        // if we did not override that here. This way they will
171 171
        // redirect back to the calendar.
172
	if (!isset($item['localized_options'])) {
173
          $item['localized_options'] = array();
174
        }
172 175
        $item['localized_options'] += array('query' => array());
173 176
        $item['localized_options']['query'] += drupal_get_destination();
174 177
        if (array_key_exists('access', $item) && $item['access']) {
drupal7/sites/all/modules/calendar/includes/calendar_plugin_style.inc
83 83
    $form['max_items'] = array(
84 84
      '#title' => t('Maximum items'),
85 85
      '#type' => 'select',
86
      '#options' => array(0 => t('Unlimited'), 1 => t('1 item'), 3 => t('3 items'), 5 => t('5 items'), 10 => t('10 items')),
86
      '#options' => array(
87
         0 => t('Unlimited'),
88
         1 => format_plural( 1, '1 item', '@count items'),
89
         3 => format_plural( 3, '1 item', '@count items'),
90
         5 => format_plural( 5, '1 item', '@count items'),
91
        10 => format_plural(10, '1 item', '@count items'),
92
      ),
87 93
      '#default_value' => $this->options['calendar_type'] != 'day' ? $this->options['max_items'] : 0,
88 94
      '#description' => t('Maximum number of items to show in calendar cells, used to keep the calendar from expanding to a huge size when there are lots of items in one day.'),
89 95
      '#dependency' => array('edit-style-options-calendar-type' => array('month')),
......
920 926
    date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
921 927
    $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
922 928

  
929
    if (!empty($this->date_info->style_with_weekno)) {
930
      $path = calendar_granularity_path($this->view, 'week');
931
      if (!empty($path)) {
932
        $url = $path . '/' . $this->date_info->year . '-W' . $week;
933
        $weekno = l($week, $url, array('query' => !empty($this->date_info->append) ? $this->date_info->append : ''));
934
      }
935
      else {
936
        // Do not link week numbers, if Week views are disabled.
937
        $weekno = $week;
938
      }
939
      $rows[$week][] = array(
940
        'data' => $weekno,
941
        'class' => 'mini week',
942
        'id' => $this->view->name . '-weekno-' . $curday_date,
943
      );
944
    }
945

  
923 946
    for ($i = 0; $i < 7; $i++) {
924 947
      $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
925 948
      $class = strtolower($weekdays[$i] . ' mini');
......
956 979
    return $rows;
957 980
  }
958 981

  
959
}
982
}
drupal7/sites/all/modules/calendar/theme/calendar-day.tpl.php
31 31
?>
32 32
<div class="calendar-calendar"><div class="day-view">
33 33
<table class="full">
34
  <col width="<?php print $first_column_width?>"></col>
34
  <col width="<?php print $first_column_width?>%"></col>
35 35
  <thead>
36 36
    <?php foreach ($columns as $column): ?>
37 37
    <col width="<?php print $column_width; ?>%"></col>
drupal7/sites/all/modules/calendar/theme/theme.inc
34 34

  
35 35
  $month_rows = $rows;
36 36
  foreach ($rows as $weekno => $row) {
37
    foreach ($row as $day => $data) {
38
      $cell = $data['data'];
39

  
40
      // If this cell is already rendered, like the weekno column,
41
      // move to the next item.
42
      if (!is_array($cell)) {
43
        $month_rows[$weekno][$day]['data'] = $cell;
44
        continue;
45
      }
46
      $data = $cell['datebox'];
47
      if ($cell['empty']) {
48
        $data .= $cell['empty'];
49
      }
50
      else {
51
        $data .= implode($cell['all_day']);
52
        foreach ($cell['items'] as $hour => $item) {
53
          $data .= implode($item);
37
    // If this row is already rendered, don't do anything.
38
    if (!isset($row['data'])) {
39
      foreach ($row as $day => $data) {
40
        $cell = $data['data'];
41

  
42
        // If this cell is already rendered, like the weekno column,
43
        // move to the next item.
44
        if (!is_array($cell)) {
45
          $month_rows[$weekno][$day]['data'] = $cell;
46
          continue;
47
        }
48
        $data = $cell['datebox'];
49
        if ($cell['empty']) {
50
          $data .= $cell['empty'];
51
        }
52
        else {
53
          $data .= implode($cell['all_day']);
54
          foreach ($cell['items'] as $hour => $item) {
55
            $data .= implode($item);
56
          }
57
          $data .= $cell['link'];
58
        }
59
        if ($view->date_info->mini) {
60
          $month_rows[$weekno][$day]['data'] = $data;
61
        }
62
        else {
63
          $month_rows[$weekno][$day]['data'] = '<div class="inner">' . $data . '</div>';
54 64
        }
55
        $data .= $cell['link'];
56
      }
57
      if ($view->date_info->mini) {
58
        $month_rows[$weekno][$day]['data'] = $data;
59
      }
60
      else {
61
        $month_rows[$weekno][$day]['data'] = '<div class="inner">' . $data . '</div>';
62 65
      }
63 66
    }
64 67
  }
drupal7/sites/all/modules/ckeditor/ckeditor.api.php
103 103
function hook_ckeditor_default_settings_alter(&$settings) {
104 104
  $settings['show_toggle'] = 'f';
105 105
}
106

  
107
/**
108
 * Hook to extend CKEditor security allowed tags list.
109
 *
110
 * This hook is invoked from ckeditor_filter_xss() where text is filtered from potentially insecure tags.
111
 */
112
function hook_ckeditor_filter_xss_allowed_tags() {
113
  // Return an array of additional allowed tags
114
}
drupal7/sites/all/modules/ckeditor/ckeditor.info
4 4
package     = User interface
5 5
configure   = admin/config/content/ckeditor
6 6

  
7
; Information added by Drupal.org packaging script on 2014-07-15
8
version = "7.x-1.15"
7
; Information added by Drupal.org packaging script on 2014-10-14
8
version = "7.x-1.16"
9 9
core = "7.x"
10 10
project = "ckeditor"
11
datestamp = "1405436656"
11
datestamp = "1413311935"
12 12

  
drupal7/sites/all/modules/ckeditor/ckeditor.module
45 45
global $_ckeditor_configuration;
46 46
global $_ckeditor_ids;
47 47

  
48
require_once('includes/ckeditor.user.inc');
48
module_load_include('inc', 'ckeditor', 'includes/ckeditor.user');
49 49

  
50 50
$_ckeditor_configuration = array();
51 51
$_ckeditor_ids = array();
......
258 258
 */
259 259
function ckeditor_form_user_profile_form_alter(&$form, &$form_state) {
260 260
  if ($form['#user_category'] == 'account') {
261
    module_load_include('inc', 'ckeditor', 'includes/ckeditor.user');
262 261
    ckeditor_user_customize($form, $form_state, 'user_profile_form');
263 262
  }
264 263
}
......
746 745
  );
747 746
  return $fields;
748 747
}
748

  
drupal7/sites/all/modules/ckeditor/includes/ckeditor.lib.inc
1202 1202

  
1203 1203
  // add custom stylesheet if configured
1204 1204
  // lets hope it exists but we'll leave that to the site admin
1205
  $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
1205
  $query_string = '?' . variable_get('css_js_query_string', '0');
1206 1206
  $css_files = array();
1207 1207
  switch ($conf['css_mode']) {
1208 1208
    case 'theme':
......
1363 1363
 *
1364 1364
 */
1365 1365
function ckeditor_load_by_field($field, $format, $show_toggle = TRUE, $add_fields_to_toggle = FALSE) {
1366
  global $theme;
1366
  global $user, $theme;
1367 1367
  static $processed_ids = array();
1368 1368
  static $is_running = FALSE;
1369 1369
  $use_ckeditor = FALSE;
......
1474 1474
    $editor_url_path = ckeditor_path('url');
1475 1475

  
1476 1476
    if (!$is_running) {
1477
      // By default sessions are not started automatically for anonymous users.
1478
      // Start one for editing content so that we had a consistent token that is used in XSS filter.
1479
      if (isset($field['#entity']) && !empty($field['#entity']->created) && empty($user->uid)) {
1480
        drupal_session_start();
1481
        $_SESSION['ckeditor_anonymous_user'] = true;
1482
        drupal_page_is_cacheable(FALSE);
1483
      }
1484

  
1477 1485
      if (!$ckeditor_in_default_format) {
1478 1486
        $load_method = 'ckeditor_basic.js';
1479 1487
        $load_time_out = 0;
drupal7/sites/all/modules/ckeditor/includes/ckeditor.page.inc
223 223
 * AJAX callback - XSS filter
224 224
 */
225 225
function ckeditor_filter_xss() {
226
  header('Content-Type: text/html; charset=utf-8');
226
  header('Content-Type: text/plain; charset=utf-8');
227 227
  $GLOBALS['devel_shutdown'] = FALSE;
228 228

  
229
  if (!isset($_POST['text']) || !is_string($_POST['text']) || !isset($_POST['input_format']) || !is_string($_POST['input_format']) || !isset($_POST['token']) || !drupal_valid_token($_POST['token'], 'ckeditorAjaxCall', TRUE)) {
229
  if (!isset($_POST['text']) || !is_string($_POST['text']) || !isset($_POST['input_format']) || !is_string($_POST['input_format']) || !isset($_POST['token']) || !drupal_valid_token($_POST['token'], 'ckeditorAjaxCall', FALSE)) {
230 230
    exit;
231 231
  }
232 232

  
......
236 236
  }
237 237

  
238 238
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
239
  $profile = ckeditor_get_profile($_POST['input_format']);
240 239

  
241 240
  $text = $_POST['text'];
242 241
  $filters = filter_get_filters();
......
250 249
      continue;
251 250
    }
252 251

  
253
    //Call default CKEditor built-in filter
252
    // Built-in filter module, a special case where we would like to strip XSS and nothing more
254 253
    if ($name == 'filter_html' && $security_filters['filters']['filter_html'] == 1) {
255 254
      preg_match_all("|</?([a-z][a-z0-9]*)(?:\b[^>]*)>|i", $text, $matches);
256 255
      if ($matches[1]) {
257
        $tags = array_unique(array_merge($matches[1], array('!--')));
258
        $tags = array_map('strtolower', $tags);
256

  
257
        // Sources of inspiration:
258
        // http://www.w3.org/TR/html4/index/elements.html
259
        // http://www.w3.org/TR/html-markup/elements.html
260
        // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
261

  
262
        $base_allowed_tags = array('a','abbr','acronym','address','area','article','aside','audio','b','base','basefont',
263
          'bdi','bdo','big','blockquote','body','br','button','canvas','caption','center','cite','code','col','colgroup',
264
          'command','datalist','dd','del','details','dfn','dialog','dir','div','dl','dt','em','fieldset','figcaption',
265
          'figure','font','footer','form','h1','h2','h3','h4','h5','h6','head','header','hgroup','hr','html','i','img',
266
          'input','ins','isindex','kbd','keygen','label','legend','li','main','map','mark','menu','menuitem','meter',
267
          'nav','noframes','noscript','ol','optgroup','option','output','p','param','pre','progress','q','rp','rt',
268
          'ruby','s','samp','section','select','small','source','span','strike','strong','sub','summary','sup','table',
269
          'tbody','td','textarea','tfoot','th','thead','time','title','tr','track','tt','u','ul','var','video','wbr',
270
        );
271

  
272
        // Get tags allowed in filter settings
273
        $filter_allowed_tags = preg_split('/\s+|<|>/', $object->settings['allowed_html'], -1, PREG_SPLIT_NO_EMPTY);
274

  
275
        // Combine allowed tags
276
        $tags = array_merge($base_allowed_tags, $filter_allowed_tags);
277

  
278
        // Tags provided by hook
279
        $hooks_allowed_tags = module_invoke_all('ckeditor_filter_xss_allowed_tags');
280
        if (!empty($hooks_allowed_tags) && is_array($hooks_allowed_tags)){
281
          foreach($hooks_allowed_tags as $tag ){
282
            if (!empty($tag) && is_string($tag) && !in_array($tag,$tags)){
283
              array_push($tags,$tag);
284
            }
285
          }
286
        }
287

  
259 288
        $text = filter_xss($text, $tags);
260 289
      }
261 290
      continue;
drupal7/sites/all/modules/nodeaccess/CHANGELOG.txt
1 1
Nodeaccess 7.x-1.x
2 2
===================
3 3

  
4
Nodeaccess 7.x-1.4
5
===================
6
Issue #436918: Aliases are not being saved for disabled roles, port to D7.
7
Issue #2187571 by e.escribano, jshirkey: Fix node type grant tab choice.
8

  
9
Nodeaccess 7.x-1.3
10
===================
11
Issue #2173497: Remove undefined variable rows.
12

  
13

  
14
Nodeaccess 7.x-1.2
15
===================
16
Issue #2173497: remove undefined variable rid.
17

  
4 18
Nodeaccess 7.x-1.1
5 19
===================
6 20
Issue #2146209: Show localized role names in Grant tab.
drupal7/sites/all/modules/nodeaccess/nodeaccess.info
3 3
core = 7.x
4 4
package = Access control
5 5
configure = admin/config/people/nodeaccess
6
version = 7.0-1.x
7 6

  
8
; Information added by Drupal.org packaging script on 2014-01-17
9
version = "7.x-1.3"
7
; Information added by Drupal.org packaging script on 2014-10-06
8
version = "7.x-1.4"
10 9
core = "7.x"
11 10
project = "nodeaccess"
12
datestamp = "1389975818"
11
datestamp = "1412639629"
13 12

  
drupal7/sites/all/modules/nodeaccess/nodeaccess.install
62 62
    $grants[1]['grant_delete'] = $role_perms[2][$delete_perm];
63 63
    variable_set('nodeaccess_' . $type, $grants);
64 64
    $author_prefs[$type] = array(
65
      'grant_view' => 1,
66
      'grant_update' => 1,
67
      'grant_delete' => 1,
65
      'grant_view' => 0,
66
      'grant_update' => 0,
67
      'grant_delete' => 0,
68 68
    );
69 69
  }
70 70
  variable_set('nodeaccess_authors', $author_prefs);
drupal7/sites/all/modules/nodeaccess/nodeaccess.module
11 11
function nodeaccess_help($path, $arg) {
12 12
  switch ($path) {
13 13
    case 'node/%/grant':
14
      return '<small>' . t('You can set grants per users. Enter a name or a partial name in the box and click Search or press return. You need to check the Keep? checkbox if you want to keep the user for granting. Note that user grants are additional to those coming from roles.') . '</small>';
14
      return t("You can set grants for individual users. Enter a name or a partial name in the box and click Search or press return. You must check the 'Keep?' checkbox if you want to keep the user for granting. Note that user grants are in addition to those coming from roles.");
15 15
  }
16 16
}
17 17

  
......
140 140
  }
141 141
  $allowed_types = variable_get('nodeaccess-types', array());
142 142
  if ($op == 'grant') {
143
    if ($node->nid && isset($allowed_types[$node->type]) &&
143
    if ($node->nid && isset($allowed_types[$node->type]) && !empty($allowed_types[$node->type]) &&
144 144
        (user_access('grant node permissions', $account) ||
145 145
         (user_access('grant editable node permissions', $account) && node_access('update', $node, $account)) ||
146 146
         (user_access('grant deletable node permissions', $account) && node_access('delete', $node, $account)) ||
......
157 157
function nodeaccess_theme($existing, $type, $theme, $path) {
158 158
  return array(
159 159
    'nodeaccess_admin_form_roles' => array(
160
      'render element'  => 'role',
160
      'render element'  => 'form',
161 161
    ),
162 162
    'nodeaccess_admin_form_types' => array(
163 163
      'render element'  => 'form',
......
175 175
  return drupal_get_form('nodeaccess_admin_form');
176 176
}
177 177

  
178

  
178 179
/**
179 180
 * Menu callback. Draws the admin page.
180 181
 */
......
189 190
    '#type' => 'checkbox',
190 191
    '#title' => t('Give node grants priority'),
191 192
    '#default_value' => variable_get('nodeaccess-priority', 0),
192
    '#description' => '<small>' . t('If you are only using this access control module, you can safely ignore this. If you are using multiple access control modules, and you want the grants given on individual nodes to override any grants given by other modules, you should check this box.') . '</small>',
193
    '#description' => t('If you are only using this access control module, you can safely ignore this. If you are using multiple access control modules, and you want the grants given on individual nodes to override any grants given by other modules, you should check this box.'),
193 194
  );
194 195

  
195 196
  // Select whether to preserve hidden grants.
......
234 235
    '#title' => t('Allowed Roles'),
235 236
    '#tree' => TRUE,
236 237
    '#theme' => 'nodeaccess_admin_form_roles',
237
    '#description' => '<small>' . t('The selected roles will be listed on individual node grants. If you wish for certain roles to be hidden from users on the node grants tab, make sure they are not selected here. You may also provide an alias for each role to be displayed to the user and a weight to order them by. This is useful if your roles have machine-readable names not intended for human users.') . '</small>',
238
    '#description' => t('The selected roles will be listed on individual node grants. If you wish for certain roles to be hidden from users on the node grants tab, make sure they are not selected here. You may also provide an alias for each role to be displayed to the user and a weight to order them by. This is useful if your roles have machine-readable names not intended for human users.'),
238 239
  );
239 240

  
240 241
  foreach ($roles as $id => $role) {
......
245 246
    if (!$role['weight']) {
246 247
      $role['weight'] = 0;
247 248
    }
248
    // $form['role'][$id] = array('#tree' => TRUE);
249 249
    $form['role'][$id]['name'] = array(
250 250
      '#type' => 'hidden',
251 251
      '#value' => $role['name'],
......
397 397
      }
398 398
      $alias_prefs[$id]['weight'] = $val['weight'];
399 399
    }
400
    else {
401
      // Otherwise, we only save alias if one was specified.
402
      if ($val['alias']) {
403
        $alias_prefs[$id]['name'] = $val['alias'];
404
        $alias_prefs[$id]['weight'] = $val['weight'];
405
      }
406
    }
400 407
  }
401 408
  variable_set('nodeaccess-roles', $allowed_roles);
402 409
  nodeaccess_save_role_aliases($alias_prefs);
......
444 451
}
445 452

  
446 453
/**
447
 * Theme functions for nodeaccess_admin_form.
454
 * Theme function for nodeaccess_admin_form.
448 455
 */
449 456
function theme_nodeaccess_admin_form_roles($variables) {
450 457
  $output = '';
451
  $roles = $variables['role'];
452
  $header = array(t('Allow Role'), t('Alias'), t('Weight'));
453

  
454
  foreach ($roles as $role) {
455
    if (!is_array($role) || !isset($role['allow'])) {
456
      continue;
457
    }
458
    $row = array();
459
    $row[] = drupal_render($role['allow']);
460
    $row[] = drupal_render($role['alias']);
461
    $row[] = drupal_render_children($role['weight']);
458
  $form = $variables['form'];
459
  $rows = array();
460
  foreach (element_children($form) as $rid) {
461
    // Classify the weight element for TableDrag.
462
    $form[$rid]['weight']['#attributes']['class'] = array('roles-order-weight');
463

  
464
    // Mark the table row as draggable for TableDrag.
465
    $row = array(
466
      'data' => array(),
467
      'class' => array('draggable'),
468
    );
469
    // Render the table columns.
470
    $row['data'][] = drupal_render($form[$rid]['allow']);
471
    $row['data'][] = drupal_render($form[$rid]['alias']);
472
    $row['data'][] = drupal_render($form[$rid]['weight']);
462 473
    $rows[] = $row;
463 474
  }
464
  $output .= theme('table', array('header' => $header, 'rows' => $rows));
475

  
476
  $header = array(t('Allow Role'), t('Alias'), t('Weight'));
477
  $output .= theme('table', array(
478
    'header' => $header,
479
    'rows' => $rows,
480
    'attributes' => array('id' => 'roles-order'),
481
  ));
482
  $output .= drupal_render_children($form);
483

  
484
  // Attach TableDrag to the table ID and contained weight elements.
485
  drupal_add_tabledrag('roles-order', 'order', 'sibling', 'roles-order-weight');
465 486

  
466 487
  return $output;
467 488
}
......
540 561
  if (!$form_values) {
541 562
    $form_values = array();
542 563
    // Load all roles.
543
    $result = db_query("SELECT r.rid, nra.name, na.grant_view, na.grant_update, na.grant_delete FROM {role} r LEFT JOIN {nodeaccess_role_alias} nra ON r.rid = nra.rid LEFT JOIN {node_access} na ON r.rid = na.gid AND na.realm = :realm AND na.nid = :nid ORDER BY nra.weight, nra.name", array(':realm' => 'nodeaccess_rid', ':nid' => $node->nid));
564
    $result = db_query("SELECT r.rid, nra.name, na.grant_view, na.grant_update, na.grant_delete
565
      FROM {role} r
566
      LEFT JOIN {nodeaccess_role_alias} nra ON r.rid = nra.rid
567
      LEFT JOIN {node_access} na ON r.rid = na.gid AND na.realm = :realm AND na.nid = :nid
568
      ORDER BY nra.weight, nra.name", array(':realm' => 'nodeaccess_rid', ':nid' => $node->nid));
544 569
    foreach ($result as $grant) {
545 570
      $form_values['rid'][$grant->rid] = array(
546 571
        'name' => $grant->name,
......
550 575
      );
551 576
    }
552 577
    // Load users from node_access.
553
    $results = db_query("SELECT uid, name, grant_view, grant_update, grant_delete FROM {node_access} LEFT JOIN {users} ON uid = gid WHERE nid = :nid AND realm = :realm ORDER BY name", array(
578
    $results = db_query("SELECT uid, name, grant_view, grant_update, grant_delete
579
      FROM {node_access}
580
      LEFT JOIN {users} ON uid = gid
581
      WHERE nid = :nid AND realm = :realm
582
      ORDER BY name", array(
554 583
        ':nid' => $node->nid,
555 584
        ':realm' => 'nodeaccess_uid',
556 585
      ));
......
594 623
      foreach (array_keys($form_values['uid']) as $uid) {
595 624
        if (!$form_values['uid'][$uid]['keep']) {
596 625
          foreach (array('grant_view', 'grant_update', 'grant_delete') as $grant_type) {
597
            $form_values['uid'][$uid][$grant_type] = db_query_range("SELECT count(*) FROM {node_access} na LEFT JOIN {users_roles} r ON na.gid = r.rid WHERE nid = :nid AND realm = :realm AND uid = :uid AND :type = 1",
626
            $form_values['uid'][$uid][$grant_type] = db_query_range("SELECT count(*) FROM {node_access} na LEFT JOIN {users_roles} r ON na.gid = r.rid WHERE nid = :nid AND realm = :realm AND uid = :uid AND $grant_type = 1",
598 627
              0, 1,
599 628
              array(
600 629
                ':nid' => $node->nid,
601 630
                ':realm' => 'nodeaccess_rid',
602 631
                ':uid' => $uid,
603
                ':type' => $grant_type,
604 632
              ))->fetchField() ||
605
              db_query_range("SELECT count(*) FROM {node_access} na WHERE nid = :nid AND realm = :realm AND gid = :gid AND :type = 1",
633
              db_query_range("SELECT count(*) FROM {node_access} na WHERE nid = :nid AND realm = :realm AND gid = :gid AND $grant_type = 1",
606 634
                0, 1,
607 635
                array(
608 636
                  ':nid' => $node->nid,
609 637
                  ':realm' => 'nodeaccess_uid',
610 638
                  ':gid' => $uid,
611
                  ':type' => $grant_type,
612 639
                )
613 640
                )->fetchField();
614 641
          }
......
880 907
  $allowed_grants = variable_get('nodeaccess-grants', array());
881 908
  // Retrieve role names for columns.
882 909
  $role_names = user_roles();
910
  $role_aliases = nodeaccess_get_role_aliases();
911

  
912
  // Replace names with aliases.
913
  foreach ($role_names as $rid => $name) {
914
    if (isset($role_aliases[$rid]['alias'])) {
915
      $role_names[$rid] = $role_aliases[$rid]['alias'];
916
    }
917
  }
918

  
883 919
  // Roles table.
884 920
  $roles = element_children($form['rid']);
885

  
886 921
  if (count($roles) && count($allowed_roles)) {
887 922
    $header = array();
888 923
    $header[] = t('Role');
......
1017 1052
    node_access_write_grants($node, array(), $realm);
1018 1053
  }
1019 1054
}
1055

  
1020 1056
/**
1021 1057
 * Implements hook_node_access_records().
1022 1058
 */
......
1026 1062
  }
1027 1063
  // Need to find out if node has own grants or whether to use defaults.
1028 1064
  $default = variable_get('nodeaccess_' . $node->type, array());
1029
  // Load priority setting.
1030
  $priority = variable_get('nodeaccess-priority', 0);
1065

  
1066
  // Setup default keys that are required by node_access_write_grants().
1067
  $grant_defaults = array(
1068
    'gid' => 0,
1069
    'realm' => 'nodeaccess_rid',
1070
    'grant_view' => 0,
1071
    'grant_update' => 0,
1072
    'grant_delete' => 0,
1073
    'priority' => variable_get('nodeaccess-priority', 0),
1074
  );
1075

  
1031 1076
  $result = db_query("SELECT count(*) FROM {nodeaccess} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField();
1032 1077
  if ($result < 1) {
1033
    // Node has no own grants, use defaults.
1034
    $grants = $default;
1035
    foreach ($grants as $id => $grant) {
1036
      $grants[$id]['priority'] = $priority;
1078
    // Node has no own grants, use defaults if published.
1079
    if ($node->status) {
1080
      $grants = $default;
1081
    }
1082
    else {
1083
      // Otherwise, check access to unpublished content for authenticated and
1084
      // anonymous users.
1085
      $role_perms = user_role_permissions(array(
1086
        DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID,
1087
        DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
1088
      ));
1089
      // Anonymous user setting.
1090
      $grants = array();
1091
      $grants[] = array(
1092
        'gid' => DRUPAL_ANONYMOUS_RID,
1093
        'grant_view' => isset($role_perms[DRUPAL_ANONYMOUS_RID]['bypass node access']) ?
1094
          intval($role_perms[DRUPAL_ANONYMOUS_RID]['bypass node access']) : 0,
1095
      );
1096
      // Authenticated user setting.
1097
      $grants[] = array(
1098
        'gid' => DRUPAL_AUTHENTICATED_RID,
1099
        'grant_view' => isset($role_perms[DRUPAL_AUTHENTICATED_RID]['bypass node access']) ?
1100
          intval($role_perms[DRUPAL_AUTHENTICATED_RID]['bypass node access']) : 0,
1101
      );
1037 1102
    }
1038 1103
  }
1039 1104
  else {
......
1047 1112
        'grant_view' => $row->grant_view,
1048 1113
        'grant_update' => $row->grant_update,
1049 1114
        'grant_delete' => $row->grant_delete,
1050
        'priority' => $priority,
1051 1115
      );
1052 1116
    }
1053 1117
  }
......
1057 1121
  $grant = $author_prefs[$node->type];
1058 1122
  $grant['gid'] = $node->uid;
1059 1123
  $grant['realm'] = 'nodeaccess_author';
1060
  $grant['priority'] = $priority;
1061 1124
  // Include author grant even with all values FALSE, it may be
1062 1125
  // needed to overwrite an older value.
1063 1126
  $grants[] = $grant;
1127

  
1128
  foreach ($grants as $id => $grant) {
1129
    // Merge missing default grant keys.
1130
    $grants[$id] = $grants[$id] + $grant_defaults;
1131
  }
1064 1132
  return $grants;
1065 1133
}
1066 1134

  
1067 1135
/**
1068
 * @todo Please document this function.
1069
 * @see http://drupal.org/node/1354
1136
 * Mark module to be in process of disabling.
1137
 *
1138
 * Prevents entries being saved to node_access while module is being disabled.
1139
 *
1140
 * @param mixed $set
1141
 *   A boolean set or NULL to not change status.
1070 1142
 */
1071 1143
function nodeaccess_disabling($set = NULL) {
1072 1144
  static $disabling = FALSE;
......
1135 1207
  // Add all permissions for author.
1136 1208
  $author_prefs = variable_get('nodeaccess_authors', array());
1137 1209
  $author_prefs[$info->type] = array(
1138
    'grant_view' => 1,
1139
    'grant_update' => 1,
1140
    'grant_delete' => 1,
1210
    'grant_view' => 0,
1211
    'grant_update' => 0,
1212
    'grant_delete' => 0,
1141 1213
  );
1142 1214
  variable_set('nodeaccess_authors', $author_prefs);
1143 1215
  node_access_needs_rebuild(TRUE);
1144 1216
}
1145 1217

  
1146 1218
/**
1147
 * @todo Please document this function.
1148
 * @see http://drupal.org/node/1354
1219
 * Retrieve role aliases.
1220
 *
1221
 * @return array or role aliases indexed by rid.
1149 1222
 */
1150 1223
function nodeaccess_get_role_aliases() {
1151 1224
  $aliases = array();
1152
  $results = db_query('SELECT r.rid, r.name, a.name AS alias, a.weight FROM {role} r LEFT JOIN {nodeaccess_role_alias} a ON r.rid = a.rid ORDER BY r.name');
1225
  $sql = 'SELECT r.rid, r.name, a.name AS alias, a.weight
1226
    FROM {role} r
1227
    LEFT JOIN {nodeaccess_role_alias} a ON r.rid = a.rid
1228
    ORDER BY a.weight, r.weight, a.name, r.name';
1229
  $results = db_query($sql);
1153 1230
  foreach ($results as $a) {
1154 1231
    $aliases[$a->rid]['name'] = $a->name;
1155 1232
    $aliases[$a->rid]['alias'] = $a->alias;
......
1158 1235
  return $aliases;
1159 1236
}
1160 1237

  
1238

  
1161 1239
/**
1162
 * @todo Please document this function.
1163
 * @see http://drupal.org/node/1354
1240
 * Save a role alias.
1241
 *
1242
 * @param array $edit
1243
 *   An array of aliases to save, indexed by rid.
1164 1244
 */
1165 1245
function nodeaccess_save_role_aliases($edit) {
1166 1246
  db_delete('nodeaccess_role_alias')->execute();

Formats disponibles : Unified diff