/**
  * @param $masterCategoryKey
  * @param $masterEntityKey
  * @param $masterFieldKey
  * @param $embeddedCategoryKey
  * @param $embeddedEntityKey
  * @param $id
  * @return mixed
  */
 function edit($masterCategoryKey, $masterEntityKey, $masterFieldKey, $embeddedCategoryKey, $embeddedEntityKey, $id)
 {
     // We flush input if we came directly from the master form, because Input::old() can otherwise be conflictual
     // (in case of attributes with same key)
     if (!Input::old("masterInstanceData")) {
         Input::flush();
     }
     return $this->form($masterCategoryKey, $masterEntityKey, $masterFieldKey, $embeddedCategoryKey, $embeddedEntityKey, $id);
 }
Example #2
0
 public function post_view()
 {
     $deletedIds = Input::get('delete');
     $search = Input::get('search');
     $i = 0;
     if (isset($deletedIds)) {
         foreach ($deletedIds as $delete) {
             Comment::find($delete)->delete() && ++$i;
         }
         return Redirect::to('/admin/comments/view')->with('message', $i . " comment(s) deleted");
     }
     if (strlen($search) > 1) {
         return Redirect::to('/admin/comments/view?filterby=search&value=' . $search);
     }
     Input::flush();
     return Redirect::to('/admin/comments/view')->with('message', ' [no action performed]');
 }
Example #3
0
 function post_add()
 {
     //Flash current values to session
     Input::flash();
     //Same action is used for editing and adding a new category
     $username = Input::get("userName");
     $password = Input::get("userPassword");
     $saving_id = Input::get('editingMode');
     $tempType = Input::get('type');
     $userDisplayName = Input::get('userDisplayName');
     if (!cmsHelper::isCurrentUserAllowedToPerform('users') && $saving_id != Auth::user()->id) {
         return;
     }
     //Add rules here
     $rules = array('userName' => 'required|max:100', 'userPassword' => 'required', 'userDisplayName' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to('/admin/users/add')->with_errors($validation);
     }
     $present = User::where('username', '=', $username)->count();
     if (empty($saving_id) && $present > 0) {
         return Redirect::to('/admin/users/add')->with("errormessage", "User with the same 'username' already exists");
     }
     $present = User::where('displayname', '=', $userDisplayName)->count();
     if (empty($saving_id) && $present > 0) {
         return Redirect::to('/admin/users/add')->with("errormessage", "User with the same 'displayname' already exists");
     }
     $temp = !empty($saving_id) ? User::find($saving_id) : new User();
     $temp->username = $username;
     $temp->password = Hash::make($password);
     $temp->displayname = $userDisplayName;
     if (isset($tempType)) {
         $temp->type = $tempType + 2;
     }
     $temp->save();
     Input::flush();
     return Redirect::to('/admin/users/add')->with("successmessage", !empty($saving_id) ? "User Edited successfuly" : "New User Added successfully");
 }
Example #4
0
 public function post_index($category, $title, $id, $idparent = null)
 {
     $id = !is_null($idparent) ? $idparent : $id;
     Input::flash();
     //check if unregistered users' are allowed to post
     if (Setting::find(5)->value != 1 && Auth::guest()) {
         echo " Only Registered user's can post comments";
         die;
     }
     if (Setting::find(6)->value < strlen(Input::get('content'))) {
         echo " Comment size cannot be greater than " . Setting::find(6)->value . ' characters ';
         die;
     }
     //Add rules here
     $rules = array('name' => 'required|max:100', 'email' => 'required|email', 'content' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Redirect::to($_SERVER['PATH_INFO'] . '#commentheading')->with_errors($validation);
     }
     $newComment = new Comment();
     $newComment->name = Input::get('name');
     $newComment->email = Input::get('email');
     $newComment->content = Input::get('content');
     $newComment->article_id = $id;
     $newComment->approved = 1;
     $blacklists = explode(',', Setting::find(8)->value);
     foreach ($blacklists as $blword) {
         if (false !== strpos($newComment->content, $blword)) {
             $newComment->approved = 0;
             break;
         }
     }
     $newComment->save();
     Input::flush();
     return Redirect::to($_SERVER['PATH_INFO'] . '#comment-' . $newComment->id);
 }
