Inheritance: extends app\components\basicRecord
Beispiel #1
0
 function all()
 {
     if (!($settings = Settings::first())) {
         $settings = new Settings();
         $settings->save();
     }
     $whereis_node = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis node')));
     $whereis_nodejs = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis nodejs')));
     $whoami = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whoami')));
     $home = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('echo $HOME')));
     $pw = @posix_getpwuid(@posix_getuid());
     $detectedHome = is_array($pw) && isset($pw['dir']) ? trim(preg_replace('/\\s\\s+/', ' ', $pw['dir'])) : '';
     $defaultNodeJsPath = false;
     if (empty($settings->nodejs_path)) {
         if (!empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_nodejs);
             if (isset($parts[0]) && $parts[0] == 'nodejs:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
         if (!$defaultNodeJsPath && !empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_node);
             if (isset($parts[0]) && $parts[0] == 'node:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
     }
     return view('settings', ['settings' => $settings, 'whereis_node' => $whereis_node, 'whereis_nodejs' => $whereis_nodejs, 'whoami' => $whoami, 'home' => $home, 'detectedHome' => $detectedHome, 'defaultNodeJsPath' => $defaultNodeJsPath]);
 }
 /**
  * set activity default field values
  */
 protected function setDefaultFieldValues()
 {
     $defaultFieldValues = $this->settingsModel->where('organization_id', $this->orgId)->first()->default_field_values;
     $this->activityData['default_field_values'] = $defaultFieldValues;
     $this->activityData['collaboration_type'] = $defaultFieldValues[0]['default_collaboration_type'];
     $this->activityData['default_flow_type'] = $defaultFieldValues[0]['default_flow_type'];
     $this->activityData['default_finance_type'] = $defaultFieldValues[0]['default_finance_type'];
     $this->activityData['default_aid_type'] = $defaultFieldValues[0]['default_aid_type'];
     $this->activityData['default_tied_status'] = $defaultFieldValues[0]['default_tied_status'];
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $settings = new Settings();
     $settings->url = 'http://localhost';
     $settings->email = '*****@*****.**';
     $settings->title = 'CMS';
     $settings->desc = 'CMS';
     $settings->keys = 'CMS';
     $settings->save();
 }
Beispiel #4
0
 public static function setValue($parameterID, $value)
 {
     $parameter = self::findByParameterID($parameterID);
     if (!$parameter) {
         $parameter = new Settings();
         $parameter->user_id = Yii::$app->user->id;
         $parameter->parameter_id = $parameterID;
     }
     $parameter->value = $value;
     if (!$parameter->save()) {
         throw new Exception('Не удалось сохранить параметр');
     }
 }
 public function savesettings()
 {
     /* Get Post */
     $rules = array();
     if (Input::has('ldapon')) {
         $rules = array('ldapserver' => 'required', 'ldapdomain' => 'required', 'ldapuser' => 'required', 'ldappassword' => 'required', 'ldapbasedn' => 'required');
     }
     // Check Validation
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         //failed to validate
         //let's go back to that form with errors, input
         $messages = $validation->messages();
         $html = '<div class="response"><div class="alert alert-error">';
         foreach ($messages->all() as $message) {
             $html .= ' ' . $message . '<br>';
         }
         $html .= '</div></div>';
         Former::withErrors($validation);
         echo json_encode(array('html' => $html));
     } else {
         $settings = Settings::find(1);
         if ($settings === null) {
             $settings = new Settings();
         }
         $settings->id = '1';
         $settings->ldapon = "0";
         $settings->ldapserver = "";
         $settings->ldapdomain = "";
         $settings->ldapuser = "";
         $settings->ldappassword = "";
         $settings->servername = Input::get('servername', '');
         $settings->adminemail = Input::get('adminemail', '');
         $settings->confdir = Input::get('confdir', '');
         if (Input::has('ldapon')) {
             $settings->ldapon = Input::get('ldapon');
             $settings->ldapserver = Input::get('ldapserver', '');
             $settings->ldapdomain = Input::get('ldapdomain', '');
             $settings->ldapuser = Input::get('ldapuser', '');
             $settings->ldappassword = Input::get('ldappassword', '');
             $settings->ldapbasedn = Input::get('ldapbasedn', '');
             $settings->ldapport = Input::get('ldapport', '');
         }
         $settings->save();
         /* Check if Conf Dir is writables */
         echo json_encode(array('html' => '<div class="response"><div class="alert alert-success"> Settings Sucessufull Updated </div><div class="response"></div>'));
     }
 }
 public function update($id, $requestData)
 {
     $settings = Settings::first();
     $companyname = $settings->company;
     $user = User::findorFail($id);
     $password = bcrypt($requestData->password);
     $role = $requestData->roles;
     $department = $requestData->departments;
     if ($requestData->hasFile('image_path')) {
         $settings = Settings::findOrFail(1);
         $companyname = $settings->company;
         $file = $requestData->file('image_path');
         $destinationPath = public_path() . '\\images\\' . $companyname;
         $filename = str_random(8) . '_' . $file->getClientOriginalName();
         $file->move($destinationPath, $filename);
         if ($requestData->password == "") {
             $input = array_replace($requestData->except('password'), ['image_path' => "{$filename}"]);
         } else {
             $input = array_replace($requestData->all(), ['image_path' => "{$filename}", 'password' => "{$password}"]);
         }
     } else {
         if ($requestData->password == "") {
             $input = array_replace($requestData->except('password'));
         } else {
             $input = array_replace($requestData->all(), ['password' => "{$password}"]);
         }
     }
     $user->fill($input)->save();
     $user->roles()->sync([$role]);
     $user->department()->sync([$department]);
     Session::flash('flash_message', 'User successfully updated!');
     return $user;
 }
 /**
  * @param $input
  * @param $organization
  * @return bool
  */
 public function storeSettings($input, $organization)
 {
     $organization->reporting_org = $input['reporting_organization_info'];
     $organization->save();
     Settings::create(['publishing_type' => $input['publishing_type'][0]['publishing'], 'registry_info' => $input['registry_info'], 'default_field_values' => $input['default_field_values'], 'default_field_groups' => $input['default_field_groups'], 'organization_id' => $organization->id]);
     $this->organizationData->create(['organization_id' => $organization->id]);
 }
