/** * Get an item from the cache, or cache and return the default value. * * <code> * // Get an item from the cache, or cache a value for 15 minutes * $name = Cache::remember('name', 'Taylor', 15); * * // Use a closure for deferred execution * $count = Cache::remember('count', function() { return User::count(); }, 15); * </code> * * @param string $key * @param mixed $default * @param int $minutes * @return mixed */ public function remember($key, $default, $minutes, $function = 'put') { if (!is_null($item = $this->get($key, null))) { Log::info('Cache hit for ' . $key); return $item; } $this->{$function}($key, $default = value($default), $minutes); Log::info('Cache miss for ' . $key); return $default; }
public static function remDataInput($dataId) { try { Content::remData($dataId); } catch (Exception $e) { Log::write('Data', 'Data Removal Not Success'); } }
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; }
public function post_deleteGroup() { $groupid = Input::get('groupid'); $name = Input::get('name'); Group::getDataModel($groupid); $existed = Group::checkData(); if (!$existed) { Group::find($groupid)->delete(); Log::write('Data', 'Data Group<b>' . $name . '</b> Remove by ' . Auth::user()->username); return json_encode(Group::listData()); } else { return json_encode(array('fail' => Str::title(Lang::line('admin.deletegroupfail')->get()))); } }
public static function remData($id) { Cat::find($id)->delete(); Log::write('Data', 'Claims Category Id <b>' . $id . '</b> Remove by ' . Auth::user()->username); }
public function validate_link_type($attribute, $value, $parameters) { if (!$this->validate_required($this->attributes['link_type'], $this->attributes['link_type'])) { $this->messages['link_type'] = 'The link type field is required.'; return false; } if ($value == 'url') { if ($this->validate_required($this->attributes['url'], $this->attributes['url'])) { // Check for valid url $this->messages['link_type'] = 'The url field must be a valid url.'; return $this->validate_url($this->attributes['url'], $this->attributes['url']); } else { $this->messages['link_type'] = 'The url field is required.'; return false; } } if ($value == 'uri') { if ($this->validate_required($this->attributes['uri'], $this->attributes['uri'])) { // Check for valid uri $this->messages['link_type'] = 'The uri field must be a valid uri.'; return preg_match('/^([-a-z0-9_\\/-])+$/i', $this->attributes['uri']); } else { $this->messages['link_type'] = 'The uri field is required'; return false; } } if ($value == 'module') { if ($this->validate_required($this->attributes['module_id'], $this->attributes['module_id'])) { // the module id is generated in the form // it should never be something different then an integer // but lets check it just in case $is_valid_integer = $this->validate_integer($this->attributes['module_id'], $this->attributes['module_id']); if ($is_valid_integer) { return true; } else { // this is really bad! maybe cross post? // log the error $this->messages['link_type'] = 'This module is invalid or cannot be selected.'; Log::write('error', 'Tried to create a link selecting a invalid module [' . $this->attributes['module_id'] . ']'); return false; } } else { $this->messages['link_type'] = 'Please select a module to link to.'; return false; } } if ($value == 'page') { if ($this->validate_required($this->attributes['page_id'], $this->attributes['page_id'])) { // the page_id is generated in the form // it should never be something different then an integer // but lets check it just in case $is_valid_integer = $this->validate_integer($this->attributes['page_id'], $this->attributes['page_id']); if ($is_valid_integer) { return true; } else { // this is really bad! maybe cross post? // log the error $this->messages['link_type'] = 'This page is invalid or cannot be selected.'; Log::write('error', 'Tried to create a link selecting a invalid page [' . $this->attributes['page_id'] . ']'); return false; } } else { $this->messages['link_type'] = 'Please select a page to link to.'; return false; } } $this->messages['link_type'] = 'Unknown'; return false; }
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; } }
/** * Removing Data Information * * @return void * @author **/ public static function remData($id) { Content::find($id)->delete(); Log::write('Data', 'Data Id <b>' . $id . '</b> Remove by ' . Auth::user()->username); }
public function post_deletestep() { $input = Input::get(); Log::write('User', 'Delete Step ID ' . Step::find($input['id'])->step . ' by ' . Auth::user()->username); Step::find($input['id'])->delete(); Step::where('parentid', '=', $input['id'])->delete(); return Menu::flowtree($input['flowid']); }
/** * 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. "); }
public static function updateUser($input) { $user = User::find($input['userid']); $profileid = $user->userprofile->profileid; $user->role = $input['role']; $user->status = $input['status']; $user->save(); $prof = array(array('fullname' => $input['fullname'], 'icno' => $input['icno'], 'emel' => $input['emel'])); $profile = Profile::find($profileid); $profile->fullname = $input['fullname']; $profile->icno = $input['icno']; $profile->emel = $input['emel']; $profile->save(); $profile = User::find($input['userid']); Log::write('User', 'Update User ' . $user->userprofile->icno . 'By ' . Auth::user()->username); }
/** * Log that a message was sent. * * @param Swift_Message $message * @return void */ protected function logMessage($message) { $emails = implode(', ', array_keys($message->getTo())); Log::info("Pretending to mail message to: {$emails}"); }
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 . '].'); } }