/** * [checkPrivacyInit description] * @param [type] $name_en [description] * @return [type] [description] */ public function checkPrivacyInit($name_en) { $rs = PrivacyInit::where('name_en', '=', $name_en)->count(); if (isset($rs)) { return $rs >= 1 ? false : true; } }
public function run() { $faker = Faker::create(); PrivacyInit::truncate(); $now = date('Y-m-d H:i:s'); $raw = array(array("name_en" => 'fname', "name_th" => 'ชื่อผู้ใช้งาน', "privacy_type" => '1', "removeable" => false, "init_value" => true, "created_at" => $now, "updated_at" => $now), array("name_en" => 'lname', "name_th" => 'นามสกุล', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now), array("name_en" => 'role', "name_th" => 'บทบาท', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now), array("name_en" => 'email', "name_th" => 'อีเมล์', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now), array("name_en" => 'telno', "name_th" => 'เบอร์ติดต่อ', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now), array("name_en" => 'agency', "name_th" => 'หน่วยงานสังกัด', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now), array("name_en" => 'department', "name_th" => 'ทบวงกรม', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now), array("name_en" => 'ministry', "name_th" => 'กระทรวง', "privacy_type" => '1', "removeable" => false, "init_value" => false, "created_at" => $now, "updated_at" => $now)); foreach (range(0, 7) as $index) { PrivacyInit::create(["name_en" => $raw[$index]['name_en'], "name_th" => $raw[$index]['name_th'], "privacy_type" => $raw[$index]['privacy_type'], "init_value" => $raw[$index]['init_value'], "removeable" => $raw[$index]['removeable'], "created_at" => $raw[$index]['created_at'], "updated_at" => $raw[$index]['updated_at']]); } }
/** * [userPeerPrivacy show informatioin of user by user's privacy in modal] * @param [integer] $id [user id] * @return [type] [description] */ public function userPeerPrivacy($id) { $user_info = new Usernhc(); $rs_userinfo = $user_info->getUsernhcPrivacyById($id); $arr_userinfo = json_decode(json_encode($rs_userinfo), true); // var_dump($arr_userinfo); // // $privacy = new Privacy; // $user_privacy = $privacy->getUserPrivacy($id); $privacyInit = PrivacyInit::orderBy('id', 'asc')->get(); // var_dump($privacyInit); return View::make('peer.ajax_userprivacy')->with('user_info', $arr_userinfo[0])->with('user_privacy', $privacyInit); }
/** * [privacyDelete description] * @param [type] $id [description] * @return [type] [description] */ public function privacyDelete($id) { PrivacyInit::where('id', '=', $id)->delete(); return Redirect::to('privacy/' . Auth::user()->id)->with('success', 'ลบทิ้งสำเร็จ'); }
public function registerAction() { Input::flash(); $data = Input::all(); $nhc_config = Config::get('nhc/site.init_privacy'); $rules = array('fname' => 'required', 'agency_id' => 'required', 'username' => 'required | alpha_dash', 'username' => 'required', 'password' => 'required | min:6 |same:password_confirmation', 'password_confirmation' => 'required', 'email' => 'required | email '); $messages = array('fname.required' => 'กรุณาระบุชื่อผู้ใช้งาน', 'agency_id.required' => 'กรุณาระหน่วยงานสังกัด', 'username.required' => 'กรุณาระบุชื่อผู้ใช้งาน', 'username.alpha_dash' => 'ชื่อผู้ใช้งานต้องประกอบด้วยตัวอักษร ตัวเลข หรืออันเดอร์สกอร์เท่านั้น', 'password.required' => 'กรุณาระบุรหัสผ่าน', 'password.min' => 'ความยามรหัสผ่านอย่างน้อย :min อักษร', 'password.same' => 'รหัสผ่านที่กรอกไม่ตรงกัน', 'password_confirmation.required' => 'กรุณาระบุรหัสผ่านอีกครั้ง', 'email.required' => 'กรุณาระบุอีเมล์', 'email.email' => 'รูปแบบอีเมล์ไม่ถูกต้อง'); $validator = Validator::make($data, $rules, $messages); if ($validator->passes()) { $usernhc = new Usernhc(); $ck_email = $usernhc->checkUserByEmail($data['email']); $ck_username = $usernhc->checkUsername($data['username']); if (!$ck_email && !$ck_username) { $usernhc->agency_id = $data['agency_id']; $usernhc->grp_id = $data['grp_id']; $usernhc->username = $data['username']; $usernhc->password = Hash::make($data['password']); $usernhc->email = $data['email']; $usernhc->fname = $data['fname']; $usernhc->lname = $data['lname']; $usernhc->telno = $data['telno']; $usernhc->status = $data['status']; $usernhc->save(); //set basic privacy to new user $privacy = new Privacy(); $privacy->userid = $usernhc->getUserIdByUserName($data['username']); // $privacy->fname = true; // $privacy->lname = false; // $privacy->email = false; // $privacy->telno = false; // $privacy->agency = false; // $privacy->ministry = false; // $privacy->role = false; $rs = PrivacyInit::all()->toArray(); foreach ($rs as $key => $value) { $result[$value['name_en']]['val'] = $value['init_value']; $result[$value['name_en']]['th'] = $value['name_th']; $result[$value['name_en']]['en'] = $value['name_en']; } $privacy->fname = $result['fname']['val']; $privacy->lname = $result['lname']['val']; $privacy->email = $result['email']['val']; $privacy->telno = $result['telno']['val']; $privacy->agency = $result['agency']['val']; $privacy->ministry = $result['ministry']['val']; $privacy->role = $result['role']['val']; $privacy->save(); $role = new RoleUser(); $role->role_id = 6; $role->user_id = $usernhc->getUserIdByUserName($data['username']); $role->save(); return Redirect::route('login')->with('success', 'ระบบบันทึกการลงทะเบียนสำเร็จกรุณารอ 24 ชั่วโมงจึงจะสามารถเข้าใช้งานระบบได้'); } else { return Redirect::route('regis')->withInput()->withErrors(array('message' => 'อีเมล์หรือชื่อผู้ใช้งานมีอยู่ในระบบแล้ว')); } } else { return Redirect::route('regis')->withErrors($validator); } }