public function store()
 {
     $validator = Testimonial::validate(Input::only('name', 'email', 'location', 'description'));
     if ($validator->fails()) {
         return Redirect::to('/createTestimonial')->withErrors($validator)->withInput(Input::all());
     } else {
         $testimonial = new Testimonial();
         $testimonial->name = Input::get('name');
         $testimonial->email = Input::get('email');
         $testimonial->location = Input::get('location');
         $testimonial->description = Input::get('description');
         $testimonial->save();
         return Redirect::to('allTestimonials')->with('message', 'Testimonial was successfully created');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $this->layout = 'admin';
     $model = new Testimonial();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Testimonial'])) {
         $model->attributes = $_POST['Testimonial'];
         if ($model->save()) {
             $this->redirect(array('create'));
         }
     }
     $dataProvider = new CActiveDataProvider('Testimonial');
     $this->render('create', array('testimonial_model' => $dataProvider, 'model' => $model, 'pageTitle' => "testimonials"));
 }
 public function run()
 {
     $replace = \Config::get('laravel-testimonials::seed.replace');
     if ($replace) {
         \DB::table('fbf_testimonials')->delete();
     }
     $faker = \Faker\Factory::create();
     $statuses = array(Testimonial::DRAFT, Testimonial::APPROVED);
     for ($i = 0; $i < 100; $i++) {
         $testimonial = new Testimonial();
         $title = $faker->sentence(rand(1, 10));
         $testimonial->title = $title;
         $youTubeVideoFreq = \Config::get('laravel-testimonials::seed.you_tube_video_freq');
         $hasYouTubeVideos = $youTubeVideoFreq > 0 && rand(1, $youTubeVideoFreq) == $youTubeVideoFreq;
         if ($hasYouTubeVideos) {
             $testimonial->you_tube_video_id = $faker->randomElement(\Config::get('laravel-testimonials::seed.you_tube_video_ids'));
             $testimonial->image = $testimonial->image_alt = $testimonial->image_width = $testimonial->image_height = '';
         } else {
             $testimonial->you_tube_video_id = '';
             $imageFreq = \Config::get('laravel-testimonials::seed.image_freq');
             $hasImage = $imageFreq > 0 && rand(1, $imageFreq) == $imageFreq;
             if ($hasImage) {
                 $thumbnail = $faker->image(public_path(Testimonial::getImageConfig('thumbnail', 'dir')), Testimonial::getImageConfig('thumbnail', 'width'), Testimonial::getImageConfig('thumbnail', 'height'));
                 $filename = basename($thumbnail);
                 $details = $faker->image(public_path(Testimonial::getImageConfig('resized', 'dir')), rand(200, Testimonial::getImageConfig('resized', 'width')), rand(200, Testimonial::getImageConfig('resized', 'height')));
                 rename($details, public_path(Testimonial::getImageConfig('resized', 'dir')) . $filename);
                 $testimonial->image = $filename;
                 $testimonial->image_alt = $title;
             } else {
                 $testimonial->image = $testimonial->image_alt = $testimonial->image_width = $testimonial->image_height = '';
             }
         }
         $testimonial->content = '<p>' . implode('</p><p>', $faker->paragraphs(rand(1, 10))) . '</p>';
         $testimonial->source = $faker->words(rand(1, 2), true);
         $testimonial->page_title = $title;
         $testimonial->meta_description = $faker->sentence();
         $testimonial->meta_keywords = $faker->words(10, true);
         $testimonial->status = $faker->randomElement($statuses);
         $testimonial->published_date = $faker->dateTimeBetween('-3 years', '+1 month');
         $testimonial->save();
     }
     echo 'Database seeded' . PHP_EOL;
 }
 public function createFeedback()
 {
     $validator = Validator::make(Input::all(), $this->rules);
     if ($validator->passes()) {
         $testimonial = new Testimonial();
         $count = Testimonial::orderby('ID_Feedback', 'DESC')->first();
         $tampID = $count->ID_Feedback;
         $checkYear = substr(strval($tampID), 3, -5);
         $incrementID = substr($tampID, 3) + 1;
         $join = "FED" . $incrementID;
         date_default_timezone_set('Asia/Jakarta');
         $date = date('Y-m-d h:i:s', time());
         if ($checkYear == strval(date("y"))) {
             $testimonial->ID_Feedback = $join;
             $testimonial->Name = Input::get('feed-fullname');
             $testimonial->Email = Input::get('feed-email');
             $testimonial->Subject = Input::get('feed-subject');
             $testimonial->Message = Input::get('feed-message');
             $testimonial->Date = $date;
             $testimonial->Status = "Pending";
             $testimonial->save();
             return Redirect::to('/testimonial')->with('message', 'Success');
         } else {
             $testimonial = new Testimonial();
             date_default_timezone_set('Asia/Jakarta');
             $date = date('Y-m-d h:i:s', time());
             $testimonial->ID_Feedback = "FED" . date('y') . "00001";
             $testimonial->Name = Input::get('feed-fullname');
             $testimonial->Email = Input::get('feed-email');
             $testimonial->Subject = Input::get('feed-subject');
             $testimonial->Message = Input::get('feed-message');
             $testimonial->Date = $date;
             $testimonial->Status = "Pending";
             $testimonial->save();
             return Redirect::to('/testimonial')->with('message', 'Success');
         }
     } else {
         return Redirect::to('/testimonial')->withErrors($validator, 'feedback')->withInput()->with('active', 'active');
     }
 }
 public function post_create()
 {
     $new_testimonial = array('client' => trim(Input::get('client')), 'testimonial' => trim(Input::get('testimonial')), 'visibility' => trim(Input::get('visible')) ? true : false);
     // set up rules for new data
     $rules = array('client' => 'required|min:3|max:128', 'testimonial' => 'required');
     // make the validator
     $v = Validator::make($new_testimonial, $rules);
     if ($v->fails()) {
         // redirect to form
         // errors
         return Redirect::to('user/testimonials/create')->with('user', Auth::user())->with_errors($v)->with_input();
     }
     // create the new testimonial
     $testimonial = new Testimonial($new_testimonial);
     $testimonial->save();
     // add organisations to Organisation_Testimonial
     foreach (Input::get('organisations') as $org_id) {
         $testimonial->organisations()->attach($org_id);
     }
     // redirect to testimonial
     return Redirect::to('user/testimonials')->with('success', 'A new testimonial has been created');
 }
