Changeset 262


Ignore:
Timestamp:
11/12/09 10:03:41 (11 years ago)
Author:
sander
Message:

Add afterSave trigger for default group membership

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/www/app/models/user.php

    r167 r262  
    9595                return false; 
    9696        } 
     97 
     98        /** 
     99         * After creating a new user, add them to all the default groups 
     100         * @param boolean $created Whether the saved user was newly created or not 
     101         */ 
     102        public function afterSave($created) 
     103        { 
     104                if (!$created) { 
     105                        return; 
     106                } 
     107 
     108                $groups = $this->Group->find('all', array( 
     109                        'conditions' => array('Group.default' => 1), 
     110                )); 
     111 
     112                foreach ($groups as $group) { 
     113                        $this->Group->add_member($this->id, $group['Group']['id']); 
     114                } 
     115        } 
    97116} 
    98117 
Note: See TracChangeset for help on using the changeset viewer.