? role_expire_coder.patch
Index: role_expire.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/role_expire/role_expire.install,v
retrieving revision 1.5
diff -u -p -r1.5 role_expire.install
--- role_expire.install	17 Aug 2009 15:13:26 -0000	1.5
+++ role_expire.install	22 Sep 2009 18:10:55 -0000
@@ -8,7 +8,7 @@
 
 
 /**
- * Implementation of hook_schema.
+ * Implementation of hook_schema().
  */
 function role_expire_schema() {
   $schema['role_expire'] = array(
@@ -19,19 +19,19 @@ function role_expire_schema() {
         'unsigned' => TRUE,
         'not null' => TRUE,
         'description' => t('User ID connected with expiration time.')
-      ),  
+      ),
       'rid' => array(
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
         'default' => 0,
         'description' => 'The role ID assigned to the user.',
-      ),  
+      ),
       'expiry_timestamp' => array(
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
-        'default' => 0,      
+        'default' => 0,
         'description' => t('Role expiration timestamp.'),
       )
     ),
@@ -47,17 +47,17 @@ function role_expire_schema() {
         'unsigned' => TRUE,
         'not null' => TRUE,
         'description' => t('The role_id.')
-       ),
+      ),
       'duration' => array(
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
         'description' => t('The default duration for the role.')
-       ),
-    ), 
+      ),
+    ),
     'indexes' => array(
     'rid' => array('rid'),
-    ),       
+    ),
   );
   return $schema;
 }
@@ -79,7 +79,7 @@ function role_expire_uninstall() {
 function role_expire_update_6100() {
   $roles = user_roles(true);
   unset($roles[DRUPAL_AUTHENTICATED_RID]);
-      
+
   $schema = array();
   $ret = array();
   foreach ($roles as $rid => $role) {
@@ -103,34 +103,35 @@ function role_expire_update_6100() {
         'uid' => array('uid'),
         )
       );
-      
+
     if (db_table_exists("role_expire_". $role)) {
       db_rename_table($ret, "role_expire_". $role, "role_expire_". $rid);
-    } else {
-      db_create_table($ret, "role_expire_". $rid, $schema["role_expire_". $rid]); 
     }
-  } 
-  
+    else {
+      db_create_table($ret, "role_expire_". $rid, $schema["role_expire_". $rid]);
+    }
+  }
+
   return $ret;
 }
 
 function role_expire_update_6120() {
   // Install new schema
   drupal_install_schema('role_expire');
-  
+
   // Get all data from old databases and input insert new table
   $ret = array();
   $roles = user_roles(true);
   unset($roles[DRUPAL_AUTHENTICATED_RID]);
 
   foreach ($roles as $rid => $role) {
-    $result = db_query("SELECT * FROM {role_expire_".$rid."}");
+    $result = db_query("SELECT * FROM {role_expire_" . $rid . "}");
     while ($row = db_fetch_object($result)) {
         $ret[] = update_sql("INSERT INTO {role_expire} VALUES ({$row->uid}, {$rid}, {$row->expiry_timestamp})");
     }
-    db_drop_table($ret, "role_expire_".$rid);
+    db_drop_table($ret, "role_expire_" . $rid);
   }
-  
+
   return $ret;
 }
 
@@ -144,20 +145,20 @@ function role_expire_update_6121() {
         'unsigned' => TRUE,
         'not null' => TRUE,
         'description' => t('The role_id.')
-       ),
+      ),
       'duration' => array(
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
         'description' => t('The default duration for the role.')
-       ),
-    ), 
+      ),
+    ),
     'indexes' => array(
     'rid' => array('rid'),
-    ),       
+    ),
   );
-  
+
   db_create_table($ret, 'role_expire_length', $role_expire_length_schema);
-  
+
   return $ret;
-}
\ No newline at end of file
+}
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	22 Sep 2009 18:10:55 -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,33 +175,33 @@ 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", array('%role' => drupal_ucfirst($role))),
     '#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) {
   if (isset($form_state['values']['role_expire']) && strlen($form_state['values']['role_expire']) && !is_numeric($form_state['values']['role_expire'])) {
-     form_set_error('role_expire', 'Role expiry defaults needs to be numeric');
+    form_set_error('role_expire', 'Role expiry defaults needs to be numeric');
   }
 }
 
@@ -219,12 +219,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 +241,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) {
@@ -250,15 +250,15 @@ function role_expire_user($op, &$edit, &
           $edit["role_expire"][$rid] = $edit['role_expire_' . $rid];
         }
         // Role exists but the expiry date is explicitly set to blank.
-        else if (isset($edit['role_expire_' . $rid]) && empty($edit['role_expire_' . $rid])) {
+        elseif (isset($edit['role_expire_' . $rid]) && empty($edit['role_expire_' . $rid])) {
           $edit["role_expire"][$rid] = '';
         }
       unset($edit['role_expire_'. $rid]);
     }
     break;
-  
+
   case 'after_update':
-    $new_roles = array_diff($account->roles,_role_static_user_roles($account->uid));
+    $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.
     foreach ($new_roles as $role_id => $role) {
       // Does a default expiry exist?.
@@ -268,18 +268,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 +292,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 
-   // 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;
-    
+    // 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') {
@@ -319,7 +319,7 @@ function role_expire_user($op, &$edit, &
         $expiry_roles = role_expire_get_all_user_records($account->uid);
         foreach ($account->roles as $key => $val) {
           if ($expiry_roles[$key]) {
-            $roles[$key] =  t("%role role - expires on %timedate", array('%role' => ucfirst($val), '%timedate' => format_date($expiry_roles[$key])));
+            $roles[$key] =  t("%role role - expires on %timedate", array('%role' => drupal_ucfirst($val), '%timedate' => format_date($expiry_roles[$key])));
           }
         }
         if ($roles) {
@@ -330,7 +330,7 @@ function role_expire_user($op, &$edit, &
             '#attributes' => array('class' => 'role-expiry-roles'),
           );
         }
-      }      
+      }
     }
     break;
   }
