Example #1
0
 public function put_set_default()
 {
     $theme = new \Themes\Model\Theme();
     $layer = Input::get('layout_type');
     $theme_slug = Input::get('theme');
     if (!isset($theme_slug) or empty($theme_slug)) {
         $this->data['message'] = __('themes::lang.Please select a theme to save as default')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::back()->with($this->data);
     }
     $layout = Input::get('layout');
     // set the old theme back to non default
     $theme::where('is_default', '=', 1)->where('layer', '=', $layer)->update(array('is_default' => '0'));
     $theme::where('slug', '=', $theme_slug)->where('layer', '=', $layer)->update(array('is_default' => '1'));
     \Settings\Model\Setting::where('slug', '=', $layer . '_theme')->update(array('value' => $theme_slug));
     \Settings\Model\Setting::where('slug', '=', $layer . '_layout')->update(array('value' => $layout));
     $this->data['message'] = __('themes::lang.Theme was saved as default')->get(ADM_LANG);
     $this->data['message_type'] = 'success';
     $theme_page = $layer == 'frontend' ? '' : '/backend';
     return Redirect::to(ADM_URI . '/themes' . $theme_page)->with($this->data);
 }
Example #2
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);
 }