Example #5
0
 public function post_view()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('settings')) {
         return;
     }
     Input::flash();
     //Add rules here
     $rules = array('articlelimit' => 'required', 'articlesize' => 'required', 'commentsize' => 'required', 'convertemotions' => 'required', 'maintenance' => 'required', 'textboxrows' => 'required', 'unregistercomments' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Redirect::to("/admin/settings/view")->with_errors($validation);
     }
     $settings = Setting::all();
     foreach ($settings as $setting) {
         $setting->value = Input::get($setting->keyname);
         $setting->save();
     }
     Input::flush();
     return Redirect::to("/admin/settings/view")->with("successmessage", "Settings updated");
 }
Example #6
0
 function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('tags')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     //Same action is used for editing and adding a new category
     $tag_title = Input::get("tagName");
     $tag_url = Input::get("tagNameUrl");
     $saving_id = Input::get('editingMode');
     //Add rules here
     $rules = array('tagName' => 'required|max:100', 'tagNameUrl' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     $checkIfTagExists = Tag::where('id', '!=', $saving_id)->where('turl', '=', $tag_url)->count();
     //Check if same tag exists
     if ($checkIfTagExists > 0) {
         return Redirect::to('/admin/tags/add')->with("errormessage", "Tag with the same url already exists");
     }
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to('/admin/tags/add')->with_errors($validation);
     }
     $temp = !empty($saving_id) ? Tag::find($saving_id) : new Tag();
     $temp->turl = $tag_url;
     $temp->tname = $tag_title;
     $temp->save();
     Input::flush();
     if (!empty($saving_id)) {
         return Redirect::to('/admin/tags/edit?id=' . $saving_id)->with('successmessage', "Tag Edited successfully");
     } else {
         return Redirect::to('/admin/tags/add')->with("successmessage", "New Tag Added successfully");
     }
 }
Example #7
0
 public function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('articles')) {
         return;
     }
     Input::flash();
     $articlecontent = Input::get('ArticleContent');
     $category = Input::get('ArticleCategory');
     $title = Input::get('ArticleTitle');
     $innercat = Input::get('ArticleCategoryInner');
     $saving_id = Input::get('ArticleEditing');
     $articleUrl = Input::get('ArticleTitleUrl');
     $articleStatus = Input::get('StatusSelect');
     $articletype = Input::get('ArticleType');
     $onlySelectTitle = Input::get('OnlyTitleSelect');
     $comments = Input::get('Comments');
     $author = Input::get('Author');
     $addedTags = !isset($_POST['selectorbox']) ? array() : $_POST['selectorbox'];
     //Add rules here
     $rules = array('ArticleTitle' => 'required|max:100', 'ArticleTitleUrl' => 'required', 'ArticleCategory' => 'required', 'ArticleContent' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if (!empty($saving_id) && $validation->fails()) {
         return Redirect::to('/admin/articles/edit?id=' . $saving_id)->with_errors($validation)->with('EditedTags', $addedTags);
     } elseif ($validation->fails()) {
         return Redirect::to('/admin/articles/add')->with_errors($validation)->with('EditedTags', $addedTags);
     }
     if (isset($innercat)) {
         $category = $innercat;
     }
     $temp = !empty($saving_id) ? Article::find($saving_id) : new Article();
     $temp->content = $articlecontent;
     $temp->category_id = $category;
     $temp->title = $title;
     $temp->url = $articleUrl;
     $temp->status = $articleStatus;
     $temp->onlytitle = $onlySelectTitle;
     $temp->articletype = $articletype;
     $temp->author_id = Auth::user()->type == 1 ? $author + 1 : Auth::user()->id;
     $temp->comments = $comments;
     $temp->Tags()->delete();
     echo $temp->save();
     foreach ($addedTags as $tagName) {
         $tagt = Tag::where("tname", "=", $tagName)->first();
         $temp->Tags()->attach($tagt->id);
     }
     Input::flush();
     if (!empty($saving_id)) {
         return Redirect::to('/admin/articles/edit?id=' . $saving_id)->with('EditedTags', $addedTags)->with("successmessage", "Article Edited successfully");
     } else {
         return Redirect::to('/admin/articles/edit?id=' . $temp->id)->with('EditedTags', $addedTags)->with("successmessage", "Article Posted");
     }
 }
