コード例 #1
0
ファイル: delete.php プロジェクト: pjflameboy/phprecipebook
require_once "classes/Ingredient.class.php";
require_once "classes/DBUtils.class.php";
// Only editors or above can remove an ingredient
if (!$SMObj->checkAccessLevel("EDITOR")) {
    die($LangUI->_('You do not have sufficient privileges to delete ingredients'));
}
// Delete all selected ingredients
$iterator = 0;
$item_id = "ingredient_id_" . $iterator;
$item_delete = "ingredient_selected_" . $iterator;
while (isset($_REQUEST[$item_id]) && $_REQUEST[$item_id] != '') {
    // check to see if it is in the list
    if ($_REQUEST[$item_delete] == "yes" && isValidID($_REQUEST[$item_id])) {
        $ingObj = new Ingredient();
        $ingObj->setIngredient($_REQUEST[$item_id]);
        // Create an ingredient object for this ID
        $ingObj->delete();
        // In mysql cascading does not really work
        if ($g_rb_database_type == "mysql") {
            $sql = "DELETE from {$db_table_ingredientmaps} WHERE map_ingredient = " . $DB_LINK->addq($_REQUEST[$item_id], get_magic_quotes_gpc());
            $result = $DB_LINK->Execute($sql);
            DBUtils::checkResult($rc, NULL, NULL, $sql);
        }
    }
    $iterator++;
    $item_id = "ingredient_id_" . $iterator;
    $item_delete = "ingredient_selected_" . $iterator;
}
?>
<P>
コード例 #2
0
ファイル: update.php プロジェクト: pjflameboy/phprecipebook
<?php

require_once "classes/Ingredient.class.php";
$ingredient_id = isValidID($_GET['ingredient_id']) ? $_GET['ingredient_id'] : 0;
$coreIngredient_id = isValidID($_POST['coreIngredient_id']) ? $_POST['coreIngredient_id'] : 0;
$ingredient_name = isset($_POST['ingredient_name']) ? htmlentities(stripslashes($_POST['ingredient_name']), ENT_QUOTES, $LangUI->getEncoding()) : '';
$ingredient_desc = isset($_POST['ingredient_desc']) ? htmlentities(stripslashes($_POST['ingredient_desc']), ENT_QUOTES, $LangUI->getEncoding()) : '';
$ingredient_loc = $_POST['ingredient_loc'] != "" ? $_POST['ingredient_loc'] : 'NULL';
$ingredient_unit = $_POST['ingredient_unit'] != "" ? $_POST['ingredient_unit'] : 'NULL';
$ingredient_solid = $_POST['ingredient_solid'] == "TRUE" ? "TRUE" : "FALSE";
if (!$SMObj->isUserLoggedIn()) {
    die($LangUI->_('You must be logged into perform the requested action.'));
}
// Load the Ingredient into an ingredient object
$ingObj = new Ingredient();
$ingObj->setIngredient($ingredient_id, $coreIngredient_id, $ingredient_name, $ingredient_desc, $ingredient_unit, $ingredient_loc, $ingredient_solid, $SMObj->getUserID());
// Add or Update the ingredient in the database
$ingObj->addUpdate();
?>