Example #1
0
 /**
  * test grabbing a User that does not exist
  **/
 public function testGetInvalidUserByUserId()
 {
     // grab a user id that exceeds the maximum allowable profile id
     $user = User::getUserByUserId($this->getPDO(), InventoryTextTest::INVALID_KEY);
     $this->assertNull($user);
 }
Example #2
0
 /**
  * test inserting a user Id profile and then grabbing it from mySQL
  */
 public function testGetValidUserByUserId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("user");
     // create a new user Id profile and insert it into mySQL
     $user = new User(null, $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_USERACCOUNTTYPE, $this->VALID_USEREMAIL, $this->VALID_USERHASH, $this->VALID_USERNAME, $this->VALID_USERSALT);
     $user->insert($this->getPDO());
     // grab the data from mySQL and see if the fields match our expected values
     $pdoUser = User::getUserByUserId($this->getPDO(), $user->getUserId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("user"));
     $this->assertSame($pdoUser->getBrowser(), $this->VALID_BROWSER);
     $this->assertEquals($pdoUser->getCreateDate(), $this->VALID_CREATEDATE);
     $this->assertSame($pdoUser->getIpAddress(), $this->VALID_IPADDRESS);
     $this->assertSame($pdoUser->getUserAccountType(), $this->VALID_USERACCOUNTTYPE);
     $this->assertSame($pdoUser->getUserEmail(), $this->VALID_USEREMAIL);
     $this->assertSame($pdoUser->getUserHash(), $this->VALID_USERHASH);
     $this->assertSame($pdoUser->getUserName(), $this->VALID_USERNAME);
     $this->assertSame($pdoUser->getUserSalt(), $this->VALID_USERSALT);
 }