Example #8
0
 /**
  * Test the Input::flush method.
  *
  * @group laravel
  */
 public function testFlushMethodClearsFlashedInput()
 {
     $this->setSession();
     $input = array('name' => 'Taylor', 'age' => 30);
     Request::foundation()->request->add($input);
     Input::flash();
     $this->assertEquals($input, Session::$instance->session['data'][':new:']['laravel_old_input']);
     Input::flush();
     $this->assertEquals(array(), Session::$instance->session['data'][':new:']['laravel_old_input']);
 }
 public function postregister()
 {
     $rules = array('state' => 'required', 'city' => 'required', 'other_city' => 'required_if:city,other', 'centre' => 'required_if:city,other', 'school' => 'required', 'name' => "required_if:school,other|string", 'addr1' => 'required_if:school,other', 'pincode' => 'required_if:school,other|digits:6', 'contact' => 'required_if:school,other', 'squad' => 'required', 'language' => 'required', 'name1' => "required|Regex:/^[\\p{L} .'-]+\$/", 'email1' => 'required|email', 'contact1' => 'required|numeric', 'name2' => "required|Regex:/^[\\p{L} .'-]+\$/", 'email2' => 'required|email', 'contact2' => 'required|numeric');
     $messages = array('name.regex' => 'School name can have words, commas, dashes, single quotes and dots.', 'pincode.digits' => 'Pincode can have exactly 6 digits.', 'contact.numeric' => 'School contact can have only digits.', 'name1.regex' => 'Name of Particpant 1 can have words, commas, dashes, single quotes and dots.', 'contact1.numeric' => 'Contact of Participant 1 can have only digits.', 'email1.email' => 'Email ID of Participant 1 has to be a valid email address.', 'name2.regex' => 'Name of Particpant 2 can have words, commas, dashes, single quotes and dots.', 'contact2.numeric' => 'Contact of Participant 2 can have only digits.', 'email2.email' => 'Email ID of Participant 2 has to be a valid email address.');
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         Input::flash();
         return Redirect::to('register')->withErrors($validator)->withInput();
     } else {
         if (Input::get('city') === 'other') {
             $city = new City();
             $city->name = ucwords(strtolower(Input::get('other_city')));
             $city->state_id = Input::get('state');
             $state = State::where('id', Input::get('state'))->first();
             $city->region = $state->region;
             //                $code=City::where('region', $state->region)->orderBy('code', 'desc')->first();
             //                $city->code=($code->code) + 1;
             $city->save();
             $cities = City::where('name', Input::get('other_city'))->orderBy('id', 'desc')->first();
             $city = $cities->id;
         } else {
             $city = Input::get('city');
         }
         if (Input::get('centre') !== "") {
             $centre = Input::get('centre') * 10;
         } else {
             $centre = $city * 10;
         }
         if (Input::get('school') === 'other') {
             $school = new School();
             $school->name = strtoupper(Input::get('name'));
             $school->address = strtoupper(Input::get('addr1') . ', ' . Input::get('addr2'));
             $school->pincode = Input::get('pincode');
             $school->contact = Input::get('contact');
             $school->email = Input::get('email');
             $school->city_id = $city;
             $school->save();
             $schools = School::where('name', Input::get('name'))->orderBy('id', 'desc')->first();
             $school = $schools->id;
         } else {
             $school = Input::get('school');
         }
         $user = new User();
         $user->name1 = strtoupper(Input::get('name1'));
         $user->email1 = Input::get('email1');
         $user->contact1 = Input::get('contact1');
         $user->name2 = strtoupper(Input::get('name2'));
         $user->email2 = Input::get('email2');
         $user->contact2 = Input::get('contact2');
         $user->squad = Input::get('squad');
         $user->school_id = $school;
         $user->language = Input::get('language');
         $user->city_id = $city;
         $user->centre_id = $centre;
         $roll = "";
         if (Input::get('squad') === 'JUNIOR') {
             $roll = "J";
         } else {
             $roll = "H";
         }
         if (Input::get('language') === 'en') {
             $roll .= "E";
         } else {
             $roll .= "H";
         }
         $centre_id = City::where('id', $centre / 10)->orderBy('id')->first();
         //            $code=$centre_id->id;
         $roll .= $centre_id->code;
         $roll .= 1;
         $lastroll = User::withTrashed()->where('roll', 'LIKE', "%{$roll}%")->count();
         $roll .= str_pad(strval($lastroll + 1), 4, "0", STR_PAD_LEFT);
         $user->roll = $roll;
         $user->year = 2015;
         $password = str_random(6);
         $user->password = Hash::make($password);
         $user->save();
         $school = School::find($user->school_id);
         $city = City::find($user->city_id);
         $state = State::find($city->state_id);
         Mail::send('emails.registered', array('user' => $user, 'school' => $school, 'city' => $city, 'state' => $state, 'password' => $password, 'name' => $user->name1), function ($message) use($user) {
             $message->to($user->email1, $user->name1)->subject('Technothlon Registration Details');
         });
         Mail::send('emails.registered', array('user' => $user, 'school' => $school, 'city' => $city, 'state' => $state, 'password' => $password, 'name' => $user->name2), function ($message) use($user) {
             $message->to($user->email2, $user->name2)->subject('Technothlon Registration Details');
         });
         Input::flush();
         //            return Redirect::route('home');
         return View::make('layouts.registersuccess')->with('user', $user);
     }
 }
