Exemplo n.º 1
0
 function trainingDelete()
 {
     $course_id = intval(Convert::raw2sql(@$_GET['course_id']));
     if ($course_id > 0) {
         $course = $this->course_repository->getBydId($course_id);
         $training = $course->training();
         if (!Member::currentUser()->canEditTraining($training->getIdentifier())) {
             die;
         }
         $this->course_manager->unRegister($course_id);
     }
     $this->redirect('training');
 }
 function trainingDelete()
 {
     $course_id = intval(Convert::raw2sql(@$_GET['course_id']));
     if ($course_id > 0) {
         $course = $this->course_repository->getById($course_id);
         $training = $course->getTraining();
         if (Member::currentUser()->canEditTraining($training->getIdentifier())) {
             $this->setMessage('Success', 'Training Course deleted.');
             $this->course_manager->unRegister($course_id);
         } else {
             $this->setMessage('Danger', "You don't have the permission required to edit this Training Curse");
         }
     }
     $this->redirect('training');
 }
Exemplo n.º 3
0
 /**
  * @param int $training_id
  * @param string $company_url_segment
  * @return array
  * @throws Exception
  */
 public function getCompanyTraining($training_id, $company_url_segment)
 {
     if (empty($company_url_segment)) {
         throw new Exception("Invalid Company");
     }
     //@todo: remove dataobjects dependencies
     $company = Company::get()->filter('URLSegment', $company_url_segment)->first();
     $training = empty($training_id) ? null : TrainingService::get()->byID($training_id);
     if (!$company) {
         throw new Exception("Invalid Company");
     }
     if (!$training) {
         //get default program
         $training = $company->getDefaultTraining();
     }
     //check if program belongs to selected company
     $training_company = $training->Company();
     if ($training_company->getIdentifier() != $company->getIdentifier()) {
         //if not , get default program
         $training = $company->getDefaultTraining();
     }
     if (!$this->training_manager->isActive($training->getIdentifier())) {
         return Security::permissionFailure($this->controller, "non active training!.");
     }
     $courses = $this->training_manager->getCoursesByDate($training->getIdentifier(), DateTimeUtils::getCurrentDate());
     $courses_vm = new ArrayList();
     foreach ($courses as $course) {
         $course_dto = new CourseDTO($course->getIdentifier(), $course->getName(), $course->getDescription(), $course->getTraining()->getIdentifier(), null, null, null, $course->level()->Level, $course->isOnline(), null, null, null, null, null, $course->getOnlineLink());
         $locations_dto = $this->course_repository->getLocationsByDate($course->getIdentifier(), DateTimeUtils::getCurrentDate());
         $locations_vm = new ArrayList();
         foreach ($locations_dto as $location_dto) {
             $locations_vm->push(new CourseLocationViewModel($location_dto));
         }
         $courses_vm->push(new CourseViewModel($course_dto, $locations_vm, $course->projects()));
     }
     $res = array('Company' => $company, 'Training' => $training, 'Courses' => $courses_vm, 'Slug' => $training->getSlug());
     return $res;
 }