Log::debug('Opensim creating new account.'); } else { Log::error('Opensim event: create account for ' . $account->firstname . ' ' . $account->lastname . ' . Account already exists.'); } }); Event::listen('users.updated', function ($user) { $account = \Opensim\Model\Os\UserAccount::where_PrincipalID($user->uuid)->first(); if (!is_null($account)) { $account = new \Opensim\Model\Os\UserAccount(); $opensim_account = $account->update_account($user); } else { Log::error('Opensim event: update account for [' . $user->uuid . '] does not exist.'); } }); Event::listen('users.updated_many', function ($user_list) { $users = Users\Model\User::where_in('id', $user_list)->get(); $users_uuids = array(); foreach ($users as $user) { $users_uuids[$user->uuid] = $user; } $user_accounts = Opensim\Model\Os\UserAccount::where_in('PrincipalID', array_keys($users_uuids))->get(); foreach ($user_accounts as $user_account) { if (isset($users_uuids[$user_account->principalid])) { $user_account->update_account($users_uuids[$user_account->principalid]); } } }); Event::listen('users.deleted', function ($user) { $account = new \Opensim\Model\Os\UserAccount(); $account = $account->destroy_account($user); });
public function post_action() { // Used by javascript // on users table to // enable or delete bulk users $action_to = Input::get('action_to'); $action = Input::get('btnAction'); if ($action == 'delete') { if (is_array($action_to) and !empty($action_to)) { $users = Users\Model\User::where_in('id', $action_to)->get(); $event_uuids = array(); $users_to_delete = array(); foreach ($users as $user) { if (!$user->is_core and $user->id != Auth::user()->id) { $event_uuids[$user->uuid] = $user; $users_to_delete[] = $user->id; } } if (!empty($users_to_delete)) { $users = Users\Model\User::where_in('id', $users_to_delete)->delete(); Event::fire('users.deleted_many', array($action_to, $event_uuids)); } $this->data['message'] = __('users::lang.User(s) were successfully destroyed')->get(ADM_LANG); $this->data['message_type'] = 'success'; } } if ($action == 'activate') { if (is_array($action_to) and !empty($action_to)) { Users\Model\User::where_in('id', $action_to)->update(array('status' => 'active')); $this->data['message'] = __('users::lang.User(s) were successfully activated')->get(ADM_LANG); $this->data['message_type'] = 'success'; Event::fire('users.updated_many', array($action_to)); } } return Redirect::back()->with($this->data); }