Exemple #1
0
 public static function getMsgBySubject($subjectId)
 {
     $result = [];
     $cursor = \Root\Src\Model\ConnectionModel::getConnection()->query("Select * From mail where subjectId = :subjectId", ["subjectId" => $subjectId]);
     $i = 0;
     while ($i < \sizeof($cursor) && $cursor) {
         $current = new MailModel();
         $current->hydrate($cursor[$i]);
         array_push($result, $current);
         $i += 1;
     }
     return $result;
 }
Exemple #2
0
 /**
  * Méthode de sauvegarde
  * @param type $params
  */
 public static function save($params = [])
 {
     isset($params['idStructure']) ? $idStructure = $params['idStructure'] : ($idStructure = '');
     $user = AppController::getUser();
     if ($user) {
         if (!(isset($_POST['structure']) && $_POST['structure'] != '')) {
             AppController::setMsg("warning", "La champs structure doit être rempli.");
         }
         if ($idStructure != '') {
             $test = \Root\Src\Model\StructureModel::loadStructureById($idStructure);
             if ($test->getOwnerId() != $user->getId()) {
                 AppController::setMsg("error", "Vous n'êtes pas propriétaire de cette structure vous ne pouvez pas la modifier");
             }
         }
         if (!AppController::hasError()) {
             $structure = new \Root\Src\Model\StructureModel($user->getId(), $_POST['structure']);
             $structure->setId($idStructure);
             $structure->record();
             if ($idStructure == '') {
                 $idStructure = \Root\Src\Model\ConnectionModel::getConnection()->lastInsertId();
             }
             $translation = new \Root\Src\Model\TranslationModel();
             $translation->setLayoutId($idStructure);
             $translation->setLanguage('c');
             $translation->setCode($_POST['translationToC']);
             $translation->record();
             $translation->setLanguage('java');
             $translation->setCode($_POST['translationToJava']);
             $translation->record();
             $translation->setLanguage('javascript');
             $translation->setCode($_POST['translationToJavascript']);
             $translation->record();
             $translation->setLanguage('python');
             $translation->setCode($_POST['translationToPython']);
             $translation->record();
             $translation->setLanguage('php');
             $translation->setCode($_POST['translationToPhp']);
             $translation->record();
             self::load([$idStructure]);
             die;
         }
     }
     self::render();
 }
Exemple #3
0
 /**
  * Vérifie si l'utilisateur exite
  * @param type $needConfirmation
  * @return boolean, UserModel renvoie false si l'utilisateur n'existe pas sinon
  * renvoie un utilisateur
  */
 public function exist($needConfirmation = true)
 {
     if ($needConfirmation) {
         $confirmation = 1;
     } else {
         $confirmation = 0;
     }
     $statement = \Root\Src\Model\ConnectionModel::getConnection()->query('Select * From user Where :name = name and :password = password and isConfirmed = :confirmation', ['name' => $this->_name, 'password' => \Root\Src\Library\Encoder::encode($this->_password), 'confirmation' => $confirmation]);
     if ($statement != Null) {
         $result = new UserModel('', '');
         $result->hydrate($statement[0]);
     } else {
         $result = false;
     }
     return $result;
 }
 /**
  * Fonction de sauvegarde
  */
 public static function save()
 {
     $id = $_POST['idToSave'];
     $name = $_POST['name'];
     $type = $_POST['type'];
     $content = $_POST['pseudoCode'];
     //$date
     $label = $_POST['label'];
     $algorithm = new \Root\Src\Model\AlgorithmModel();
     $algorithm->setId($id);
     $algorithm->setName($name);
     $algorithm->setType($type);
     $algorithm->setContent($content);
     $algorithm->setLabel($label);
     $algorithm->setOwnerId(AppController::getUser()->getId());
     $execution = $algorithm->record();
     if ($execution && $id == '') {
         AppController::setMsg("success", "La fonction a bien été ajoutée à la base");
     } else {
         if ($execution) {
             AppController::setMsg("success", "La fonction a bien été mise à jour");
         } else {
             AppController::setMsg("error", "Une erreur lors de la connexion à la base s'est déroulée.");
         }
     }
     unset($_POST['save']);
     if ($id == '') {
         $id = \Root\Src\Model\ConnectionModel::getConnection()->lastInsertId();
     }
     self::open([$id]);
 }