$many_to_many = $bigtree["many-to-many"]; // Check to see if this is a positioned element // If it is and the form is setup to create new items at the top and this is a new record, update the position column. $table_description = BigTree::describeTable($table); if (isset($table_description["columns"]["position"]) && $bigtree["form"]["default_position"] == "Top" && !$_POST["id"]) { $max = sqlrows(sqlquery("SELECT id FROM `{$table}`")) + sqlrows(sqlquery("SELECT id FROM `bigtree_pending_changes` WHERE `table` = '" . sqlescape($table) . "'")); $item["position"] = $max; } // Let's stick it in the database or whatever! $data_action = $_POST["save_and_publish"] || $_POST["save_and_publish_x"] || $_POST["save_and_publish_y"] ? "publish" : "save"; $did_publish = false; // We're an editor or "Save" was chosen if ($bigtree["access_level"] == "e" || $data_action == "save") { // We have an existing module entry we're saving a change to. if ($edit_id) { BigTreeAutoModule::submitChange($bigtree["module"]["id"], $table, $edit_id, $item, $many_to_many, $tags); $admin->growl($bigtree["module"]["name"], "Saved " . $bigtree["form"]["title"] . " Draft"); // It's a new entry, so we create a pending item. } else { $edit_id = "p" . BigTreeAutoModule::createPendingItem($bigtree["module"]["id"], $table, $item, $many_to_many, $tags); $admin->growl($bigtree["module"]["name"], "Created " . $bigtree["form"]["title"] . " Draft"); } // We're a publisher and we want to publish } elseif ($bigtree["access_level"] == "p" && $data_action == "publish") { // If we have an edit_id we're modifying something that exists. if ($edit_id) { // If the edit id starts with a "p" it's a pending entry we're publishing. if (substr($edit_id, 0, 1) == "p") { $edit_id = BigTreeAutoModule::publishPendingItem($table, substr($edit_id, 1), $item, $many_to_many, $tags); $admin->growl($bigtree["module"]["name"], "Updated & Published " . $bigtree["form"]["title"]); $did_publish = true;
$many_to_many = $bigtree["many-to-many"]; // Check to see if this is a positioned element // If it is and the form is setup to create new items at the top and this is a new record, update the position column. $table_description = BigTree::describeTable($table); if (isset($table_description["columns"]["position"]) && $bigtree["form"]["default_position"] == "Top" && !$_POST["id"]) { $max = sqlrows(sqlquery("SELECT id FROM `{$table}`")) + sqlrows(sqlquery("SELECT id FROM `bigtree_pending_changes` WHERE `table` = '" . sqlescape($table) . "'")); $item["position"] = $max; } // Let's stick it in the database or whatever! $data_action = $_POST["save_and_publish"] || $_POST["save_and_publish_x"] || $_POST["save_and_publish_y"] ? "publish" : "save"; $did_publish = false; // We're an editor or "Save" was chosen if ($bigtree["access_level"] == "e" || $data_action == "save") { // We have an existing module entry we're saving a change to. if ($edit_id) { BigTreeAutoModule::submitChange($bigtree["module"]["id"], $table, $edit_id, $item, $many_to_many, $tags, $bigtree["form"]["hooks"]["publish"]); $admin->growl($bigtree["module"]["name"], "Saved " . $bigtree["form"]["title"] . " Draft"); // It's a new entry, so we create a pending item. } else { $edit_id = "p" . BigTreeAutoModule::createPendingItem($bigtree["module"]["id"], $table, $item, $many_to_many, $tags, $bigtree["form"]["hooks"]["publish"]); $admin->growl($bigtree["module"]["name"], "Created " . $bigtree["form"]["title"] . " Draft"); } // We're a publisher and we want to publish } elseif ($bigtree["access_level"] == "p" && $data_action == "publish") { // If we have an edit_id we're modifying something that exists. if ($edit_id) { // If the edit id starts with a "p" it's a pending entry we're publishing. if (substr($edit_id, 0, 1) == "p") { $edit_id = BigTreeAutoModule::publishPendingItem($table, substr($edit_id, 1), $item, $many_to_many, $tags); $admin->growl($bigtree["module"]["name"], "Updated & Published " . $bigtree["form"]["title"]); $did_publish = true;