Example #3
0
     if ($requestObject->password !== $requestObject->passwordConfirm) {
         throw new InvalidArgumentException("passwords do not match", 400);
     }
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", $requestObject->password, $salt, 262144, 128);
     // handle optional fields
     $activation = empty($requestObject->activation) === true ? null : $requestObject->activation;
     $user = new User($userId, $requestObject->accessLevelId, false, $activation, $requestObject->email, $requestObject->firstName, $hash, $requestObject->lastName, $requestObject->phone, $requestObject->profilePath, $salt);
     $user->insert($pdo);
     $_SESSION["user"] = $user;
     $reply->data = "User created OK";
     // delete an existing User
 } else {
     if ($method === "DELETE") {
         verifyXsrf();
         $user = User::getUserByUserId($pdo, $userId);
         $user->delete($pdo);
         $reply->data = "User deleted OK";
         // put to an existing User
     } else {
         if ($method === "PUT") {
             // convert PUTed JSON to an object
             verifyXsrf();
             $requestContent = file_get_contents("php://input");
             $requestObject = json_decode($requestContent);
             $salt = bin2hex(openssl_random_pseudo_bytes(32));
             $hash = hash_pbkdf2("sha512", $requestObject->password, $salt, 262144, 128);
             $user = new User($userId, $requestObject->accessLevelId, $requestObject->activation, $requestObject->email, $requestObject->firstName, $hash, $requestObject->lastName, $requestObject->phone, $requestObject->profilePath, $salt);
             $user->update($pdo);
             $reply->data = "User updated OK";
         }
 /**
  * @author Ruffy
  * @param int $business_id
  * @return mixed
  * @description Adds an option to display the broadcast page by Business
  */
 public function getBusiness($business_id = 0)
 {
     $data = json_decode(file_get_contents(public_path() . '/json/' . $business_id . '.json'));
     $arr = explode("-", $data->display);
     if ($arr[0]) {
         $template_type = 'ads-' . $arr[1];
     } else {
         $template_type = 'noads-' . $arr[1];
     }
     if ($data->ad_type == 'image') {
         $ad_src = array();
         $res = AdImages::getAllImagesByBusinessId($business_id);
         foreach ($res as $count => $img) {
             $ad_src[] = $img->path;
         }
         /*
         $ad_directory = public_path() . '/ads/' . $business_id;
         if (file_exists($ad_directory)) {
           foreach(glob($ad_directory . '/*.*') as $filename){
             $ad_src[] = 'ads/' . $business_id . '/' . basename($filename);
           }
         }
         */
     } else {
         $ad_src = $data->ad_video;
     }
     $business_name = Business::name($business_id);
     $open_time = str_pad(Business::openHour($business_id), 2, 0, STR_PAD_LEFT) . ':' . str_pad(Business::openMinute($business_id), 2, 0, STR_PAD_LEFT) . ' ' . Business::openAMPM($business_id);
     $close_time = str_pad(Business::closeHour($business_id), 2, 0, STR_PAD_LEFT) . ':' . str_pad(Business::closeMinute($business_id), 2, 0, STR_PAD_LEFT) . ' ' . Business::closeAMPM($business_id);
     $first_service = Service::getFirstServiceOfBusiness($business_id);
     $allow_remote = QueueSettings::allowRemote($first_service->service_id);
     // Update Contact Form with Custom Fields if applicable
     $custom_fields = '';
     $forms = new FormsController();
     $fields = $forms->getFields($business_id);
     foreach ($fields as $form_id => $field_data) {
         if ($field_data['field_type'] == 'Text Field') {
             $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div>
           <div class="col-md-9"><input type="text" class="form-control custom-field" id="forms_' . $form_id . '" /></div>';
         } elseif ($field_data['field_type'] == 'Radio') {
             $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div>
           <div class="col-md-9"><label class="radio-inline"><input type="radio" name="forms_' . $form_id . '" value="' . $field_data['value_a'] . '" >' . $field_data['value_a'] . '</label><label class="radio-inline"><input type="radio" name="forms_' . $form_id . '" value="' . $field_data['value_b'] . '">' . $field_data['value_b'] . '</label></div>';
         } elseif ($field_data['field_type'] == 'Checkbox') {
             $custom_fields .= '<div class="col-md-offset-3 col-md-9 mb10 mt10"><label class="checkbox-inline"><input type="checkbox" id="forms_' . $form_id . '" value="1"/>' . $field_data['label'] . '</label></div>';
         } elseif ($field_data['field_type'] == 'Dropdown') {
             $select_options = '';
             $select_options .= '<option value="0">- Select -</option>';
             foreach ($field_data['options'] as $count => $val) {
                 $select_options .= '<option value="' . $val . '">' . $val . '</option>';
             }
             $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div>
           <div class="col-md-9"><select class="form-control custom-dropdown" id="forms_' . $form_id . '"/>' . $select_options . '</select></div>';
         }
     }
     $ticker_message = array();
     if (isset($data->ticker_message)) {
         if ($data->ticker_message != '') {
             array_push($ticker_message, $data->ticker_message);
         }
     }
     if (isset($data->ticker_message2)) {
         if ($data->ticker_message2 != '') {
             array_push($ticker_message, $data->ticker_message2);
         }
     }
     if (isset($data->ticker_message3)) {
         if ($data->ticker_message3 != '') {
             array_push($ticker_message, $data->ticker_message3);
         }
     }
     if (isset($data->ticker_message4)) {
         if ($data->ticker_message4 != '') {
             array_push($ticker_message, $data->ticker_message4);
         }
     }
     if (isset($data->ticker_message5)) {
         if ($data->ticker_message5 != '') {
             array_push($ticker_message, $data->ticker_message5);
         }
     }
     if (Auth::check()) {
         $user = User::getUserByUserId(Auth::user()->user_id);
         // business owners have different broadcast screens for display
         if (UserBusiness::getBusinessIdByOwner(Auth::user()->user_id) == $business_id) {
             if ($arr[0] == 2 || $arr[0] == 3) {
                 $ad_src = $data->tv_channel;
                 // check if TV is on
                 if ($arr[0] == 3) {
                     $template_type = 'ads-' . $arr[1] . '-2';
                 }
                 $broadcast_template = 'broadcast.default.internet-tv-master';
             } else {
                 $broadcast_template = 'broadcast.default.business-master';
             }
         } else {
             $broadcast_template = 'broadcast.default.public-master';
         }
     } else {
         $user = [];
         $broadcast_template = 'broadcast.default.public-master';
     }
     $date = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
     return View::make($broadcast_template)->with('carousel_interval', isset($data->carousel_delay) ? (int) $data->carousel_delay : 5000)->with('custom_fields', $custom_fields)->with('ad_type', $data->ad_type)->with('ad_src', $ad_src)->with('box_num', $arr[1])->with('template_type', $template_type)->with('broadcast_type', $data->display)->with('open_time', $open_time)->with('close_time', $close_time)->with('local_address', Business::localAddress($business_id))->with('business_id', $business_id)->with('business_name', $business_name)->with('lines_in_queue', Analytics::getBusinessRemainingCount($business_id))->with('estimate_serving_time', Analytics::getAverageTimeServedByBusinessId($business_id, 'string', $date, $date))->with('first_service', Service::getFirstServiceOfBusiness($business_id))->with('allow_remote', $allow_remote)->with('ticker_message', $ticker_message)->with('user', $user);
 }