Ejemplo n.º 1
0
 public function insert_items($folder_name, $items = array())
 {
     $folder = InventoryFolder::where_folderName($folder_name)->first();
     if (!isset($folder)) {
         Log::error('Failed to insert items. Folder ' . $folder_name . ' does not exist.');
         return null;
     }
     foreach ($items as $item) {
         $item['parentFolderID'] = $folder->folderid;
     }
     $this->insert($items);
     return $items;
 }
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();
 }