Exemplo n.º 1
0
 public function viewuserAction()
 {
     if ($this->isLoggedIn() == 0) {
         $this->_redirect('/admin/index');
     }
     $this->view->loginStatus = $this->isLoggedIn();
     $fitnessUserGeneral = new FitnessUserGeneral();
     $fitnessUserSettings = new FitnessUserSettings();
     $fitnessTargets = new FitnessTargets();
     $fitnessInterest = new FitnessInterests();
     $fitnessworkoutsDone = new FitnessUserWorkoutsDone();
     $fitnessworkoutGeneralMulti = new FitnessExerciseGeneralMultilang();
     $fitnessworkoutsUnlocked = new FitnessUserWorkoutsUnlocked();
     $fitnessworkoutsCustom = new FitnessUserCustomWorkouts();
     $fitnessworkoutsMembership = new FitnessUserMembership();
     $fitnessMembershipPlans = new FitnessMembershipPlans();
     $userId = $this->_request->getParam('userId');
     $userSettingsData = $fitnessUserSettings->getUserSettings($userId);
     $usertargets = explode(",", $userSettingsData["workout_targets"]);
     $userinterests = explode(",", $userSettingsData["workout_interests"]);
     $userworkouts = $fitnessworkoutsDone->getUserWorkoutsDone($userId);
     $userworkoutsUnlocked = $fitnessworkoutsUnlocked->getUserWorkoutsUnlocked($userId);
     $userworkoutsCustom = $fitnessworkoutsCustom->getUserWorkoutCustom($userId);
     $userworkoutsMembership = $fitnessworkoutsMembership->getUserMembership($userId);
     $membershipPlan = $fitnessMembershipPlans->getPlans($userworkoutsMembership['membership_plan']);
     $userworkoutArray = array();
     $userworkoutUnlockedArray = array();
     $userworkoutCustomArray = array();
     foreach ($usertargets as $targetId) {
         $targets = $fitnessTargets->getTarget($targetId);
         $targetName[] = $targets['target_name'];
     }
     foreach ($userinterests as $interestId) {
         $interest = $fitnessInterest->getInterest($interestId);
         $interestName[] = $interest['interest_name'];
     }
     $i = 0;
     foreach ($userworkouts as $workout) {
         $workoutData = $fitnessworkoutGeneralMulti->getWorkoutName($workout['workout_id']);
         $userworkoutArray[$i]['workout_name'] = $workoutData['workout_name'];
         $userworkoutArray[$i]['workout_time'] = $workout['workout_time'];
         $userworkoutArray[$i]['workout_date'] = $workout['workout_done_date'];
         $i = $i + 1;
     }
     $k = 0;
     foreach ($userworkoutsUnlocked as $workout) {
         $workoutData = $fitnessworkoutGeneralMulti->getWorkoutName($workout['workout_id']);
         $userworkoutUnlockedArray[$k]['workout_name'] = $workoutData['workout_name'];
         $userworkoutUnlockedArray[$k]['workout_status'] = $workout['workout_purchase_status'];
         $userworkoutUnlockedArray[$k]['workout_date'] = $workout['unlocked_date'];
         $k = $k + 1;
     }
     $j = 0;
     foreach ($userworkoutsCustom as $custom) {
         $userworkoutCustomArray[$j]['workout_name'] = $custom['custom_workout_name'];
         $userworkoutCustomArray[$j]['workout_time'] = $workout['total_workout_time'];
         $userworkoutCustomArray[$j]['workout_date'] = $workout['date_created'];
         $j = $j + 1;
     }
     $this->view->userGeneralData = $fitnessUserGeneral->getUser($userId);
     $this->view->userTargetData = implode(",", $targetName);
     $this->view->userInterestData = implode(",", $interestName);
     $this->view->userSettingsData = $userSettingsData;
     $this->view->userWorkoutData = $userworkoutArray;
     $this->view->userWorkoutUnlockedData = $userworkoutUnlockedArray;
     $this->view->userWorkoutCustomData = $userworkoutCustomArray;
     $this->view->userWorkoutMembershipData = $userworkoutsMembership;
     $this->view->userMembershipName = $membershipPlan['membership_plan'];
     //get targets from the target model
 }
