Exemplo n.º 1
0
 public function actionAddPlanPicture()
 {
     if (isset($_FILES) && count($_FILES) > 0 && ControleurRights::canAddPlans()) {
         $plan = new Plan();
         $plan = Plan::getEntity($_POST['id_plan']);
         // Delete old picture
         if ($plan->getMedia_id() != null) {
             $old_media = Media::getEntity($plan->getMedia_id());
             $old_media->deleteEntity();
         }
         // Upload new picture
         $media_list = ControleurMedia::actionUploadNewMedia($_FILES, $_POST['id_plan'], $plan->getName());
         // Save picture to plan
         $media = $media_list[0];
         $media->setIs_main_media(true);
         $media->updateEntity();
         $plan->setMedia_id($media->getId());
         $plan->updateEntity();
     }
 }
Exemplo n.º 2
0
 public static function actionAddMedia()
 {
     if (isset($_POST['table']) && isset($_POST['table']) != '') {
         $table = $_POST['table'];
         $currentId = $_POST['id'];
         if ($table == 'projects' && ControleurRights::canAddProjects()) {
             return ControleurCRUD::addMedia('Project', $currentId, ProjectColumns::name, true);
         } elseif ($table == 'users' && ControleurRights::canAddUser()) {
             return ControleurCRUD::addMedia('User', $_POST['id'], UserColumns::first_name, true);
         } elseif ($table == 'plans' && ControleurRights::canAddPlans()) {
             return ControleurCRUD::addMedia('Plan', $currentId, PlanColumns::name, true);
         } elseif ($table == 'skills' && ControleurRights::canAddSkills()) {
             return ControleurCRUD::addMedia('Skill', $currentId, SkillColumns::name, true);
         }
     }
 }