? role_expire.migrate.inc
? role_expire_name.patch
Index: role_expire.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/role_expire/role_expire.module,v
retrieving revision 1.6
diff -u -p -r1.6 role_expire.module
--- role_expire.module	21 Sep 2009 10:16:09 -0000	1.6
+++ role_expire.module	21 Sep 2009 23:20:09 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: role_expire.module,v 1.6 2009/09/21 10:16:09 stewsnooze Exp $ 
+// $Id: role_expire.module,v 1.6 2009/09/21 10:16:09 stewsnooze Exp $
 
 /**
  * @file
@@ -47,7 +47,7 @@ function role_expire_get_all_user_record
 
 /**
  * API function; Delete a record from the database.
- * 
+ *
  * @param $rid
  *   Role ID.
  * @param $uid
@@ -59,7 +59,7 @@ function role_expire_delete_record($uid,
 }
 /**
  * API function; Delete all user expirations.
- * 
+ *
  * @param $rid
  *   Role ID.
  * @param $uid
@@ -69,11 +69,11 @@ function role_expire_delete_record($uid,
 function role_expire_delete_user_records($uid) {
   db_query("DELETE FROM {role_expire} WHERE uid = %d", $uid);
 }
-    
+
 
 /**
  * API function; Insert or update a record in the database.
- * 
+ *
  * @param $rid
  *   Role ID.
  * @param $uid
@@ -104,7 +104,7 @@ function role_expire_get_default_duratio
 
 /**
  * API function; Set the default expiry duration for a role.
- * 
+ *
  * @param $rid
  *   Role ID.
  * @param $duration
@@ -128,7 +128,7 @@ function role_expire_delete_default_dura
 
 /**
  * API function; Get all records that should be expired.
- * 
+ *
  * @param $time
  *   Optional. The time to check, if not set it will check current time.
  */
@@ -175,28 +175,29 @@ function role_expire_form_user_register_
  */
 function role_expire_form_user_profile_form_alter(&$form, $form_state) {
   $form['account']['roles']['#attributes'] = array('class' => 'role-expire-roles');
-} 
+}
 
 /**
  * Implementation of hook_form_FORM-ID_alter().
  */
 function role_expire_form_user_admin_role_alter(&$form, $form_state) {
   $form['role_expire'] = array(
-    '#title' => t("Default day length for the role", array('%role' => ucfirst($role))),
+    '#title' => t("Default day length for the role %role",
+      array('%role' => ucfirst($form['name']['#default_value']))),
     '#type' => 'textfield',
     '#size' => 8,
     '#default_value' => role_expire_get_default_duration($form['rid']['#value']),
-    '#maxlength' => 5,    
+    '#maxlength' => 5,
     '#attributes' => array('class' => 'role-expire-role-expiry'),
     '#description' => t("Leave blank for no default length. Values should indicate the number of days the role should be active for.")
-  ); 
+  );
   // Reposition the submit button and delete.
   $form['submit']['#weight'] = 2;
   if (arg(4)) {
     $form['delete']['#weight'] = 3;
   }
