Ejemplo n.º 1
0
function load_ruth_appearance($user_uuid)
{
    $items_array = array('AvatarHeight' => array('PrincipalID' => $user_uuid, 'Name' => 'AvatarHeight', 'Value' => '1.690999'), 'AvatarType' => array('PrincipalID' => $user_uuid, 'Name' => 'AvatarType', 'Value' => '1'), 'Serial' => array('PrincipalID' => $user_uuid, 'Name' => 'Serial', 'Value' => '0'), 'VisualParams' => array('PrincipalID' => $user_uuid, 'Name' => 'VisualParams', 'Value' => '33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150'), 'Wearable 0:0' => array('PrincipalID' => $user_uuid, 'Name' => 'Wearable 0:0', 'Value' => '66c41e39-38f9-f75a-024e-585989bfab73'), 'Wearable 1:0' => array('PrincipalID' => $user_uuid, 'Name' => 'Wearable 1:0', 'Value' => '77c41e39-38f9-f75a-024e-585989bbabbb'), 'Wearable 2:0' => array('PrincipalID' => $user_uuid, 'Name' => 'Wearable 2:0', 'Value' => 'd342e6c0-b9d2-11dc-95ff-0800200c9a66'), 'Wearable 3:0' => array('PrincipalID' => $user_uuid, 'Name' => 'Wearable 3:0', 'Value' => '4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7'), 'Wearable 4:0' => array('PrincipalID' => $user_uuid, 'Name' => 'Wearable 4:0', 'Value' => '00000000-38f9-1111-024e-222222111110'), 'Wearable 5:0' => array('PrincipalID' => $user_uuid, 'Name' => 'Wearable 5:0', 'Value' => '00000000-38f9-1111-024e-222222111120'));
    // From the appearance,
    // get only items with uuid values
    // those must be wearable items
    $items_only_uuids = array();
    foreach ($items_array as $key => $value) {
        if (\Opensim\UUID::is_valid($value['Value'])) {
            $items_only_uuids[$value['Name']] = $value['Value'];
        }
    }
    // Get items inserted on the database
    $apearance_items = \Opensim\Model\Os\InventoryItem::where_in('assetID', array_values($items_only_uuids))->where('avatarID', '=', $user_uuid)->get();
    // Build appearance values with
    // received appareance items
    foreach ($apearance_items as $a_item) {
        $key = array_search($a_item->assetid, $items_only_uuids);
        if (isset($key) and !empty($key)) {
            // inventoryid:assetid
            $items_array[$key]['Value'] = $a_item->inventoryid . ':' . $items_only_uuids[$key];
        }
    }
    return $items_array;
}
Ejemplo n.º 2
0
 public function get_inventory()
 {
     $inventory = InventoryFolder::where_agentID($this->principalid)->get();
     $items = InventoryItem::where_avatarID($this->principalid)->get();
     $items_array = array();
     foreach ($items as $item) {
         $i = array('assetid' => $item->assetid, 'assettype' => $item->assettype, 'inventoryname' => $item->inventoryname, 'inventorydescription' => $item->inventorydescription, 'inventorynextpermissions' => $item->inventorynextpermissions, 'inventorycurrentpermissions' => $item->inventorycurrentpermissions, 'invtype' => $item->invtype, 'creatorid' => $item->creatorid, 'inventorybasepermissions' => $item->inventorybasepermissions, 'inventoryeveryonepermissions' => $item->inventoryeveryonepermissions, 'saleprice' => $item->saleprice, 'saletype' => $item->saletype, 'creationdate' => $item->creationdate, 'groupid' => $item->groupid, 'groupowned' => $item->groupowned, 'flags' => $item->flags, 'inventoryid' => $item->inventoryid, 'avatarid' => $item->avatarid, 'parentfolderid' => $item->parentfolderid, 'inventorygrouppermissions' => $item->inventorygrouppermissions);
         $items_array[$item->parentfolderid] = $i;
     }
     $new_array = array();
     foreach ($inventory as $inventory_folder) {
         $f = array('foldername' => $inventory_folder->foldername, 'type' => $inventory_folder->type, 'version' => $inventory_folder->version, 'folderid' => $inventory_folder->folderid, 'agentid' => $inventory_folder->agentid, 'parentfolderid' => $inventory_folder->parentfolderid, 'items' => array());
         $new_array[$inventory_folder->folderid] = $f;
     }
     //ff($this->buildTree($new_array, $items_array));
 }
