[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/pathauto/ -> pathauto_user.inc (source)

   1  <?php
   2  
   3  /**
   4   * @file
   5   * Hook implementations for user module integration.
   6   *
   7   * @ingroup pathauto
   8   */
   9  
  10  /**
  11   * Implements hook_pathauto().
  12   */
  13  function user_pathauto($op) {
  14    switch ($op) {
  15      case 'settings':
  16        $settings = array();
  17        $settings['module'] = 'user';
  18        $settings['token_type'] = 'user';
  19        $settings['groupheader'] = t('User paths');
  20        $settings['patterndescr'] = t('Pattern for user account page paths');
  21        $settings['patterndefault'] = 'users/[user-raw]';
  22        $patterns = token_get_list('user');
  23        foreach ($patterns as $type => $pattern_set) {
  24          if ($type != 'global') {
  25            foreach ($pattern_set as $pattern => $description) {
  26              $settings['placeholders']['['. $pattern .']'] = $description;
  27            }
  28          }
  29        }
  30        $settings['bulkname'] = t('Bulk generate aliases for users that are not aliased');
  31        $settings['bulkdescr'] = t('Generate aliases for all existing user account pages which do not already have aliases.');
  32        return (object) $settings;
  33      default:
  34        break;
  35    }
  36  }
  37  
  38  /**
  39   * Implements hook_pathauto().
  40   */
  41  function blog_pathauto($op) {
  42    switch ($op) {
  43      case 'settings':
  44        $settings = array();
  45        $settings['module'] = 'blog';
  46        $settings['token_type'] = 'user';
  47        $settings['groupheader'] = t('Blog paths');
  48        $settings['patterndescr'] = t('Pattern for blog page paths');
  49        $settings['patterndefault'] = 'blogs/[user-raw]';
  50        $patterns = token_get_list('user');
  51        foreach ($patterns['user'] as $pattern => $description) {
  52          $settings['placeholders']['['. $pattern .']'] = $description;
  53        }
  54        $settings['supportsfeeds'] = 'feed';
  55        $settings['bulkname'] = t('Bulk generate aliases for blogs that are not aliased');
  56        $settings['bulkdescr'] = t('Generate aliases for all existing blog pages which do not already have aliases.');
  57        return (object) $settings;
  58      default:
  59        break;
  60    }
  61  }
  62  
  63  /**
  64   * Implementation of hook_pathauto() for user-tracker aliases.
  65   */
  66  function tracker_pathauto($op) {
  67    switch ($op) {
  68      case 'settings':
  69        $settings = array();
  70        $settings['module'] = 'tracker';
  71        $settings['token_type'] = 'user';
  72        $settings['groupheader'] = t('User tracker paths');
  73        $settings['patterndescr'] = t('Pattern for user-tracker page paths');
  74        $settings['patterndefault'] = 'users/[user-raw]/track';
  75        $patterns = token_get_list('user');
  76        foreach ($patterns['user'] as $pattern => $description) {
  77          $settings['placeholders']['['. $pattern .']'] = $description;
  78        }
  79        $settings['supportsfeeds'] = 'feed';
  80        $settings['bulkname'] = t('Bulk generate aliases for user-tracker paths that are not aliased');
  81        $settings['bulkdescr'] = t('Generate aliases for all existing user-tracker pages which do not already have aliases.');
  82        return (object) $settings;
  83      default:
  84        break;
  85    }
  86  }
  87  
  88  /**
  89   * Implements hook_pathauto().
  90   */
  91  function contact_pathauto($op) {
  92    switch ($op) {
  93      case 'settings':
  94        $settings = array();
  95        $settings['module'] = 'contact';
  96        $settings['token_type'] = 'user';
  97        $settings['groupheader'] = t('User contact forms paths');
  98        $settings['patterndescr'] = t('Pattern for the user contact form paths');
  99        $settings['patterndefault'] = 'users/[user-raw]/contact';
 100        $patterns = token_get_list('user');
 101        foreach ($patterns['user'] as $pattern => $description) {
 102          $settings['placeholders']['['. $pattern .']'] = $description;
 103        }
 104        $settings['bulkname'] = t('Bulk generate aliases for user contact form paths that are not aliased');
 105        $settings['bulkdescr'] = t('Generate aliases for all existing user contact form pages which do not already have aliases.');
 106        return (object) $settings;
 107      default:
 108        break;
 109    }
 110  }
 111  
 112  /**
 113   * Bulk generate aliases for all users without aliases.
 114   */
 115  function user_pathauto_bulkupdate() {
 116    $concat = _pathauto_sql_concat("'user/'", 'u.uid');
 117    $sql = "SELECT u.uid FROM {users} u LEFT JOIN {url_alias} ua ON $concat = ua.src WHERE u.uid > 0 AND ua.src IS NULL";
 118    $query = db_query_range($sql, 0, variable_get('pathauto_max_bulk_update', 50));
 119  
 120    $count = 0;
 121    $placeholders = array();
 122    while ($uid = db_result($query)) {
 123      $account = user_load($uid);
 124      $placeholders = pathauto_get_placeholders('user', $account);
 125      $source = 'user/'. $account->uid;
 126      if (pathauto_create_alias('user', 'bulkupdate', $placeholders, $source, $account->uid)) {
 127        $count++;
 128      }
 129    }
 130  
 131    drupal_set_message(format_plural($count,
 132      'Bulk generation of users completed, one alias generated.',
 133      'Bulk generation of users completed, @count aliases generated.'));
 134  }
 135  
 136  /**
 137   * Bulk generate aliases for all blogs without aliases.
 138   */
 139  function blog_pathauto_bulkupdate() {
 140    $concat = _pathauto_sql_concat("'blog/'", 'u.uid');
 141    $sql = "SELECT u.uid FROM {users} u LEFT JOIN {url_alias} ua ON $concat = ua.src WHERE u.uid > 0 AND ua.src IS NULL";
 142    $query = db_query_range($sql, 0, variable_get('pathauto_max_bulk_update', 50));
 143  
 144    $count = 0;
 145    $placeholders = array();
 146    while ($uid = db_result($query)) {
 147      $account = user_load($uid);
 148      $placeholders = pathauto_get_placeholders('user', $account);
 149      $source = 'blog/'. $account->uid;
 150      if (pathauto_create_alias('blog', 'bulkupdate', $placeholders, $source, $account->uid)) {
 151        $count++;
 152      }
 153    }
 154  
 155    drupal_set_message(format_plural($count,
 156      'Bulk generation of user blogs completed, one alias generated.',
 157      'Bulk generation of user blogs completed, @count aliases generated.'));
 158  }
 159  
 160  /**
 161   * Bulk generate aliases for user trackers without aliases.
 162   */
 163  function tracker_pathauto_bulkupdate() {
 164    $concat = _pathauto_sql_concat("'user/'", 'u.uid', "'/track'");
 165    $sql = "SELECT u.uid FROM {users} u LEFT JOIN {url_alias} ua ON $concat = ua.src WHERE u.uid > 0 AND ua.src IS NULL";
 166    $query = db_query_range($sql, 0, variable_get('pathauto_max_bulk_update', 50));
 167  
 168    $count = 0;
 169    $placeholders = array();
 170    while ($uid = db_result($query)) {
 171      $account = user_load($uid);
 172      $placeholders = pathauto_get_placeholders('user', $account);
 173      $src = 'user/'. $account->uid .'/track';
 174      if (pathauto_create_alias('tracker', 'bulkupdate', $placeholders, $src, $account->uid)) {
 175        $count++;
 176      }
 177    }
 178  
 179    drupal_set_message(format_plural($count,
 180      'Bulk generation of user tracker pages completed, one alias generated.',
 181      'Bulk generation of user tracker pages completed, @count aliases generated.'));
 182  }
 183  
 184  /**
 185   * Bulk generate aliases for all users without aliases
 186   */
 187  function contact_pathauto_bulkupdate() {
 188    $sql = "SELECT u.uid FROM {users} u LEFT JOIN {url_alias} ua ON CONCAT(CONCAT('user/', CAST(u.uid AS CHAR)), '/contact') = ua.src WHERE u.uid > 0 AND ua.src IS NULL";
 189    $query = db_query_range($sql, 0, variable_get('pathauto_max_bulk_update', 50));
 190  
 191    $count = 0;
 192    $placeholders = array();
 193    while ($uid = db_result($query)) {
 194      $account = user_load($uid);
 195      $placeholders = pathauto_get_placeholders('user', $account);
 196      $source = 'user/'. $account->uid .'/contact';
 197      if (pathauto_create_alias('contact', 'bulkupdate', $placeholders, $source, $account->uid)) {
 198        $count++;
 199      }
 200    }
 201  
 202    drupal_set_message(format_plural($count,
 203      'Bulk generation of contact pages completed, one alias generated.',
 204      'Bulk generation of contact pages completed, @count aliases generated.'));
 205  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7