예제 #1
0
 public static function expandirabajo($id, $itemtype, $pivot, $oldpivot = 0)
 {
     $cadenaabajo = "";
     $a = PluginRelationRelation::getDescendentsItem($itemtype, $id);
     $resuldown = PluginRelationRelation::checkArrayExpande($_SESSION['glpi_expandeabajo'], $id, $itemtype);
     if ($resuldown == true) {
         $registrodown = array('source' => $oldpivot, 'target' => $pivot, 'id' => $id, 'itemtype' => $itemtype);
         array_push($_SESSION['glpi_expandeabajo'], $registrodown);
     }
     $npivot = 0;
     $i = 1;
     /* sólo para efectos ilustrativos */
     $struct = "";
     $direction = "";
     $ramas = "";
     foreach ($a as $v) {
         //echo $v["id"]."/".$v["name"]."/".$v["name_relation"]."/".$v["itemtype"];
         $rst = PluginRelationRelation::checkArrayExpande($_SESSION['glpi_expandeabajo'], $v['id'], $v['itemtype']);
         if ($rst == true) {
             $struct .= "struct" . $i . $pivot . " [margin=0 shape=ellipse, style=filled, fillcolor=white, color=blue, label=<<TABLE border=\"0\" cellborder=\"0\">\n\t\t\t\t\t\t\t\t\t<TR><TD width=\"35\" height=\"25\" fixedsize=\"true\"><IMG SRC='" . PluginRelationRelation::getIconItem($v["itemtype"], $v["id"]) . "' scale=\"true\"/></TD><td><font face=\"Arial\" point-size=\"7\">" . $v["name"] . "</font></td></TR>\n\t\t\t\t\t\t\t\t\t<TR><TD colspan=\"2\" fixedsize=\"true\"><font face=\"Arial\" point-size=\"7\">" . PluginRelationRelation::getViewNameClass($v["itemtype"]) . "</font></TD></TR>\n\t\t\t\t\t\t   </TABLE>>];\n\t\t\t\t\t\t\t";
             $direction .= "struct" . $pivot . " -> struct" . $i . $pivot . " [ label = \"" . $v["name_relation"] . "\" penwidth = 1 fontname=Arial fontsize = 7 fontcolor = \"black\"];\n\t\t\t\t\t\t\t\t";
         } else {
             $existe = PluginRelationRelation::checkDownExists($pivot);
             //$rstpivot = "[".$pivot."-".$v['id']."-".$v['itemtype']."] >>".$existe;
             if ($existe == 1) {
                 $recurpivot = PluginRelationRelation::getTargetStructDown($_SESSION['glpi_expandeabajo'], $v['id'], $v['itemtype']);
                 $direction .= "struct" . $pivot . " -> struct" . $recurpivot . " [ label = \"" . $v["name_relation"] . "\" penwidth = 1 fontname=Arial fontsize = 7 fontcolor = \"black\"];\n\t\t\t\t\t\t";
             }
         }
         $npivot = $i . $pivot;
         $ramas .= PluginRelationRelation::expandirabajo($v["id"], $v["itemtype"], $npivot, $pivot);
         $i++;
     }
     $cadenaabajo = $struct . $direction . $ramas;
     return $cadenaabajo;
 }