Creating custom admin-pages

Defining adminpage in extension
Version 4 only

1. Create admin-page and include user privilege check

Create your custom admin-page file in the text editor and insert following lines at the top of the file:

# This file must be included at the top of the custom admin-page,
# if access is not granted to the current user then page load will be terminated and login-page is displayed.

# Set relative path to the website root (depending on where your admin-page script is located)
# if admin-page is located in folder /extensions/my_extension/admin/:
$webroot_path = '../../../';

$class_path = $webroot_path.'classes/';
include($webroot_path."admin/check_adminpage.php");
echo "Go on with your custom admin-page";

2. Save your file in the extension

Save file into the admin/ directory in your custom extension. Eg "/extensions/my_extension/admin/my_adminpage.php"

3. Modify extensions' config file

Open extensions' configuration file (eg "/extensions/my_extension/extension.config.php"), search for admin-page lines and insert custom admin-page file info:

// Array of admin-pages which are displayed under Extensions menu
$EXTENSION['adminpages'][] = array(
 "name" => "My adminpage",
 "file" => "admin/my_adminpage.php"
);

4. Synchronize extensions in the admin-area

Created admin-page will appear under "Extensions" menu

 

Inserting adminpage manually (ver3)

For older Saurus 3 versions

1. Insert page info into database

For displaying your page under admin menu "Tools", insert the following SQL into your database:

INSERT INTO admin_osa (id, parent_id, sorteering, nimetus, eng_nimetus, fail, moodul_id, extension) VALUES (1000, 69, 9, 'Custompage', 'Custompage', 'custompage.php', 0, NULL);

"1000" - admin-page ID, use always values larger than 1000
"69" - admin menu "Tools" ID
"9" - sort order in menu
"Custompage" - admin-page name in menu
"custompage.php" - admin-page filename

2. Include user privilege check in your custom admin-page

Open your custom admin-page file in the text editor and insert following lines at the top of the file:

# This file must be included at the top of the custom admin-page,
# if access is not granted to the current user then page load will be terminated and login-page is displayed.

include("check_adminpage.php");
echo "Go on with your custom admin-page";

3. Save your file

Save your admin-page file into the admin/ directory.