CMS  Version 3.9
redirect_form.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("redirect");
3 
4 $menu_item = "Redirects";
5 
6 $redirect_id = checkNumeric($_GET["redirect_id"]);
7 
9 
10 if ($redirect_id)
11 {
12  $redirect->load($redirect_id);
13 }
14 
15 $form = new AutoForm($redirect);
16 
17 $form->hide("user_id");
18 $form->required("redirect_from", "redirect_to");
19 $form->allowDelete = true;
20 $form->annotate("exemption_flag", "Specifies the name of a flag that can be set on a user's session to exempt them from the redirect");
21 $roleSelect = new CheckListFieldRenderer($form, "exempt_roles", "Exempt Roles", SiteRole::getRolesArray());
22 $roleSelect->setSize(350, 150, 10);
23 
24 $form->group("Redirect Settings", "redirect_from", "redirect_to", "user_id", "active", "override", "preserve_query_string");
25 $form->group("Exemptions", "exemption_flag", "exempt_roles");
26 $form->makeGroupCollapsible("Exemptions", "override");
27 
28 if ($method == "POST")
29 {
30  $_POST["user_id"] = $user->user_id;
31  if ($form->save())
32  {
33  Fakoli::notifyOnNextPage($form->deleted ? "Redirect remoted" : "Redirect added");
34  Cache::invalidate("resource_overrides");
35  redirect("/admin/redirects");
36  }
37 }
38 
39 $script .= $form->writeScript();
40 $form->drawForm();
$_POST["owner_id"]
Definition: blog_form.inc:54
static notifyOnNextPage($message, $blocking=false, $button="OK", $onClick="null")
Schedules a notification message to be displayed to the user at the next full page load.
Definition: core.inc:1223
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static getRolesArray()
Retrieves the array of roles and their names for the current site for use in a CMS form.
Definition: role.inc:75
global $user
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
if($redirect_id) $form
$redirect_id
$roleSelect
$redirect
$menu_item
if($method=="POST") $script