コード例 #1
0
 public static function rechargerProjet($p, $isFullLoad, $updateDate = null, Doctrine_Connection $conn = null)
 {
     $res = array('project_id', 'project_ref');
     if ($updateDate == null) {
         $updateDate = date('Y-m-d H:i:s');
     }
     $ref_id = $p->getAttribute("ref_id");
     $res['project_ref'] = $ref_id;
     $project_id = $p->getAttribute("project_id");
     $res['project_id'] = $project_id;
     $name = $p->getElementsByTagName("name")->item(0)->nodeValue;
     $description = $p->getElementsByTagName("description")->item(0)->nodeValue;
     $state = $p->getElementsByTagName("state")->item(0)->nodeValue;
     $default_notice_lang = $p->getElementsByTagName("default_notice_lang")->item(0)->nodeValue;
     $user_ref = $p->getElementsByTagName("user_ref")->item(0)->nodeValue;
     $user_id = $p->getElementsByTagName("user_id")->item(0)->nodeValue;
     /* Récupération du systeme*/
     $syst = $p->getElementsByTagName("system_id");
     if (!$syst->length > 0) {
         $system_id = null;
     } else {
         $system_id = $syst->item(0)->nodeValue;
     }
     $version = $p->getElementsByTagName("version")->item(0)->nodeValue;
     //recherche du projet en base
     if ($project_id != null && $ref_id != null) {
         $q = Doctrine_Core::getTable('EiProjet')->findOneByProjectIdAndRefId($project_id, $ref_id);
     }
     if ($q && $q != null || $q && $q != null && $isFullLoad == true) {
         //si l'element existe , on fait une mise à jour
         $q->name = $name;
         $q->description = $description;
         $q->state = $state;
         $q->system_id = $system_id;
         $q->default_notice_lang = $default_notice_lang;
         if ($isFullLoad == true) {
             //changement de la date de mise à jour du projet et de la version si mise à jour complète d'un projet
             $q->updated_at = $updateDate;
             $q->version_courante = $version;
         }
         $q->obsolete = false;
         $q->checked_at = $updateDate;
         $q->version_kalifast = $version;
         $q->save($conn);
     } else {
         //le projet n'existe pas encore et dans ce cas on le crée
         $ei_project = new EiProjet();
         $ei_project->project_id = $project_id;
         $ei_project->ref_id = $ref_id;
         $ei_project->name = $name;
         $ei_project->description = $description;
         $ei_project->state = $state;
         $ei_project->default_notice_lang = $default_notice_lang;
         $ei_project->user_id = $user_id;
         $ei_project->user_ref = $user_ref;
         $ei_project->system_id = $system_id;
         $ei_project->version_courante = 0;
         $ei_project->version_kalifast = $version;
         $ei_project->checked_at = $updateDate;
         $ei_project->obsolete = false;
         $ei_project->save($conn);
         $ei_project->createRootFolderIfNew($conn);
         /* Initialisation des statuts par défaut du projet (statuts de livraison, */
         //$this->initProjectObjStates();
     }
     return $res;
 }