Projet

Général

Profil

Révision 082b75eb

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/cas/cas.info
7 7
files[] = cas.test
8 8
files[] = includes/views/handlers/cas_handler_field_cas_name.inc
9 9

  
10
; Information added by Drupal.org packaging script on 2017-12-02
11
version = "7.x-1.6"
10
; Information added by Drupal.org packaging script on 2018-02-12
11
version = "7.x-1.7"
12 12
core = "7.x"
13 13
project = "cas"
14
datestamp = "1512242294"
14
datestamp = "1518448970"
15 15

  
drupal7/sites/all/modules/cas/cas.install
158 158
        'title' => $t('CAS SSL certificate bundle'),
159 159
        'severity' => REQUIREMENT_ERROR,
160 160
        'value' => $t('Not set'),
161
        'description' => $t('The CAS authentication process is not completely secure. Please <a href="@settings_url">visit the CAS settings page</a> and provide the path to the certificate authority bundle.'),
161
        'description' => $t('The CAS authentication process is not completely secure. Please <a href="@settings_url">visit the CAS settings page</a> and provide the path to the certificate authority bundle.', array('@settings_url' => url('admin/config/people/cas'))),
162 162
      );
163 163
    }
164 164
  }
drupal7/sites/all/modules/cas/cas.module
447 447
 * @see cas_translated_menu_link_alter()
448 448
 */