Beispiel #8
0
 public function start($id)
 {
     if (!($workflow = Workflow::find((int) $id))) {
         return redirect('workflows')->with('status_error', "Workflow not found.");
     }
     if (empty($workflow->path)) {
         return redirect('workflows')->with('status_error', "Workflow not found.");
     }
     if (!empty($workflow->pid)) {
         return redirect('workflows')->with('status_error', "Workflow already started.");
     }
     if ($anotherStarted = Workflow::where('id', '!=', $id)->where('pid', '!=', '')->first()) {
         return redirect('workflows')->with('status_error', "Another workflow is already running. Please stop any other workflow first.");
     }
     if (!($settings = Settings::first())) {
         return redirect('workflows')->with('status_error', "Please fill in all the required settings.");
     }
     if (empty($settings->home_path)) {
         return redirect('workflows')->with('status_error', "Please fill in your home path.");
     }
     if (empty($settings->c9_path)) {
         return redirect('workflows')->with('status_error', "Please specify Cloud9 IDE path in settings.");
     }
     $command = "/usr/bin/nohup {$settings->nodejs_path} {$settings->c9_path} -w {$workflow->path} {$workflow->args} {$settings->default_args} > /dev/null & echo \$!";
     putenv("HOME={$settings->home_path}");
     $return = shell_exec($command);
     $pid = (int) $return;
     if (!$pid) {
         return redirect('workflows')->with('status_error', "Error while starting the server ({$return}).");
     }
     $workflow->pid = $pid;
     $workflow->save();
     return redirect('workflows')->with('status_success', "Workflow started. PID #{$pid}");
 }
 public function run()
 {
     $array = ['locales' => 'en, bg', 'sitename_en' => 'My site', 'sitename_bg' => 'Моят сайт', 'fallback_locale' => 'bg', 'favicon' => 'favicon.ico'];
     foreach ($array as $key => $item) {
         $settings = Settings::create(['param' => $key, 'value' => $item]);
         $settings->save();
     }
 }
 public function init()
 {
     parent::init();
     $pageSize = Settings::findOne(['type' => 'main', 'key' => 'page_size']);
     if ($pageSize !== null) {
         self::$defaultPageSize = $pageSize->value;
     }
 }
Beispiel #11
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Settings::get('show_contacts_page')) {
         return $next($request);
     } else {
         return new Response('', 404);
     }
 }
