Example #1
0
function _edit($OID = 0, $CID = 0)
{
    loginRequireMgmt();
    if (!loginCheckPermission(USER::TEST_EVENT)) {
        redirect("errors/401");
    }
    $item = "Event";
    $urlPrefix = "test_event";
    $object = new Event();
    $object->retrieve($OID, $CID);
    if (!$object->exists()) {
        $data['body'][] = "<p>{$item} Not Found!</p>";
    } else {
        $fdata['form_heading'] = "Edit {$item}";
        $fdata['object'] = $object;
        $fdata['actionUrl'] = myUrl("{$urlPrefix}/ops_update");
        $fdata['actionLabel'] = "Submit";
        $fdata['cancelUrl'] = myUrl("{$urlPrefix}/manage");
        $fdata['cancelLabel'] = "Cancel";
        $form = View::do_fetch(VIEW_PATH . "{$urlPrefix}/form.php", $fdata);
        $data['head'][] = View::do_fetch(VIEW_PATH . "{$urlPrefix}/form_js.php");
        $data['body'][] = "<h2>Edit {$item}</h2>";
        $data['body'][] = $form;
    }
    View::do_dump(VIEW_PATH . 'layouts/mgmtlayout.php', $data);
}
Example #2
0
 public function testAllRetrieve()
 {
     self::authorizeFromEnv();
     $events = Event::all(array('limit' => 3, 'offset' => 0));
     if (count($events['data'])) {
         $event = Event::retrieve($events['data'][0]->id);
         $this->assertSame($events['data'][0]->id, $event->id);
     }
 }
function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = '';
    loginRequireMgmt();
    if (!loginCheckPermission(USER::TEST_EVENT)) {
        redirect("errors/401");
    }
    $itemName = "Event";
    $urlPrefix = "test_event";
    $object = new Event();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        transactionBegin();
        if ($object->create()) {
            transactionCommit();
            $msg = "{$itemName} created!";
        } else {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
Example #4
0
 public function __construct()
 {
     self::authorizeFromEnv();
     $this->data = array('parameters' => array("key" => "value"));
     $this->datas = array();
     // CRUD ___________________________________
     // Create
     for ($x = 0; $x <= 2; $x++) {
         $this->datas[] = Event::create($this->data);
     }
     $this->created = $this->datas[0];
     // Retrieve
     $this->retrieved = Event::retrieve($this->created->id);
     // Update
     // Delete
     $this->deleted = $this->created->delete();
     // List
     $this->order = Event::all(array("order" => "id"));
     $this->orderInv = Event::all(array("order" => "-id"));
     $this->limit5 = Event::all(array("limit" => "5", "order" => "id"));
     $this->limit1 = Event::all(array("start_after" => $this->limit5[1]->id, "end_before" => $this->limit5[3]->id));
     $this->oneId = Event::all(array("id" => $this->limit5[1]->id));
 }