Ejemplo n.º 3
0
 public function create_account($user, $default_avatar_name = 'ruth')
 {
     // Check if user already exists
     $user_account = self::where_PrincipalID($user->uuid)->first();
     if (!isset($user_account)) {
         $ServiceURLs = 'HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI=';
         $user_account = new self();
         $user_account->PrincipalID = $user->uuid;
         $user_account->ScopeID = UUID::ZERO;
         $user_account->FirstName = $user->avatar_first_name;
         $user_account->LastName = $user->avatar_last_name;
         $user_account->Email = $user->email;
         $user_account->ServiceURLs = $ServiceURLs;
         $user_account->Created = time();
         $user_account->UserLevel = 0;
         $user_account->UserFlags = 0;
         $user_account->UserTitle = '';
         $user_account->save();
     }
     // Set passwords
     $account_auth = Auth::where_UUID($user->uuid)->first();
     // Check if there is no
     // password already set for this account
     if (!isset($account_auth)) {
         $account_auth = new Auth();
         if ($user->status == 'active') {
             $account_auth->passwordHash = $user->hash;
             $account_auth->passwordSalt = $user->salt;
         } else {
             $account_auth->passwordHash = $user->status;
             $account_auth->passwordSalt = $user->status;
         }
         $account_auth->UUID = $user->uuid;
         $account_auth->webLoginKey = UUID::ZERO;
         $account_auth->accountType = 'UserAccount';
         $account_auth->save();
     }
     // Set home location
     $home_location = \Settings\Model\Setting::where_module_slug('opensim')->where_slug('opensim_home_location')->first();
     if (isset($home_location->value) and \Opensim\UUID::is_valid($home_location->value)) {
         $home_location_data = array('UserID' => $user->uuid, 'HomeRegionID' => $home_location->value, 'HomePosition' => '<0,0,0>', 'HomeLookAt' => '<0,0,0>', 'LastRegionID' => $home_location->value, 'LastPosition' => '<128,128,22>', 'LastLookAt' => '<0,1,0>', 'Online' => 'False', 'Login' => $user->created_at->getTimestamp(), 'Logout' => $user->created_at->getTimestamp());
         Griduser::insert($home_location_data);
     }
     // create inventory
     $account_inventory = InventoryFolder::where_agentID($user->uuid)->get();
     if (!isset($account_inventory) or empty($account_inventory)) {
         $account_inventory = new InventoryFolder();
         $account_inventory = $account_inventory->create_inventory($user->uuid);
     } else {
         $acc_inv = array();
         foreach ($account_inventory as $folder_name => $folder) {
             $acc_inv[$folder->foldername] = array('folderName' => $folder->foldername, 'type' => $folder->type, 'version' => $folder->version, 'folderID' => $folder->folderid, 'agentID' => $folder->agentid, 'parentFolderID' => $folder->parentfolderid);
         }
         $account_inventory = $acc_inv;
     }
     // Load avatar initial items items
     $items = Event::until('opensim.load.avatar.items', array($default_avatar_name, $user, $account_inventory));
     if (is_null($items)) {
         $items = \Opensim\load_ruth_items($user->uuid, $account_inventory);
     }
     if (isset($items) and !empty($items)) {
         $invento = InventoryItem::insert($items);
     }
     // Load Avatar appearance
     $items_array = Event::until('opensim.load.avatar.appearance', array($default_avatar_name, $user));
     if (is_null($items_array)) {
         $items_array = \Opensim\load_ruth_appearance($user->uuid);
     }
     // Save appearance
     $avatar_apearance = \Opensim\Model\Os\Avatar::insert($items_array);
 }
Ejemplo n.º 4
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();
 }