449 449
function cas_menu_link_alter(&$item) {
450
  if (strtolower($item['link_path']) == 'cas' || strtolower($item['link_path']) == 'caslogout') {
450
  $link_path = strtolower($item['link_path']);
451
  if ($link_path == 'cas' || $link_path == 'caslogout') {
451 452
    $item['options']['alter'] = TRUE;
452 453
  }
453 454
}
......
455 456
/**
456 457
 * Implements hook_translated_menu_item_alter().
457 458
 *
458
 * Append dynamic query 'destination' to several menu items.
459
 * Append dynamic query 'destination' to CAS menu links.
459 460
 */
460 461
function cas_translated_menu_link_alter(&$item) {
461
  if (strtolower($item['href']) == 'cas') {
462
    $item['localized_options']['query'] = drupal_get_destination();
463
  }
464
  elseif (strtolower($item['href']) == 'caslogout' && !variable_get('cas_logout_destination', '')) {
465
    $item['localized_options']['query'] = drupal_get_destination();
462
  $href = strtolower($item['href']);
463
  $append_destination = $href == 'cas' || ($href == 'caslogout' && !variable_get('cas_logout_destination', ''));
464
  if ($append_destination) {
465
    // Don't overwrite existing query params that may exist in the menu link.
466
    if (isset($item['localized_options']['query'])) {
467
      $menu_link_query_params = array_merge(drupal_get_destination(), $item['localized_options']['query']);
468
    }
469
    else {
470
      $menu_link_query_params = drupal_get_destination();
471
    }
472
    $item['localized_options']['query'] = $menu_link_query_params;
466 473
  }
467 474
}
468 475

  
drupal7/sites/all/modules/cas/cas_server.info
4 4
description = "Provides protocol compliant CAS Server"
5 5
configure = admin/config/people/cas_server
6 6

  
7
; Information added by Drupal.org packaging script on 2017-12-02
8
version = "7.x-1.6"
7
; Information added by Drupal.org packaging script on 2018-02-12
8
version = "7.x-1.7"
9 9
core = "7.x"
10 10
project = "cas"
11
datestamp = "1512242294"
11
datestamp = "1518448970"
12 12

  
drupal7/sites/all/modules/cas/tests/cas_test.info
8 8
; code duplication we use several themes defined by that module.
9 9
dependencies[] = cas_server
10 10

  
11
; Information added by Drupal.org packaging script on 2017-12-02
12
version = "7.x-1.6"
11
; Information added by Drupal.org packaging script on 2018-02-12
12
version = "7.x-1.7"
13 13
core = "7.x"
14 14
project = "cas"
15
datestamp = "1512242294"
15
datestamp = "1518448970"
16 16

  
drupal7/sites/all/modules/entity/entity.info
25 25
files[] = views/handlers/entity_views_handler_relationship_by_bundle.inc
26 26
files[] = views/handlers/entity_views_handler_relationship.inc
27 27
files[] = views/plugins/entity_views_plugin_row_entity_view.inc
28
; Information added by Drupal.org packaging script on 2016-09-22
29
version = "7.x-1.8"
28
; Information added by Drupal.org packaging script on 2018-02-14
29
version = "7.x-1.9"
30 30
core = "7.x"
31 31
project = "entity"
32
datestamp = "1474546503"
32
datestamp = "1518620551"
33 33

  
drupal7/sites/all/modules/entity/entity.module
1088 1088
  // Care about entitycache tables.
1089 1089
  if (module_exists('entitycache')) {
1090 1090
    $tables = array();
1091
    foreach (entity_crud_get_info() as $entity_type => $entity_info) {
1092
      if (isset($entity_info['module']) && !empty($entity_info['entity cache'])) {
1093
        $tables[] = 'cache_entity_' . $entity_type;
1091
    $tables_created = variable_get('entity_cache_tables_created');
1092
    if (is_array($tables_created)) {
1093
      foreach ($tables_created as $module => $entity_cache_tables) {
1094
        $tables = array_merge($tables, $entity_cache_tables);
1094 1095
      }
1095 1096
    }
1096 1097
    return $tables;
drupal7/sites/all/modules/entity/entity_token.info
5 5
files[] = entity_token.module
6 6
dependencies[] = entity
7 7

  
8
; Information added by Drupal.org packaging script on 2016-09-22
9
version = "7.x-1.8"
8
; Information added by Drupal.org packaging script on 2018-02-14
9
version = "7.x-1.9"
10 10
core = "7.x"
11 11
project = "entity"
12
datestamp = "1474546503"
12
datestamp = "1518620551"
13 13

  
drupal7/sites/all/modules/entity/includes/entity.wrapper.inc
121 121
    if (!$this->validate($value)) {
122 122
      throw new EntityMetadataWrapperException(t('Invalid data value given. Be sure it matches the required data type and format. Value at !location: !value.', array(
123 123
        // An exception's message is output through check_plain().
124
        '!value' => is_array($value) || is_object($value) ? var_export($value) : $value,
124
        '!value' => is_array($value) || is_object($value) ? var_export($value, TRUE) : $value,
125 125
        '!location' => $this->debugIdentifierLocation(),
126 126
      )));
127 127
    }
......
755 755
    if (!$this->validate($value)) {
756 756
      throw new EntityMetadataWrapperException(t('Invalid data value given. Be sure it matches the required data type and format. Value at !location: !value.', array(
757 757
        // An exception's message is output through check_plain().
758
        '!value' => is_array($value) || is_object($value) ? var_export($value) : $value,
758
        '!value' => is_array($value) || is_object($value) ? var_export($value, TRUE) : $value,
759 759
        '!location' => $this->debugIdentifierLocation(),
760 760
      )));
761 761
    }
......
1116 1116
   */
1117 1117
  public function getIterator() {
1118 1118
    // In case there is no data available, just iterate over the first item.
1119
    return new EntityMetadataWrapperIterator($this, $this->dataAvailable() ? array_keys(parent::value()) : array(0));
1119
    return new EntityMetadataWrapperIterator($this, ($this->dataAvailable() && is_array(parent::value())) ? array_keys(parent::value()) : array(0));
1120 1120
  }
1121 1121

  
1122 1122
  /**
drupal7/sites/all/modules/entity/modules/callbacks.inc
673 673
    if (empty($node->vid) && in_array($op, array('create', 'update'))) {
674 674
      // This is a new node or the original node.
675 675
      if (isset($node->type)) {
676
        $op = !empty($node->is_new) && $node->is_new ? 'create' : 'update';
676
        $op = empty($node->nid) || !empty($node->is_new) ? 'create' : 'update';
677 677
        return node_access($op, $op == 'create' ? $node->type : $node, $account);
678 678
      }
679 679
      else {
drupal7/sites/all/modules/entity/tests/entity_feature.info
6 6
dependencies[] = entity_test
7 7
hidden = TRUE
8 8

  
9
; Information added by Drupal.org packaging script on 2016-09-22
10
version = "7.x-1.8"
9
; Information added by Drupal.org packaging script on 2018-02-14
10
version = "7.x-1.9"
11 11
core = "7.x"
12 12
project = "entity"
13
datestamp = "1474546503"
13
datestamp = "1518620551"
14 14

  
drupal7/sites/all/modules/entity/tests/entity_test.info
7 7
dependencies[] = entity
8 8
hidden = TRUE
9 9

  
10
; Information added by Drupal.org packaging script on 2016-09-22
11
version = "7.x-1.8"
10
; Information added by Drupal.org packaging script on 2018-02-14
11
version = "7.x-1.9"
12 12
core = "7.x"
13 13
project = "entity"
14
datestamp = "1474546503"
14
datestamp = "1518620551"
15 15

  
drupal7/sites/all/modules/entity/tests/entity_test_i18n.info
5 5
package = Multilingual - Internationalization
6 6
core = 7.x
7 7
hidden = TRUE
8
; Information added by Drupal.org packaging script on 2016-09-22
9
version = "7.x-1.8"
8
; Information added by Drupal.org packaging script on 2018-02-14
9
version = "7.x-1.9"
10 10
core = "7.x"
11 11
project = "entity"
12
datestamp = "1474546503"
12
datestamp = "1518620551"
13 13

  
drupal7/sites/all/modules/entity/views/handlers/entity_views_handler_area_entity.inc
40 40
    $form['entity_id'] = array(
41 41
      '#type' => 'textfield',
42 42
      '#title' => t('Entity id'),
43
      '#description' => t('Choose the entity you want to display in the area.'),
43
      '#description' => t('Choose the entity you want to display in the area. To render an entity given by a contextual filter use "%1" for the first argument, "%2" for the second, etc.'),
44 44
      '#default_value' => $this->options['entity_id'],
45 45
    );
46 46

  
......
105 105
   * Render an entity using the view mode.
106 106
   */
107 107
  public function render_entity($entity_type, $entity_id, $view_mode) {
108
    $tokens = $this->get_render_tokens();
109
    // Replace argument tokens in entity id.
110
    $entity_id = strtr($entity_id, $tokens);
108 111
    if (!empty($entity_type) && !empty($entity_id) && !empty($view_mode)) {
109 112
      $entity = entity_load_single($entity_type, $entity_id);
110 113
      if (!empty($this->options['bypass_access']) || entity_access('view', $entity_type, $entity)) {
......
117 120
      return '';
118 121
    }
119 122
  }
123

  
124
  /**
125
   * Get the 'render' tokens to use for advanced rendering.
126
   *
127
   * This runs through all of the fields and arguments that
128
   * are available and gets their values. This will then be
129
   * used in one giant str_replace().
130
   */
131
  function get_render_tokens() {
132
    $tokens = array();
133
    if (!empty($this->view->build_info['substitutions'])) {
134
      $tokens = $this->view->build_info['substitutions'];
135
    }
136
    $count = 0;
137
    foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
138
      $token = '%' . ++$count;
139
      if (!isset($tokens[$token])) {
140
        $tokens[$token] = '';
141
      }
142
      // Use strip tags as there should never be HTML in the path.
143
      // However, we need to preserve special characters like " that
144
      // were removed by check_plain().
145
      $tokens['%' . $count] = $handler->argument;
146
    }
147

  
148
    return $tokens;
149
  }
120 150
}
drupal7/sites/all/modules/file_entity/file_entity.admin.inc
1157 1157
    '#default_value' => variable_get('file_entity_file_upload_wizard_skip_fields', FALSE),
1158 1158
    '#description' => t('The field selection step is only available if the file type the file belongs to has any available fields. If this step is skipped, any fields on the file will be left blank.'),
1159 1159
  );
1160
  $form['file_replace_options'] = array(
1161
    '#type' => 'fieldset',
1162
    '#title' => t('File replace optons'),
1163
    '#collapsible' => TRUE,
1164
    '#collapsed' => FALSE,
1165
    '#description' => t('Default settings for how to handle file name changes during replace.'),
1166
  );
1167
  $form['file_replace_options']['file_entity_file_replace_options_keep_original_filename'] = array(
1168
    '#type' => 'checkbox',
1169
    '#title' => t('Keep original file name'),
1170
    '#default_value' => variable_get('file_entity_file_replace_options_keep_original_filename', FALSE),
1171
    '#description' => t('Rename the newly uploaded file to the name of the original file. This action cannot be undone.'),
1172
  );
1160 1173

  
1161 1174
  return system_settings_form($form);
1162 1175
}
drupal7/sites/all/modules/file_entity/file_entity.info
32 32
; We have to add a fake version so Git checkouts do not fail Media dependencies
33 33
version = 7.x-2.x-dev
34 34

  
35
; Information added by Drupal.org packaging script on 2018-01-08
36
version = "7.x-2.15"
35
; Information added by Drupal.org packaging script on 2018-02-11
36
version = "7.x-2.16"
37 37
core = "7.x"
38 38
project = "file_entity"
39
datestamp = "1515421989"
39
datestamp = "1518385686"
40 40

  
drupal7/sites/all/modules/file_entity/file_entity.module
1818 1818
 * access conditions are added for field values belonging to files only.
1819 1819
 */
1820 1820
function file_entity_query_entity_field_access_alter(QueryAlterableInterface $query) {
1821
  _file_entity_query_file_entity_access_alter($query, 'entity');
1821
  //_file_entity_query_file_entity_access_alter($query, 'entity');
1822 1822
}
1823 1823

  
1824 1824
/**
......
1856 1856

  
1857 1857
  $tables = $query->getTables();
1858 1858
  $base_table = $query->getMetaData('base_table');
1859
  // Do not use the base table for general entity queries unless this is
1860
  // querying the file_managed table directly.
1861
  if ($base_table && $type == 'entity' && $base_table != 'file_managed') {
1862
    $base_table = '';
1863
  }
1864

  
1865 1859
  // If no base table is specified explicitly, search for one.
1866 1860
  if (!$base_table) {
1867 1861
    $fallback = '';
......
1893 1887
              $fallback = $table;
1894 1888
            }
1895 1889
          }
1896
          elseif (isset($schema['fields']['entity_id']) && isset($schema['fields']['entity_type']) && isset($schema['fields']['deleted']) && isset($schema['fields']['delta'])) {
1897
            // The table is a field data table, use it as fallback.
1898
            $base_table = $table;
1899
          }
1900 1890
        }
1901 1891
      }
1902 1892
    }
......
1907 1897
        $base_table = $fallback;
1908 1898
      }
1909 1899
      else {
1910
        // Ignore this query as it was a general field query and no
1911
        // relationships were found to the file_managed table.
1912
        if ($type == 'entity') {
1913
          return;
1914
        }
1915 1900
        throw new Exception(t('Query tagged for file access but there is no fid. Add foreign keys to file_managed.fid in schema to fix.'));
1916 1901
      }
1917 1902
    }
......
1974 1959
        }
1975 1960
      }
1976 1961

  
1977
      // If there is no subquery conditions, the query is likely for file usage.
1978
      // Or user can only access public files.
1979
      // If there are subquery conditions then add them to the subquery.
1980
      if ($subquery_conditions->count() >= 1) {
1962
      if ($subquery_conditions->count()) {
1981 1963
        $subquery->condition($subquery_conditions);
1982
      }
1983 1964

  
1984
      $field = 'fid';
1985
      // Now handle entities.
1986
      if ($type == 'entity') {
1987
        // Set a common alias for entities.
1988
        $base_alias = $falias;
1989
        $field = ($falias == 'file_managed' ? 'fid' : 'entity_id');
1990
      }
1991
      $subquery->where("$falias.$field = fm_access.fid");
1965
        $field = 'fid';
1966
        // Now handle entities.
1967
        if ($type == 'entity') {
1968
          // Set a common alias for entities.
1969
          $base_alias = $falias;
1970
          $field = 'entity_id';
1971
        }
1972
        $subquery->where("$falias.$field = fm_access.fid");
1992 1973

  
1993
      // For an entity query, attach the subquery to entity conditions.
1994
      if ($type == 'entity') {
1995
        $file_conditions->exists($subquery);
1996
      }
1997
      // Otherwise attach it to the node query itself.
1998
      elseif ($table == 'file_managed') {
1999
        // Fix for https://drupal.org/node/2073085
2000
        $db_or = db_or();
2001
        $db_or->exists($subquery);
2002
        $db_or->isNull($falias . '.' . $field);
2003
        $query->condition($db_or);
2004
      }
2005
      else {
2006
        $query->exists($subquery);
1974
        // For an entity query, attach the subquery to entity conditions.
1975
        if ($type == 'entity') {
1976
          $file_conditions->exists($subquery);
1977
        }
1978
        // Otherwise attach it to the node query itself.
1979
        elseif ($table == 'file_managed') {
1980
          // Fix for https://drupal.org/node/2073085
1981
          $db_or = db_or();
1982
          $db_or->exists($subquery);
1983
          $db_or->isNull($falias . '.' . $field);
1984
          $query->condition($db_or);
1985
        }
1986
        else {
1987
          $query->exists($subquery);
1988
        }
2007 1989
      }
2008 1990
    }
2009 1991
  }
......
2011 1993
  if ($type == 'entity' && $file_conditions->count()) {
2012 1994
    // All the file access conditions are only for field values belonging to
2013 1995
    // files.
2014
    if ($base_alias !== 'file_managed') {
2015
      $file_conditions->condition("$base_alias.entity_type", 'file');
2016
      $or = db_or();
2017
      $or->condition($file_conditions);
2018
      // If the field value belongs to a non-file entity type then this function
2019
      // does not do anything with it.
2020
      $or->condition("$base_alias.entity_type", 'file', '<>');
2021
      // Add the compiled set of rules to the query.
2022
      $query->condition($or);
2023
    }
2024
    else {
2025
      $query->condition($file_conditions);
2026
    }
1996
    $file_conditions->condition("$base_alias.entity_type", 'file');
1997
    $or = db_or();
1998
    $or->condition($file_conditions);
1999
    // If the field value belongs to a non-file entity type then this function
2000
    // does not do anything with it.
2001
    $or->condition("$base_alias.entity_type", 'file', '<>');
2002
    // Add the compiled set of rules to the query.
2003
    $query->condition($or);
2027 2004
  }
2028 2005
}
2029 2006

  
drupal7/sites/all/modules/file_entity/file_entity.pages.inc
675 675
      '#upload_validators' => file_entity_get_upload_validators($replacement_options),
676 676
      '#pre_render' => array('file_entity_upload_validators_pre_render'),
677 677
    );
678
    $form['replace_keep_original_filename'] = array(
679
      '#type' => 'checkbox',
680
      '#title' => t('Keep original filename'),
681
      '#default_value' => variable_get('file_entity_file_replace_options_keep_original_filename', FALSE),
682
      '#description' => t('Rename the newly uploaded file to the name of the original file. This action cannot be undone.'),
683
    );
678 684
  }
679 685

  
680 686
  $form['preview'] = file_view_file($file, 'preview');
......
832 838
        file_delete($replacement);
833 839
      }
834 840
    } else {
835
      $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri);
841
      if (!empty($form_state['values']['replace_keep_original_filename'])
842
      && $form_state['values']['replace_keep_original_filename']) {
843
        $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($file->uri);
844
      }
845
      else {
846
        $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri);
847
      }
836 848
      $replace_mode = $destination_uri == $file->uri ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME;
837 849
      if ($new_file_uri = file_unmanaged_copy($replacement->uri, $destination_uri, $replace_mode)) {
838 850
        // @todo Add watchdog() about replaced file here?
drupal7/sites/all/modules/file_entity/file_entity.test
1671 1671
      $this->assertEqual($build['#file']->$attribute, $expected_value, format_string('The %attribute was overridden correctly.', array('%attribute' => $attribute)));
1672 1672
    }
1673 1673
  }
1674

  
1675
  /**
1676
   * @param EntityFieldQuery $query
1677
   * @param $expected
1678
   *   An associative array of expected result. Keys are file ids, values are
1679
   *   booleans to indicate if the result should include the file.
1680
   */
1681
  function assertEntityFieldQueryAccess(EntityFieldQuery $query, $expected, $account = NULL, $query_name = 'unnamed') {
1682
    if ($account) {
1683
      $query->addMetaData('account', $account);
1684
    }
1685
    $query->addTag('entity_field_access');
1686
    $results = $query->execute();
1687
    $fids = isset($results['file']) ? array_keys($results['file']) : array();
1688
    foreach ($expected as $fid => $in_result) {
1689
      if ($in_result) {
1690
        $this->assertTrue(in_array($fid, $fids), format_string("For the %name query, the result should contain %fid", array('%name' => $query_name, '%fid' => $fid)));
1691
      }
1692
      else {
1693
        $this->assertFalse(in_array($fid, $fids), format_string("For the %name query, the result should not contain %fid", array('%name' => $query_name, '%fid' => $fid)));
1694
      }
1695
    }
1696
  }
1697

  
1698
  /**
1699
   * Test file entity access for entity field queries.
1700
   */
1701
  function testEntityFieldQueryAccess() {
1702
    // Attach a text field to the default image file type.
1703
    $field = array(
1704
      'field_name' => drupal_strtolower($this->randomName()),
1705
      'type' => 'text',
1706
      'settings' => array(
1707
        'max_length' => 255,
1708
      )
1709
    );
1710
    field_create_field($field);
1711
    $instance = array(
1712
      'field_name' => $field['field_name'],
1713
      'entity_type' => 'file',
1714
      'bundle' => 'document',
1715
      'widget' => array(
1716
        'type' => 'text_textfield',
1717
      ),
1718
      'display' => array(
1719
        'default' => array(
1720
          'type' => 'text_default',
1721
        ),
1722
      ),
1723
    );
1724
    field_create_instance($instance);
1725
    // Create test files.
1726
    $file_owner = $this->drupalCreateUser(array('view own files', 'view own private files'));
1727
    $public_file = $this->createFileEntity(array(
1728
      'status' => 0,
1729
    ));
1730
    $private_file = $this->createFileEntity(array('scheme' => 'private'));
1731
    $owned_public_file = $this->createFileEntity(array(
1732
      'uid' => $file_owner->uid,
1733
      'scheme' => 'public',
1734
    ));
1735
    $owned_private_file = $this->createFileEntity(array(
1736
      'uid' => $file_owner->uid,
1737
      'scheme' => 'private',
1738
    ));
1739
    $fids = array(
1740
      $public_file->fid,
1741
      $private_file->fid,
1742
      $owned_public_file->fid,
1743
      $owned_private_file->fid,
1744
    );
1745
    foreach (file_load_multiple($fids) as $file) {
1746
      $file->{$field['field_name']}[LANGUAGE_NONE][0] = array('value' => 'find me');
1747
      file_save($file);
1748
    }
1749

  
1750
    $efq_fids = new EntityFieldQuery();
1751
    $queries['entity type and id conditions'] = $efq_fids
1752
      ->entityCondition('entity_type', 'file')
1753
      ->entityCondition('entity_id', $fids);
1754
    $efq_field_name = new EntityFieldQuery();
1755
    $queries['single field condition'] = $efq_field_name
1756
      ->fieldCondition($field['field_name'], 'value', 'find me');
1757

  
1758
    foreach($queries as $name => $query) {
1759
      $message = format_string('');
1760
      // User should not see private files, only his own public files.
1761
      $this->assertEntityFieldQueryAccess(clone $query, array(
1762
        $public_file->fid => TRUE,
1763
        $private_file->fid => FALSE,
1764
        $owned_public_file->fid => TRUE,
1765
        $owned_private_file->fid => FALSE,
1766
      ), $this->drupalCreateUser(array('create files')), $name);
1767

  
1768
      // A user with the 'view own files' and 'view own private files' permissions should only see owned files and public files.
1769
      $this->drupalLogin($file_owner);
1770
      $this->assertEntityFieldQueryAccess(clone $query, array(
1771
        $public_file->fid => TRUE,
1772
        $private_file->fid => FALSE,
1773
        $owned_public_file->fid => TRUE,
1774
        $owned_private_file->fid => TRUE,
1775
      ), $file_owner, $name);
1776

  
1777
      // User with the 'view files' permission should only see public files but cannot create files.
1778
      $this->assertEntityFieldQueryAccess(clone $query, array(
1779
        $public_file->fid => TRUE,
1780
        $private_file->fid => FALSE,
1781
        $owned_public_file->fid => TRUE,
1782
        $owned_private_file->fid => FALSE,
1783
      ), $this->drupalCreateUser(array('view files')), $name);
1784

  
1785
      // User with the 'view files' and 'view private files' permissions should only see all files.
1786
      $this->assertEntityFieldQueryAccess(clone $query, array(
1787
        $public_file->fid => TRUE,
1788
        $private_file->fid => TRUE,
1789
        $owned_public_file->fid => TRUE,
1790
        $owned_private_file->fid => TRUE,
1791
      ), $this->drupalCreateUser(array('view files', 'view private files')), $name);
1792

  
1793
      // User with the 'bypass file access' permissions should only see all files.
1794
      $this->assertEntityFieldQueryAccess(clone $query, array(
1795
        $public_file->fid => TRUE,
1796
        $private_file->fid => TRUE,
1797
        $owned_public_file->fid => TRUE,
1798
        $owned_private_file->fid => TRUE,
1799
      ), $this->drupalCreateUser(array('bypass file access')), $name);
1800
    }
1801
  }
1802 1674
}
drupal7/sites/all/modules/file_entity/file_entity.tokens.inc
44 44
    'type' => 'url',
45 45
  );
