Changeset 2481 in subversion


Ignore:
Timestamp:
May 14, 2009 3:26:34 PM (4 years ago)
Author:
thomasb
Message:

Trigger 'create_identity' when creating a new user; Allow 'create_user' hook to abort the operation

Location:
trunk/roundcubemail/program
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcmail.php

    r2472 r2481  
    492492        // $a_mailboxes = $this->imap->list_mailboxes(); 
    493493      } 
     494      else { 
     495        raise_error(array( 
     496          'code' => 600, 
     497          'type' => 'php', 
     498          'message' => "Failed to create a user record. Maybe aborted by a plugin?" 
     499          ), true, false);         
     500      } 
    494501    } 
    495502    else { 
  • trunk/roundcubemail/program/include/rcube_user.php

    r2453 r2481  
    354354    $user_name = $data['user_name']; 
    355355    $user_email = $data['user_email']; 
     356     
     357    // plugin aborted this operation 
     358    if ($data['abort']) 
     359      return false; 
    356360 
    357361    $dbh = $rcmail->get_dbh(); 
     
    393397      $standard = 1; 
    394398      foreach ($email_list as $email) { 
    395         $dbh->query( 
    396             "INSERT INTO ".get_table_name('identities')." 
    397               (user_id, del, standard, name, email) 
    398              VALUES (?, 0, ?, ?, ?)", 
    399             $user_id, 
    400             $standard, 
    401             strip_newlines($user_name), 
    402             preg_replace('/^@/', $user . '@', $email)); 
     399        $plugin = $RCMAIL->plugins->exec_hook('create_identity', array('record' => array( 
     400          'login' => true, 
     401          'user_id' => $user_id, 
     402          'name' => strip_newlines($user_name), 
     403          'email' => $email, 
     404          'standard' => $standard))); 
     405           
     406        if (!$plugin['abort'] && $plugin['record']['name'] && $plugin['record']['email']) { 
     407          $dbh->query( 
     408              "INSERT INTO ".get_table_name('identities')." 
     409                (user_id, del, standard, name, email) 
     410               VALUES (?, 0, ?, ?, ?)", 
     411              $user_id, 
     412              $plugin['record']['standard'], 
     413              $plugin['record']['name'], 
     414              $plugin['record']['email']); 
     415        } 
    403416        $standard = 0; 
    404417      } 
  • trunk/roundcubemail/program/steps/settings/save_identity.inc

    r2441 r2481  
    9393    $save_data['email'] = $RCMAIL->user->get_username(); 
    9494 
    95   $plugin = $RCMAIL->plugins->exec_hook('create_identity', array('id' => $iid, 'record' => $save_data)); 
     95  $plugin = $RCMAIL->plugins->exec_hook('create_identity', array('record' => $save_data)); 
    9696  $save_data = $plugin['record']; 
    9797 
Note: See TracChangeset for help on using the changeset viewer.