function checkAddNode($pid, $isConnector, $link1, $link2, $link3) { $count = getCountByPid($pid); if ($count >= 6) { return "Pattern is full"; } if ($isConnector == 1) { if (getConnectorByPid($pid) != null) { return "already exist a connector in this pattern"; } } elseif ($isConnector == 0) { if (getConnectorByPid($pid) == null) { return "This pattern do not exist,please create a connector for it"; } if ($link1 == null && $link2 == null && $link3 == null) { return "A normal node must need to connect to the other node(s)"; } } if (getLinkCountByNid($link1) >= 3) { return "Can not connect to Node" . $link1 . " because it has already connected with three nodes"; } if (getLinkCountByNid($link2) >= 3) { return "Can not connect to Node" . $link2 . " because it has already connected with three nodes"; } if (getLinkCountByNid($link3) >= 3) { return "Can not connect to Node" . $link3 . " because it has already connected with three nodes"; } return "true"; }
// return; } if (count($nodes1) < 1) { echo "You need to connect to at least one node\n"; $flag = false; } if ($flag) { insertNode($nid, 1, $pid, $pName, $nName, "yes", $did); foreach ($nodes1 as $key => $value) { insertLink($nid, $value); } echo "success"; } } else { $pid = $_POST['pid']; $count = getCountByPid($pid); if ($count >= 6) { echo "The pattern is full\n"; $flag = false; } $nodes0 = $_POST['nodes0']; if ($nodes0 == null) { echo "You need to connect to at least one node\n"; $flag = false; } if (count($nodes0) == 0) { echo "You need to connect to at least one node\n"; $flag = false; } if (count($nodes0) > 3) { echo "Please select at most three nodes\n";