@@ -340,7 +340,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 +349,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 +360,7 @@ function role_expire_cron() { 
 
 /**
  * Add form element that accepts the role expiration time.
- * 
+ *
  * @param $account
  *   The user object.
  * @return
@@ -370,7 +370,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 +383,7 @@ function role_expire_add_expiration_inpu
       );
     }
   }
-  return $form;  
+  return $form;
 }
 
 /*******************************************************************************
@@ -395,18 +395,18 @@ function role_expire_add_expiration_inpu
  * @return
  *   array of roles
  */
-function _role_static_user_roles($id,$roles = '') {
+function _role_static_user_roles($id, $roles = '') {
   static $user_roles = array();
-  if(!isset($user_roles[$id]) && is_array($roles)) {
+  if (!isset($user_roles[$id]) && is_array($roles)) {
     $user_roles[$id] = $roles;
   }
-  if(!isset($user_roles[$id])) {
+  if (!isset($user_roles[$id])) {
     return FALSE;
   }
   else {
     return $user_roles[$id];
   }
-  
+
 }
 
 /**
Index: role_expire.rules.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/role_expire/role_expire.rules.inc,v
retrieving revision 1.1
diff -u -p -r1.1 role_expire.rules.inc
--- role_expire.rules.inc	3 Jun 2009 19:42:37 -0000	1.1
+++ role_expire.rules.inc	22 Sep 2009 18:10:56 -0000
@@ -17,12 +17,12 @@ function role_expire_rules_action_info()
       'user' => array(
         'type' => 'user',
         'label' => t('The user which the expiration time will be added'),
-      ), 
+      ),
     ),
     'eval input' => array('timestamp'),
-    'module' => 'Role expire',    
+    'module' => 'Role expire',
   );
-  
+
   $items['role_expire_rules_action_remove_role_expire'] = array(
     'label' => t('Remove expire time from role'),
     'help' => t('Remove an expiration time to a role a user has. This action does not remove the role, only the expiration time.'),
@@ -30,11 +30,11 @@ function role_expire_rules_action_info()
       'user' => array(
         'type' => 'user',
         'label' => t('The user which the expiration time will be removed'),
-      ), 
+      ),
     ),
-    'module' => 'Role expire',    
+    'module' => 'Role expire',
   );
-    
+
   return $items;
 }
 
@@ -51,10 +51,10 @@ function role_expire_rules_action_set_ro
 function role_expire_rules_action_set_role_expire_form($settings = array(), &$form) {
   $settings += array('rid' => '', 'timestamp' => '');
 
-   
+
   // The role ID.
   $form['settings']['rid'] = _role_expire_get_rids($settings);
-  
+
   //The timestamp.
   $form['settings']['timestamp'] = array(
     '#type' => 'textfield',
@@ -72,7 +72,7 @@ function role_expire_rules_action_set_ro
   $timestamp = strtotime($form_state['values']['settings']['timestamp']);
   if (!$timestamp) {
     form_set_error('timestamp', t('Role expiration time is not in correct format.'));
-  }  
+  }
 }
 
 /**
@@ -87,7 +87,7 @@ function role_expire_rules_action_remove
  */
 function role_expire_rules_action_remove_role_expire_form($settings = array(), &$form) {
   $settings += array('rid' => '');
-   
+
   // The role ID.
   $form['settings']['rid'] = _role_expire_get_rids($settings);
 }
@@ -109,5 +109,5 @@ function _role_expire_get_rids($settings
     '#required' => TRUE,
     '#description' => t('Select a role.'),
     '#default_value' => $settings['rid'],
-  );    
-}
\ No newline at end of file
+  );
+}
Index: role_expire.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/role_expire/role_expire.views.inc,v
retrieving revision 1.3
diff -u -p -r1.3 role_expire.views.inc
--- role_expire.views.inc	3 Jun 2009 19:42:37 -0000	1.3
+++ role_expire.views.inc	22 Sep 2009 18:10:56 -0000
@@ -1,4 +1,4 @@
-<?php 
+<?php
 // $Id: role_expire.views.inc,v 1.3 2009/06/03 19:42:37 bdziewierz Exp $
 
 /**
@@ -12,27 +12,27 @@
  * Implementation of hook_views_data().
  */
 function role_expire_views_data() {
-	$data['role_expire']['table']['group']  = t('User');
-	  
-	$data['role_expire']['table']['join'] = array(
-	  'users' => array(
-	    'left_field' => 'uid',
-	    'field' => 'uid',
-	  ),
-	);	  
-	$data['role_expire']['expiry_timestamp'] = array(
-	  'title' => t('Role expiration time'), 
-	  'help' => t('Time and date the role will expire.'), 
-	  'field' => array(
-	    'handler' => 'views_handler_field_date',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort_date',
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_date',
-	  ),
-  );  
+  $data['role_expire']['table']['group']  = t('User');
+
+  $data['role_expire']['table']['join'] = array(
+    'users' => array(
+      'left_field' => 'uid',
+      'field' => 'uid',
+    ),
+  );
+  $data['role_expire']['expiry_timestamp'] = array(
+    'title' => t('Role expiration time'),
+    'help' => t('Time and date the role will expire.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
   return $data;
-}
\ No newline at end of file
+}