Example #10
-1
 public function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('categories')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     global $category_title;
     //Same action is used for editing and adding a new category
     $category_title = Input::get("categoryName");
     $category_url = Input::get("categoryNameUrl");
     $parnet_id = Input::get("parentId");
     $category_desc = Input::get("description");
     $saving_id = Input::get('editingMode');
     $counter = 0;
     if ($parnet_id == 0) {
         $counter = Category::where('id', '!=', $saving_id)->where('curl', '=', $category_url)->count();
     } else {
         $counter = Category::where('id', '!=', $saving_id)->where('parent_id', '=', $parnet_id)->where('curl', '=', $category_url)->count();
     }
     //Add rules here
     $rules = array('categoryName' => 'required|max:100', 'categoryNameUrl' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($counter > 0 || $validation->fails()) {
         if ($counter == 0) {
             return Redirect::to('/admin/categories/add')->with_errors($validation);
         } else {
             return Redirect::to('/admin/categories/add')->with('errormessage', 'Category with the same name already exists (having the same settings)');
         }
     }
     /* //Check if a category with the same name exists (skip current editing category)
        if (Category::where("cname", '=', $category_title)->where("parent_id", '=', $parnet_id)->where("id", '!=', $saving_id)->count() > 0) {
            echo "Category already present";
            die();
        }*/
     //Check if edit/new post action is performed
     $saveCategory = !empty($saving_id) ? Category::find($saving_id) : new Category();
     $saveCategory->cname = $category_title;
     $saveCategory->curl = $category_url;
     $saveCategory->cdescription = $category_desc;
     $saveCategory->parent_id = $parnet_id != 0 ? $parnet_id : null;
     $saveCategory->save();
     Input::flush();
     //Print appropriate message
     if (!empty($saving_id)) {
         return Redirect::to('/admin/categories/edit?id=' . $saving_id)->with('successmessage', 'Category Edited Successfully');
     } else {
         return Redirect::to('/admin/categories/add')->with('successmessage', 'New Category Added Successfully');
     }
 }