コード例 #1
0
 public function register()
 {
     $this->auth->force_authentication();
     $user_nick = $this->auth->get_user();
     $errors = [];
     $user_details = $this->model->is_registered_for_ttt($user_nick);
     if (!$user_details && $_SERVER['REQUEST_METHOD'] === 'POST') {
         required_post_params(['contact_number'], $errors);
         if (!empty($_POST['contact_number']) && !is_valid_phone_number($_POST['contact_number'])) {
             $errors['contact_number'] = 'Please enter a valid phone number';
         }
         if (!$errors) {
             $success = $this->model->register_for_ttt($user_nick, $_POST['contact_number']);
             if ($success) {
                 $redirect_url = $this->get_ttt_payment_url($user_nick, $_POST['contact_number']);
                 $this->load_library('http_lib', 'http');
                 $this->http->redirect($redirect_url);
             } else {
                 $errors['common'] = 'Some unexpected error occured';
             }
         }
     }
     $payment_url = $this->get_ttt_payment_url($user_nick, $user_details['contact_number']);
     $this->load_view('skeleton_template/header', ['title' => __('Register') . ' · ' . __('Terribly Tiny Tales Workshop'), 'is_authenticated' => true, 'user_nick' => $user_nick]);
     $this->load_view('contest/ttt_workshop', ['user_nick' => $user_nick, 'user_details' => $user_details, 'payment_url' => $payment_url, 'errors' => $errors]);
     $this->load_view('skeleton_template/footer');
 }
コード例 #2
0
 public function webdev_workshop()
 {
     $user_nick = $this->auth->get_user();
     $user_details = $this->model->is_registered_for_webdev($user_nick);
     if ($user_details) {
         $this->go_to_webdev_workshop_payment($user_details);
     } else {
         $errors = [];
         if ($_SERVER['REQUEST_METHOD'] === 'POST') {
             required_post_params(['contact_number', 'stream', 'year', 'experience', 'why_join'], $errors);
             if (!empty($_POST['contact_number']) && !is_valid_phone_number($_POST['contact_number'])) {
                 $errors['contact_number'] = 'Please enter a valid phone number';
             }
             if (!$errors) {
                 $user_details = ['nick' => $user_nick, 'contact_number' => $_POST['contact_number'], 'stream' => $_POST['stream'], 'year' => $_POST['year'], 'experience' => $_POST['experience'], 'why_join' => $_POST['why_join']];
                 if ($this->model->register_for_webdev($user_details)) {
                     $this->go_to_webdev_workshop_payment($user_details);
                 } else {
                     $errors['common'] = __('Some unexpected error occurred');
                 }
             }
         }
         $this->load_view('skeleton_template/header', ['title' => __('Register') . ' · ' . __('Web development Workshop'), 'is_authenticated' => true, 'user_nick' => $user_nick]);
         $this->load_view('contest/webdev_workshop', ['user_nick' => $user_nick, 'errors' => $errors]);
         $this->load_view('skeleton_template/footer');
     }
 }