query("SELECT MAX(rlid) as max FROM link WHERE nid = {$node->nid}"); if (PEAR::isError($result)) { trigger_error($result->getUserInfo(), E_USER_ERROR); } $row =& $result->fetchRow(); if ($row) { $rlid = $row['max'] + 1; } else { $rlid = 1; } foreach ($_POST as $k => $val) { if (substr($k, 0, 5) == "save_") { $r =& unserializeRectangle($val); $lid = substr($k, 5); $link = new DB_DataObject_Link; $link->lid = $lid; $link->rlid = $rlid; $link->nid = $node->nid; $link->to_title = $r->getLink(RECTANGLE_RAW_LINK); $result = $link->insert(); if (PEAR::isError($result)) { trigger_error($result->getMessage(), E_USER_ERROR); } } } // /** Perform sql query */ // $validated_title = validate_name($_POST['title']); // $sql = sprintf("SELECT COUNT(*) FROM `node` WHERE `title`='%s'", $validated_title); // $result = $DB->getOne($sql); // // if ($result == 0) { // $sql = sprintf("INSERT INTO `%s` SET title='%s', map='%s'", 'node', $validated_title, mysql_escape_string($map->serialize())); // } else { // $sql = sprintf("UPDATE `%s` SET map='%s' WHERE title='%s'", 'node', mysql_escape_string($map->serialize()), $validated_title); // } // $result = $DB->query($sql); } ?>