本文整理汇总了PHP中Web::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Web::error方法的具体用法?PHP Web::error怎么用?PHP Web::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login_POST
function login_POST(Web &$w)
{
if ($_POST['login'] && $_POST['password']) {
$client_timezone = "Australia/Sydney";
//$_POST['user_timezone'];
$user = $w->Auth->login($_POST['login'], $_POST['password'], $client_timezone);
if ($user) {
if ($w->session('orig_path') != "auth/login") {
$url = $w->session('orig_path');
$w->Log->debug("Original path: " . $url);
// If no url specified, go to the users defined url
if (empty($url) || $url == "/") {
$url = $user->redirect_url;
}
$w->sessionUnset('orig_path');
$w->redirect($w->localUrl($url));
} else {
$w->redirect(!empty($user->redirect_url) ? $w->localUrl($user->redirect_url) : $w->localUrl());
}
} else {
$w->error("Login or Password incorrect", "/auth/login");
}
} else {
$w->error("Please enter your login and password", "/auth/login");
}
}
示例2: attach_POST
function attach_POST(Web &$w)
{
$table = $w->request('table');
$id = $w->request('id');
$title = $w->request('title');
$description = $w->request('description');
$type_code = $w->request('type_code');
$url = str_replace(" ", "/", $w->request('url'));
$object = $w->Auth->getObject($table, $id);
if (!$object) {
$w->error("Nothing to attach to.", $url);
}
$aid = $w->service("File")->uploadAttachment("file", $object, $title, $description, $type_code);
if ($aid) {
$w->ctx('attach_id', $aid);
$w->ctx('attach_table', $table);
$w->ctx('attach_table_id', $id);
$w->ctx('attach_title', $title);
$w->ctx('attach_description', $description);
$w->ctx('attach_type_code', $type_code);
$w->msg("File attached.", $url);
} else {
$w->error("There was an error. Attachment could not be saved.", $url);
}
}
示例3: edit_POST
function edit_POST(Web $w)
{
$p = $w->pathMatch("id");
$processor_id = $p["id"];
// Break the selected processor up into module and class
$processor_class = $w->request("processor_class");
$processor_expl = explode(".", $processor_class);
// Make sure we only have two values
if (count($processor_expl) !== 2) {
$w->error("Missing Processor values", "/channels/listprocessors");
exit;
}
// make sure the selected class exists in config
if (!in_array($processor_expl[1], $w->moduleConf($processor_expl[0], "processors"))) {
$w->error("Could not find processor in config", "/channels/listprocessors");
exit;
}
$processor_object = $processor_id ? $w->Channel->getProcessor($processor_id) : new ChannelProcessor($w);
$processor_object->fill($_POST);
$processor_object->channel_id = $w->request("channel_id");
$processor_object->module = $processor_expl[0];
$processor_object->class = $processor_expl[1];
$processor_object->insertOrUpdate();
$w->msg("Processor " . ($processor_id ? "updated" : "created"), "/channels/listprocessors");
}
示例4: editworkentry_POST
function editworkentry_POST(Web $w)
{
list($workentry_id) = $w->pathMatch("id");
if (empty($workentry_id)) {
$w->error("Missing an ID");
}
$we = $w->Bend->getWorkEntryForId($workentry_id);
if (empty($we)) {
$w->error("No work entry found for this id: " . $workentry_id);
}
$we->fill($_POST);
if (empty($we->user_id)) {
$we->user_id = $w->Auth->user()->id;
}
// now get the category
if (!empty($_POST['category_3'])) {
$we->bend_work_category_id = $_POST['category_3'];
} else {
if (!empty($_POST['category_2'])) {
$we->bend_work_category_id = $_POST['category_2'];
} else {
if (!empty($_POST['category_1'])) {
$we->bend_work_category_id = $_POST['category_1'];
}
}
}
// TODO check work period, etc.
$we->update();
$w->msg("Work hours recorded", "/bend-workhours/list");
}
示例5: delete_ALL
function delete_ALL(Web $w)
{
$p = $w->pathMatch("id");
if (empty($p['id'])) {
$w->error("Group not found", "/admin-groups");
}
$group = $w->Auth->getUser($p['id']);
if (empty($group->id)) {
$w->error("Group not found", "/admin-groups");
}
$group->delete();
$roles = $group->getRoles();
if (!empty($roles)) {
foreach ($roles as $role) {
$group->removeRole($role);
}
}
$members = $w->Auth->getGroupMembers($option['group_id']);
if ($members) {
foreach ($members as $member) {
$member->delete();
}
}
$w->msg("Group deleted", "/admin-groups");
}
示例6: delete_GET
function delete_GET(Web $w)
{
$p = $w->pathMatch("id");
if (empty($p['id'])) {
$w->error("Report template not found", "/report-templates");
}
$report_template = $w->Report->getReportTemplate($p['id']);
if (empty($report_template->id)) {
$w->error("Report template not found", "/report-templates");
}
$report_template->delete();
$w->msg("Report template removed", "/reports/edit/{$report_template->report_id}#templates");
}
示例7: deleteoccupant_GET
function deleteoccupant_GET(Web $w)
{
list($householdid, $occupantid) = $w->pathMatch("a", "b");
$household = $w->Bend->getHouseholdForId($householdid);
if (empty($household)) {
$w->error("Household not found");
}
$occupant = $w->Bend->getHouseholdOccupantForId($occupantid);
if (empty($occupant)) {
$w->error("Occupant not found");
}
$occupant->delete();
$w->msg("Occupant deleted", "/bend-household/show/{$householdid}");
}
示例8: useredit_POST
/**
* Handle User Edit form submission
*
* @param <type> $w
*/
function useredit_POST(Web &$w)
{
$w->pathMatch("id");
$errors = $w->validate(array(array("login", ".+", "Login is mandatory")));
if ($_REQUEST['password'] && $_REQUEST['password'] != $_REQUEST['password2']) {
$error[] = "Passwords don't match";
}
$user = $w->Auth->getObject("User", $w->ctx('id'));
if (!$user) {
$errors[] = "User does not exist";
}
if (sizeof($errors) != 0) {
$w->error(implode("<br/>\n", $errors), "/admin/useredit/" . $w->ctx("id"));
}
$user->login = $_REQUEST['login'];
$user->fill($_REQUEST);
if ($_REQUEST['password']) {
$user->setPassword($_REQUEST['password']);
} else {
$user->password = null;
}
$user->is_admin = isset($_REQUEST['is_admin']) ? 1 : 0;
$user->is_active = isset($_REQUEST['is_active']) ? 1 : 0;
$user->update();
$contact = $user->getContact();
if ($contact) {
$contact->fill($_REQUEST);
$contact->private_to_user_id = null;
$contact->update();
}
$w->callHook("admin", "account_changed", $user);
$w->msg("User " . $user->login . " updated.", "/admin/users");
}
示例9: editlookup_POST
function editlookup_POST(Web &$w)
{
$p = $w->pathMatch("id", "type");
$err = "";
if ($_REQUEST['type'] == "") {
$err = "Please add select a TYPE<br>";
}
if ($_REQUEST['code'] == "") {
$err .= "Please enter a KEY<br>";
}
if ($_REQUEST['title'] == "") {
$err .= "Please enter a VALUE<br>";
}
if ($err != "") {
$w->error($err, "/admin/lookup/?type=" . $p['type']);
} else {
$lookup = $w->Admin->getLookupbyId($p['id']);
if ($lookup) {
$lookup->fill($_REQUEST);
$lookup->update();
$msg = "Lookup Item edited";
} else {
$msg = "Could not find item?";
}
$w->msg($msg, "/admin/lookup/?type=" . $p['type']);
}
}
示例10: showlot_GET
function showlot_GET(Web $w)
{
list($id) = $w->pathMatch("id");
if (empty($id)) {
$w->error("Need a Lot ID");
}
$lot = $w->Bend->getLotForId($id);
if (empty($lot)) {
$w->error("Lot {$id} does not exist");
}
History::add("Bend Lot: " . $lot->lot_number);
$lotTable = array();
$lotTable["Lot"] = array(array(array("Lot Number", "static", "", $lot->lot_number), array("Occupancy", "static", "", $lot->occupancy)));
$w->ctx("lot", $lot);
$w->ctx("lotTable", Html::multiColTable($lotTable));
$w->ctx("owners", $lot->getAllOwners());
$w->ctx("households", $lot->getAllHouseholds());
}
示例11: deletelotowner_GET
function deletelotowner_GET(Web $w)
{
list($lotid, $ownerid) = $w->pathMatch("lotid", "ownerid");
if (!empty($lotid)) {
$lot = $w->Bend->getLotForId($lotid);
}
if (empty($lot)) {
$w->error("lot not found");
}
if (!empty($ownerid)) {
$owner = $w->Bend->getBendLotOwnerForId($ownerid);
}
if (empty($owner)) {
$w->error("lot owner not found");
}
$owner->delete();
$w->msg("Owner removed.", "bend-lot/showlot/{$lotid}");
}
示例12: deletehousehold_GET
function deletehousehold_GET(Web $w)
{
list($lotid, $householdid) = $w->pathMatch("lotid", "housholdid");
if (!empty($lotid)) {
$lot = $w->Bend->getLotForId($lotid);
}
if (empty($lot)) {
$w->error("lot not found");
}
if (!empty($householdid)) {
$household = $w->Bend->getHouseholdForId($householdid);
}
if (empty($household)) {
$w->error("lot owner not found");
}
$household->delete();
$w->msg("Household removed.", "bend-lot/showlot/{$lotid}");
}
示例13: deleteprintfile_GET
function deleteprintfile_GET(Web $w)
{
$filename = strip_tags($_GET["filename"]);
if (file_exists($filename)) {
unlink($filename);
$w->Log->info("File {$filename} deleted");
$w->msg("File deleted", "/admin/printqueue");
}
$w->error("Missing filename", "/admin/printqueue");
}
示例14: editcategory_POST
function editcategory_POST(Web $w)
{
list($id) = $w->pathMatch("a");
$cat = $w->Bend->getWorkCategoryForId($id);
if (empty($cat)) {
$w->error("no category found", "/bend-workhours/admin");
}
$cat->fill($_POST);
$cat->update();
$w->msg("Category updated", "/bend-workhours/admin");
}
示例15: deleteprinter_ALL
function deleteprinter_ALL(Web $w)
{
$p = $w->pathMatch("id");
if (!empty($p["id"])) {
$printer = $w->Printer->getPrinter($p["id"]);
if (!empty($printer->id)) {
$printer->delete();
$w->msg("Printer deleted", "/admin");
}
}
$w->error("Could not find printer", "/admin");
}