Message-ID: <469895038.1633.1556112231833.JavaMail.javamailuser@localhost> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1632_1995844854.1556112231832" ------=_Part_1632_1995844854.1556112231832 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Adding a new admin section

Adding a new admin section

Sometimes you need to add sections to your v2.X site that only a= dministrators can see and use (e.g. pages that modify your ushahidi site, d= ownload sensitive data etc).=C2=A0

Add code to the admin directories

First, y= our directory structure is slightly different to the one in=C2=A0Adding a new page. =C2=A0By conventio= n, Ushahidi admin pages are all in the =C2=A0/admin section of the controll= ers, views, etc directories. =C2=A0

Use the Admin view template

Second, you'll pro= bably want to use the admin template so your new section is part of the adm= in look-and-feel: to make this happen, your controller class should extend = Admin_Controller, e.g. for the Reporters admin section, you see this at the= top of plugins/reporters/controllers/admin/reporters.php

class Rep=
orters_Controller extends Admin_Controller

Secure your code against non-ad= min access

You'll want to secure your code against access by anyone = who isn't an admin. Which means the usual scruipt at the top of your contro= ller:

<?php defined('SYSPATH') or die('No direct script access.'=
);

And also a piece of code at the top of every function in your co= ntroller code that checks that users have the right permissions to be there= , e.g.=C2=A0

// If user doesn't have access, redirect to dashboard<=
br /> if ( ! $this->auth->has_permission("messages_reporters&quo=
t;))
{
url::redirect('admin/dashboard');
}

(these= permissions, e.g. messages_reporters, are different for different user typ= es)

Add your new section to the admin navigation bar

=C2=A0

------=_Part_1632_1995844854.1556112231832--