Esempio n. 1
0
// Check if opensim database is
// configured before enable listners
$db_is_ready = Config::get('settings::core.passes_db_settings');
if ((bool) $db_is_ready) {
    Event::listen('users.created', function ($user, $customAvatar = 'ruth') {
        $account = \Opensim\Model\Os\UserAccount::where_FirstName($user->avatar_first_name)->where_LastName($user->avatar_last_name)->where_PrincipalID($user->uuid)->first();
        if (is_null($account)) {
            $account = new \Opensim\Model\Os\UserAccount();
            $opensim_account = $account->create_account($user, $customAvatar);
            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) {
Esempio n. 2
0
 public function destroy_account($user)
 {
     // Authentication
     $account_auth = \Opensim\Model\Os\Auth::where_UUID($user->uuid);
     $account_auth->delete();
     // Avatars
     $account_avatar = \Opensim\Model\Os\Avatar::where_PrincipalID($user->uuid);
     $account_avatar->delete();
     // Friends
     $account_friend = \Opensim\Model\Os\Friend::where_PrincipalID($user->uuid);
     $account_friend->delete();
     // GridUser
     $account_griduser = \Opensim\Model\Os\Griduser::where_UserID($user->uuid);
     $account_griduser->delete();
     // InventoryFolders
     $account_inventoryfolder = \Opensim\Model\Os\InventoryFolder::where_agentID($user->uuid);
     $account_inventoryfolder->delete();
     // InventoryItems
     $account_inventoryitem = \Opensim\Model\Os\InventoryItem::where_avatarID($user->uuid);
     $account_inventoryitem->delete();
     // Presence
     $account_presence = \Opensim\Model\Os\Presence::where_UserID($user->uuid);
     $account_presence->delete();
     // Tokens
     $account_token = \Opensim\Model\Os\Token::where_UUID($user->uuid);
     $account_token->delete();
     // UserAccounts
     $account_useraccount = \Opensim\Model\Os\UserAccount::where_PrincipalID($user->uuid);
     $account_useraccount->delete();
 }