Exemplo 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;
 }
Exemplo n.º 2
0
 /**
  * Return partial view rendered
  * 
  * @param string $partial
  * @param array $data
  */
 public function render_partial($partial, $data = array())
 {
     if (\Event::listeners("themes.render.partial: {$partial}")) {
         $result = \Event::until("themes.render.partial: {$partial}", array($view));
         if (!is_null($result)) {
             if ($result instanceof \DOMDocument) {
                 $view = $result->saveHTML();
             } elseif (is_string($result)) {
                 $view = $result;
             } elseif (is_array($result)) {
                 // array to dom
                 $view = '<!DOCTYPE html>';
                 $view .= Dom::arrayToDOMDocument($result, 'html')->saveHTML();
             } else {
                 // trow exception
             }
         }
     }
     $data = $this->_share_data($data);
     $bundle_parts = \Bundle::parse($partial);
     $bundle_name = $bundle_parts['0'] == 'application' ? '' : $bundle_parts['0'] . DS;
     $partial_path = str_replace('.', DS, $bundle_parts['1']);
     $theme_view_folder = $this->_theme_absolute_path . DS . 'views' . DS;
     // Check for a custom path
     $has_partial = $this->_view_exists(str_replace('.', DS, $partial));
     if ($has_partial) {
         return View::make($has_partial, $data);
     }
     // Check on the themes views folder
     $has_partial = $this->_view_exists($theme_view_folder . $bundle_name . 'partials' . DS . $partial_path);
     if ($has_partial) {
         return View::make($has_partial, $data);
     }
     // Check on custom folder (fallback for all themes)
     $has_partial = $this->_view_exists(path('public') . 'custom' . DS . 'views' . DS . $bundle_name . 'partials' . DS . $partial_path);
     if ($has_partial) {
         return View::make($has_partial, $data);
     }
     // bundles folder
     $has_partial = $this->_view_exists($partial);
     if ($has_partial) {
         return View::make($has_partial, $data);
     }
     // try to load from application views folder
     $has_partial = $this->_view_exists('partials' . DS . $partial_path);
     if ($has_partial) {
         return View::make($has_partial, $data);
     }
     Log::error('Failed to render partial from ' . $partial);
     throw new \Exception("Failed to render partial. Partial [{$partial}] doesn't exist. ");
 }
Exemplo n.º 3
0
 public static function publish($module_slug)
 {
     require path('sys') . 'cli' . DS . 'dependencies' . EXT;
     try {
         $module_assets_path = path('bundle') . $module_slug . DS . 'public' . DS;
         if (\File::exists($module_assets_path)) {
             \Bundle::register($module_slug);
             $publish_cmd = \Laravel\CLI\Command::run(array('bundle:publish', $module_slug));
             \Bundle::disable($module_slug);
             return true;
         }
         return true;
     } catch (\Exception $e) {
         Log::error($e->getMessage());
         Log::error('Failed to publish assets for module [' . $module_slug . '].');
         return false;
     }
 }
Exemplo n.º 4
0
 public function update_account($user)
 {
     $user_account = self::where_PrincipalID($user->uuid)->first();
     if (!is_null($user_account)) {
         $account_auth = Auth::where_UUID($user->uuid)->first();
         if (!is_null($account_auth)) {
             if ($user->status == 'active') {
                 // update password
                 $account_auth_update['passwordHash'] = $user->hash;
                 $account_auth_update['passwordSalt'] = $user->salt;
             } else {
                 // set password to blank
                 $account_auth_update['passwordHash'] = $user->status;
                 $account_auth_update['passwordSalt'] = $user->status;
             }
             $account_auth->where('UUID', '=', $user->uuid)->update($account_auth_update);
         } else {
             Log::error('UserAccount Model: [update_account] failed. Authentication passwords does not exist for UUID: [' . $user->uuid . '] First Name: [' . $user->avatar_first_name . '] Last Name: [' . $user->avatar_last_name . '].');
         }
         // Update user account
         $user_account_update['FirstName'] = $user->avatar_first_name;
         $user_account_update['LastName'] = $user->avatar_last_name;
         $user_account_update['Email'] = $user->email;
         $user_account->where('PrincipalID', '=', $user->uuid)->update($user_account_update);
     } else {
         Log::error('UserAccount Model: [update_account] failed. Account does not exist for UUID: [' . $user->uuid . '] First Name: [' . $user->avatar_first_name . '] Last Name: [' . $user->avatar_last_name . '].');
     }
 }