public static function createDistantView(EiProjet $ei_project, EiTree $ei_parent_tree, $data, Doctrine_Connection $conn = null) { $result_file = new DOMDocument(); if ($conn == null) { $conn = Doctrine_Manager::connection(); } try { $conn->beginTransaction(); //Début de la transaction //$result_file = new DOMDocument(); //Appel du webservice $result_update = MyFunction::loadResultOfWebServiceByPostJson(MyFunction::getPrefixPath(null) . "/serviceweb/project/view/create.json", array('project_id' => $ei_project->getProjectId(), 'project_ref' => $ei_project->getRefId(), 'parent_id' => $ei_parent_tree->getId(), 'data' => $data)); $array_result = json_decode(html_entity_decode($result_update), true); //Récupération de la vue pour traitement if (count($array_result) == 0) { return false; } if (array_key_exists("error", $array_result)) { return false; } if (!$array_result[0]) { return false; } //Rechargement d'une vuew EiView::reload($array_result, $conn); $conn->commit(); return true; } catch (Exception $e) { $conn->rollback(); //return false; throw $e; } }
public static function createDistantFunction(EiProjet $ei_project, $data, EiUserDefaultPackage $defPack, EiTree $ei_parent_tree = null, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } try { $conn->beginTransaction(); //Début de la transaction //$result_file = new DOMDocument(); $ei_subject = Doctrine_Core::getTable("EiSubject")->findOneByPackageIdAndPackageRef($defPack->getTicketId(), $defPack->getTicketRef()); if ($ei_subject == null) { return false; } $result_update = MyFunction::loadResultOfWebServiceByPostJson(MyFunction::getPrefixPath(null) . "serviceweb/project/function/create.json", array('project_id' => $ei_project->getProjectId(), 'project_ref' => $ei_project->getRefId(), 'ticket_id' => $defPack->getTicketId(), 'ticket_ref' => $defPack->getTicketRef(), 'package_name' => "Package_S" . $ei_subject->getId(), 'parent_id' => $ei_parent_tree != null ? $ei_parent_tree->getId() : null, 'user_id' => $defPack->getUserId(), 'user_ref' => $defPack->getUserRef(), 'data' => $data)); $array_result = json_decode(html_entity_decode($result_update), true); //Récupération du projet pour traitement if (count($array_result) == 0) { return false; } if (array_key_exists("error", $array_result)) { return false; } if (!$array_result[0]) { return false; } //Rechargement d'une fonction KalFunction::reload($array_result, $conn); $conn->commit(); return true; } catch (Exception $e) { $conn->rollback(); //return false; throw $e; } }
public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null, $openNodes) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $items = $projets->getElementsByTagName("ei_trees"); if ($items->length > 0) { //ya t-il des éléments à traiter? $ei_trees = $items->item(0)->getElementsByTagName("ei_tree"); $collection = new Doctrine_Collection("EiTree"); if ($ei_trees != null) { foreach ($ei_trees as $ei_tree) { $id = $ei_tree->getAttribute("id"); //recherche du profil en base if ($id != null) { $q = Doctrine_Core::getTable('EiTree')->findOneById($id); } if ($q && $q != null) { //si l'element existe , on fait une mise à jour $q->name = $ei_tree->getElementsByTagName("name")->item(0)->nodeValue; $q->type = $ei_tree->getElementsByTagName("type")->item(0)->nodeValue; $q->obj_id = $ei_tree->getElementsByTagName("obj_id")->item(0)->nodeValue; $q->ref_obj = $ei_tree->getElementsByTagName("ref_obj")->item(0)->nodeValue; $q->is_root = $ei_tree->getElementsByTagName("is_root")->item(0)->nodeValue; if ($ei_tree->getElementsByTagName("path")->length > 0) { $q->path = $ei_tree->getElementsByTagName("path")->item(0)->nodeValue; } $q->project_id = $project_id; $q->project_ref = $project_ref; $q->position = $ei_tree->getElementsByTagName("position")->item(0)->nodeValue; $q->root_id = $ei_tree->getElementsByTagName("root_id")->item(0)->nodeValue; $q->save($conn); } else { //l'élément n'existe pas encore, et dans ce cas on le crée $new_ei_tree = new EiTree(); $new_ei_tree->setId($id); $new_ei_tree->name = $ei_tree->getElementsByTagName("name")->item(0)->nodeValue; $new_ei_tree->type = $ei_tree->getElementsByTagName("type")->item(0)->nodeValue; $new_ei_tree->obj_id = $ei_tree->getElementsByTagName("obj_id")->item(0)->nodeValue; $new_ei_tree->ref_obj = $ei_tree->getElementsByTagName("ref_obj")->item(0)->nodeValue; $new_ei_tree->is_root = $ei_tree->getElementsByTagName("is_root")->item(0)->nodeValue; if ($ei_tree->getElementsByTagName("path")->length > 0) { $new_ei_tree->path = $ei_tree->getElementsByTagName("path")->item(0)->nodeValue; } $new_ei_tree->project_id = $project_id; $new_ei_tree->project_ref = $project_ref; $new_ei_tree->position = $ei_tree->getElementsByTagName("position")->item(0)->nodeValue; $new_ei_tree->root_id = $ei_tree->getElementsByTagName("root_id")->item(0)->nodeValue; $new_ei_tree->save($conn); if (isset($openNodes) && array_key_exists($new_ei_tree->getId(), $openNodes)) { foreach ($openNodes[$new_ei_tree->getId()] as $i => $opened) { $copy = new EiTreeOpenedBy(); $copy->setEiTreeId($id); $copy->setUserId($opened->getUserId()); $copy->setRefId($opened->getRefId()); $copy->save($conn); } } } } return 1; } return null; } }