public function loadPage(Request $request) { $this->getChart($request); $result = new Helper(); //$result->buildNavMenuNew(); return View('linechart')->with('result', $result->buildNavMenu()); }
public function loadPage(Request $request) { $nav = new Helper(); $runsModel = new \App\Run(); //$runs = $this->getRuns(); $runs = $runsModel->getRunsWithinXDays(90); $runs_for_dropdown = $runsModel->getRunsForDropdown(); return view('Admin.edit')->with(['runs' => $runs, 'nav' => $nav->buildNavMenu(), 'runs_for_dropdown' => $runs_for_dropdown]); }
public function loadPage($id = null) { $runModel = new \App\Run(); $run = $runModel->getRun($id); if (is_null($run)) { \Session::flash('flash_message', 'Run not found.'); return redirect('/'); } $nav = new Helper(); return view('runs.single')->with(['nav' => $nav->buildNavMenu(), 'run' => $run]); }
public function getCharts($testResultTotals) { $chart = new Helper(); $smoke = \Lava::DataTable(); $integration = \Lava::DataTable(); $regression = \Lava::DataTable(); $smoke->addStringColumn('TestResults')->addNumberColumn('Percent')->addRow(array('Passed', $testResultTotals['Passed']))->addRow(array('Failed', $testResultTotals['Failed']))->addRow(array('Skipped', $testResultTotals['Skipped'])); $integration->addStringColumn('TestResults')->addNumberColumn('Percent')->addRow(array('Passed', 90))->addRow(array('Failed', 5))->addRow(array('Skipped', 5)); $regression->addStringColumn('TestTesults')->addNumberColumn('Percent')->addRow(array('Passed', 82))->addRow(array('Failed', 18))->addRow(array('Skipped', 20)); $chart->getChart('SmokeTestChart', 'PieChart', 250, 250, array('078B3E', 'CD1E35', 'FCDC27'), $smoke); $chart->getChart('IntegrationTestChart', 'PieChart', 250, 250, array('078B3E', 'CD1E35', 'FCDC27'), $integration); $chart->getChart('RegressionTestChart', 'PieChart', 250, 250, array('078B3E', 'CD1E35', 'FCDC27'), $regression); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @param int $thread_id * @param int $parent_id * @return \Illuminate\Http\Response */ public function store(Request $request, $thread_id, $parent_id = null) { $user_id = Auth::user()->id; $position = ''; $depth = 0; $thread = DB::table('threads')->where('id', $thread_id)->first(); if ($thread == null) { abort(404); } if ($parent_id != null) { $parent = DB::table('replies')->where('id', $parent_id)->first(); if ($parent == null || $parent->thread_id != $thread_id) { abort(404); } $position = $parent->position; $depth = $parent->depth + 1; } // Validation $this->validate($request, ['content' => 'string|required']); $content = $request->input('content'); $id = DB::table('replies')->insertGetId(['thread_id' => $thread_id, 'user_id' => $user_id, 'parent_id' => $parent_id, 'content' => $content, 'depth' => $depth]); $position = $position . Helper::appendZero($id, 5) . ','; DB::table('replies')->where('id', $id)->update(['position' => $position]); DB::table('threads')->where('id', $thread_id)->increment('comment_count'); DB::table('users')->where('id', $user_id)->increment('comment_count'); $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id; DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $thread_id]); return redirect('/thread/' . $thread_id); }
/** * Admin login request * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['username' => 'required', 'password' => 'required']); if ($validator->fails()) { Flashy::error($validator->errors()->first()); return back(); } // If we have already set an admin user, do they match? if (Setting::has('admin_user')) { if ($request->username != Setting::get('admin_user')['username'] && $request->username != Setting::get('admin_user')['email']) { Flashy::error('Admin user is not recognised'); return back(); } } // Is this a valid plex user? $admin_user = (array) Helper::getPlexUser($request->username, $request->password); if (!$admin_user) { back(); } // So, have we got an admin user already? If not, let's set that now. if (!Setting::has('admin_user')) { Flashy::success('Admin user has been set to ' . $request->username); } Setting::set('admin_user', $admin_user); Session::set('admin_user', $admin_user); return back(); }
public function loginAction() { $fc = FrontController::getInstance(); $model = new FrontModel(); $userModel = new UserTableModel(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $userModel->setTable('user'); $userModel->setData(); $userModel->login(); $redirect = Helper::getRedirect(); if (is_array($redirect) && !empty($redirect['url'])) { $redirect = implode('#', $redirect); header('Location: ' . $redirect); exit; } if ($fc->getAction() !== 'loginAction') { header('Location: ' . $_SERVER['REQUEST_URI']); } else { header('Location: ' . '/'); } exit; } else { if ($_SESSION['user_id']) { header('Location: /'); } $output = $model->render('../views/user/login.php', 'withoutSliderAndSidebar'); $fc->setPage($output); } }
/** * Bootstrap any application services. * * @return void */ public function boot() { // image Blade::directive('image', function ($expression) { $externalUrl = "/img/"; $expression = substr($expression, 2, strlen($expression) - 4); return "<?php echo '{$externalUrl}{$expression}'; ?>"; }); // breadcrumbs Blade::directive('breadcrumbs', function ($expression) { // return "echo with{$expression}->format('m/d/Y H:i'); $expression = \App\Helpers\Helper::substring($expression, 1, 1); $expression = \App\Helpers\Helper::stringRemove($expression, "'"); $params = explode(", ", $expression); $string = ""; $arrow = '<i class="fa fa-chevron-right navigation-arrow"></i>'; for ($i = 0; $i < count($params) - 1; $i += 2) { $url = route($params[$i]); $title = $params[$i + 1]; $string .= "<a href='{$url}'>{$title}</a>"; if (isset($params[$i + 2])) { $string .= $arrow; } } $string .= $params[count($params) - 1]; // return "< ? php echo with{$string}; ; return $string; }); }
/** * Run the database seeds. * * @return void */ public function run() { for ($count = 1; $count <= 10; $count++) { $thread_id = rand(1, DB::table('threads')->count()); $position = Helper::appendZero($count, 5); $user_id = rand(1, DB::table('users')->count()); DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'position' => $position . ',', 'depth' => 0]); DB::table('threads')->where('id', $thread_id)->increment('comment_count'); DB::table('users')->where('id', $user_id)->increment('comment_count'); $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id; DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $count]); } for ($count = 11; $count <= 30; $count++) { $parent_id = rand(1, DB::table('replies')->count()); $parent = DB::table('replies')->where('id', $parent_id)->first(); $position = $parent->position . Helper::appendZero($count, 5) . ','; $thread_id = $parent->thread_id; $user_id = rand(1, DB::table('users')->count()); DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'parent_id' => $parent_id, 'depth' => $parent->depth + 1, 'position' => $position]); DB::table('threads')->where('id', $thread_id)->increment('comment_count'); DB::table('users')->where('id', $user_id)->increment('comment_count'); $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id; DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $thread_id]); } }
/** * Returns a view with the user's profile form for editing * * @author [A. Gianotto] [<*****@*****.**>] * @since [v1.0] * @return View */ public function getIndex() { // Get the user information $user = Auth::user(); $location_list = Helper::locationsList(); return View::make('account/profile', compact('user'))->with('location_list', $location_list); }
/** * Statuslabel create. * * @return View */ public function getCreate() { // Show the page $statuslabel = new Statuslabel(); $use_statuslabel_type = $statuslabel->getStatuslabelType(); $statuslabel_types = Helper::statusTypeList(); return View::make('statuslabels/edit', compact('statuslabel_types', 'statuslabel'))->with('use_statuslabel_type', $use_statuslabel_type); }
function indexAction() { $fc = FrontController::getInstance(); $model = new FrontModel(); $popProducts = (new IndexWidgets())->recAndPopProductsWidget('popular', 6); $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended'); $model->setData(['slides' => IndexWidgets::getSliderWidget(), 'currentCategory' => (new IndexWidgets())->currentCategoryWidget(Helper::getSiteConfig()->currentCategoryWidget), 'popularProducts' => Generator::popularProducts($popProducts, 6), 'recommendedProducts' => Generator::recommendedProducts($recProducts)]); $output = $model->render('../views/index.php', 'main'); $fc->setPage($output); }
/** * Validates input before processing user requests * @param Array $data array of fields to validate * @param Array $rules array of rules to apply * @return \Illuminate\Http\Response response if validation fails */ public static function validator(array $data, array $rules, $redirectRoute) { // Validate $validator = Validator::make($data, $rules); // If validator fails get the errors and warn the user // this redirects to prevent further execution if ($validator->fails()) { $message = Helper::getValidationErrors($validator); return redirect()->route($redirectRoute)->with('message', $message); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // dd(Helper::makePermissionsCRUD($request->privilege)); $array_of_permissions = Helper::makePermissionsCRUD($request->privilege); foreach ($array_of_permissions as $key => $permission) { $privilege = new Privilege(); $privilege->permission = $permission; $privilege->status_id = 1; $privilege->save(); } return \Redirect::to('settings/roles'); }
public function start(Request $request) { if (empty(Session::get('session_id'))) { Helper::saveSession(); } else { $session = Session::get('session_id'); $existe = SaveSession::where('cookie', '=', $session)->first(); if (empty($existe)) { Helper::saveSession(); } } return redirect('cuando-comes-fuera-de-casa-vas-a'); }
public function postPermissiongen(Request $request) { $special = []; #special permissions $special[0] = Helper::octalgen($request->input('setuid'), $request->input('setgid'), $request->input('stickybit')); #user permissions $special[1] = Helper::octalgen($request->input('userread'), $request->input('userwrite'), $request->input('userexecute')); #group permissions $special[2] = Helper::octalgen($request->input('groupread'), $request->input('groupwrite'), $request->input('groupexecute')); #other permissions $special[3] = Helper::octalgen($request->input('otherread'), $request->input('otherwrite'), $request->input('otherexecute')); return view('permissiongen.permissiongen', ['special' => $special]); }
public function compose(View $view) { $catTree = null; /* if(\Cache::has('tree')) { $catTree = \Cache::get('tree'); } else { \Cache::put('tree', $this->category->get()->toTree(), Carbon::now()->addDay()); $catTree = \Cache::get('tree'); }*/ $catTree = $this->category->get()->toTree(); $view->with('categories', Helper::treeToArray($catTree)); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id = 0) { if ($id == 0) { $id = Auth::user()->id; } $user = DB::table('users')->where('id', $id)->first(); if ($user == null) { return abort(401); } if ($user->profile_picture !== null) { $user->profile_picture = Helper::getUserResource($user->profile_picture, $user->id); } return view('show_profile', ['user' => $user]); }
function addAllImages() { if (!empty($this->mainImage)) { $mImage = str_replace('//', '/', $this->path . 'main_' . Generator::strToLat($this->mainImage)); $this->addImage($mImage, TRUE); Helper::moveFile('mainimage', TRUE, $this->productId); } if (!empty($this->images[0]) && is_array($this->images)) { foreach ($this->images as $img) { $image = str_replace('//', '/', $this->path . Generator::strToLat($img)); $this->addImage($image, FALSE); } Helper::moveFile('images', FALSE, $this->productId); } }
public static function emailHandler($to = FALSE) { try { if (!$to) { $to = Helper::getSiteConfig()->contactinfo->siteMail->value; } if (empty(self::$data)) { throw new Exception('Класс не инициализирован должным образом'); } self::emailSender((string) $to, self::$data['subject'], self::$data['message'], self::$data['email']); return TRUE; } catch (Exception $ex) { Session::setUserMsg('Пожалуйста, заполните все поля формы', 'danger'); header('Location: ' . $_SERVER['REQUEST_URI']); } }
/** * Execute the console command. * * @return mixed */ public function handle() { if (Setting::getSettings()->alert_email != '' && Setting::getSettings()->alerts_enabled == 1) { $data['data'] = Helper::checkLowInventory(); $data['count'] = count($data['data']); if (count($data['data']) > 0) { \Mail::send('emails.low-inventory', $data, function ($m) { $m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name); $m->subject('Low Inventory Report'); }); } } else { if (Setting::getSettings()->alert_email == '') { echo "Could not send email. No alert email configured in settings. \n"; } elseif (Setting::getSettings()->alerts_enabled != 1) { echo "Alerts are disabled in the settings. No mail will be sent. \n"; } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['plex_username' => 'required']); if ($validator->fails()) { foreach ($validator->errors()->all() as $error) { Flashy::error($error); } return redirect('/'); } // We've got a user, lets see if it's valid $users = Helper::getAllPlexFriends(); if (!in_array($request->plex_username, $users)) { Flashy::error('Username not found'); return redirect('/'); } else { // Set a simple session to remember this user $request->session()->put('user', $request->plex_username); Flashy::success('Welcome, ' . $request->plex_username . '!'); return redirect('/'); } }
/** * Show user related resources. * * @return \Illuminate\Http\Response */ public function getResource($id = 0, $filename) { if ($id == 0) { $id = Auth::user()->id; } if (DB::table('users')->where('id', $id)->first() == null) { return abort(401); } $file = 'users/' . $id . '/' . $filename; if (!Storage::has($file)) { return abort(404); } $mimeType = Storage::mimeType($file); if (!Helper::startsWith($mimeType, 'image/')) { return abort(404); } $file = Storage::get($file); $response = Response::make($file, 200); $response->header("Content-Type", $mimeType); return $response; }
$I->lookForwardTo('seeing errors display'); $I->click(['link' => 'Create New']); $I->amOnPage('admin/users/create'); $I->dontSee('Create User', '.page-header'); $I->see('Create User', 'h1.pull-left'); /* Submit form and expect errors */ $I->click(['name' => 'email']); $I->submitForm('#userForm', ['email' => '*****@*****.**']); $I->seeElement('.alert-danger'); $I->dontSeeInSource('<br><'); /* Submit form and expect errors */ $I->click(['name' => 'email']); $I->click(['name' => 'username']); $I->submitForm('#userForm', ['email' => \App\Helpers\Helper::generateRandomString(15) . '@example.com', 'first_name' => 'Joe', 'last_name' => 'Smith', 'username' => \App\Helpers\Helper::generateRandomString(15)]); $I->seeElement('.alert-danger'); $I->dontSeeInSource('<br><'); /* Submit form and expect success */ $I->wantTo('submit the form successfully'); $I->click(['name' => 'email']); $I->fillField(['name' => 'email'], \App\Helpers\Helper::generateRandomString(15) . '@example.com'); $I->fillField(['name' => 'first_name'], 'Joe'); $I->fillField(['name' => 'last_name'], 'Smith'); $I->click(['name' => 'username']); $I->fillField(['name' => 'username'], \App\Helpers\Helper::generateRandomString(15)); $I->click(['name' => 'password']); $I->fillField(['name' => 'password'], 'password'); $I->click(['name' => 'password_confirm']); $I->fillField(['name' => 'password_confirm'], 'password'); $I->click('Save'); $I->seeElement('.alert-success'); $I->dontSeeInSource('<br><');
/** * Get all titles and return a simple array for dropdown list. * * * @return array $titleArray */ public function getAllForDropdown() { $countries = Country::all(); return Helper::getDropdownArray($countries); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id ID of the template to update * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // Load selected templates $template = Template::find($id); if ($template == null) { return redirect()->route('dashboard.settings.templates.index')->with('message', 'Error: Template not found'); } // Get request inputs $txtTemplateName = $request->input('txtTemplateName'); $txtTemplateClass = $request->input('txtTemplateClass'); $numTemplateDuration = $request->input('numTemplateDuration'); $data = array('txtTemplateName' => $txtTemplateName, 'txtTemplateClass' => $txtTemplateClass, 'numTemplateDuration' => $numTemplateDuration); $rules = array('txtTemplateName' => 'required|max:60|unique:template,name,' . $id, 'txtTemplateClass' => 'required|max:50|unique:template,class_name,' . $id, 'numTemplateDuration' => 'required|integer|min:1'); // Validate $reponse = Helper::validator($data, $rules, 'dashboard.settings.templates.index'); if (isset($reponse)) { return $reponse; } // Update $template->name = $txtTemplateName; $template->class_name = $txtTemplateClass; $template->duration = $numTemplateDuration; // Upload image 1 $imageInput = Input::file('filTemplateThumbnail'); if ($imageInput != null) { $imagePath = Images::processImage($imageInput, 'template_thumbmails'); // If we have a valid image then set the path in the database if ($imagePath != null) { $template->thumbnail = $imagePath; } } // Update! $template->save(); return redirect()->route('dashboard.settings.templates.index')->with('message', 'Templated updated successfully'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id ID of the department to update * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // Get selected department $department = Department::find($id); // Only continue if one was found if ($department == null) { return redirect()->route('dashboard.settings.departments.index')->with('message', 'Error: Department not found'); } // Get request inputs $txtDepartmentName = $request->input('txtDepartmentName'); $data = array('txtDepartmentName' => $txtDepartmentName); $rules = array('txtDepartmentName' => 'required|min:1|max:40|unique:department,name,' . $id); // Validate input $reponse = Helper::validator($data, $rules, 'dashboard.settings.departments.index'); if (isset($reponse)) { return $reponse; } // Update department $department->name = $txtDepartmentName; $department->save(); return redirect()->route('dashboard.settings.departments.index')->with('message', 'Department updated successfully'); }
/** * Returns a form view to edit a selected asset maintenance. * * @see AssetMaintenancesController::postEdit() method that stores the data * @author Vincent Sposato <*****@*****.**> * @param int $assetMaintenanceId * @version v1.0 * @since [v1.8] * @return mixed */ public function getEdit($assetMaintenanceId = null) { // Check if the asset maintenance exists if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) { // Redirect to the improvement management page return redirect()->to('admin/asset_maintenances')->with('error', trans('admin/asset_maintenances/message.not_found')); } elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) { return static::getInsufficientPermissionsRedirect(); } if ($assetMaintenance->completion_date == '0000-00-00') { $assetMaintenance->completion_date = null; } if ($assetMaintenance->start_date == '0000-00-00') { $assetMaintenance->start_date = null; } if ($assetMaintenance->cost == '0.00') { $assetMaintenance->cost = null; } // Prepare Improvement Type List $assetMaintenanceType = ['' => 'Select an improvement type'] + AssetMaintenance::getImprovementOptions(); $assets = Company::scopeCompanyables(Asset::with('model', 'assignedUser')->get(), 'assets.company_id')->lists('detailed_name', 'id'); // Get Supplier List $supplier_list = Helper::suppliersList(); // Render the view return View::make('asset_maintenances/edit')->with('asset_list', $assets)->with('selectedAsset', null)->with('supplier_list', $supplier_list)->with('assetMaintenanceType', $assetMaintenanceType)->with('assetMaintenance', $assetMaintenance); }
public function actionFbAuth() { $model = new ClientUsers(); if ($model->load(Yii::$app->request->post())) { if ($model->fbAuth()) { return ['auth_key' => $model->auth_key]; } } throw new HttpException(400, 'Your credentials are invalid ' . Helper::recursive_implode($model->errors, ',', false, false)); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id ID of the user to update * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // Get selected user $user = User::find($id); if ($user == null) { return redirect()->route('dashboard.settings.users.index')->with('message', 'Error: User not found'); } // Get all request inputs $data = $request->all(); $rules = array('username' => 'min:1|max:40|unique:user,username,' . $id, 'password' => 'confirmed|min:6|max:60'); // Validate $reponse = Helper::validator($data, $rules, 'dashboard.settings.users.index'); if (isset($reponse)) { return $reponse; } // Update $user->username = $data['username']; if (isset($data['password'])) { $user->password = bcrypt($data['password']); } $user->save(); return redirect()->route('dashboard.settings.users.index')->with('message', 'User created successfully'); }