Beispiel #12
0
 /**
  * @return string
  */
 public function run()
 {
     if ($this->inventory <= Settings::value('stock', 'outofstock')) {
         return '<span class="out-of-stock">' . \Yii::t('app', 'Out of stock') . '</span>';
     } elseif ($this->inventory <= Settings::value('stock', 'lowstock')) {
         return '<span class="low-stock">' . \Yii::t('app', 'Low stock') . '</span>';
     }
     return '<span class="in-stock">' . \Yii::t('app', 'In stock') . '</span>';
 }
Beispiel #13
0
 /**
  * The attributes that are mass assignable.
  *
  * @var array
  */
 static function getSetting()
 {
     $Data = Settings::get()->all();
     $Result = [];
     foreach ($Data as $key => $value) {
         $Result[$value['key']] = $value['value'];
     }
     return $Result;
 }
 public static function getSetting($setting_id)
 {
     $setting = Settings::findOne(['pm_id' => $setting_id]);
     if ($setting) {
         return $setting->{$setting_id};
     } else {
         return false;
     }
 }
Beispiel #15
0
 /**
  * @param Settings $settings
  */
 protected function upgradeSettings(Settings $settings)
 {
     $defaultFieldValues = (array) $settings->default_field_values;
     foreach ($defaultFieldValues as $defaultFieldValueIndex => $defaultFieldValue) {
         $defaultFieldValues[$defaultFieldValueIndex]['humanitarian'] = "0";
     }
     !$defaultFieldValues ?: ($settings->default_field_values = $defaultFieldValues);
     $settings->save();
 }
 public function run()
 {
     $is_locked = Settings::getSetting('locked');
     $items = [['title' => 'Fragen', 'icon' => 'question-circle', 'url' => 'question', 'items' => [['title' => 'Neue frage', 'url' => 'question/create', 'options' => []], ['title' => 'Aus Datei einspielen', 'url' => 'question/import', 'options' => []], ['title' => 'Liste', 'url' => 'question/index', 'options' => []]]], ['title' => 'Banken', 'icon' => 'money', 'url' => 'bank', 'items' => [['title' => 'Neue bank', 'url' => 'bank/create', 'options' => []], ['title' => 'Liste', 'url' => 'bank/index', 'options' => []], ['title' => 'Bankenstatistik', 'url' => 'bank/statistic-list', 'options' => []], ['title' => 'Platzhalter', 'url' => 'bank/placeholders', 'options' => []], ['title' => 'Aus Datei einspielen', 'url' => 'bank/import', 'options' => []]]], ['title' => 'Benutzergruppen', 'icon' => 'users', 'url' => 'group', 'items' => [['title' => 'Neue Gruppe', 'url' => 'group/create', 'options' => []], ['title' => 'Liste', 'url' => 'group/index', 'options' => []]]], ['title' => 'Fragebögen', 'icon' => 'terminal', 'url' => 'form', 'items' => [['title' => 'Neue Fragebögen', 'url' => 'form/create', 'options' => []], ['title' => 'Liste', 'url' => 'form/index', 'options' => []]]], ['title' => 'Zugangscodes', 'icon' => 'barcode', 'url' => 'code', 'items' => [['title' => 'Neue Codes erzeugen', 'url' => 'code/create', 'options' => []]]], ['title' => 'Individualisierung', 'icon' => 'paint-brush', 'url' => 'user-text', 'items' => [['title' => 'Texte', 'url' => 'texts/index', 'options' => []], ['title' => 'Styles', 'url' => 'styles/index', 'options' => []], ['title' => 'Begrüßungstexte', 'url' => 'user-text/index/start', 'options' => []], ['title' => 'Schlusstexte', 'url' => 'user-text/index/end', 'options' => []]]], ['title' => 'Sprachen', 'icon' => 'language', 'url' => 'language', 'items' => [['title' => 'Neue Sprache', 'url' => 'language/create', 'options' => []], ['title' => 'Liste', 'url' => 'language/index', 'options' => []], ['title' => 'Aus Datei einspielen', 'url' => 'language/import', 'options' => []], ['title' => 'Übersetzungen', 'url' => 'translation/index', 'options' => []]]], ['title' => 'System', 'icon' => 'cogs', 'url' => 'system', 'items' => [['title' => 'Statistik', 'url' => 'system/statistic', 'options' => []], ['title' => 'Sperren', 'icon' => 'lock', 'url' => 'system/lock', 'options' => ['data-confirm' => $is_locked == 0 ? 'Das System wird gesperrt. Nachdem sie OK geklickt haben, kann nur mehr der Superdamin die Sperre aufheben.' : 'Diese Aktion hebt die Sperre auf. Wollen sie dies?']], ['title' => 'Reset', 'url' => 'system/reset', 'options' => ['data-confirm' => 'Alle Produktionsdaten werden gelöscht. Bitte stellen sie sicher, dass sie ein Backup haben. Wollen sie alles löschen?']], ['title' => 'Ergebnisse löschen', 'url' => 'system/clean', 'options' => ['data-confirm' => 'Alle Statistiken werden gelöscht. Wollen sie dies?']]]]];
     if ($is_locked == 1) {
         $items[7]['items'][1]['title'] = 'Öffnen';
     }
     echo $this->render('adminmenu', ['items' => $items]);
 }