Exemplo n.º 2
0
 /**
  * function that displays the workout information before the video
  * @params workout id
  * @author lekha
  * @date 4/25/2012
  */
 public function playvideoAction()
 {
     $this->view->loginStatus = $this->isLoggedIn();
     //$this->_helper->layout()->setLayout('layout_workouts');
     $this->_helper->layout()->disableLayout();
     if ($this->isLoggedIn() == 0) {
         $this->_redirect('/index/login');
     }
     $this->view->workoutid = $this->_request->getParam('workout_id');
     $fitnessWorkouts = new FitnessWorkouts();
     $fitnessWorkoutsMulti = new FitnessWorkoutsMultilang();
     $fitnessWorkoutsUnlocked = new FitnessUserWorkoutsUnlocked();
     $fitnessDocuments = new FitnessExerciseDocuments();
     $fitnessRepetition = new FitnessExerciseRepetition();
     $fitnessExercises = new FitnessExerciseGeneral();
     $fitnessExerciseEquipments = new FitnessExerciseEquipments();
     $fitnessEquipmentsMulti = new FitnessEquipmentsMultilang();
     $fitnessDevices = new AppleDevices();
     $fitnessKeys = new FitnessAndroidKey();
     $fitnessFavWorkouts = new FitnessUserFavWorkouts();
     $fitnessUserSettings = new FitnessUserSettings();
     $fitnessUser = new FitnessUserGeneral();
     // get workout info
     $workoutInfo = $fitnessWorkouts->getWorkout($this->_request->getParam('workout_id'));
     $workoutMulti = $fitnessWorkoutsMulti->getWorks($this->_request->getParam('workout_id'), $this->getDefaultLanguage());
     $user_level = $this->_request->getParam('userlevel');
     $userid = $this->_request->getParam('userid');
     $userDetails = $fitnessUser->getUser($userid);
     $userSettings = $fitnessUserSettings->getUserSettings($userid);
     print_r($userDetails);
     exit;
     if ($userSettings['address_check'] != 1) {
         $this->_redirect('user/checksettings');
     }
     $defaultLang = $this->getDefaultLanguage();
     $workoutData = $fitnessWorkouts->listWorkouts($defaultLang, $user_level);
     $favWorkouts = $fitnessFavWorkouts->getFavWorkouts($userid);
     foreach ($favWorkouts as $fav) {
         $favIds[] = $fav['workout_id'];
     }
     $workout_id = $workoutInfo['id'];
     if (in_array($workout_id, $favIds)) {
         $this->view->favstatus = 1;
     } else {
         $this->view->favstatus = 0;
     }
     //umlock free workouts
     if ($this->_request->getParam('workoutUnlock') != "") {
         $unlockedArray = array();
         $unlockedArray['user_id'] = $userid;
         $unlockedArray['workout_id'] = $this->_request->getParam('workoutUnlock');
         $unlockedArray['workout_purchase_status'] = 'false';
         $unlockedArray['unlocked_date'] = date('Y-m-d');
         $unlockedArray['unlocked_status'] = 1;
         $unlockedArray['unlock_location'] = 1;
         $fitnessWorkoutsUnlocked->addData($unlockedArray);
         //send notification
         $devicetokenDetail = $fitnessDevices->getDeviceByUser($userid);
         $androidKey = $fitnessKeys->getKeyByUser($userid);
         if ($devicetokenDetail['devicetoken'] != "") {
             $this->sendNotification('lekha', "A free workout has been unlocked in fitness4.me", $devicetokenDetail['devicetoken'], '', 4);
         }
         if ($androidKey['android_key'] != "") {
             $this->sentandroid($androidKey['android_key'], "A free workout has been unlocked in fitness4.me", 4);
         }
         $this->_redirect('/user/playvideo/workout_id/' . $this->_request->getParam('workoutUnlock') . '/userlevel/' . $this->_request->getParam('userlevel') . '/userid/' . $userid);
     }
     $unlocked = $fitnessWorkoutsUnlocked->getUserWorkoutsUnlocked($userid);
     foreach ($unlocked as $workout) {
         $unlockedIds[] = $workout['workout_id'];
     }
     if (count($unlockedIds) > 0) {
         foreach ($workoutData as $work) {
             if ($work['status'] == 1) {
                 array_push($unlockedIds, $work['id']);
             }
         }
     } else {
         foreach ($workoutData as $work) {
             if ($work['status'] == 1) {
                 $unlockedIds[] = $work['id'];
             }
         }
     }
     $this->view->userunlocked = $unlockedIds;
     //get props used if any
     $exerciseList = $fitnessWorkouts->getExercises($workout_id);
     $exerArray = explode(",", $exerciseList['work_exercises']);
     foreach ($exerArray as $exer) {
         $equipmentsList = $fitnessExerciseEquipments->getEquipment($exer);
         $equipmentArray[] = explode(",", $equipmentsList['equipments_home']);
     }
     $result = array();
     foreach ($equipmentArray as $key => $value) {
         if (is_array($value)) {
             $result = array_merge($result, $value);
         } else {
             $result[$key] = $value;
         }
     }
     $equipmentArray = array_unique($result);
     $b = 0;
     foreach ($equipmentArray as $equip) {
         if ($equip != "") {
             $equipName = $fitnessEquipmentsMulti->getEquipmentById($equip, $this->getDefaultLanguage());
             if ($equipName['equipment_name'] == "chair") {
                 $equipName['equipment_name'] = "chair/s maximum no 2";
             }
             $equipments .= $equipName['equipment_name'] . ",";
             $b = $b + 1;
         }
     }
     $equipmentsStr = rtrim($equipments, ",");
     $workoutArray = $fitnessWorkouts->getWorkout($workout_id);
     if ($workoutArray['work_exercises_order'] == "") {
         $exerciseArray = explode(",", rtrim($workoutArray['work_exercises'], ','));
     } else {
         $exerciseArray = explode(",", rtrim($workoutArray['work_exercises_order'], ','));
     }
     $totalExerciseCount = count($exerciseArray);
     //build the repetition array for the videos
     $m = 1;
     foreach ($exerciseArray as $exercise) {
         $repetition = $fitnessRepetition->getRecord($exercise, $user_level);
         $video = $fitnessDocuments->getRecord($exercise);
         if ($repetition['repetitions'] > 0) {
             $repetitionArray[] = 1;
             $repetitionArray[] = 1;
             $repetitionArray[] = 1;
             if ($this->getDefaultLanguage() == 2) {
                 $intro_array = explode('.mp4', $video['poster_video']);
                 $intro_video = "intro/de/" . $intro_array[0] . "_de.mp4";
                 $stopvideo = "test/de/stop_exercise_de.mp4";
                 $otherSide = "test/de/otherside_exercise_de.mp4";
                 $recovery = "recovery/de/recovery_" . $workoutInfo['work_recovery_time'] . "_de.mp4";
                 $next = "test/de/next_exercise_de.mp4";
                 $completed = "test/de/completed_exercise_de.mp4";
             } else {
                 $intro_video = "intro/" . $video['poster_video'];
                 $stopvideo = "test/stop_exercise.mp4";
                 $otherSide = "test/otherside_exercise.mp4";
                 $recovery = "recovery/recovery_" . $workoutInfo['work_recovery_time'] . ".mp4";
                 $next = "test/next_exercise.mp4";
                 $completed = "test/completed_exercise.mp4";
             }
             $videoArray[] = $intro_video;
             $videoArray[] = $video['workout_video_file'] . "-" . $repetition['repetitions'] . ".mp4";
             $videoArray[] = $stopvideo;
             //insert the recovery here
             $videoexplode = $video['workout_video_file'] . "-" . $repetition['repetitions'];
             if (file_exists('./public/videos/' . $videoexplode . '-2.mp4')) {
                 $repetitionArray[] = 1;
                 $repetitionArray[] = 1;
                 $repetitionArray[] = 1;
                 //$repetitionArray[] =  1;
                 $videoArray[] = $otherSide;
                 $videoArray[] = $videoexplode . '-2.mp4';
                 $videoArray[] = $stopvideo;
                 //$videoArray[]    =   "test/next_exercise.mp4";
             }
             //else
             //{
             if ($workoutInfo['work_recovery_interval'] == 1 && $m != $totalExerciseCount) {
                 $repetitionArray[] = 1;
                 $videoArray[] = $recovery;
             }
             if ($workoutInfo['work_recovery_interval'] == 2) {
                 if ($m % 2 == 0) {
                     $repetitionArray[] = 1;
                     $videoArray[] = $recovery;
                 }
             }
             if ($workoutInfo['work_recovery_interval'] == 3) {
                 if ($m % 3 == 0) {
                     $repetitionArray[] = 1;
                     $videoArray[] = $recovery;
                 }
             }
             //}
             if ($m != $totalExerciseCount) {
                 $repetitionArray[] = 1;
                 $videoArray[] = $next;
             }
         }
         $m = $m + 1;
     }
     array_push($repetitionArray, 1);
     array_push($videoArray, $completed);
     $videoStr = implode(",", $videoArray);
     $repsStr = implode(",", $repetitionArray);
     $this->view->description = $workoutMulti['description_big'];
     $this->view->name = $workoutMulti['work_name'];
     $this->view->benefits = $workoutInfo['work_filter'];
     $this->view->image = $workoutInfo['work_image_list'];
     $this->view->videoStr = $videoStr;
     $this->view->repStr = $repsStr;
     $this->view->siteurl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $this->view->baseUrl();
     $this->view->userid = $userid;
     $this->view->userlevel = $user_level;
     $this->view->workoutid = $workout_id;
     $this->view->props = $equipmentsStr;
     $this->view->defaultLang = $defaultLang;
     $this->view->fullpurchase = $userDetails['workout_purchase'];
 }