コード例 #1
0
 /**
  * Stores the given MOC's data
  */
 public function save()
 {
     $db = DB::get_db();
     $sql = sprintf("INSERT INTO mocs (code) VALUES ('%s')", $db->real_escape_string($this->code));
     if (!$db->query($sql)) {
         error_log("Unable to insert new MOC: " . $db->error . " (sql: {$sql})");
         return FALSE;
     }
     $this->id = $db->insert_id;
     if ($this->create_directory_or_delete()) {
         // Force a reload in case further reads occur
         MOC::load_all_from_db();
         return TRUE;
     }
     return FALSE;
 }
コード例 #2
0
<?php

require_once __DIR__ . "/includes/root.php";
must_allow("manage mocs");
$moc = MOC::find($_GET["id"]);
if ($moc->delete()) {
    audit("delete MOC", sprintf("ID: %d, Code: %s", $moc->id, $moc->code));
    $renderer->flash_success("Deleted MARC Org Code");
} else {
    $renderer->flash_alert("Error trying to delete MARC Org Code; is the directory empty?");
}
header("Location: mocs-list.php");
コード例 #3
0
<?php

require_once __DIR__ . "/includes/root.php";
must_allow("manage mocs");
$mocs = MOC::all();
$renderer->variable("mocs", $mocs);
$renderer->variable("title", "MARC Org Code List");
$renderer->render("mocs-list");
コード例 #4
0
<?php

require_once __DIR__ . "/includes/root.php";
must_allow("manage mocs");
$moc = new MOC();
$moc->code = $_POST["code"];
$errors = $moc->errors();
if (count($errors) == 0) {
    if (!$moc->save()) {
        array_push($errors, "Unknown error trying to save a MARC Org Code!  Try again or contact support.");
    }
}
if (count($errors) == 0) {
    audit("new MOC", sprintf("Code: %s", $moc->code));
    $renderer->flash_success("Saved MARC Org Code");
    header("Location: mocs-list.php");
} else {
    $renderer->variable("errors", $errors);
    $renderer->variable("moc", $moc);
    $renderer->variable("title", "Creating a new MARC Org Code");
    $renderer->render("mocs-form");
}