public function addworkAction() { if ($this->isLoggedIn() == 0) { $this->_redirect('/admin/index'); } $this->view->loginStatus = $this->isLoggedIn(); $fitnessWorkouts = new FitnessWorkouts(); $fitnessWorkoutsMulti = new FitnessWorkoutsMultilang(); $fitnessExercises = new FitnessExerciseGeneral(); $fitnessExercisesMulti = new FitnessExerciseGeneralMultilang(); $fitnessTimeframes = new FitnessWorkoutTimeframes(); $fitnessMembers = new FitnessUserMembership(); $fitnessUnlockedWorkouts = new FitnessUserWorkoutsUnlocked(); $fitnessUser = new FitnessUserGeneral(); $listExercises = $fitnessExercises->selectRecordsWorkout(); $exerciseArray = array(); $i = 0; foreach ($listExercises as $exercise) { $exerciseArray[$i]["exercise_id"] = $exercise['workout_id']; $exerciseNameArray = $fitnessExercisesMulti->getWorkoutName($exercise['workout_id'], $this->getDefaultLanguage()); $exerciseArray[$i]["exercise_name"] = $exerciseNameArray['workout_name']; $i = $i + 1; } $exerciseArray = $this->array_sort_by_column($exerciseArray, 'exercise_name'); $this->view->listExercises = $exerciseArray; $this->view->listtimeframes = $fitnessTimeframes->listTimeframes(); $workArray = array(); $workMultiArray = array(); if ($this->_request->isPost()) { //$workImage = $_FILES["work_image"]["name"]; $workArray['work_name'] = $this->_request->getPost('work_name'); $workArray['work_image_list'] = ""; $workArray['work_exercises'] = rtrim($this->_request->getPost("exerciseslist"), ","); $workArray['work_duration'] = ""; $workArray['work_recovery_time'] = ""; $workArray['work_recovery_interval'] = ""; $workArray['work_filter'] = rtrim($this->_request->getPost("filterlist"), ","); $workArray['description_small'] = $this->_request->getPost("description_small"); $workArray['description_big'] = $this->_request->getPost("description_big"); $workArray['work_level'] = $this->_request->getPost('work_level'); // print_r($workArray);exit; $fitnessWorkouts->addData($workArray); $workID = $fitnessWorkouts->getLastWorkId(); $workMultiArray['work_name'] = $this->_request->getPost('work_name'); $workMultiArray['work_id'] = $workID['id']; $workMultiArray['lang_id'] = $this->getDefaultLanguage(); $workMultiArray['description_small'] = $this->_request->getPost("description_small"); $workMultiArray['description_big'] = $this->_request->getPost("description_big"); $fitnessWorkoutsMulti->addData($workMultiArray); //check if members exists and add the workout to their unlocked list $memberData = $fitnessMembers->getAllMemberIds(); $unlockedArray = array(); foreach ($memberData as $userId) { $unlockedArray['user_id'] = $userId['user_id']; $unlockedArray['workout_id'] = $workID['id']; $unlockedArray['workout_purchase_status'] = "true"; $unlockedArray['unlocked_date'] = date('Y-m-d'); $unlockedArray['unlocked_status'] = 1; $fitnessUnlockedWorkouts->addData($unlockedArray); } $this->_redirect('/admin/listworks'); } }
/** * 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']; }