Ejemplo n.º 6
0
 private function _add()
 {
     use_helper('Validate');
     $data = $_POST['testimonial'];
     Flash::set('testimonial_postdata', $data);
     // Add pre-save checks here
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'testimonial/add')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('testimonial/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('testimonial/add'));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a testimonial name!'));
         redirect(get_url('testimonial/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('testimonial/add'));
     }
     $new_testimonial = new Testimonial($data);
     $new_testimonial->created_by_id = AuthUser::getId();
     $new_testimonial->created_on = date('Y-m-d H:i:s');
     if ($new_testimonial->save()) {
         /*if (isset($_FILES)) {
         			if(strlen($_FILES['upload_file']['name'])>0||strlen($_FILES['upload_file_home']['name'])>0){
         				$testimonial_id = $new_testimonial->lastInsertId();
         				
         				$overwrite=false;
         				if(strlen($_FILES['upload_file']['name'])>0){
         					$file = $this->upload_pdf_file($testimonial_id, $_FILES['upload_file']['name'], FILES_DIR.'/testimonial/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
         				}
         				if(strlen($_FILES['upload_file_home']['name'])>0){
         					$file2 = $this->upload_pdf_file2($testimonial_id, $_FILES['upload_file_home']['name'], FILES_DIR.'/testimonial/home/', $_FILES['upload_file_home']['tmp_name'], $overwrite);
         				}
         				if ($file === false||$file2 === false)
         				Flash::set('error', __('File has not been uploaded!'));
         	            redirect(get_url('testimonial/edit/'.$new_testimonial->id));
                 	}
         		}
         		*/
         Flash::set('success', __('Testimonial has been added!'));
         Observer::notify('testimonial_after_add', $new_testimonial->name);
         // save and quit or save and continue editing?
         if (isset($_POST['commit'])) {
             redirect(get_url('testimonial'));
         } else {
             redirect(get_url('testimonial/edit/' . $new_testimonial->id));
         }
     } else {
         Flash::set('error', __('Testimonial has not been added2!'));
         redirect(get_url('testimonial/add'));
     }
 }