46 46

  
47
  if (module_exists('token')) {
48
    $info['types']['file_field'] = array(
49
      'name' => t('Media'),
50
      'description' => t('Tokens related to a file_entity field.'),
51
      'hidden' => TRUE,
52
    );
53

  
54
    $default_text = ' ' . t('Defaults to first value.');
55

  
56
    $info['tokens']['file_field'] = array(
57
      'field' => array(
58
        'name' => t('Field token value'),
59
        'description' => t('Default: The value returned by the token field formatter.') . $default_text,
60
      ),
61
      'url' => array(
62
        'name' => t('URL'),
63
        'description' => t('URL of the file_entity resource.') . $default_text,
64
        'type' => 'array',
65
      ),
66
      'filename' => array(
67
        'name' => t('Filename'),
68
        'description' => t('Filename the file_entity resource.') . $default_text,
69
        'type' => 'array',
70
      ),
71
      'filemime' => array(
72
        'name' => t('MIME type'),
73
        'description' => t('MIME type of the file_entity resource.') . $default_text,
74
        'type' => 'array',
75
      ),
76
      'type' => array(
77
        'name' => t('File type'),
78
        'description' => t('File type of the file_entity resource.') . $default_text,
79
        'type' => 'array',
80
      ),
81
      'image' => array(
82
        'name' => t('Image'),
83
        'description' => t('URL of a representative image for the file_entity resource, e.g. a video thumbnail.') . $default_text,
84
        'type' => 'array',
85
      ),
86
      'height' => array(
87
        'name' => t('Height'),
88
        'description' => t('Height of the file_entity resource, for videos or images.') . $default_text,
89
        'type' => 'array',
90
      ),
91
      'width' => array(
92
        'name' => t('Width'),
93
        'description' => t('Width of the file_entity resource, for videos or images.') . $default_text,
94
        'type' => 'array',
95
      ),
96
      'https-url' => array(
97
        'name' => t('Secure URL'),
98
        'description' => t('URL of the file_entity resource using HTTPS.') . $default_text,
99
        'type' => 'array',
100
      ),
101
      'https-image' => array(
102
        'name' => t('Secure image'),
103
        'description' => t('URL of a representative image for the file_entity resource using HTTPS, usually for videos.') . $default_text,
104
        'type' => 'array',
105
      ),
106
    );
107

  
108
    $all_fields = field_info_field_map();
109
    foreach ($all_fields as $field_name => $field) {
110
      if ($field['type'] == 'file') {
111
        $field_info = _token_field_info($field_name);
112
        foreach (array_keys($field['bundles']) as $entity_type) {
113
          $info['tokens'][$entity_type][$field_name] = array(
114
            'name' => $field_info['label'],
115
            'description' => $field_info['description'],
116
            'type' => 'file_field',
117
            'module' => 'file_entity',
118
          );
119
        }
120
      }
121
    }
122
  }