Beispiel #17
0
 /**
  * Saves settings.
  */
 public function save()
 {
     foreach ($this->_attributes as $name => $value) {
         $_name = explode('.', $name);
         $settings = Settings::get($_name[0], $_name[1]);
         $settings->value = $value;
         $settings->save();
     }
 }
Beispiel #18
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $favicon = Settings::getSettings()['favicon'];
     $logo = Settings::getSettings()['logo'];
     $parent_categories = Category::getCategoriesByPublish(1, 0, 1);
     View::share('favicon', $favicon);
     View::share('logo', $logo);
     View::share('parent_categories', $parent_categories);
 }
 /**
  * return default field groups
  * @return mixed
  */
 public function get()
 {
     $orgId = Activity::find(request()->route()->activity)->organization_id;
     $settings = Settings::where('organization_id', $orgId)->first();
     $defaultFieldGroups = $settings->default_field_groups[0];
     $identification = isset($defaultFieldGroups['Identification']) ? $defaultFieldGroups['Identification'] : [];
     $defaultFieldGroup['Identification'] = array_merge(['reporting_organization' => 'Reporting Organization', 'iati_identifier' => 'Activity Identifier'], $identification);
     $defaultFieldGroups = $defaultFieldGroup + $defaultFieldGroups;
     return $defaultFieldGroups;
 }
Beispiel #20
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $fallback_locale = Settings::getFallBackLocale();
     $locales = Settings::getLocales();
     if (!Session::has('locale') || !in_array(Session::get('locale'), $locales)) {
         Session::put('locale', $fallback_locale);
     }
     app()->setLocale(Session::get('locale'));
     return $next($request);
 }
Beispiel #21
0
 public function destroy($id)
 {
     $admin = Settings::find($id);
     $query = $admin->delete();
     if ($query) {
         flash()->success('操作成功');
     } else {
         flash()->error('操作失败');
     }
     return redirect()->route('dashboard.setting.index');
 }
 public function actionIndex()
 {
     $settings = Settings::getAppSettings();
     $model = new SettingsForm();
     $model->loadFromArray(ArrayHelper::map($settings, 'key', 'value'));
     if ($model->load(\Yii::$app->request->post())) {
         $model->app_logo = UploadedFile::getInstance($model, 'app_logo');
         $model->save();
         return $this->refresh();
     }
     return $this->render('index', ['model' => $model]);
 }
 public function actionLock()
 {
     $is_locked = Settings::getSetting('locked');
     $setting = Settings::findOne(['pm_id' => 'locked']);
     $setting->locked = $is_locked == 1 ? 0 : 1;
     if (true == $setting->save()) {
         Yii::$app->user->logout();
         return $this->redirect(['/admin']);
     } else {
         return $this->redirect(['index']);
     }
 }
 public function actionUpdate($id)
 {
     $model = $this->findModel(Settings::className(), $id);
     if ($model->load(\Yii::$app->request->post())) {
         if ($model->save()) {
             $this->setFlash('success', \Yii::t('app', 'Modifications have been saved'));
         } else {
             $this->setFlash('error', \Yii::t('app', 'Modifications have not been saved'));
         }
         return $this->redirect('/settings/index');
     }
     return $this->render('form', ['model' => $model]);
 }
Beispiel #25
0
 /**
  * @param Request $request
  * @param string $collectionName
  * @return \Illuminate\View\View
  */
 public function editCollection(Request $request, $collectionName)
 {
     $settings = new SettingsModel();
     if (!empty($request->newCollectionName) && ($dbName = env('DB_DATABASE', ''))) {
         $newCollectionName = $request->newCollectionName;
         if ($settings->renameCollection($dbName, $collectionName, $newCollectionName)) {
             return view('json', ['data' => ['status' => false, 'errors' => $settings->isError() ? $settings->getErrors() : "Collection rename error (from [{$collectionName}] to [{$newCollectionName}])."]]);
         }
         $collectionName = $newCollectionName;
     }
     return view('json', ['data' => ['status' => $settings->editDocument($collectionName, $request->id, $request->fields), 'url' => "/settings/{$collectionName}", 'errors' => $settings->isError() ? $settings->getErrors() : NULL]]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Settings::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Beispiel #27
0
 /**
  * Site settings
  *
  * @param Request $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function index(Request $request)
 {
     $settings = Settings::getSettings();
     if ($request->isMethod('post')) {
         $rules = ['url' => 'required', 'email' => 'required|email', 'title' => 'required', 'desc' => 'required', 'keys' => 'required', 'logo' => 'mimes:jpeg,png', 'favicon' => 'mimes:jpeg,png'];
         Validator::make($request->all(), $rules)->validate();
         $settings->url = $request->input('url');
         $settings->email = $request->input('email');
         $settings->title = $request->input('title');
         $settings->desc = $request->input('desc');
         $settings->keys = $request->input('keys');
         if (!empty($request->file("logo"))) {
             if (Storage::exists('uploads/' . $settings->logo)) {
                 Storage::delete('uploads/' . $settings->logo);
             }
             $generated_string = str_random(32);
             $file = $request->file("logo")->store('uploads');
             $new_file = $generated_string . '.' . $request->file("logo")->getClientOriginalExtension();
             Storage::move($file, 'uploads/' . $new_file);
             $img = Image::make($request->file('logo'));
             $img->crop(200, 26);
             $img->save(storage_path('app/public/uploads/' . $new_file));
             $settings->logo = $new_file;
         }
         if (!empty($request->file("favicon"))) {
             if (Storage::exists('uploads/' . $settings->favicon)) {
                 Storage::delete('uploads/' . $settings->favicon);
             }
             $generated_string = str_random(32);
             $file = $request->file("favicon")->store('uploads');
             $new_file = $generated_string . '.' . $request->file("favicon")->getClientOriginalExtension();
             Storage::move($file, 'uploads/' . $new_file);
             $img = Image::make($request->file('favicon'));
             $img->crop(16, 16);
             $img->save(storage_path('app/public/uploads/' . $new_file));
             $settings->favicon = $new_file;
         }
         if ($request->input('maintenance') == '0') {
             Artisan::call('down');
         } else {
             Artisan::call('up');
         }
         $settings->maintenance = $request->input('maintenance');
         $settings->save();
         return redirect()->back();
     } else {
         return view('admin.settings', compact('settings'));
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $lead = Leads::findOrFail($request->id);
     $settings = Settings::all();
     $isAdmin = Auth()->user()->hasRole('administrator');
     $settingscomplete = $settings[0]['lead_assign_allowed'];
     if ($isAdmin) {
         return $next($request);
     }
     if ($settingscomplete == 1 && Auth()->user()->id == $lead->fk_user_id_assign) {
         Session()->flash('flash_message_warning', 'Not allowed to create lead');
         return redirect()->back();
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $task = Tasks::findOrFail($request->id);
     $settings = Settings::all();
     $isAdmin = Auth()->user()->hasRole('administrator');
     $settingscomplete = $settings[0]['task_assign_allowed'];
     if ($isAdmin) {
         return $next($request);
     }
     if ($settingscomplete == 1 && Auth()->user()->id != $task->fk_user_id_assign) {
         Session()->flash('flash_message_warning', 'Only assigned user are allowed to do this');
         return redirect()->back();
     }
     return $next($request);
 }
Beispiel #30
0
 public function save()
 {
     foreach ($this->attributes as $key => $value) {
         $setting = Settings::find()->where(['key' => $key])->one();
         if ($setting == null) {
             $setting = new Setting();
             $setting->key = $key;
         }
         $setting->value = $value;
         if (!$setting->save(false)) {
             return false;
         }
     }
     return true;
 }