UP PREVIOUS NEXT   Technologies Internet et Education, © TECFA
  5. Admin and user interface

5. Admin and user interface

Admin Interface:

User Interface:

5.1 Separate GUI from API functions

GUI: pnadmin.php, pnuser.php

API: pnadminapi.php, pnuserapi.php

5.2 Everything in functions or classes

Function names inside pnadmin.php et pnadminapi.php :

Function names inside pnuser.php et pnuserapi.php :

5.3 Use official API functions (doc!)

to call a function: pnModURL()

	pnModURL('joinproject', 'user', 'main')

to redirect a page: pnRedirect()

	pnRedirect(pnModURL('joinproject', 'admin', 'main'));

and many others ...

5.4 For SQL use the ADODB library (doc!)

PN uses ADODB library for SQL and below one can find the most basic pieces of code needed:
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$projectstable = $pntable['joinproject_projects'];
$result1=$dbconn->Execute("SELECT * FROM $projectstable");

5.5 Manage exceptions (doc!)

PN has an internal system to manage exceptions ("system" and "user") and it is at your interest to use it.

5.6 Security and permissions

PN has a very elaborated system to manage permissions (see online manual). For this reason, there is an API function and it is better to be called in the very beginning of every function in order to avoid security holes:

  if (!pnSecAuthAction(0, 'joinproject::', '::', ACCESS_ADMIN)) {
    return $output->GetOutput(); }

There are several levels of access (according to official doc):

ACCESS_OVERVIEW Allowed to get an overview of the content
ACCESS_READ Allowed to read the content
ACCESS_COMMENT Allowed to comment on the content
ACCESS_MODERATE Allowed to moderate the content
ACCESS_EDIT Allowed to edit the content
ACCESS_ADD Allowed to add content
ACCESS_DELETE Allowed to delete content
ACCESS_ADMIN Full access

5.7 For HTML use "pnHTML" object and it's methods (doc!)

NEVER use "echo" or "print", instead use "pnHTML" methods that will take care of the HTML tags (and thus guarantee clean, correct and compliant HTML).

There are many methods for all kinds of HTML elements, some are listed below:

  	$output = new pnHTML();
  	return $output->GetOutput();