-  $form['#validate'][] = 'role_expire_user_admin_role_validate';  
-  $form['#submit'][] = 'role_expire_user_admin_role_submit';  
+  $form['#validate'][] = 'role_expire_user_admin_role_validate';
+  $form['#submit'][] = 'role_expire_user_admin_role_submit';
 }
 
 function role_expire_user_admin_role_validate($form, &$form_state) {
@@ -219,12 +220,12 @@ function role_expire_user_admin_role_sub
  * Implementation of hook_user().
  */
 function role_expire_user($op, &$edit, &$account, $category = NULL) {
-  switch ($op) {    
+  switch ($op) {
   case 'form':
     if ($category == 'account') {
       return role_expire_add_expiration_input($account);
     }
-  break;  
+  break;
   case 'validate':
     if (isset($edit['roles'])) {
       $time = time();
@@ -241,7 +242,7 @@ function role_expire_user($op, &$edit, &
       }
     }
     break;
-        
+
   case 'submit':
     // We go over all existing roles, because use might have disabled a role.
     foreach (_role_expire_get_role() as $rid => $role) {
@@ -256,7 +257,7 @@ function role_expire_user($op, &$edit, &
       unset($edit['role_expire_'. $rid]);
     }
     break;
-  
+
   case 'after_update':
     $new_roles = array_diff($account->roles,_role_static_user_roles($account->uid));
     // We have the new roles, loop over them and see whether we need to assign expiry to them.
@@ -268,18 +269,18 @@ function role_expire_user($op, &$edit, &
         // If the expiry is empty then we act!.
         if (!$user_role_expiry) {
           // Add the current date to the role day period and save it back to the role_expire row.
-          role_expire_write_record($account->uid, $role_id, mktime(0, 0, 0, date("m"), date("d") + $role_day_period, date("Y")));          
+          role_expire_write_record($account->uid, $role_id, mktime(0, 0, 0, date("m"), date("d") + $role_day_period, date("Y")));
         }
       }
     }
   break;
 
   case 'update':
-  case 'insert':  
+  case 'insert':
 
     // Add roles expiry information for the user role.
     $edit += array('role_expire' => array());
-    foreach ($edit['role_expire'] as $rid => $role) {   
+    foreach ($edit['role_expire'] as $rid => $role) {
       if ($role) {
         $expiry_timestamp = strtotime($role);
         role_expire_write_record($account->uid, $rid, $expiry_timestamp);
@@ -292,25 +293,25 @@ function role_expire_user($op, &$edit, &
     // We can remove this now.
     unset($edit['role_expire']);
     break;
-     
 
-  case 'delete':    
+
+  case 'delete':
     // Delete user records.
     role_expire_delete_user_records($uid);
     break;
-    
+
   case 'load':
-   // We don't load the information to the user object. Other modules can use 
+   // We don't load the information to the user object. Other modules can use
    // our API to query the information.
-   
+
    /**
     * Load the starter roles into a static cache so it is easy to
     * see what has changed later on.
-    */ 
+    */
      _role_static_user_roles($account->uid,$account->roles);
-   
+
    break;
-    
+
   case 'view':
     global $user;
     if ($category == 'account') {
@@ -330,7 +331,7 @@ function role_expire_user($op, &$edit, &
             '#attributes' => array('class' => 'role-expiry-roles'),
           );
         }
-      }      
+      }
     }
     break;
   }
@@ -340,7 +341,7 @@ function role_expire_user($op, &$edit, &
 /**
  * Implementation of hook_cron().
  */
-function role_expire_cron() { 
+function role_expire_cron() {
   if ($expires = role_expire_get_expired()) {
     $roles = _role_expire_get_role();
     foreach ($expires as $expire) {
@@ -349,10 +350,10 @@ function role_expire_cron() { 
       $account = user_load($expire['uid']);
       unset($account->roles[$expire['rid']]);
       user_save($account, array('roles' => $account->roles), NULL);
-      
+
       // Remove the role expiration record.
       role_expire_delete_record($expire['uid'], $expire['rid']);
-      watchdog('role expire', 'Remove role @role from user @account.', array('@role' => $roles[$expire['rid']], '@account' => $account->name));    
+      watchdog('role expire', 'Remove role @role from user @account.', array('@role' => $roles[$expire['rid']], '@account' => $account->name));
     }
   }
 }
@@ -360,7 +361,7 @@ function role_expire_cron() { 
 
 /**
  * Add form element that accepts the role expiration time.
- * 
+ *
  * @param $account
  *   The user object.
  * @return
@@ -370,7 +371,7 @@ function role_expire_add_expiration_inpu
   $form = array();
   if (user_access('administer users') || user_access('administer role expire')) {
     drupal_add_js(drupal_get_path('module', 'role_expire') .'/role_expire.js', 'module');
-    $form['roles']['#attributes'] = array('class' => 'role-expire-roles');    
+    $form['roles']['#attributes'] = array('class' => 'role-expire-roles');
 
     foreach (_role_expire_get_role() as $rid => $role) {
       $expiry_timestamp = role_expire_get_user_role_expiry_time($account->uid, $rid);
@@ -383,7 +384,7 @@ function role_expire_add_expiration_inpu
       );
     }
   }
-  return $form;  
+  return $form;
 }
 
 /*******************************************************************************
@@ -406,7 +407,7 @@ function _role_static_user_roles($id,$ro
   else {
     return $user_roles[$id];
   }
-  
+
 }
 
 /**