Ejemplo n.º 7
0
<?php

require_once __DIR__ . DS . '..' . DS . '..' . DS . 'bootstrap.php';
$weight = 0;
if (is_cli()) {
    $testimonial = new Testimonial();
    $testimonial->setName('Peter Wang');
    $testimonial->setFrom('UNSW master student');
    $testimonial->setComment('Great service! I got my uni offer in just 20 days. Thumbs up!');
    $testimonial->setImage('files/testimonial/1.jpg');
    $testimonial->save();
    $testimonial = new Testimonial();
    $testimonial->setName('Helen White');
    $testimonial->setFrom('Staint George College');
    $testimonial->setComment('The staff at Century 21 are very open and helpful. Whenever I\'ve got any enquiry, they always respond me promptly. Nice job!');
    $testimonial->setImage('files/testimonial/2.jpg');
    $testimonial->save();
    $testimonial = new Testimonial();
    $testimonial->setName('Steven Tan');
    $testimonial->setFrom('English course student in UOW');
    $testimonial->setComment('I was an oversea student and not so good with my English. Century 21 assisted me finding the right English language instition and I now have got my college offer. All thanks to them!');
    $testimonial->setImage('files/testimonial/3.jpg');
    $testimonial->save();
    $testimonial = new Testimonial();
    $testimonial->setName('Mike Nash');
    $testimonial->setFrom('High school student at ACIIA');
    $testimonial->setComment('Very appreciated for the free consulation. Century 21 provided me all the school details free of charge. I choose their service and got the offer!');
    $testimonial->setImage('files/testimonial/4.jpg');
    $testimonial->save();
}
Ejemplo n.º 8
0
        Message::register(new Message(Message::DANGER, i18n(array("en" => "comment is required.", "zh" => "请填写comment"))));
        $error_flag = true;
    }
    // validation for $from
    $from = isset($_POST["from"]) ? strip_tags($_POST["from"]) : null;
    /// proceed submission
    // proceed for $name
    $object->setName($name);
    // proceed for $image
    $object->setImage($image);
    // proceed for $comment
    $object->setComment($comment);
    // proceed for $from
    $object->setFrom($from);
    if ($error_flag == false) {
        if ($object->save()) {
            Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
            HTML::forwardBackToReferer();
        } else {
            Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败"))));
        }
    }
}
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Testimonial', 'zh' => 'Create 客户评语'))));
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$html->renderOut('testimonial/backend/testimonial_create', array('object' => $object));
$html->output('</div>');
$html->renderOut('core/backend/html_footer');
exit;
Ejemplo n.º 9
0
 /**
  * Tests this month testimonial retrieval.
  */
 public function testCurrentTestimonial()
 {
     $this->assertNull(Testimonial::getCurrentTestimonial());
     $testi = $this->testimonials('testimonial1');
     $currentTimestamp = date('Y-m-d H:i:s');
     $testi->status = Testimonial::STATUS_NEW;
     $testi->timestamp = $currentTimestamp;
     $this->assertTrue($testi->save());
     $this->assertNull(Testimonial::getCurrentTestimonial());
     $student = $this->students('student1');
     $content = 'Test content.';
     $newTesti = new Testimonial();
     $newTesti->setAttributes(array('content' => 'Test content.', 'status' => Testimonial::STATUS_APPROVED, 'timestamp' => $currentTimestamp, 'student_id' => $student->id));
     $this->assertTrue($newTesti->save());
     $testi = Testimonial::getCurrentTestimonial();
     $this->assertNotNull($testi);
     $this->assertTrue($testi instanceof Testimonial);
     $this->assertEquals($student->id, $testi->student_id);
     $this->assertEquals($content, $testi->content);
     $this->assertEquals(Testimonial::STATUS_APPROVED, $testi->status);
     $this->assertEquals(date('m', strtotime($currentTimestamp)), date('m', strtotime($testi->timestamp)));
     $this->assertEquals($student->id, $testi->student_id);
 }