/[drupal]/contributions/modules/regcode/regcode_roles/regcode_roles.module
ViewVC logotype

Diff of /contributions/modules/regcode/regcode_roles/regcode_roles.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.5, Wed Oct 14 14:48:11 2009 UTC revision 1.1.2.6, Wed Oct 14 23:44:02 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: regcode_roles.module,v 1.1.2.4 2009/10/08 20:26:45 aidan Exp $  // $Id: regcode_roles.module,v 1.1.2.5 2009/10/14 14:48:11 aidan Exp $
3    
4    
5  /**  /**
# Line 168  function regcode_roles_create_rule($cate Line 168  function regcode_roles_create_rule($cate
168   *   *
169   * Add the new role to the user   * Add the new role to the user
170   */   */
171  function regcode_roles_regcode_used($account, $regcode) {  function regcode_roles_regcode_used(&$edit, &$account, $regcode) {
172    
173    // We only want to do this if the regcode is valid    // Do nothing if the regcode is not valid
174    if (is_array($regcode)) {    if (!is_array($regcode)) {
175        return $edit;
176      }
177    
178      // Get applicable rules    // Grab applicable roles for category used
179      $rules = regcode_roles_get_rules($regcode['category']);    $rules = regcode_roles_get_rules($regcode['category']);
180    
181      // Build list of roles    // Apply the rules
182      if (count($rules)) {
183        if (!is_array($edit['roles'])) {
184          $edit['roles'] = array();
185        }
186      foreach ($rules as $rule) {      foreach ($rules as $rule) {
187        $account->roles[$rule['rid']] = $rule['role'];        $edit['roles'][$rule['rid']] = $rule['role'];
188      }      }
   
     // Save  
     user_save($account, array('roles' => $account->roles));  
189    }    }
190    
191      return $edit;
192  }  }

Legend:
Removed from v.1.1.2.5  
changed lines
  Added in v.1.1.2.6

  ViewVC Help
Powered by ViewVC 1.1.2