123

  
47 124
  return $info;
48 125
}
49 126

  
......
55 132
}
56 133

  
57 134
/**
58
 * Implements hook_tokens().
135
 * Provide replacement values for placeholder tokens.
59 136
 */
60 137
function file_entity_tokens($type, $tokens, array $data = array(), array $options = array()) {
61 138
  $replacements = array();
62 139

  
140
  // Check that this token call contains the data we need
141
  if ($type == 'entity' && !empty($data['entity_type']) && !empty($data['entity']) &&
142
    !empty($data['token_type']) && module_exists('token')) {
143

  
144
    foreach ($tokens as $name => $original) {
145

  
146
      // Split out the token into its parts
147
      $parts = explode(':', $name, 3);
148

  
149
      $field_name    = $parts[0];
150
      $property      = (isset($parts[1])) ? $parts[1] : '';
151
      $array_handler = (isset($parts[2])) ? $parts[2] : '';
152

  
153
      // Check that the field has content and that we should handle it
154
      if (!empty($data['entity']->$field_name) && _token_module($data['token_type'], $field_name) == 'file_entity') {
155

  
156
        // Get basic information
157
        $entity_type = $data['entity_type'];
158
        $langcode = isset($options['language']) ? $options['language']->language : NULL;
159
        $entity = clone $data['entity'];
160

  
161
        // If we are looking for the field output, let field module handle it
162
        if (empty($property) || $property == 'field') {
163
          unset($entity->_field_view_prepared);
164
          $field_output = field_view_field($entity_type, $entity, $field_name, 'token', $langcode);
165
          $field_output['#token_options'] = $options;
166
          $field_output['#prerender'][] = 'token_pre_render_field_token';
167
          $replacements[$original] = drupal_render($field_output);
168
        }
169
        else {
170
          $items = field_get_items($entity_type, $entity, $field_name);
171
          $return = _file_entity_tokens_get_property($items, $property, $array_handler);
172

  
173
          // We may get a single value or an array.
174
          // Handle array with the array function from token module.
175
          if (is_array($return)) {
176
            $search_tokens = token_find_with_prefix($tokens, $field_name);
177
            if ($array_tokens = token_find_with_prefix($search_tokens, $property)) {
178
              $replacements += token_generate('array', $array_tokens, array('array' => $return), $options);
179
            }
180
          }
181
          else {
182
            $replacements[$original] = $return;
183
          }
184
        }
185

  
186
        // Unset clone of entity
187
        unset($entity);
188
      }
189
    }
190
  }
191

  
63 192
  $url_options = array('absolute' => TRUE);
64 193
  if (isset($options['language'])) {
65 194
    $url_options['language'] = $options['language'];
......
131 260

  
132 261
  return $replacements;
133 262
}
263

  
264
/**
265
 * This helper function gets file properties for token replacement.
266
 *
267
 * @param array $files
268
 * An array of files that are values for the field.
269
 *
270
 * @param string $property
271
 * The property to retrieve from the file info. See file_entity_token_info() for
272
 * a list of properties.
273
 *
274
 * @param string $array_handler
275
 * The optional array modifier, e.g. "count" or "join:,".
276
 *
277
 * @return mixed
278
 * Either a single value, the first of the array, or an array of values.
279
 */
280
function _file_entity_tokens_get_property($files, $property, $array_handler = 'first') {
281

  
282
  // If we only need the first variable
283
  $return_first = ($array_handler == 'first' || empty($array_handler) || $array_handler == 'value:0');
284

  
285
  // This static variable stores image info
286
  $info = &drupal_static(__FUNCTION__);
287

  
288
  foreach ($files as $file) {
289
    $file['url'] = file_create_url($file['uri']);
290
    $file['https-url'] = str_replace('http://', 'https://', $file['url']);
291

  
292
    // If values are: filename, filemime, type, url, https-url
293
    if (isset($file[$property])) {
294
      $value = $file[$property];
295
    }
296

  
297
    // If values are: image, height, width, https-image
298
    elseif (!empty($info[$file['fid']])) {
299
      $value = $info[$file['fid']][$property] ?: NULL;
300
    }
301
    // If values are files types
302
    else {
303

  
304
      // If file type is image
305
      if ($file['type'] == 'image') {
306
        $imageuri = $file['uri'];
307
      }
308

  
309
      // If file type is video
310
      elseif ($file['type'] == 'video') {
311
        list($provider, $filename) = explode('://v/', $file['uri']);
312
        $imageuri = "public://file_entity-$provider/$filename.jpg";
313
      }
314

  
315
      // Do nothing for other file types
316
      // @todo: Other file types may need handling
317
      else {
318
        $imageuri = FALSE;
319
      }
320

  
321
      if ($info[$file['fid']] = image_get_info($imageuri)) {
322
        $info[$file['fid']]['image'] = file_create_url($imageuri);
323
        $info[$file['fid']]['https-image'] = str_replace('http://', 'https://', $info[$file['fid']]['image']);
324
      }
325

  
326
      $value = $info[$file['fid']][$property] ?: NULL;
327
    }
328

  
329
    if ($return_first) {
330
      return $value;
331
    }
332
    $values[] = $value;
333
  }
334

  
335
  return $values;
336
}
drupal7/sites/all/modules/file_entity/tests/file_entity_test.info
5 5
dependencies[] = file_entity
6 6
hidden = TRUE
7 7

  
8
; Information added by Drupal.org packaging script on 2018-01-08
9
version = "7.x-2.15"
8
; Information added by Drupal.org packaging script on 2018-02-11
9
version = "7.x-2.16"
10 10
core = "7.x"
11 11
project = "file_entity"
12
datestamp = "1515421989"
12
datestamp = "1518385686"
13 13

  
drupal7/sites/all/modules/job_scheduler/JobScheduler.inc
16 16
class JobScheduler {
17 17
  /**
18 18
   * The name of this scheduler.
19
   *
20
   * @var string
19 21
   */
20 22
  protected $name;
21 23

  
......
58 60
   *
59 61
   * A job is uniquely identified by $job = array(type, id).
60 62
   *
61
   * @param $job
63
   * @param array $job
62 64
   *   An array that must contain the following keys:
63 65
   *   'type'     - A string identifier of the type of job.
64 66
   *   'id'       - A numeric identifier of the job.
65
   *   'period'   - The time when the task should be executed.
66 67
   *   'periodic' - True if the task should be repeated periodically.
67 68
   *
69
   *   The array must also contain one of the following keys:
70
   *   'period'  - The time when the task should be executed.
71
   *   'crontab' - A crontab entry which describes the times a task should be
72
   *               executed.
73
   *
68 74
   * @code
69 75
   * function worker_callback($job) {
70 76
   *   // Work off job.
......
74 80
   *   $scheduler->set($job);
75 81
   * }
76 82
   * @endcode
83
   *
84
   * @codingStandardsIgnoreStart
77 85
   */
78 86
  public function set($job) {
87
    // @codingStandardsIgnoreEnd
79 88
    $job['name'] = $this->name;
80 89
    $job['last'] = REQUEST_TIME;
81 90
    if (!empty($job['crontab'])) {
......
130 139
   * Executes a worker callback or if schedule declares a queue name, queues a
131 140
   * job for execution.
132 141
   *
133
   * @param $job
142
   * @param array $job
134 143
   *   A $job array as passed into set() or read from job_schedule table.
135 144
   *
136 145
   * @throws Exception
137 146
   *   Exceptions thrown by code called by this method are passed on.
147
   *
148
   * @codingStandardsIgnoreStart
138 149
   */
139 150
  public function dispatch($job) {
151
    // @codingStandardsIgnoreEnd
140 152
    $info = $this->info();
141 153
    if (!$job['periodic']) {
142 154
      $this->remove($job);
......
152 164
  }
153 165

  
154 166
  /**
155
   * Executes a job that
167
   * Executes a job that.
156 168
   *
157
   * @param $job
169
   * @param array $job
158 170
   *   A $job array as passed into set() or read from job_schedule table.
159 171
   *
160 172
   * @throws Exception
161 173
   *   Exceptions thrown by code called by this method are passed on.
174
   *
175
   * @codingStandardsIgnoreStart
162 176
   */
163 177
  public function execute($job) {
178
    // @codingStandardsIgnoreEnd
164 179
    $info = $this->info();
165
    // If the job is periodic, re-schedule it before calling the worker, just in case
180
    // If the job is periodic, re-schedule it before calling the worker, just in
181
    // case.
166 182
    if ($job['periodic']) {
167 183
      $job['last'] = REQUEST_TIME;
168 184
      $this->reschedule($job);
169 185
    }
186
    if (!empty($info['file']) && file_exists($info['file'])) {
187
      include_once $info['file'];
188
    }
170 189
    if (function_exists($info['worker callback'])) {
171 190
      call_user_func($info['worker callback'], $job);
172 191
    }
......
178 197
  }
179 198

  
180 199
  /**
181
   * Re-schedule a job if intended to run again
200
   * Re-schedule a job if intended to run again.
182 201
   *
183 202
   * (If cannot determine the next time, drop the job)
184 203
   */
......
196 215
      drupal_write_record('job_schedule', $job, array('item_id'));
197 216
    }
198 217
    else {
199
      // If no next time, it may mean it wont run again the next year (crontab)
218
      // If no next time, it may mean it won't run again the next year (crontab)
200 219
      $this->remove($job);
201 220
    }
202 221
  }
203 222

  
204 223
  /**
205
   * Check whether a job exists in the queue and update its parameters if so
224
   * Check whether a job exists in the queue and update its parameters if so.
206 225
   */
207 226
  public function check($job) {
208 227
    $job += array('id' => 0, 'period' => 0, 'crontab' => '');
......
213 232
      ->condition('id', $job['id'])
214 233
      ->execute()
215 234
      ->fetchAssoc();
216
    // If existing, and changed period or crontab, we need to reschedule the job
235
    // If existing, and changed period or crontab, we need to reschedule the
236
    // job.
217 237
    if ($existing) {
218 238
      if ($job['period'] != $existing['period'] || $job['crontab'] != $existing['crontab']) {
219 239
        $existing['period'] = $job['period'];
......
223 243
      return $existing;
224 244
    }
225 245
  }
246

  
226 247
}
drupal7/sites/all/modules/job_scheduler/JobSchedulerCronTab.inc
17 17
 * I hate Sundays.
18 18
 */
19 19
class JobSchedulerCronTab {
20
  // Original crontab elements
20

  
21
  /**
22
   * Original crontab elements.
23
   *
24
   * @var string
25
   */
21 26
  public $crontab;
22
  // Parsed numeric values indexed by type
27

  
28
  /**
29
   * Parsed numeric values indexed by type.
30
   *
31
   * @var string
32
   */
23 33
  public $cron;
24 34

  
25 35
  /**
26
   * Constructor
36
   * Constructor.
27 37
   *
28 38
   * About crontab strings, see all about possible formats
29
   * http://linux.die.net/man/5/crontab
39
   * http://linux.die.net/man/5/crontab.
30 40
   *
31
   * @param $crontab string
32
   *   Crontab text line: minute hour day-of-month month day-of-week
41
   * @param string $crontab
42
   *   Crontab text line: minute hour day-of-month month day-of-week.
33 43
   */
34 44
  public function __construct($crontab) {
35 45
    $this->crontab = $crontab;
......
37 47
  }
38 48

  
39 49
  /**
40
   * Parse full crontab string into an array of type => values
50
   * Parse full crontab string into an array of type => values.
41 51
   *
42
   * Note this one is static and can be used to validate values
52
   * Note this one is static and can be used to validate values.
43 53
   */
44 54
  public static function parse($crontab) {
45 55
    // Crontab elements, names match PHP date indexes (getdate)
46
    $keys = array('minutes', 'hours', 'mday', 'mon', 'wday');
47
    // Replace multiple spaces by single space
56
    // Example:
57
    // $keys = array('minutes', 'hours', 'mday', 'mon', 'wday');
58
    // Replace multiple spaces by single space.
48 59
    $crontab = preg_replace('/(\s+)/', ' ', $crontab);
49
    // Expand into elements and parse all
60
    // Expand into elements and parse all.
50 61
    $values = explode(' ', trim($crontab));
51 62
    return self::values($values);
52 63
  }
53 64

  
54 65
  /**
55
   * Parse array of values, check whether this is valid
66
   * Parse array of values, check whether this is valid.
56 67
   */
57 68
  public static function values($array) {
58 69
    if (count($array) == 5) {
......
71 82
  }
72 83

  
73 84
  /**
74
   * Find the next occurrence within the next year as unix timestamp
85
   * Find the next occurrence within the next year as unix timestamp.
86
   *
87
   * @param timestamp $start_time
88
   *   Starting time.
89
   * @param int $limit
90
   *   Default is 366.
75 91
   *
76
   * @param $start_time timestamp
77
   *   Starting time
92
   * @codingStandardsIgnoreStart
78 93
   */
79 94
  public function nextTime($start_time = NULL, $limit = 366) {
95
    // @codingStandardsIgnoreEnd
80 96
    $start_time = isset($start_time) ? $start_time : time();
81
    $start_date = getdate($start_time); // Get minutes, hours, mday, wday, mon, year
97
    // Get minutes, hours, mday, wday, mon, year.
98
    $start_date = getdate($start_time);
82 99
    if ($date = $this->nextDate($start_date, $limit)) {
83 100
      return mktime($date['hours'], $date['minutes'], 0, $date['mon'], $date['mday'], $date['year']);
84 101
    }
......
88 105
  }
89 106

  
90 107
  /**
91
   * Find the next occurrence within the next year as a date array,
108
   * Find the next occurrence within the next year as a date array,.
109
   *
110
   * @param array $date
111
   *   Date array with: 'mday', 'mon', 'year', 'hours', 'minutes'.
112
   * @param int $limit
113
   *   Default is 366.
92 114
   *
93 115
   * @see getdate()
94 116
   *
95
   * @param $date
96
   *   Date array with: 'mday', 'mon', 'year', 'hours', 'minutes'
117
   * @codingStandardsIgnoreStart
97 118
   */
98 119
  public function nextDate($date, $limit = 366) {
120
    // @codingStandardsIgnoreEnd
99 121
    $date['seconds'] = 0;
100
    // It is possible that the current date doesn't match
122
    // It is possible that the current date doesn't match.
101 123
    if ($this->checkDay($date) && ($nextdate = $this->nextHour($date))) {
102 124
      return $nextdate;
103 125
    }
......
110 132
  }
111 133

  
112 134
  /**
113
   * Check whether date's day is a valid one
135
   * Check whether date's day is a valid one.
114 136
   */
115 137
  protected function checkDay($date) {
116 138
    foreach (array('wday', 'mday', 'mon') as $key) {
......
122 144
  }
123 145

  
124 146
  /**
125
   * Find the next day from date that matches with cron parameters
147
   * Find the next day from date that matches with cron parameters.
126 148
   *
127
   * Maybe it's possible that it's within the next years, maybe no day of a year matches all conditions.
149
   * Maybe it's possible that it's within the next years, maybe no day of a year
150
   * matches all conditions.
128 151
   * However, to prevent infinite loops we restrict it to the next year.
129 152
   */
130 153
  protected function nextDay($date, $limit = 366) {
131
    $i = 0; // Safety check, we love infinite loops...
154
    // Safety check, we love infinite loops...
155
    $i = 0;
132 156
    while ($i++ <= $limit) {
133 157
      // This should fix values out of range, like month > 12, day > 31....
134 158
      // So we can trust we get the next valid day, can't we?
......
141 165
      }
142 166
    }
143 167
  }
168

  
144 169
  /**
145
   * Find the next available hour within the same day
170
   * Find the next available hour within the same day.
146 171
   */
147 172
  protected function nextHour($date) {
148 173
    $cron = $this->cron;
......
177 202
      $string = self::translateNames($type, $string);
178 203
    }
179 204
    if ($string === '*') {
180
      // This means all possible values, return right away, no need to double check
205
      // This means all possible values, return right away, no need to double
206
      // check.
181 207
      return self::possibleValues($type);
182 208
    }
183 209
    elseif (strpos($string, '/')) {
184
      // Multiple. Example */2, for weekday will expand into 2, 4, 6
210
      // Multiple. Example */2, for weekday will expand into 2, 4, 6.
185 211
      list($values, $multiple) = explode('/', $string);
186 212
      $values = self::parseElement($type, $values);
187 213
      foreach ($values as $value) {
......
191 217
      }
192 218
    }
193 219
    elseif (strpos($string, ',')) {
194
      // Now process list parts, expand into items, process each and merge back
220
      // Now process list parts, expand into items, process each and merge back.
195 221
      $list = explode(',', $string);
196 222
      $range = array();
197 223
      foreach ($list as $item) {
......
201 227
      }
202 228
    }
203 229
    elseif (strpos($string, '-')) {
204
      // This defines a range. Example 1-3, will expand into 1,2,3
230
      // This defines a range. Example 1-3, will expand into 1,2,3.
205 231
      list($start, $end) = explode('-', $string);
206
      // Double check the range is within possible values
232
      // Double check the range is within possible values.
207 233
      $range = range($start, $end);
208 234
    }
209 235
    elseif (is_numeric($string)) {
210
      // This looks like a single number, double check it's int
211
      $range = array((int)$string);
236
      // This looks like a single number, double check it's int.
237
      $range = array((int) $string);
212 238
    }
213 239

  
214
    // Return unique sorted values and double check they're within possible values
240
    // Return unique sorted values and double check they're within possible
241
    // values.
215 242
    if (!empty($range)) {
216 243
      $range = array_intersect(array_unique($range), self::possibleValues($type));
217 244
      sort($range);
218
      // Sunday validation. We need cron values to match PHP values, thus week day 7 is not allowed, must be 0
245
      // Sunday validation. We need cron values to match PHP values, thus week
246
      // day 7 is not allowed, must be 0.
219 247
      if ($type == 'wday' && in_array(7, $range)) {
220 248
        array_pop($range);
221 249
        array_unshift($range, 0);
......
223 251
      return $range;
224 252
    }
225 253
    else {
226
      // No match found for this one, will produce an error with validation
254
      // No match found for this one, will produce an error with validation.
227 255
      return array();
228 256
    }
229 257
  }
230 258

  
231 259
  /**
232
   * Get values for each type
260
   * Get values for each type.
233 261
   */
234 262
  public static function possibleValues($type) {
235 263
    switch ($type) {
236 264
      case 'minutes':
237 265
        return range(0, 59);
266

  
238 267
      case 'hours':
239 268
        return range(0, 23);
269

  
240 270
      case 'mday':
241 271
        return range(1, 31);
272

  
242 273
      case 'mon':
243 274
        return range(1, 12);
275

  
244 276
      case 'wday':
245
        // These are PHP values, not *nix ones
277
        // These are PHP values, not *nix ones.
246 278
        return range(0, 6);
247 279

  
248 280
    }
249 281
  }
250 282

  
251 283
  /**
252
   * Replace element names by values
284
   * Replace element names by values.
253 285
   */
254 286
  public static function translateNames($type, $string) {
255 287
    switch ($type) {
256 288
      case 'wday':
257 289
        $replace = array_merge(
258
          // Tricky, tricky, we need sunday to be zero at the beginning of a range, but 7 at the end
259
          array('-sunday' => '-7', '-sun' => '-7', 'sunday-' => '0-', 'sun-' => '0-'),
260
          array_flip(array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday')),
290
          // Tricky, tricky, we need sunday to be zero at the beginning of a
291
          // range, but 7 at the end.
292
          array(
293
            '-sunday' => '-7',
294
            '-sun' => '-7',
295
            'sunday-' => '0-',
296
            'sun-' => '0-',
297
          ),
298
          array_flip(array(
299
            'sunday',
300
            'monday',
301
            'tuesday',
302
            'wednesday',
303
            'thursday',
304
            'friday',
305
            'saturday',
306
          )),
261 307
          array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'))
262 308
        );
263 309
        break;
310

  
264 311
      case 'mon':
265 312
        $replace = array_merge(
266
          array_flip(array('nomonth1', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december')),
267
          array_flip(array('nomonth2', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec')),
313
          array_flip(array(
314
            'nomonth1',
315
            'january',
316
            'february',
317
            'march',
318
            'april',
319
            'may',
320
            'june',
321
            'july',
322
            'august',
323
            'september',
324
            'october',
325
            'november',
326
            'december',
327
          )),
328
          array_flip(array(
329
            'nomonth2',
330
            'jan',
331
            'feb',
332
            'mar',
333
            'apr',
334
            'may',
335
            'jun',
336
            'jul',
337
            'aug',
338
            'sep',
339
            'oct',
340
            'nov',
341
            'dec',
342
          )),
268 343
          array('sept' => 9)
269 344
        );
270 345
        break;
......
276 351
      return strtr($string, $replace);
277 352
    }
278 353
  }
354

  
279 355
}
drupal7/sites/all/modules/job_scheduler/README.txt
1

  
2
Job Scheduler
3
=============
1
CONTENTS OF THIS FILE
2
---------------------
3
   
4
 * Introduction
5
 * Requirements
6
 * Installation
7
 * Configuration
8
 * Usage
9
  * Drupal Queue integration
10
  * Example
11
  * Hidden settings
12
 * Maintainers
13

  
14

  
15
INTRODUCTION
16
------------
4 17

  
5 18
Simple API for scheduling tasks once at a predetermined time or periodically at
6 19
a fixed interval.
7 20

  
8 21

  
9
Usage
10
=====
22
REQUIREMENTS
23
------------
24

  
25
No special requirements
26

  
27

  
28
INSTALLATION
29
------------
30

  
31
Install as you would normally install a contributed Drupal module. See:
32
https://drupal.org/documentation/install/modules-themes/modules-7 for further
33
information.
34

  
35

  
36
CONFIGURATION
37
-------------
38

  
39
No menu or modifiable settings.
40

  
11 41

  
12
Declare scheduler.
42
USAGE
43
-----
44

  
45
 * Declare scheduler.
13 46

  
14 47
  function example_cron_job_scheduler_info() {
15
    $schedulers = array();
16
    $schedulers['example_unpublish'] = array(
17
      'worker callback' => 'example_unpublish_nodes',
48
    $schedulers - array();
49
    $schedulers['example_unpublish'] - array(
50
      'worker callback' -> 'example_unpublish_nodes',
18 51
    );
19 52
    return $schedulers;
20 53
  }
21 54

  
22
Add a job.
55
 * Add a job.
23 56

  
24
  $job = array(
25
    'type' => 'story',
26
    'id' => 12,
27
    'period' => 3600,
28
    'periodic' => TRUE,
57
  $job - array(
58
    'type' -> 'story',
59
    'id' -> 12,
60
    'period' -> 3600,
61
    'periodic' -> TRUE,
29 62
  );
30 63
  JobScheduler::get('example_unpublish')->set($job);
31 64

  
32
Work off a job.
65
 * Work off a job.
33 66

  
34 67
  function example_unpublish_nodes($job) {
35 68
    // Do stuff.
36 69
  }
37 70

  
38
Remove a job.
71
 * Remove a job.
39 72

  
40
  $job = array(
41
    'type' => 'story',
42
    'id' => 12,
73
  $job - array(
74
    'type' -> 'story',
75
    'id' -> 12,
43 76
  );
44 77
  JobScheduler::get('example_unpublish')->remove($job);
45 78

  
46
Optionally jobs can declared together with a schedule in a hook_cron_job_scheduler_info().
79
Optionally jobs can declared together with a schedule in a:
80
hook_cron_job_scheduler_info().
47 81

  
48 82
  function example_cron_job_scheduler_info() {
49
    $schedulers = array();
50
    $schedulers['example_unpublish'] = array(
51
      'worker callback' => 'example_unpublish_nodes',
52
      'jobs' => array(
53
         array('type' => 'story', 'id' => 12, 'period' => 3600, 'periodic' => TRUE),
83
    $schedulers - array();
84
    $schedulers['example_unpublish'] - array(
85
      'worker callback' -> 'example_unpublish_nodes',
86
      'jobs' -> array(
87
          array(
88
            'type' -> 'story',
89
            'id' -> 12,
90
            'period' -> 3600,
91
            'periodic' -> TRUE,
92
          ),
54 93
      )
55 94
    );
56 95
    return $schedulers;
57 96
  }
58 97

  
59
Jobs can have a 'crontab' instead of a period. Crontab syntax are Unix-like formatted crontab lines.
98
Jobs can have a 'crontab' instead of a period. Crontab syntax are Unix-like
99
formatted crontab lines.
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff