コード例 #1
0
 /**
  * This function will create a new user object and return the newly created user object.
  *
  * @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
  *
  * @return mixed
  */
 public function registerUser(array $userInfo, $userLanguage)
 {
     $user = \User::create($userInfo);
     //make the first user an admin
     if (\User::all()->count() <= 1) {
         $user->is_admin = 1;
     }
     // Trim trailing whitespace from user first and last name.
     $user->firstname = trim($user->firstname);
     $user->lastname = trim($user->lastname);
     $user->save();
     \Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
     /* Add welcome note to user - create notebook, tag and note */
     //$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
     $notebookCreate = new \Notebook();
     $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
     $notebookCreate->save();
     $notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     //$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
     $tagCreate = new \Tag();
     $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
     $tagCreate->visibility = 0;
     $tagCreate->user_id = $user->id;
     $tagCreate->save();
     //$tagCreate->users()->attach($user->id);
     $noteCreate = new \Note();
     $versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $notebookCreate->id;
     $noteCreate->save();
     $noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     $noteCreate->tags()->sync([$tagCreate->id]);
     return $user;
 }
コード例 #2
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Setting::create([]);
     }
 }
コード例 #3
0
 /**
  * Store a newly created setting in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Setting::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Setting::create($data);
     return Redirect::route('settings.index');
 }
コード例 #4
0
ファイル: Setting.php プロジェクト: xJakub/LCE
 static function setKey($key, $value)
 {
     self::$cache[$key] = $value;
     $setting = Setting::findOne('`key` = ?', [$key]);
     if (!$setting) {
         $setting = Setting::create();
         $setting->key = $key;
     }
     $setting->value = $value;
     $setting->save();
 }
コード例 #5
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Setting::truncate();
     Schema::table('settings', function (Blueprint $table) {
         $table->string('key')->unique();
         $table->string('value')->nullable();
     });
     $settings = ['project_name' => 'Logboek', 'ex_title' => 'ex_logboek', 'ex_customer' => 'Opdrachtgever', 'ex_date' => '01-01-1970', 'ex_version' => '1.0', 'ex_disclaimer' => '', 'ex_disclaimer_html' => '', 'ex_pdf_sh_evidences' => '1', 'ex_pdf_sh_coc' => '1', 'ex_pdf_sh_attachments' => '1', 'ex_pdf_sh_suspects' => '1', 'ex_pdf_sh_legals' => '1', 'ex_html_sh_evidences' => '1', 'ex_html_sh_coc' => '1', 'ex_html_sh_attachments' => '1', 'ex_html_sh_suspects' => '1', 'ex_html_sh_legals' => '1', 'menu' => join(';', ['entries', 'logbooks', 'tasks', 'attachments', 'evidences', 'exports', 'menu', 'settings', 'intro'])];
     foreach ($settings as $key => $value) {
         Setting::create(['key' => $key, 'value' => $value]);
     }
 }
コード例 #6
0
ファイル: Settings.php プロジェクト: Grapheme/amway
 public static function decrease($name = false)
 {
     if (!$name) {
         return false;
     }
     $set = Setting::where('name', $name)->first();
     if (is_object($set)) {
         $set->value = $set->value > 0 ? $set->value - 1 : 0;
         $set->save();
         $set->touch();
     } else {
         Setting::create(array('name' => $name, 'value' => 0));
     }
     return true;
 }
コード例 #7
0
 /**
  * Stores new account
  *
  * @return  Illuminate\Http\Response
  */
 public function store()
 {
     $repo = App::make('UserRepository');
     $user = $repo->signup(Input::all());
     if ($user->id) {
         $settings = array('user_id' => $user->id, 'language' => 'en', 'currency_id' => 840);
         Setting::create($settings);
         if (Config::get('confide::signup_email')) {
             Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) {
                 $message->to($user->email, $user->username)->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
             });
         }
         return Redirect::action('UsersController@login')->with('notice', Lang::get('confide::confide.alerts.account_created'));
     } else {
         $error = $user->errors()->all(':message');
         return Redirect::action('UsersController@create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
コード例 #8
0
ファイル: InitController.php プロジェクト: digideskio/voip-id
 public function getIndex()
 {
     // truncate tables and add default user 'admin'
     DB::table('users')->truncate();
     DB::table('profiles')->truncate();
     DB::table('password_resets')->truncate();
     DB::table('settings')->truncate();
     DB::table('domains')->truncate();
     DB::table('phone_numbers')->truncate();
     DB::table('logs')->truncate();
     $profile = new Profile(array('first_name' => 'System', 'last_name' => 'Administrator', 'website' => 'https://github.com/antonraharja/laravel-startup'));
     $profile->save();
     $user = new User(array('email' => '*****@*****.**', 'username' => 'admin', 'password' => Hash::make('admin123'), 'status' => 2, 'ban' => 0));
     $user->profile()->associate($profile);
     $user->save();
     $settings = array(array('name' => 'global_prefix', 'value' => '62520'), array('name' => 'panel_path', 'value' => 'dcp'), array('name' => 'domain_limit', 'value' => '1'), array('name' => 'phone_number_limit', 'value' => '1'), array('name' => 'email_address_for_notification', 'value' => '*****@*****.**'), array('name' => 'email_address_for_admin', 'value' => '*****@*****.**'), array('name' => 'sender_name', 'value' => 'VoIP ID'), array('name' => 'sip_server', 'value' => '192.168.1.150'), array('name' => 'reserved_extension', 'value' => '100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 123456, 654321'), array('name' => 'reserved_domain_prefix', 'value' => '100, 200, 300, 400, 500, 600, 700, 800, 900, 111, 222, 333, 444, 555, 666, 777, 888, 999, 123, 456, 789, 987, 654, 321'), array('name' => 'log_file', 'value' => '/var/log/voip_id/voip_id.log'), array('name' => 'available_css', 'value' => 'default, flatly, united, lumen, yeti, paper, cerulean, cyborg, darkly, journal, readable, sandstone, simplex, slate, spacelab, superhero'));
     foreach ($settings as $setting) {
         Setting::create($setting);
     }
     // just throw something
     print_r('init done.');
 }
コード例 #9
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Setting::truncate();
     Schema::table('settings', function (Blueprint $table) {
         $table->dropColumn('project_name');
         $table->dropColumn('vw_menu_entries');
         $table->dropColumn('vw_menu_logbooks');
         $table->dropColumn('vw_menu_tasks');
         $table->dropColumn('vw_menu_attachments');
         $table->dropColumn('vw_menu_evidences');
         $table->dropColumn('vw_menu_exports');
         $table->dropColumn('vw_menu_cipher');
         $table->dropColumn('vw_menu_settings');
         $table->dropColumn('vw_menu_intro');
         $table->string('key')->unique();
         $table->string('value')->nullable();
     });
     $settings = ['project_name' => 'Logboek', 'menu' => join(';', ['entries', 'logbooks', 'tasks', 'attachments', 'evidences', 'exports', 'cipher', 'settings', 'intro'])];
     foreach ($settings as $key => $value) {
         Setting::create(['key' => $key, 'value' => $value]);
     }
 }
コード例 #10
0
 public function storeReview()
 {
     $inputs = Input::only(array('frequency', 'hour', 'minute', 'ng-word', 'id'));
     if ($inputs['id'] != null) {
         // DB更新
         $setting = Setting::where('id', '=', $inputs['id'])->update(array('frequency' => $inputs['frequency'], 'hour' => $inputs['hour'], 'minute' => $inputs['minute'], 'ng_word' => $inputs['ng-word']));
     } else {
         // 新しい設定の挿入
         $setting = Setting::create(array('frequency' => $inputs['frequency'], 'hour' => $inputs['hour'], 'minute' => $inputs['minute'], 'ng_word' => $inputs['ng-word']));
     }
     /**
      *  TODO このファイルの指定方法危険
      */
     $fp = fopen("/usr/local/www/rst.prodrb.com/bin/cron/cron.txt", 'w');
     //$text = "MAILTO=itakedaka@gmail.com\n{$inputs['minute']} {$inputs['hour']} * * * /usr/bin/php /usr/local/www/rst.prodrb.com/bin/scripts/getReviewScript.php\n";
     $text = "*/5 * * * * /usr/bin/php /usr/local/www/rst.prodrb.com/bin/scripts/getReviewScript.php\n";
     fputs($fp, $text);
     $resutl = system('crontab /usr/local/www/rst.prodrb.com/bin/cron/cron.txt');
     fclose($fp);
     // フラッシュデータ
     Session::flush('message', '設定を更新しました');
     return Redirect::route('setting.review');
 }
コード例 #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Setting::create(['index' => 'security', 'subindex' => 'password', 'parameter' => 'salt_left', 'value' => 'd5Gjh', 'description' => 'Salt esquerdo da senha', 'type' => 'string']);
     Setting::create(['index' => 'security', 'subindex' => 'password', 'parameter' => 'salt_right', 'value' => 's2Gv0', 'description' => 'Salt direito da senha', 'type' => 'string']);
 }
コード例 #12
0
ファイル: UserController.php プロジェクト: neynah/paperwork
 public function checkSandstormUsers()
 {
     if (Config::get('paperwork.emergency_export') && DB::table('migrations')->where('batch', '=', 1)->count() == Config::get('paperwork.emergency_export_count')) {
         $credentials = ["username" => "sandstorm_dummy", "password" => "sandstorm_dummy"];
         if (Auth::attempt($credentials)) {
             $settings = Setting::where('user_id', '=', Auth::user()->id)->first();
             Session::put('ui_language', $settings->ui_language);
             return View::make('user.emergency_export');
         }
     } else {
         // get permission via HTTP_X_SANDSTORM header
         $sandstorm_permissions = $_SERVER['HTTP_X_SANDSTORM_PERMISSIONS'];
         // Only when we are admin, we check and create users
         if ($sandstorm_permissions == "admin,write,read") {
             // check for admin user
             if (User::where('username', '=', 'sandstorm_admin')->count() == 0) {
                 $sandstorm_admin = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
                 if ($sandstorm_admin) {
                     //make the first user an admin
                     $sandstorm_admin->firstname = "sandstorm_admin";
                     $sandstorm_admin->lastname = " ";
                     $sandstorm_admin->username = "******";
                     $sandstorm_admin->password = "******";
                     $sandstorm_admin->is_admin = 1;
                     $sandstorm_admin->save();
                     $setting_sandstorm_admin = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_admin->id]);
                 }
             } else {
                 $sandstorm_admin = User::where('username', '=', 'sandstorm_admin');
             }
             // Then the read & write  user
             if (User::where('username', '=', 'sandstorm_readwrite')->count() == 0) {
                 $sandstorm_readwrite = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
                 if ($sandstorm_readwrite) {
                     $sandstorm_readwrite->firstname = "sandstorm_readwrite";
                     $sandstorm_readwrite->lastname = " ";
                     $sandstorm_readwrite->username = "******";
                     $sandstorm_readwrite->password = "******";
                     $sandstorm_readwrite->save();
                     $setting_sandstorm_readwrite = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readwrite->id]);
                 }
             } else {
                 $sandstorm_readwrite = User::where('username', '=', 'sandstorm_readwrite');
             }
             // Then the read only  user
             if (User::where('username', '=', 'sandstorm_readonly')->count() == 0) {
                 $sandstorm_readonly = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
                 if ($sandstorm_readonly) {
                     $sandstorm_readonly->firstname = "sandstorm_readonly";
                     $sandstorm_readonly->lastname = " ";
                     $sandstorm_readonly->username = "******";
                     $sandstorm_readonly->password = "******";
                     $sandstorm_readonly->save();
                     $setting_sandstorm_readonly = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readonly->id]);
                 }
             } else {
                 $sandstorm_readonly = User::where('username', '=', 'sandstorm_readonly');
             }
         }
         // Now that the required users are there we create the default
         if (Notebook::all()->count() == 0 && Tag::all()->count() == 0 && Note::all()->count() == 0) {
             // Notebook ...
             $notebookCreate = new Notebook();
             $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
             $notebookCreate->save();
             $notebookCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]);
             $notebookCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]);
             $notebookCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]);
             // Tag ...
             $tagCreate = new Tag();
             $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
             $tagCreate->visibility = 1;
             $tagCreate->user_id = $sandstorm_admin->id;
             $tagCreate->save();
             // Note ...
             $noteCreate = new Note();
             $versionCreate = new Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $sandstorm_admin->id]);
             $versionCreate->save();
             $noteCreate->version()->associate($versionCreate);
             $noteCreate->notebook_id = $notebookCreate->id;
             $noteCreate->save();
             $noteCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]);
             $noteCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]);
             $noteCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]);
             $noteCreate->tags()->sync([$tagCreate->id]);
         }
         // login
         if ($sandstorm_permissions == "read") {
             $credentials = ["username" => "sandstorm_readonly", "password" => "sandstorm_readonly"];
         }
         if ($sandstorm_permissions == "write,read") {
             $credentials = ["username" => "sandstorm_readwrite", "password" => "sandstorm_readwrite"];
         }
         if ($sandstorm_permissions == "admin,write,read") {
             $credentials = ["username" => "sandstorm_admin", "password" => "sandstorm_admin"];
         }
         if (Auth::attempt($credentials)) {
             $settings = Setting::where('user_id', '=', Auth::user()->id)->first();
             Session::put('ui_language', $settings->ui_language);
             return Redirect::route("/");
         }
     }
 }
コード例 #13
0
 /**
  * Enter description here...
  */
 function getsetting($name = null)
 {
     if (!$name) {
         return false;
     }
     $objSetting = new Setting();
     $setting = $objSetting->find('first', array('conditions' => array('parent_id' => '<> 0', 'name' => $name)));
     if (empty($setting)) {
         $defaultGroup = $objSetting->find('first', array('conditions' => array('parent_id' => 0, 'name' => 'Global'), 'fields' => 'id'));
         if (empty($defaultGroup)) {
             $objSetting->create(array('parent_id' => 0, 'name' => 'Global'));
             $objSetting->save() or $this->logErr('cannot create default settings group');
             $gid = $objSetting->id;
         } else {
             $gid = $defaultGroup['Setting']['id'];
         }
         $objSetting->create(array('parent_id' => $gid, 'name' => $name));
         $objSetting->save();
         //or $this->logErr('cannot create a new setting');
     } else {
         return $setting['Setting']['value'];
     }
 }
コード例 #14
0
ファイル: report.php プロジェクト: billyriantono/ihrmis
 function headings($line = '1')
 {
     Setting::create(array('name' => 'test123'));
     $data['page_name'] = '<b>Payroll Headings</b>';
     $data['msg'] = '';
     $data['rows'] = PayrollHeading::line(1)->orderBy('order')->get();
     $data['rows2'] = PayrollHeading::line(2)->orderBy('order')->get();
     $data['main_content'] = 'report/headings';
     $validator = Validator::make($data1 = array('name' => '', 'email' => '*****@*****.**'), $rules = array('name' => 'email|required|max:5', 'email' => 'email|required|max:5'));
     if ($validator->fails()) {
         // The given data did not pass validation
         $messages = $validator->messages()->all();
         foreach ($messages as $message) {
             //
             echo $message;
         }
     }
     //var_dump(class_exists('Input1'));
     //echo Input1::get('aa');
     //print_r(get_declared_classes());
     //\Illuminate\Support\Facades\Input::all();
     //$a->all();
     //var_dump($a);
     //exit;
     //$v = new View(Illuminate\View\Environment, EngineInterface, $view = '');
     //return View::make('account.register', $data);
     //exit;
     //Decoration::setLineColors();
     //$p = new Payment;
     //$p->process();
     //Input::get();
     //https://github.com/laravel/framework/issues/854
     //var_dump($validator);
     return View::make('includes/template', $data);
 }
コード例 #15
0
 private function postInstallData($siteTitle)
 {
     // Add default settings
     $host = substr_count($_SERVER['HTTP_HOST'], '.') > 1 ? substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.') + 1) : $_SERVER['HTTP_HOST'];
     $host = strpos($host, ':') !== false ? substr($host, 0, strpos($host, ':')) : $host;
     // Remove port if present on unusual configurations
     App::uses('Setting', 'Model');
     $settingModel = new Setting();
     $defaultSettings = array();
     $defaultSettings['title'] = $siteTitle;
     $defaultSettings['theme'] = json_encode(array('logo' => '/img/logo.png', 'bgcolor' => '#444444', 'bgimage' => $this->request->webroot . 'img/bg.png', 'bgrepeat' => 'repeat'));
     $defaultSettings['css'] = '';
     $defaultSettings['notifications'] = json_encode(array('enabled' => 1, 'signup' => 0, 'contact' => ''));
     $defaultSettings['email'] = json_encode(array('name' => 'MushRaider', 'from' => 'mushraider@' . $host, 'encoding' => '', 'transport' => 'Mail', 'host' => '', 'port' => '', 'username' => '', 'password' => ''));
     $defaultSettings['Mushstats'] = time();
     $defaultSettings['calendar'] = json_encode(array('weekStartDay' => 1, 'title' => 'event', 'timeToDisplay' => 'time_invitation', 'gameIcon' => 1, 'dungeonIcon' => 1));
     $defaultSettings['timezone'] = 'Europe/Paris';
     foreach ($defaultSettings as $option => $value) {
         $settingModel->create();
         $settingModel->save(array('option' => $option, 'value' => $value));
     }
     // Add default roles permissions
     $rolesPermissions = array(array('title' => __('Full permissions'), 'alias' => 'full_permissions', 'description' => __('Like Chuck Norris, he can do anything. This overwrite every permissions')), array('title' => __('Limited admin access'), 'alias' => 'limited_admin', 'description' => __('Like Robin, he can do some things but not all (like driving the batmobile or change user role)')), array('title' => __('Can manage events'), 'alias' => 'manage_events', 'description' => __('Can create, edit and delete events. Can also manage the roster for each events')), array('title' => __('Can manage own events only'), 'alias' => 'manage_own_events', 'description' => __('Can create, edit and delete own events only. Can also manage the roster for his events')), array('title' => __('Can create templates'), 'alias' => 'create_templates', 'description' => __('Can create events templates')), array('title' => __('Can create reports'), 'alias' => 'create_reports', 'description' => __('Can create events reports')));
     App::uses('RolePermission', 'Model');
     $RolePermissionModel = new RolePermission();
     foreach ($rolesPermissions as $rolesPermission) {
         $RolePermissionModel->create();
         $RolePermissionModel->save($rolesPermission);
     }
     // Add new roles permissions to existing roles
     App::uses('Role', 'Model');
     $RoleModel = new Role();
     App::uses('RolePermissionRole', 'Model');
     $RolePermissionRoleModel = new RolePermissionRole();
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('admin'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('full_permissions')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('limited_admin')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('manage_events')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_templates')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_reports')));
 }
コード例 #16
0
 public function run()
 {
     $faker = Faker::create();
     Setting::create(['answer_time' => 10, 'daily_bonus' => 10, 'general_cost' => 10, 'test_cost' => 10, 'top_bonus' => 10, 'word_cost' => 10]);
 }
コード例 #17
0
 public function run()
 {
     Setting::create(array('name' => 'ali', 'value' => 'asfafsafas'));
     Setting::create(array('name' => 'test_setting', 'value' => 'test_value'));
 }
コード例 #18
0
 public function run()
 {
     Setting::create(array('name' => 'hotel_name', 'value' => 'Open Hotel Booking'));
     Setting::create(array('name' => 'test_setting', 'value' => 'test_value'));
 }