コード例 #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();
     }
 }
コード例 #2
0
ファイル: ControleurRights.php プロジェクト: alexloic/abime
 public static function canAddSkills($id_user = null)
 {
     $rights = Right::getEntity(ControleurRights::parseUser($id_user));
     return $rights->getAdd_skill();
 }
コード例 #3
0
 public static function actionConnexion()
 {
     if (!defined('CURRENT_VIEW')) {
         define('CURRENT_VIEW', 'desktop');
     }
     // Pause dans le script pour limiter le brut de force
     //usleep ( 250000 );
     if (CURRENT_VIEW == 'mobile') {
         if (isset($_POST['current_id']) && !isset($_POST['current_id_alternatif']) && !ControleurRights::isActiveUser()) {
             return false;
         }
         if (isset($_POST['sign_in_username']) && isset($_POST['sign_in_password'])) {
             $session_id = ControleurConnexion::isLoginOk($_POST['sign_in_username'], $_POST['sign_in_password']);
             if ($session_id != false) {
                 return $session_id;
             } else {
                 // si erreur d'authentification
                 return false;
             }
         } else {
             if (isset($_POST['current_id']) && $_POST['current_id'] != '') {
                 // si coockie existant
                 if (ControleurConnexion::isSessionIdOk($_POST['current_id'])) {
                     // Verification de l'authentification
                     return true;
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
     } else {
         // d�onnexion de l'utilisateur s'il a été désactivé
         if (isset($_COOKIE['compte']) && !isset($_COOKIE['compte_alternatif']) && !ControleurRights::isActiveUser()) {
             ControleurConnexion::actionDeconnexion();
             return false;
         }
         // vérification de l'existence et de l'activation du compte utilisateur
         if (isset($_POST['sign_in_username']) && isset($_POST['sign_in_password'])) {
             // si connection classique
             $session_id = ControleurConnexion::isLoginOk($_POST['sign_in_username'], $_POST['sign_in_password']);
             if ($session_id != false) {
                 setcookie("compte", $session_id, time() + 2592000);
                 // coockie invalide après 1 mois
                 $_COOKIE['compte'] = $session_id;
                 return true;
             } else {
                 // si erreur d'authentification
                 return false;
             }
         } else {
             if (isset($_COOKIE['compte']) && $_COOKIE['compte'] != '') {
                 // si coockie existant
                 if (ControleurConnexion::isSessionIdOk($_COOKIE['compte'])) {
                     // Verification de l'authentification
                     setcookie("compte", $_COOKIE['compte'], time() + 2592000);
                     // mise à jour du cookie
                     return true;
                 } else {
                     ControleurConnexion::actionDeconnexion();
                     return false;
                 }
             } else {
                 return false;
             }
         }
     }
 }
コード例 #4
0
 public static function actionModifyPassword()
 {
     if (ControleurRights::canAddUser()) {
         if (isset($_POST['data']['password']) && isset($_POST['data']['id']) && strlen($_POST['data']['password']) > 7) {
             $id = $_POST['data']['id'];
             $password = $_POST['data']['password'];
             $user = User::getEntity($id);
             $user->setPassword(sha1($password . $user->getSalt()));
             $user->updateEntity();
         }
     }
 }
コード例 #5
0
ファイル: ControleurCRUD.php プロジェクト: alexloic/abime
 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);
         }
     }
 }