Install the App?

ZnetDK PHP API

Server-side Application PHP Methods

The ZnetDK PHP API simplifies the development on the web server side of:

  • the views implemented to display data,
  • the navigation menu items and icons,
  • the controller actions generally called in AJAX by the views of the application,
  • the validation of data transmitted by the view
  • and the access to the MySQL database in read or write.

Its source code is defined through PHP classes located in the INSTALL_DIR/engine/core/ folder.

Application views

Application views are PHP scripts that are developed to display data and input forms dedicated to the end user.
They are written in pure HTML and include if necessary, PHP and JavaScript code.
A view is usually displayed when you click an item of the Navigation menu.

Once a view is displayed, it remains in the DOM (Document Object Model) of the page, even when another one is displayed as a replacement.
This means that the view is not reloaded when it is displayed again later.
To force the content of the view to refresh each time it is displayed again, simply add the zdk-viewreload CSS class to any HTML element in the view.

The PHP script of a view, for example myview.php, is installed into the INSTALL_DIR/applications/default/app/view/ folder.

EXAMPLE: myview.php
<h3>My view</h3>
<p class="zdk-viewreload">The name of the application is <?php echo LC_HEAD_TITLE; ?></p>
<p>The current time is <span id="current-time"></span>
<script>
    var currentTime = new Date();
    $('#current-time').text(currentdate.getHours()
        + ':' + currentdate.getMinutes());
</script>

A view can be translated and displayed into multiple languages if the application is configured for multi-language display.

Navigation menu

The basics

The Web app navigation menu is defined in PHP on the server side of the application.
Its definition is centralized into the INSTALL_DIR/applications/default/app/menu.php script through the \app\Menu class.
The \app\Menu::initAppMenuItems() method is called by ZnetDK to retrieve the menu items to display in the horizontal and vertical menus.
Each menu item is added to the navigation menu by calling the \MenuManager::addMenuItem() static method.

Here is below the definition of the Starter App navigation menu.

The Starter App's menu.php script

<?php
/**
 * ZnetDK, Starter Web Application for rapid & easy development
 * See official website http://www.znetdk.fr
 * ------------------------------------------------------------
 * Custom navigation menu of the application
 * YOU CAN FREELY CUSTOMIZE THE CONTENT OF THIS FILE
 */
namespace app;
class Menu implements \iMenu {

    static public function initAppMenuItems() {
        \MenuManager::addMenuItem(NULL, 'home', 'Home', 'fa-home');

        \MenuManager::addMenuItem(NULL, '_authorizations', LC_MENU_AUTHORIZATION, 'fa-unlock-alt');
        \MenuManager::addMenuItem('_authorizations', 'z4musers', LC_MENU_AUTHORIZ_USERS, 'fa-user');
        \MenuManager::addMenuItem('_authorizations', 'z4mprofiles', LC_MENU_AUTHORIZ_PROFILES, 'fa-key');
    }

}

The first call to \MenuManager::addMenuItem() adds the Home menu item in first position. This is a one level menu item so the Home label is both displayed on the main vertical menu and the secondary horizontal menu.

The three next calls to \MenuManager::addMenuItem() add the Authorizations menu item on the main vertical menu. This is a two levels menu item with two subitems named Users and Profiles displayed on the secondary horizontal menu.

Class \MenuManager

 Method addMenuItem()

DESCRIPTION Add a menu item to the navigation menu. This method is called from the class app\Menu of the application.
PARAMETERS
$parentMenuItemID String | NULL Parent menu item ID, NULL for root item.
$menuItemID String Menu item ID of the item to add. This ID matches the name of the PHP view script (without .php file extension) if the menu item is not the level one menu item of a two levels menu definition.
$menuItemLabel String Menu item label of the item to add.
$menuItemIcon String Font Awesome 4 style class of the icon to display for the menu item.
$menuItemSEOlink String OPTIONAL, SEO link for the menu item (only used if CFG_VIEW_PAGE_RELOAD is set to TRUE).
$menuItemDescription String OPTIONAL, Text for the HTML meta tag description (only used if CFG_VIEW_PAGE_RELOAD is set to TRUE).
$menuItemKeywords String OPTIONAL, Text for the HTML meta tag keywords (only used if CFG_VIEW_PAGE_RELOAD is set to TRUE).
$menuItemAuthor String OPTIONAL, Text for the HTML meta tag author (only used if CFG_VIEW_PAGE_RELOAD is set to TRUE).

EXAMPLE
<?php
// The 'my_view.php' view is displayed on clicking on the "My view" menu item.
// The Font Awesome 4 'fa-book' icon is displayed for this menu item.
\MenuManager::addMenuItem(NULL, 'my_view', 'My view', 'fa-book');

Application controllers

\AppController | \Request | \Response

An application controller is a PHP class derived from the ZnetDK \AppController class that performs actions in response to AJAX requests sent by a view of the application.
A controller action is a protected method of the controller class whose name is prefixed by the action_ string.
The POST parameters sent by the view in AJAX are read thanks to a \Request object.
The response is returned to the calling view in JSON format through a \Response object.

Here is an example below of the mycontroller.php PHP script implementing the MyController class having a myaction action.

EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $request = new \Request();
        $postValue = $request->my_param;
        $response = new \Response();
        $response->my_response = $postValue;
        return $response;
    }
}
?>

This controller action reads the value of the my_param POST parameter and returns a JSON object with a property named my_response and a value matching the my_param parameter value.

You can notice in this example that the namespace is set to app\controller. It matches the folder in which the mycontroller.php script file must be located, i.e. in the INSTALL_DIR/applications/default/app/controller/ folder if the running application is the Starter Application (default subfolder).

In ZnetDK 4 Mobile version >=2.8, The PHP script containing the controller class definition can be named using the same case as the class name (for example MyController.php) to comply with the PSR-4 autoloading standard.

Class \AppController

doAction(), setAllowedActions(), setRequiredProfileForAction(), setForbiddenProfileForAction(), setRequiredMenuItemForAction(), isActionAllowed()

Any application controller class must derive from the abstract \AppController class.

 Method doAction()

DESCRIPTION Executes the action specified in parameter.
PARAMETERS
$action String Name of the action without the action_ prefix of the class method (for example 'store' that corresponds to the action_store() method of the controller class).
RETURNED VALUE \Response The response returned by the controller's action as a \Response object.
EXAMPLE
<?php
$response = \app\controller\MyCtrl::doAction('getall');

 Method setAllowedActions()

DESCRIPTION

This method, optional in an application controller class, is called by ZnetDK to know whether a controller action can be executed or not for the logged in user.
An HTTP error 403 is returned by the application if an action is not allowed.

EXAMPLE
<?php
class MyController extends \AppController {

    static protected function setAllowedActions() {
        // User must not have the 'My Profile' profile to be allowed to execute the 'myaction' action.
        self::setForbiddenProfileForAction('myaction', 'My Profile');
        // The action named 'myaction' is allowed if user has access to the view named 'my_view'.
        self::setRequiredMenuItemForAction('myaction', 'my_view');
    }

    static protected function action_myaction() {
        $response = new \Response();
        $response->success = TRUE;
        return $response;
    }
}

 Method setRequiredProfileForAction()

DESCRIPTION Specifies the user profile allowed to execute the controller's action.
If menu item ID is set (see $menuItemID parameter passed to the \MenuManager::addMenuItem() method), it must be selected for the specified profile.
This method must be called from the setAllowedActions() controller's method.
PARAMETERS
$action String Name of the action without the action_ prefix of the class method (for example 'store' that corresponds to the action_store() method of the controller class).
$profileName String Name of the user profile.
$menuItem String OPTIONAL, identifier of the menu item.
EXAMPLE
<?php
class MyController extends \AppController {

    static protected function setAllowedActions() {
        // User must have the 'My Profile' profile to be allowed to execute the 'myaction' action.
        // In addition, the 'my_view' menu item must be selected in the 'My Profile' user profile.
        self::setRequiredProfileForAction('myaction', 'My Profile', 'my_view');
    }

    static protected function action_myaction() {
        $response = new \Response();
        $response->success = TRUE;
        return $response;
    }
}

 Method setForbiddenProfileForAction()

DESCRIPTION Specifies the user profile NOT allowed to execute the controller's action.
If menu item ID is set (see $menuItemID parameter passed to the \MenuManager::addMenuItem() method), it must NOT be selected for the specified profile.
This method must be called from the setAllowedActions() controller's method.
PARAMETERS
$action String Name of the action without the action_ prefix of the class method (for example 'store' that corresponds to the action_store() method of the controller class).
$profileName String Name of the user profile.
$menuItem String OPTIONAL, identifier of the menu item.
EXAMPLE
<?php
class MyController extends \AppController {

    static protected function setAllowedActions() {
        // User must NOT have the 'My Profile' profile with the 'my_view' menu item selected, to be allowed to execute the 'myaction' action.
        self::setForbiddenProfileForAction('myaction', 'My Profile', 'my_view');
    }

    static protected function action_myaction() {
        $response = new \Response();
        $response->success = TRUE;
        return $response;
    }
}

 Method setRequiredMenuItemForAction()

DESCRIPTION Sets the menu item ID (see $menuItemID parameter passed to the \MenuManager::addMenuItem() method) which must be assigned to the connected user to allow them to execute the specified controller action.
This method must be called from the setAllowedActions() controller's method.
PARAMETERS
$action String Name of the action without the action_ prefix of the class method (for example 'store' that corresponds to the action_store() method of the controller class).
$menuItem String Identifier of the menu item.
VERSION >= 3.0
EXAMPLE
<?php
class MyController extends \AppController {

    static protected function setAllowedActions() {
        // The action named 'myaction' is allowed if user has access to the view named 'my_view'.
        self::setRequiredMenuItemForAction('myaction', 'my_view');
    }

    static protected function action_myaction() {
        $response = new \Response();
        $response->success = TRUE;
        return $response;
    }
}

 Method isActionAllowed()

DESCRIPTION

Checks whether the specified action is allowed for the connected user according to the profile definition of the controller set through the setAllowedActions() method.
This public method can be overloaded to check if extra conditions are met (see example below).

PARAMETERS
$action String Name of the action without the action_ prefix of the class method (for example 'store' that corresponds to the action_store() method of the controller class).
RETURNED VALUE Boolean TRUE if the controller action is allowed, FALSE otherwise.
VERSION >= 3.0
EXAMPLE
<?php
class MyController extends \AppController {

    static public function isActionAllowed($action) {
        // Checking first according the standard process
        $status = parent::isActionAllowed($action);
        if ($status === FALSE) {
            return FALSE; // User not allowed to execute action
        }
        // Extra custom conditions
        $loginName = \UserSession::getLoginName();
        if ($action === 'myaction' && $loginName === 'john_doe') {
            // Action named 'myaction' is not allowed for user named 'john_doe'
            return FALSE;
        }
        return TRUE;
    }

    static protected function action_myaction() {
        $response = new \Response();
        $response->success = TRUE;
        return $response;
    }
}

Class \Request

The class \Request when instantiated in a controller action, is used to read the values of the POST parameters sent through an AJAX request from an app view.

 Property $[postParameterName]

DESCRIPTION Value of the POST parameter named [postParameterName] which was transmitted by the HTTP request.
ACCESS Public
DATATYPE String
DEFAULT VALUE NULL
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $request = new \Request();
        /* POST parameter to read is named "address" */
        $requestedAddress = $request->address;

        /* ... the rest of the source code ... */
    }
}

 Method getValuesAsMap()

DESCRIPTION Returns the POST parameters whose names are given as parameters in the form of an associative array, where each key corresponds to the name of the POST parameter.
PARAMETERS
$postParameter1 String Name of the first POST parameter.
$postParameter2 String Name of the second POST parameter.
$postParameterN String Name of the Nth POST parameter.
RETURNED VALUE Array Associative array of values whose POST parameters have been given as parameters.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $request = new \Request();
        $postValues = $request->getValuesAsMap('lastname','firstname');
        // For example, the returned associative array is ['lastname' => 'DOE','firstname' => 'John']

        /* ... the rest of the source code ... */
    }
}

Class \Response

PROPERTIES | METHODS

A controller action always returns an object of type \Response in response to the original HTTP request.
The returned object takes one of the following formats, depending on the case:

\Response PROPERTIES

 Property $[propertyName]
DESCRIPTION Property named [propertyName] of the JSON object returned by a controller action in response to a HTTP POST request.
ACCESS Public
DATATYPE Mixed
DEFAULT VALUE NULL
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        $response->myFirstValue = 'value 1';
        $response->myOtherValue = 124.59;
        return $response;
    }
}

\Response METHODS

setResponse(), setFileToDownload(), setView(), setDataForCsv(), setPrinting(), setCustomContent(), setSuccessMessage(), setWarningMessage(), setFailedMessage(), setCriticalMessage()

 Method setResponse()
DESCRIPTION Set the response of the controller action from an array.
The array is converted to a JSON object before beeing returned in response of the HTTP POST request.
PARAMETERS
$responseData Array Data to return in JSON by the controller action
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        $response->setResponse([
            'status' => 'KO',
            'message' => 'An error occurred!'
        ]);
        return $response;
    }
}

 Method setFileToDownload()
DESCRIPTION Specifies the file to return in the HTTP GET response for download.
This method must only be called from the action_download() method of an application controller.
PARAMETERS
$filePath String File path of the file to download. The CFG_DOCUMENTS_DIR constant can be used to get the web server side storage path of the file to download.
$forDisplayInline Boolean OPTIONAL, if set to TRUE, the file is downloaded with the content-disposition attribute set to inline in the HTTP response header.
$downloadedFilename String OPTIONAL, name of the downloaded file. If not set, the name specified for the $filepath parameter is used instead.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_download() {
        $response = new \Response();
        $fileToDownload = CFG_DOCUMENTS_DIR . DIRECTORY_SEPARATOR . 'mydoc.pdf';
        $response->setFileToDownload($fileToDownload, TRUE);
        return $response;
    }
}

 Method setView()
DESCRIPTION Specifies the name of the view and its type to return in the HTTP GET response.
PARAMETERS
$viewName String Name of the view to render.
$viewType String Type of view to render ('view' or 'help').
$viewCaller mixed OPTIONAL, caller of this method or data given to the view.
This value can be read within the called view through the $this->viewCaller property. So, the called view can adapt the content to be rendered according to this property value.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        /* Returns the view "applications\default\app\view\customers.php" */
        $response->setView('customers','view');
        return $response;
    }
}

 Method setDataForCsv()
DESCRIPTION Sets the data of the CSV file to be returned in the HTTP GET response for download.
This method must only be called from the action_download() method of an application controller.
The LC_LOCALE_CSV_SEPARATOR parameter of the application's translation script INSTALL_DIR/applications/default/app/lang indicates which character separates the values of the CSV file to generate (comma or semicolon separator).
PARAMETERS
$rowData Array 2-dimensional array containing the data rows of the CSV file.
$filename String Name given to the CSV file requested for download
$header array OPTIONAL, array which contains the column header labels of the CSV file.
$forDisplayInline Boolean OPTIONAL, set to FALSE by default, specifies whether the file should be viewed or saved to disk after downloading.
If the value is TRUE, the downloaded file is intended to be displayed directly in the internet browser (Content-Disposition: inline header).
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_download() {
        $response = new \Response();
        $header = array('Column 1','Column 2','Column 3');
        $data = array(
            array('Row 1 col. 1','Row 1 col. 2','Row 1 col. 3'),
            array('Row 2 col. 1','Row 2 col. 2','Row 2 col. 3'),
            array('Row 3 col. 1','Row 3 col. 2','Row 3 col. 3'),
        );
        $response->setDataForCsv($data, 'myfile.csv', $header);
        return $response;
    }
}

 Method setPrinting()
DESCRIPTION Defines an object of type FPDF as a response to the HTTP GET request.
This method must only be called from the action_download() method of an application controller.
PARAMETERS
$printingObject FPDF FPDF object to output.
$filename String OPTIONAL, name given to the PDF file requested for download (named doc.pdf by default).
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_download() {
        $response = new \Response();
        $pdf = new \FPDF();
        $pdf->AddPage();
        $pdf->SetFont('Arial','B',16);
        $pdf->Cell(40,10,'PDF document generated from ZnetDK!');
        $response->setPrinting($pdf, 'mydoc.pdf');
        return $response;
    }
}

 Method setCustomContent()
DESCRIPTION Sets custom content (XML, text, ...) to return as response of the HTTP request
PARAMETERS
$content String The custom content as String.
VERSION >= 2.8
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_run() {
        $response = new \Response();
        $response->setCustomContent('OK');
        return $response;
    }
}

 Method setSuccessMessage()
DESCRIPTION Initializes the message to be returned in JSON format to the user in the HTTP POST response, to confirm that the requested action was performed successfully.
PARAMETERS
$summary String Summary of the message
$message String Text of the message.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        $response->setSuccessMessage('New item','Item added successfully.');
        return $response;
    }
}

 Method setWarningMessage()
DESCRIPTION Initializes the message to be returned in JSON format to the user in the HTTP POST response, to confirm that the requested action succeeded with warning.
PARAMETERS
$summary String Summary of the message
$message String Text of the message.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        $response->setWarningMessage('New item','Item added even if it was incomplete.');
        return $response;
    }
}

 Method setFailedMessage()
DESCRIPTION Initializes the message to be returned in JSON format to the user in the HTTP POST response, to notify user that the requested action failed.
PARAMETERS
$summary String Summary of the message
$message String Text of the message.
$fieldInError String OPTIONAL, name of the data form's HTML field in error.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        $response->setFailedMessage('New item','Item added even if it was incomplete.');
        return $response;
    }
}

 Method setCriticalMessage()
DESCRIPTION Initializes the message to be returned in JSON format to the user in the HTTP POST response, to notify user that the requested action failed with a critical error.
PARAMETERS
$message String Text of the message.
$exception \Exception Exception causing critical error.
EXAMPLE
<?php
namespace app\controller;
class MyController extends \AppController {

    static protected function action_myaction() {
        $response = new \Response();
        $response->setCriticalMessage('Unable to store the item data', $ex);
        return $response;
    }
}

Database Access

\DAO | \SimpleDAO | \Database

Access to the data stored into the database of the application is simplified thanks to the ZnetDK PHP classes \DAO and \SimpleDAO, both based on the PHP PDO class.

Class \DAO

PROPERTIES | METHODS

The ZnetDK class \DAO allows to achieve complex database operations, in particular when data is to be selected from multiple SQL tables.

This class is abstract and so requires the declaration of a derived class which implements the method initDaoProperties().
At least, the $table or $query property must be initialized from the initDaoProperties() method.
The PHP script of the derived \DAO class is located into the INSTALL_DIR/applications/default/app/model/ folder if the running application is the Starter Application (default subfolder).

See below an example of the custom app\model\TaskDAO class derived from the ZnetDK \DAO class.

EXAMPLE
<?php
namespace app\model;
class TaskDAO extends \DAO {

    protected function initDaoProperties() {
        $this->table = "zdkapp_tasks";
        $this->query = "SELECT tas.*, tas.id AS task_id, usr.user_name,
            IF(tas.status_id < 3 AND tas.end_date < CURDATE(), 1, 0) AS late,
            IF(tas.status_id < 3, 0, 1) AS display_priority
            FROM tasks AS tas
            INNER JOIN zdk_users AS usr ON usr.user_id = tas.user_id";
        $this->dateColumns = array('begin_date', 'end_date', 'creation_date');
    }

    public function setNotFinishedAsFilter() {
        $this->filterClause = 'WHERE tas.status_id != ?';
        $this->setFilterCriteria(3);
    }

}
?>

In ZnetDK 4 Mobile version >=2.8, The PHP script containing the custom DAO class definition can be named using the same case as the class name (for example TaskDAO.php) to comply with the PSR-4 autoloading standard.


\DAO PROPERTIES

$table, $query, $filterClause, $groupByClause, $idColumnName, $dateColumns, $moneyColumns, $amountColumns, $tableAlias

 Property $table
DESCRIPTION Name of the SQL table to update when calling the \DAO::store() and \DAO::remove() methods.
If the \DAO::$query property is not initialized, the \DAO::getResult() method returns all the rows and columns of the specified table.
ACCESS Protected
DATATYPE String
DEFAULT VALUE undefined
EXAMPLE
<?php
$this->table = 'my_table';

 Property $query
DESCRIPTION SQL query executed to select data when the \DAO::getResult() method is called.
ACCESS Protected
DATATYPE String
DEFAULT VALUE undefined
EXAMPLE
<?php
$this->query = "SELECT col1, col2 FROM my_table";

 Property $filterClause
DESCRIPTION SQL condition applied dynamically when calling the \DAO::getResult() method to filter the rows returned.
The values of the SQL condition are set through a call to the \DAO::setFilterCriteria() method.
ACCESS Protected
DATATYPE String
DEFAULT VALUE FALSE
EXAMPLE
<?php
$this->filterClause = "WHERE col1 = ?";

 Property $groupByClause
DESCRIPTION GROUP BY clause of the SQL query.
The grouping clause must be specified outside the \DAO::$query property in the case where a custom filter is defined through the \DAO::$filterClause property.
ACCESS Protected
DATATYPE String
DEFAULT VALUE FALSE
EXAMPLE
<?php
$this->groupByClause = "GROUP BY col1 HAVING COUNT(col1) > 5";

 Property $IdColumnName
DESCRIPTION Name of the column in the SQL table corresponding to the Primary Key.
This property must be changed if the primary key column is not named id.
ACCESS Protected
DATATYPE String
DEFAULT VALUE 'id'
EXAMPLE
<?php
$this->IdColumnName = 'my_row_id';

 Property $dateColumns
DESCRIPTION Array containing the names of the DATE columns to format according to the current displayed language.
The specified date columns are returned by the \DAO::getResult() method with _locale as suffix (for example mydatecol_locale).
ACCESS Protected
DATATYPE Array
DEFAULT VALUE []
EXAMPLE
<?php
$this->dateColumns = ['creation_date', 'update_date'];

 Property $moneyColumns
DESCRIPTION Array containing the names of the columns to display as money according to the current displayed language.
The specified columns are returned by the \DAO::getResult() method with _money as suffix (for example my_amount_money).
ACCESS Protected
DATATYPE Array
DEFAULT VALUE []
EXAMPLE
<?php
$this->moneyColumns = ['subtotal', 'total'];

 Property $amountColumns
DESCRIPTION Array containing the names of the columns to display as amount according to the current displayed language.
The specified columns are returned by the \DAO::getResult() method with _amount as suffix (for example balance_amount).
ACCESS Protected
DATATYPE Array
DEFAULT VALUE []
EXAMPLE
<?php
$this->amountColumns = ['subtotal', 'total'];

 Property $tableAlias
DESCRIPTION Alias of the SQL table.
The alias must be specified if the SQL query defined for the \DAO::$query property uses an SQL alias.
If you don't specify the alias, an error is returned by the \DAO::getById() method.
ACCESS Protected
DATATYPE String
DEFAULT VALUE FALSE
EXAMPLE
<?php
$this->query = "SELECT col1, col2 FROM my_table AS tab";
$this->tableAlias = 'tab';

\DAO METHODS

initDaoProperties(), addCondition(), setFilterCriteria(), setSortCriteria(), setLimit(), setSelectedColumns(), setForUpdate(), setAmountColumns(), setMoneyColumns(), setDateColumns(), getResult(), getById(), getCount(), store(), remove(), beginTransaction(), commit(), rollback()

 Method initDaoProperties()
DESCRIPTION Abstract method implemented by the derived class to initialize the properties of the \DAO object.
EXAMPLE
<?php
namespace app\model;
class Customers extends \DAO
{
  protected function initDaoProperties() {
    $this->query = "SELECT id, customer_name FROM customers";
    $this->filterClause = "WHERE customer_name LIKE ?";
  }
}

 Method addCondition()
DESCRIPTION Adds a condition to the WHERE clause of the SQL query.
The specified condition is added to the $filterClause property.

This method can be called multiple times. At the first call, the specified condition is added to the $filterClause property and is prefixed by the WHERE clause. For the next calls, the specified condition is added at the end of the $filterClause property and is prefixed by the AND operator.
ACCESS Protected
PARAMETERS
$condition string The SQL WHERE clause condition to add.
$values array The values matching the placeholders (i.e ?) set within the condition.
EXAMPLE
<?php
namespace app\model;
class Customers extends \DAO
{
  protected function initDaoProperties() {
    $this->table = "customers";
  }
  public function setCountryAsFilter($countryCode) {
    $this->addCondition("country = ?", [$countryCode]);
  }
  public function setContactAsFilter($firstName, $lastName) {
    $this->addCondition("first_name = ? AND last_name = ?", [$firstName, $lastName]);
  }
}

 Method setFilterCriteria()
DESCRIPTION Sets one or several values for filtering rows.
These values are passed in parameters of the method in the same order than the placeholders (i.e ?) set for the $filterClause property.
PARAMETERS
$filterValue1 mixed First value of the first filter criterium.
$filterValue2 mixed Second value of the second filter criterium.
$filterValueN mixed Nth value of the Nth filter criterium.
EXAMPLE
<?php
$customers = [];
$myDao = new \app\model\Customers();
$myDao->setFilterCriteria('spain','france','uk');
while($row = $myDao->getResult()) {
    $customers[] = $row;
}

 Method setSortCriteria()
DESCRIPTION Sets the sort criteria to apply to the rows returned by the getResult() method.
PARAMETERS
$sortCriteria String A comma-separated list of the columns involved in row sorting, just like the ORDER BY clause in SQL.
EXAMPLE
<?php
$customers = [];
$myDao = new \app\model\Customers();
$myDao->setSortCriteria('name DESC, city ASC');
while($row = $myDao->getResult()) {
    $customers[] = $row;
}

 Method setLimit()
DESCRIPTION Limits the number of rows returned by the getResult() method.
This method applies the LIMIT clause to the SQL query executed to select the rows.
PARAMETERS
$offset Integer First row number to select starting to 0.
$count Integer Number of rows to select.
EXAMPLE
<?php
$customers = [];
$myDao = new \app\model\Customers();
$myDao->setLimit(20,40);
while($row = $myDao->getResult()) {
    $customers[] = $row;
}

 Method setSelectedColumns()
DESCRIPTION Reduces the values returned when selecting rows to only specified columns.
PARAMETERS
$columns Array The columns to select.
EXAMPLE
<?php
$customers = [];
$myDao = new \app\model\Customers();
$myDao->setSelectedColumns(array('id','name'));
while($row = $myDao->getResult()) {
    $customers[] = $row;
}

 Method getResult()
DESCRIPTION Returns the current data row.
RETURNED VALUE Array | FALSE Data of the current row as an associative array where each key matches a column name of the SQL table.
Returns FALSE if no data row exists or if the last data row has already been returned at the previous call.

EXAMPLE
<?php
$customers = [];
$myDao = new \app\model\Customers();
while($row = $myDao->getResult()) {
    $customers[] = $row;
}

 Method getById()
DESCRIPTION Returns the row's data matching the specified identifier.
PARAMETERS
$id Integer Identifier of the row to select in the SQL table.
RETURNED VALUE Array | FALSE Associative array containing the data of the selected row.
Returns FALSE if no data row exists for the specified identifier.

EXAMPLE
<?php
$myDao = new \app\model\Customers();
$rowData = $myDao->getById(43);
$customerName = $rowData['customer_name'];

 Method getCount()
DESCRIPTION Returns the total number of data rows returned by the method getResult() if it is next called.
RETURNED VALUE Integer Number of data rows.
EXAMPLE
<?php
$myDao = new \app\model\Customers();
$rowCount = $myDao->getCount();

 Method store()
DESCRIPTION Stores in the SQL table of the DAO the specified data row.
PARAMETERS
$row Array Data row as an associative array where each key corresponds to a column name in the SQL table.
If the identifier is specified in the array, the data row is updated (UPDATE in SQL).
Otherwise, the data row is inserted in the table (INSERT in SQL).
$autocommit Boolean Specifies whether the data must be commited after its update or insertion.
$emptyValuesToNull Boolean If TRUE, converts the empty values (ie '') to NULL.
RETURNED VALUE Integer Identifier of the row inserted or updated.
EXAMPLE
<?php
$row = array('id'=>18,'name'=>'MARTIN','city'=>'Paris');
$myDao = new \app\model\Customers();
$result = $myDao->store($row);

 Method remove()
DESCRIPTION Removes the table's row matching the specified row identifier.
If the row identifier is not set in paramater, the filter criteria set for the DAO object (see $filterClause property) are used to remove the corresponding rows.
In ZnetDK 4 Mobile version >= 3.5, the sort order (see setSortCriteria() method) is took in account when no row identifier is set in parameter.
PARAMETERS
$rowID Integer | NULL Identifier of the row to remove or NULL for removing multiple rows matching selection criteria.
$autocommit Boolean Specifies whether the data once removed must be commited or not.
RETURNED VALUE Integer The number of rows removed.
EXAMPLE
<?php
$customerId = 52;
$myDao = new \app\model\Customers();
$rowCount = $myDao->remove($customerId);

 Method beginTransaction()
DESCRIPTION Starts an explicit SQL transaction which requires a call to commit() or rollback() to end it.
PARAMETERS
$silent Boolean OPTIONAL, set to FALSE by default. if set to TRUE, the transaction is not started if it is already active and no exception is thrown.
EXAMPLE
<?php
$myDao = new \app\model\Customers();
$myDao->beginTransaction();

 Method setForUpdate()
DESCRIPTION Enables or disables the locking of selected rows by adding the FOR UDATE clause to the SQL query.
A SQL transaction must first be explicity started via beginTransaction() before calling this method.
Next the rows are selected using the getResult() and getById() methods.
PARAMETERS
$isForUpdate Boolean Value TRUE for enabling rows locking, FALSE to disable it.
EXAMPLE
<?php
$myDao = new \app\model\Customers();
$myDao->beginTransaction();
$myDao->setForUpdate(TRUE);
$row = $myDao->getById(18);
$row['is_visible'] = 'Y';
$myDao->store($row, FALSE);
$myDao->commit();

 Method setAmountColumns()
DESCRIPTION Set columns to display as Amount according locale settings.
For example, if the column 'total' is specified, the column named 'total_amount' is added to the row returned by the getResult() and getById() methods and contains the formated value as amount.
See also LC_LOCALE_DECIMAL_SEPARATOR, LC_LOCALE_THOUSANDS_SEPARATOR, LC_LOCALE_NUMBER_OF_DECIMALS ZnetDK constants.
PARAMETERS
$column String one or several column names
VERSION >= 2.8
EXAMPLE
<?php
$myDao = new \app\model\Customers();
$myDao->setAmountColumns('balance', 'expenses');
$customer = $myDao->getById(18);
$balanceAmount = $customer['balance_amount'];
$expensesAmount = $customer['expenses_amount'];

 Method setMoneyColumns()
DESCRIPTION Set columns to display as Money according locale settings.
For example, if the column 'total' is specified, the column named 'total_money' is added to the row returned by the getResult() and getById() methods and contains the formated value as money.
See also LC_LOCALE_DECIMAL_SEPARATOR, LC_LOCALE_THOUSANDS_SEPARATOR, LC_LOCALE_NUMBER_OF_DECIMALS, LC_LOCALE_CURRENCY_SYMBOL, LC_LOCALE_CURRENCY_SYMBOL_PRECEDE, LC_LOCALE_CURRENCY_SYMBOL_SEPARATE ZnetDK constants.
PARAMETERS
$column String one or several column names
VERSION >= 2.8
EXAMPLE
<?php
$myDao = new \app\model\Customers();
$myDao->setMoneyColumns('balance', 'expenses');
$customer = $myDao->getById(18);
$balanceAsMoney = $customer['balance_money'];
$expensesAsMoney = $customer['expenses_money'];

 Method setDateColumns()
DESCRIPTION Set columns to display as Date according locale settings.
For example, if the column 'update_date' is specified, the column named 'update_date_locale' is added to the row returned by the getResult() and getById() methods and contains the formated value as money.
See also LC_LOCALE_DATE_FORMAT ZnetDK constant.
PARAMETERS
$column String one or several column names
VERSION >= 2.8
EXAMPLE
<?php
$myDao = new \app\model\Customers();
$myDao->setMoneyColumns('creation_date', 'birthday');
$customer = $myDao->getById(18);
$localeCreationDate = $customer['creation_date_locale'];
$localeBirthday = $customer['birthday_locale'];

 Method commit()
DESCRIPTION Commits the data changed in the table.
EXAMPLE
<?php
$row = array('id'=>18,'name'=>'MARTIN','city'=>'Paris');
$myDao = new \app\model\Customers();
$myDao->beginTransaction();
$result = $myDao->store($row, FALSE);
$myDao->commit();

 Method rollback()
DESCRIPTION Cancels in the database the SQL transaction explicitly initiated by a call to the beginTransaction() method of the DAO.
EXAMPLE
<?php
$row = array('id'=>18,'name'=>'MARTIN','city'=>'Paris');
$myDao = new \app\model\Customer();
$myDao->beginTransaction();
$result = $myDao->store($row);
$myDao->rollback();

Class \SimpleDAO

_construct(), getRows(), getRowsForCondition(), getSuggestions(), setKeywordSearchColumn()

The ZnetDK class \SimpleDAO offers an easy and quick way to operate on a single SQL table or view.

As it is a concrete class, no need to create any DAO class, just instantiate a \SimpleDAO object by specifying in the constructor the SQL table name.
The \SimpleDAO class is derived from the \DAO class and so gives access to all its methods.

Here is an example of usage of the \SimpleDAO class.

EXAMPLE
<?php
$contactsDao = new \SimpleDAO('contacts');
$rowsFound = array();
$rowCount = $contactsDao->getRows($rowsFound, 'name');
?>

 Constructor _construct()

DESCRIPTION Constructor of the \SimpleDAO class to instantiate an object used in order to access the SQL table specified in parameter.
Once instantiated, a SimpleDAO object can also access to all protected and public properties and methods of the \DAO class.
PARAMETERS
$tableName String Name of the SQL table or view to browse or to update.
RETURNED VALUE \SimpleDAO New object of type SimpleDAO.
EXAMPLE
<?php
$dao = new \SimpleDAO('customers');

 Method getRows()

DESCRIPTION Returns the rows of the SQL table specified in the object constructor, also taking the following POST parameters into account:
 first: the first line to return,
 count: the number of rows to return,
 sortfield: the sorted column,
 sortorder: the sort order ('1' or '-1'),
 keyword: the keyword to search for in the specified rows' column through the setKeywordSearchColumn() method.
PARAMETERS
&$rowsFound Array The rows found in the SQL table that are returned by reference by the method.
$defaultSortFields String OPTIONAL, a comma-separated list of the columns involved in row sorting, just like the ORDER BY clause in SQL.
These sort criteria are only applied if the POST parameters sortfield and sortorder are not set.
For example: 'city ASC, id DESC'.
RETURNED VALUE Array Total number of rows that exist in the SQL table if the keyword POST parameter is empty.
Otherwise this number is the total number of rows found in the SQL table for the specified keyword.
In all cases, this total number is always greater than or equal to the number of rows returned in the $rowsFound variable.
EXAMPLE
<?php
/* POST parameters: first='0', count='10', keyword='paul' */
$dao = new \SimpleDAO('customers');
/* keywords searched into the table's column 'name' */
$dao->setKeywordSearchColumn('name');
$customers = array();
/* Rows found are sorted by 'name' (sorting POST parameters not set) */
$total = $dao->getRows($customers, 'name ASC');

 Method getRowsForCondition()

DESCRIPTION Returns the rows matching the specified condition and values.
PARAMETERS
$condition String Condition to apply to select the SQL table's rows.
It is given as a standard SQL WHERE clause condition with a question mark (i.e ?) as placeholder for each value set as parameter.
For example: 'color = ? AND type = ?'.

$value1 [,$value2, $valueN] mixed Values matching each question marks existing within the SQL condition ($condition).
The first value is mandatory. The next values are optionals.
The number of values passed as parameter of this method depends on the number of existing question marks within the SQL condition.
For example: [
['id' => '5', 'color' => 'Blue', 'type' = 'public'],
['id' => '8', 'color' => 'Red', 'type' => 'private']
].
RETURNED VALUE Array The rows found as an array of associative arrays where the keys match the table's column names.
EXAMPLE
<?php
$dao = new \SimpleDAO('customers');
$condition = 'name LIKE ?';
$value = 'jean';
$result = $dao->getRowsForCondition($condition, "%{$value}%");

 Method getSuggestions()

DESCRIPTION Returns the suggestions matching the keyword set through the query POST parameter.
The setKeywordSearchColumn() method must be called first to specify the SQL column name in which the keyword is searched in.
PARAMETERS
$count Integer OPTIONAL, maximum number of suggestions to return (value 10 by default).
RETURNED VALUE Array | FALSE The suggestions as an array of associative arrays where each subarray has 'value' and 'label' keys.
For example: [['value' => '7', 'label' => 'Jean MORISSON'], ['value' => '59', 'label' => 'Jean CARRY']]
Returns FALSE if the table's column name is not set through the setKeywordSearchColumn() method.
EXAMPLE
<?php
/* POST parameter: query='jean' */
$dao = new \SimpleDAO('customers');
$dao->setKeywordSearchColumn('name');                
$suggestions = $dao->getSuggestions(20);

 Method setKeywordSearchColumn()

DESCRIPTION Specifies the name of the SQL table column in database in which the keywords are searched in.
This method is invoked before calling the getRows() and getSuggestions() methods.
PARAMETERS
$columnName String Column name of the table set when calling the SimpleDAO class constructor.
EXAMPLE
<?php
$dao = new \SimpleDAO('customers');
$dao->setKeywordSearchColumn('name');

Class \Database

getCustomDbConnection(), beginTransaction(), inTransaction(), commit(), rollback()

 Method getCustomDbConnection()

DESCRIPTION Returns a custom database connection from the specified parameters.
PARAMETERS
$host String Hostname of the MySQL server.
$database String Database name.
$user String User account.
$password String User's password.
$port Integer The TCP/IP port number where the database server is listening.
RETURNED VALUE \PDO Database connection object.
EXAMPLE
<?php
$dbConnection = \Database::getCustomDbConnection('localhost', 'my-dbname', 'db-user', 'mypassword', 8083);

 Method beginTransaction()

DESCRIPTION Begins a database transaction.
EXAMPLE
<?php
\Database::beginTransaction();
// Data storage...
\Database::commit();

 Method inTransaction()

DESCRIPTION Checks if a database transaction is active.
RETURNED VALUE Boolean TRUE if a transaction is active, FALSE otherwise
EXAMPLE
<?php
if (!\Database::inTransaction()) {
    \Database::beginTransaction();
}
// Data storage...
\Database::commit();

 Method commit()

DESCRIPTION Commits a database transaction.
EXAMPLE
<?php
\Database::beginTransaction();
// Data storage...
\Database::commit();

 Method rollback()

DESCRIPTION rollbacks a database transaction.
EXAMPLE
<?php
\Database::beginTransaction();
// Data storage...
\Database::rollback();

Data Validation

Form data sent to the web server can be verified before storage using a custom PHP class in charge of their validation.

Class \Validator

The \Validator class is abstract and can only be instantiated through a derived class that implements:
  • initVariables() method to specify the names of the HTTP request data to check,
  • Optionally, the initOptionalVariables() method to indicate the names of the HTTP request data whose values are not mandatory,
  • Finally, a check_[dataName]() control method for each data of the HTTP request to be checked. For example, it will be called check_email() to check the POST data named email.

The custom derived class is generally stored into the INSTALL_DIR/applications/default/app/validator/ folder.

EXAMPLE: custom MyValidator class derived from the \Validator class
<?php
namespace app\validator;
class MyValidator extends \Validator {
    protected function initVariables() {
        return array('user_name','user_email');
    }

    protected function check_user_name($value) {
        // 100 characters maximum
        if (strlen($value) > 100) {
            $this->setErrorMessage('User name is too long!');
            return FALSE;
        }
        return TRUE;
    }

    protected function check_user_email($value) {
        // Must be a valid email address
        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
            $this->setErrorMessage('Email address invalid!');
            return FALSE;
        }
        return TRUE;
    }
}
?>

In ZnetDK 4 Mobile version >=2.8, The PHP script containing the validation class definition can be named using the same case as the class name (for example MyValidator.php) to comply with the PSR-4 autoloading standard.


Checking data with a validator object

The application controller, at the origin of the data verification request, instantiates an object derived from the Validator class and evaluates the quality of the HTTP data before their processing by calling:
  • In option, setCheckingMissingValues() method to specify that empty data (null) are also checked,
  • validate() method to check data,
  • getErrorVariable() method to obtain the name of the first POST data detected in error,
  • getErrorMessage() method to get the error message returned by the check_[dataName]() method that detected the error,
  • In option, getValues() method to get the values of the POST data that have been checked.
EXAMPLE: Call of the custom MyValidator class for data checking
<?php
namespace app\controller;
class MyController extends \AppController {

    protected function action_save() {
        $request = new \Request();
        $response = new \Response();
        // Form data validation
        $validator = new \app\validator\MyValidator();
        $validator->setCheckingMissingValues();
        if (!$validator->validate()) {
            $response->setFailedMessage(NULL, $validator->getErrorMessage(),
                $validator->getErrorVariable());
            return $response;
        }
        // Storage
        $request = new \Request();
        $row = $validator->getValues();
        $row['id'] = $request->id;
        $dao = new \SimpleDAO('my_users');
        $dao->store($row);
        $response->setSuccessMessage('User', 'Stored successfully.');
        return $response;
    }

}
?>

User Data

\UserSession | \User | \controller\Users | \controller\Security

Class \UserSession

setCustomValue(), getCustomValue(), removeCustomValue(), getUserId() getLoginName(), getLanguage(), getUserName(), getUserEmail(), hasFullMenuAccess(), getUserProfiles(), hasUserProfile(), isAuthenticated(), isUITokenValid()

User sessions are managed via the \UserSession ZnetDK class that is used to get informations about the logged in user and to store custom data.

The session is started automatically and so doesn't need to be started explicitly.

 Method setCustomValue()

DESCRIPTION Stores in the user's session a value for the specified variable name.
Please note that text data is sanitized before it is stored in session.
So to store data in HTML format, the data must first be converted before storage calling the htmlentities() PHP function and restored after session read by calling the html_entity_decode() PHP function.
PARAMETERS
$variableName String Name of the variable used to store the value in session.
$value mixed Value to store in session.
$sanitize = FALSE Boolean When set to TRUE, value is sanitized before being stored in session.
EXAMPLE
<?php
\UserSession::setCustomValue('myVarInSession', 18);
?>

 Method getCustomValue()

DESCRIPTION Retrieves in the user's session, the value previously stored for the specified variable name.
PARAMETERS
$variableName String Name of the variable used to store the value in session.
$sanitize = FALSE Boolean When set to TRUE, value is sanitized before being returned.
RETURNED VALUE mixed | NULL The value stored in session for the specified variable name.
Returns NULL if no variable exists in the user's session for the name of variable specified in parameter.
EXAMPLE
<?php
$myValueInSession = \UserSession::getCustomValue('myVarInSession');
?>

 Method removeCustomValue()

DESCRIPTION Removes in the user's session, the value previously stored for the specified variable name.
PARAMETERS
$variableName String Name of the variable to remove from the user's session.
RETURNED VALUE Boolean Returns TRUE if the variable exists and has been removed, FALSE if the specified variable does not exist in session.
EXAMPLE
<?php
\UserSession::removeCustomValue('myVarInSession');
?>

 Method getUserId()

DESCRIPTION Returns the user ID stored in the user session for the authenticated current user.
RETURNED VALUE Integer Identifier in the database (user_id) of the authenticated user or value NULL if user is not authenticated.
VERSION >= 2.5
EXAMPLE
<?php
$userId = \UserSession::getUserId();
?>

 Method getLoginName()

DESCRIPTION Returns the login name stored in session for the logged in user.
RETURNED VALUE String The login name of the logged in user or NULL if no user is logged in.
EXAMPLE
<?php
$loginName = \UserSession::getLoginName();
?>

 Method getLanguage()

DESCRIPTION Returns the language ISO 639-1 code stored in the user session.
RETURNED VALUE String Language ISO 639-1 code.
EXAMPLE
<?php
$userLang = \UserSession::getLanguage();
?>

 Method getUserName()

DESCRIPTION Returns the user name stored in the user session for the authenticated current user.
RETURNED VALUE String User's name.
VERSION >= 2.9
EXAMPLE
<?php
$userName = \UserSession::getUserName();
?>

 Method getUserEmail()

DESCRIPTION Returns the user email stored in session for the authenticated current user.
RETURNED VALUE String User's email address.
VERSION >= 2.9
EXAMPLE
<?php
$userEmail = \UserSession::getUserEmail();
?>

 Method hasFullMenuAccess()

DESCRIPTION Indicates whether or not the authenticated user has full access to the application's navigation menu.
RETURNED VALUE Boolean Returns TRUE if user has full menu access, FALSE otherwise.
VERSION >= 2.9
EXAMPLE
<?php
$fullAccess = \UserSession::hasFullMenuAccess();
?>

 Method getUserProfiles()

DESCRIPTION Returns the user profiles for the authenticated user.
RETURNED VALUE Array All the profiles assigned to the authenticated user.
VERSION >= 2.9
EXAMPLE
<?php
$userProfiles = \UserSession::getUserProfiles();
?>

 Method hasUserProfile()

DESCRIPTION Checks if the authenticated user has the specified profile name.
PARAMETERS
$profileName String Name of the user profile to check for the authenticated user.
RETURNED VALUE Boolean Returns TRUE if user has the specified profile, FALSE otherwise.
VERSION >= 2.9
EXAMPLE
<?php
$hasProfile = \UserSession::hasUserProfile();
?>

 Method isAuthenticated()

DESCRIPTION Indicates whether the user is authenticated or not.
PARAMETERS
$silent = FALSE Boolean if TRUE, no 401 HTTP error is thrown.
RETURNED VALUE Boolean TRUE if user is authenticated, FALSE otherwise.
EXAMPLE
<?php
if (!\UserSession::isAuthenticated(TRUE)) {
    // User not authenticated!
}
?>

 Method isUITokenValid()

DESCRIPTION Checks if the UI token sent in POST request is the same than the one stored in user's session.
PARAMETERS
$silent = TRUE Boolean Specifies if an error message is traced into the errors.log file when no token exists in the HTTP POST request while a token exists in the user's session.
RETURNED VALUE Boolean TRUE if this is a GET request, if no token is stored in session and if POST request token matches the one stored in Session.
VERSION >= 3.0
EXAMPLE
<?php
if (!\UserSession::isUITokenValid(TRUE)) {
    // Token is invalid!
}
?>

Class \User

__construct(), __get(), __set(), add(), addProfile() disableNotification() generateLoginName() generateNewPassword() getPasswordInClear() getProfiles() grantProfiles() hasProfile() notify(), remove(), removeProfile(), setCustomDatabaseConnexion(), setExpirationDate(), update(), validate()

The \User class can be used to manage user accounts programmatically. User accounts are stored in the zdk_users SQL table.

This class exists in version >=3.3 of ZnetDK.

 Method __construct()

DESCRIPTION Instantiates a new user object to record a new user, edit or remove an existing user.
PARAMETER
$id = NULL int OPTIONAL, Identifier of an existing user stored in the datatabase (value of the user_id column in the zdk_users SQL table).
To record a new user, this argument is set to NULL.
RETURNED VALUE \User New user object.
EXCEPTION
\ZDKException URA-003 when $id is specified and no user matches the identifier value.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
?>

 Method __get()

DESCRIPTION Returns the value of the specified property.
PARAMETERS
$name string The property name matching a column name in the zdk_users SQL table (for example, 'user_name', 'user_email', ...).
RETURNED VALUE string Value found for the specified property.
EXCEPTION
\ZDKException URA-008 when $name does not match any column name in the zdk_users SQL table.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$loginName = $existingUser->login_name;
?>

 Method __set()

DESCRIPTION Sets a value for the specified property.
PARAMETERS
$property string The property name matching a column name in the zdk_users SQL table (for example, 'user_name', 'user_email', ...).
$value string The value to set to the property.
EXCEPTION
\ZDKException URA-008 when $name does not match any column name in the zdk_users SQL table.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$newUser->login_name = 'john_doe';
?>

 Method add()

DESCRIPTION Adds a new user.
Mandatory properties: login_name, user_name and user_email.
Optional properties: login_password, expiration_date, user_phone, notes, full_menu_access and user_enabled.
if login_password is not set: it is automatically generated.
if expiration_date is not set: its default value is today.
if user_enabled is not set: it is enabled by default.
PARAMETERS
$autocommit = TRUE boolean If FALSE, user is stored within the database transaction started before calling this method.
RETURNED VALUE integer New internal identifier assigned to the user (user_id column).
EXCEPTION
\ZDKException URA-006 no property set for the user. URA-007 mandatory user property not set set. URA-009 a user property value is invalid.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$newUser->login_name = 'john_doe';
$newUser->user_name = 'John DOE';
$newUser->user_email = 'johndoe@myemail.xyz';
$userId = $newUser->add();
?>

 Method addProfile()

DESCRIPTION Grants the specified profile to an existing user.
PARAMETERS
$profileName string Name of the profile to grant to the user
$autocommit = TRUE boolean If FALSE, user is stored within the database transaction started before calling this method.
EXCEPTION
\ZDKException URA-004 user identifier not set. URA-012 the specified profile name is unknown. URA-013 the specified profile name is already granted to the user.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$existingUser->addProfile('Super user');
?>

 Method disableNotification()

DESCRIPTION Disables user notification when user is added or when their password has been changed (see \controller\Users::notify() method).
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$newUser->disableNotification();
?>

 Method generateLoginName()

DESCRIPTION Generates a unique login name from the specified string
PARAMETERS
$string string String used to generate a new login name.
RETURNED VALUE string The new login name with only alphabetic characters in lower case.
Whitespaces are replaced by '_'.
The minimum length of the new login name is 8 characters (padded on the right with '0' characters) and the maximum length is 20 characters.
If the same login name already exists, a number from 1 is added as suffix on the right.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$loginName = $newUser->generateLoginName('John DOE');
?>

 Method generateNewPassword()

DESCRIPTION Generates a new password for the user and assign it to the login_password property.
RETURNED VALUE string The auto generated password in clear.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$newPasswordInClear = $existingUser->generateNewPassword();
$existingUser->update(); // Updates new password in database
?>

 Method getPasswordInClear()

DESCRIPTION Returns the password in clear after calling the \User::add() method.
RETURNED VALUE string | NULL The password in clear or NULL if no password has been hashed.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$newUser->login_name = 'john_doe';
$newUser->user_name = 'John DOE';
$newUser->user_email = 'johndoe@myemail.xyz';
$userId = $newUser->add();
$passwordInClear = $newUser->getPasswordInClear();
?>

 Method getProfiles()

DESCRIPTION Returns the granted profiles to an existing user.
RETURNED VALUE array The profile names granted to user.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$profileNames = $existingUser->getProfiles();
?>

 Method grantProfiles()

DESCRIPTION Grants the specified profiles to an existing user.
PARAMETERS
$profiles array The profile names to grant
$autocommit = TRUE boolean If FALSE, profiles are stored within the database transaction started before calling this method.
EXCEPTION
\ZDKException URA-011 $profiles is not an array or is empty. URA-004 user identifier not set. URA-012 the specified profile name is unknown. URA-013 the specified profile name is already granted to the user.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$existingUser->grantProfiles(['Resource manager', 'Scheduler']);
?>

 Method hasProfile()

DESCRIPTION Checks whether the specified profile is granted or not to an existing user.
PARAMETERS
$profileName string Name of the profile to check.
RETURNED VALUE boolean TRUE if user has the specified profile, FALSE otherwise.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$hasSchedulerProfile = $existingUser->hasProfile('Scheduler');
?>

 Method notify()

DESCRIPTION Notifies a user when added or when their password has been changed (see \controller\Users::notify() method).
This method is generally called at an opportune moment when notification has been previously disabled through the \User::disableNotification() method.
PARAMETERS
$isNewUser boolean TRUE if a new user has been created, FALSE in the case of a password change.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$newPasswordInClear = $existingUser->generateNewPassword();
$existingUser->disableNotification(); // Automatic notification is disabled
\Database::beginTransaction();
$existingUser->update(FALSE); // Updates new password in database
// Other stuff...
\Database::commit();
$existingUser->notify(FALSE);
?>

 Method remove()

DESCRIPTION Removes an existing user.
The controller\Users::onRemove() hook methods are called if exist in the application and in the modules in order to remove custom user's data.
If profiles are granted to the user, they are removed first.
PARAMETERS
$autocommit = TRUE boolean If FALSE, user is removed within the database transaction started before calling this method.
VERSION >= 3.3
EXAMPLE
<?php
$user = new \User(43);
$user->remove();
?>

 Method removeProfile()

DESCRIPTION Removes the specified granted profile name to an existing user.
PARAMETERS
$profileName string Profile name
$autocommit = TRUE boolean If FALSE, the statement is executed within the database transaction started before calling this method..
EXCEPTION
\ZDKException URA-014 the specified profile is not granted to the user.
VERSION >= 3.3
EXAMPLE
<?php
$existingUser = new \User(56);
$existingUser->removeProfile('Scheduler');
?>

 Method setCustomDatabaseConnexion()

DESCRIPTION Set a Custom database connection to manage user.
PARAMETERS
$databaseConnection \PDO Database connection obtained by calling the \Database::getCustomDbConnection() method.
VERSION >= 3.3
EXAMPLE
<?php
$dbConnection = \Database::getCustomDbConnection('localhost', 'my-dbname', 'db-user', 'mypassword', 8083);
$newUser = new \User();
$newUser->setCustomDatabaseConnexion($dbConnection);
?>

 Method setExpirationDate()

DESCRIPTION Sets the expiration date of the user's password.
This date is calculated from the CFG_DEFAULT_PWD_VALIDITY_PERIOD constant value set for the application.
The name of the property set by this method is expiration_date.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$newUser->setExpirationDate();
?>

 Method update()

DESCRIPTION Updates user information.
PARAMETERS
$autocommit boolean If FALSE, user is stored within the database transaction started before calling this method.
RETURNED VALUE integer Internal identifier of the updated user (user_id column).
VERSION >= 3.3
EXAMPLE
<?php
$user = new \User(43);
$user->user_email = 'johndoe@mynewemail.xyz';
$user->update();
?>

 Method validate()

DESCRIPTION Validates user data.
PARAMETERS
$throwException = FALSE boolean If TRUE, an exception is triggered if validation failed.
RETURNED VALUE TRUE | array TRUE if validation has succeeded otherwise informations about failed validation (keys are 'message' and 'property').
EXCEPTION
\ZDKException URA-015 no data set to validate. URA-009 validation error if $throwException is TRUE.
VERSION >= 3.3
EXAMPLE
<?php
$newUser = new \User();
$newUser->login_name = 'john_doe';
$newUser->user_name = 'John DOE';
$newUser->user_email = 'johndoe@myemail.xyz';
try {
    $newUser->validate(TRUE);
    $newUser->add();
} catch(\Exception $ex) {
    \General::writeErrorLog(__METHOD__, $ex->getMessage());
}
?>

Class \controller\Users

getUserName(), getUserEmail(), getUserTheme(), hasProfile(), hasMenuItem(), notify(), onRemove()

The \controller\Users class is used to get informations stored in database about the logged in user. A custom \controller\Users class can also be declared within the application or within a module to enhance standard features.

 Method getUserName()

DESCRIPTION Returns the user name of the currently logged in user.
RETURNED VALUE String User name or NULL if the user name can't be read in the database or if no user is authenticated.
EXAMPLE
<?php
$userName = \controller\Users::getUserName();
?>

 Method getUserEmail()

DESCRIPTION Returns the user email of the currently logged in user.
RETURNED VALUE String User email or NULL if the user email can't be read in the database or if no user is authenticated.
EXAMPLE
<?php
$userEmail = \controller\Users::getUserEmail();
?>

 Method getUserTheme()

DESCRIPTION Custom method called by ZnetDK to get the user's preferred theme CSS stylesheet.
To be declared in the application (in INSTALL_DIR/applications/default/app/controller) or in a module (in INSTALL_DIR/engine/modules/[module_name]/mod/controller where [module_name] is to replace by the module name), this method is useful for applying a specific theme to the logged in user.
RETURNED VALUE String | FALSE The relative path of the theme CSS stylesheet to load for the logged in user or FALSE if the default theme is to apply.
VERSION >= 3.2
EXAMPLE
<?php
namespace app\controller; // Namespace for the application
// namespace mymodule\mod\controller; // Namespace for the module named 'mymodule'
class Users extends \AppController {
    static public function getUserTheme() {
        /* Method called to get the logged in user's preferred theme */
        $preferredTheme = self::getPreferredThemeForUser(\UserSession::getUserId());
        if ($preferredTheme === 'dark') {
            /* Dark theme stylesheet relative path is returned */
            return 'applications/default/public/css/theme-dark.css';
        } else {
            return FALSE; // Default theme is applied
        }
    }
    static private function getPreferredThemeForUser($userID) {
        // Your code...
    }
}
?>

 Method hasProfile()

DESCRIPTION Indicates whether the user has the specified profile or not.
RETURNED VALUE Boolean TRUE if user has the specified profile, otherwise FALSE.
EXAMPLE
<?php
if (\controller\Users::hasProfile('Manager')) {
    // User is manager
}
?>

 Method hasMenuItem()

DESCRIPTION Indicates whether the logged in user has access to the specified menu item.
PARAMETERS
$menuItem String The menu item (name of the view without the .php extension).
RETURNED VALUE Boolean TRUE if the user has access to the specified menu item, otherwise FALSE.
EXAMPLE
<?php
if (\controller\Users::hasMenuItem('myview')) {
    // User has access to "myview.php"
}
?>

 Method notify()

DESCRIPTION Custom method called by ZnetDK each time a user is created or modified.
To be declared in the application (in INSTALL_DIR/applications/default/app/controller) or in a module (in INSTALL_DIR/engine/modules/[module_name]/mod/controller where [module_name] is to replace by the module name), this method is useful for sending by email to the user, the URL of the application, their login ID and their password.
PARAMETERS
$isNewUser Boolean Specifies whether this a new user (value TRUE) or an existing user (value FALSE).
$passwordInClear String The user's password in clear.
$userRow Array Informations of the user stored in the SQL table zdk_users (see Security SQL Tables).
EXAMPLE
<?php
namespace app\controller; // Namespace for the application
// namespace mymodule\mod\controller; // Namespace for the module named 'mymodule'
class Users extends \AppController {
    static public function notify($isNewUser, $passwordInClear, $userRow) {
        if ($isNewUser) { // New user
            /* Method called to send the credentials to a newly created user */
            self::sendCredentialsToNewUser($passwordInClear, $userRow);
        } else { // Existing user
            /* Method called to send the new password to an existing user */
            self::sendNewPasswordToExistingUser($passwordInClear, $userRow);
        }
    }
    static private function sendCredentialsToNewUser($passwordInClear, $userRow) {
        // Your code...
    }
    static private function sendNewPasswordToExistingUser($passwordInClear, $userRow) {
        // Your code...
    }
}
?>

 Method onRemove()

DESCRIPTION Custom method called by ZnetDK before a user is removed to delete custom SQL rows in database.
To be declared in the application (in INSTALL_DIR/applications/default/app/controller) or in a module (in INSTALL_DIR/engine/modules/[module_name]/mod/controller where [module_name] is to replace by the module name).
PARAMETERS
$userID Integer User identifier in zdk_users SQL table.
VERSION >=3.3
EXAMPLE
<?php
namespace app\controller; // Namespace for the application
// namespace mymodule\mod\controller; // Namespace for the module named 'mymodule'
class Users extends \AppController {
    static public function onRemove($userID) {
        $dao = new \SimpleDAO('my_custom_table');
        $rows = $dao->getRowsForCondition('user_id = ?', $userID);
        foreach ($rows as $row) {
            $dao->remove($row['id'], FALSE);
        }
    }
}
?>

Class \controller\Security

A custom \controller\Security class can be declared within the application or within a module to enhance standard features.

 Method loginResult()

DESCRIPTION Custom method called by ZnetDK to provide informations about users who logged in to the application.
To be declared in the application (in INSTALL_DIR/applications/default/app/controller) or in a module (in INSTALL_DIR/engine/modules/[module_name]/mod/controller where [module_name] is to replace by the module name), this method is useful for storing in datatabase the history of users who logged in to the application.
PARAMETERS
$loginInfos Array Informations about users who logged in to the application. The array keys are: login_date, login_name, ip_address, status and message.
EXAMPLE
<?php
namespace app\controller; // Namespace for the application
// namespace mymodule\mod\controller; // Namespace for the module named 'mymodule'
class Security extends \AppController {
    static public function loginResult($loginInfos) {
        if ($loginInfos['status'] === FALSE) {
            // User failed to log in...
            \General::writeErrorLog(__METHOD__, 'User ' . $loginInfos['login_name']
                . ' (IP: ' . $loginInfos['ip_address'] . ')'
                . ' failed to login on ' . $loginInfos['login_date']
                . ' with error: ' . $loginInfos['message']
            );
        }
    }
}
?>

Miscellaneous Tools

\General | \Convert

The ZnetDK framework provides useful utility classes in PHP through the \General class.
Data conversion is ensured through the \Convert class.

Class \General

callRemoteAction(), getCurrentW3CDate(), getFilledMessage(), getURIforDownload(), isW3cDateValid(), isPictureTooBig(), reducePictureSize(), writeErrorLog()

 Method callRemoteAction()

DESCRIPTION Call a controller action of a remote ZnetDK application.
The remote controller action must be exposed as a Web Service (see CFG_HTTP_BASIC_AUTHENTICATION_ENABLED and CFG_ACTIONS_ALLOWED_FOR_WEBSERVICE_USERS parameters).
PARAMETERS
$swUrl String URL of the remote application. For example 'https://usr:pwd@mydomain.com/'
$method String Value 'POST' or 'GET'
$controller String Controller name
$action String Action name
$extraParameters Array OPTIONAL, POST or GET parameters expected by the remote action (set to [] by default).
For example: [my_param1 => 'val1', my_param2 => 'val2']
$extraHeaders VERSION >= 3.3 Array OPTIONAL, extra header lines to add to the HTTP header sent to the remote action (set to [] by default).
For example: ['Accept-language: fr', 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT']]
$returnHeader VERSION >= 3.3 Boolean OPTIONAL, If TRUE, the HTTP header is also returned by the method (set to FALSE by default).
RETURNED VALUE Mixed Data returned by the remote action. If JSON data are returned, they can be converted with the PHP json_decode function.
In version >= 3.3, if $returnHeader is TRUE, an array is returned and the header is returned as second value of the array.

VERSION >= 2.5
EXAMPLE
<?php
print_r(json_decode(\General::callRemoteAction('https://usr:pwd@mydomain.com/', 'POST',
            'mycontroller', 'myaction', ['my_param1' => 'val1', 'my_param2' => 'val2'])));
?>

 Method getCurrentW3CDate()

DESCRIPTION Get the current date in W3C format.
PARAMETERS
$withTime Boolean When set to TRUE (FALSE by default), the time is also returned on the right of the formated date.
RETURNED VALUE String the current date in W3C format ('Y-m-d').
EXAMPLE
<?php
echo \General::getCurrentW3CDate();
?>

 Method getFilledMessage()

DESCRIPTION Replace in the text of the message specified for the first parameter, the placeholders %1, %2, ... by the text value specified in the same order for the next paramaters.
This method is particularly useful when the string passed as first parameter is a PHP constant defined into the locale.php script.
PARAMETERS
$message String Original message in which the placeholders %1, %2, ... are to be replaced by the values specified as other parameters.
$text1 String Text for replacement of the placeholder %1.
$text2 String Text for replacement of the placeholder %2 if exists.
$textN String Text for replacement of the placeholder %N if exists.
RETURNED VALUE String Message filled with the pieces of text specified in input parameters.
EXAMPLE
<?php
echo \General::getFilledMessage('Your car is %1 and %2.','blue','yellow');
/* Display: Your car is blue and yellow. */
?>

 Method getURIforDownload()

DESCRIPTION Returns URI for downloading a file
PARAMETERS
$controller String Name of the controller taking in charge the file download. It corresponds to the name given to the controller PHP script without the .php extension. A download action must be implemented by the controller (PHP method named action_download()). See Class \Response() for getting more information about the action_download() controller's action.
$parameters String Extra parameters to send to the download controller action (NULL by default).
In version >= 2.6, the parameter cache=true when specified, enables to store in the browser's cache the downloaded file.
RETURNED VALUE String The URI for downloading the file.
EXAMPLE
<?php
$downloadUrl = \General::getURIforDownload('mycontroller', 'doc_id=98&cache=true');
/* The URI returned is "/znetdk/?control=mycontroller&action=download&doc_id=98&cache=true" */
echo '<a href="' . $downloadUrl . '">File to download</a>';

 Method isW3cDateValid()

DESCRIPTION Checks if the specified W3C date is valid
PARAMETERS
$w3cDate String A date as string in W3C format ('Y-m-d').
RETURNED VALUE boolean TRUE if the date is valid, FALSE otherwise.
EXAMPLE
<?php
$isValid = \General::isW3cDateValid('2022-12-29'); // Returns TRUE
$isNotValid = \General::isW3cDateValid('2022-02-30'); // Returns FALSE

 Method isPictureTooBig()

DESCRIPTION Checks if the picture is too big to be processed in server-side memory.
PARAMETERS
$filePath String Full file path of the original picture to resize.
$tweakFactor = 2 Float Factor used to evaluate the memory required for processing picture.
RETURNED VALUE Boolean TRUE if the picture is too big to be processed, otherwise FALSE.

VERSION >= 2.8
EXAMPLE
<?php
if (!\General::isPictureTooBig('mypicture.jpg')) {
    $resizedPicture = \General::reducePictureSize('mypicture.jpg', 260, 220);
}
?>

 Method reducePictureSize()

DESCRIPTION Resizes pictures (JPG or PNG) to the specified maximum width and height.
PARAMETERS
$filePath String Full file path of the original picture to resize.
$maxWidth Integer Maximum width in pixels
$maxHeight Integer Maximum height in pixels
$asBase64Url = TRUE Boolean When set to TRUE (default value) the picture is returned as URL format encoded in Base64. Otherwise, image content is returned in binary.
$tweakFactor = 2 Float Factor used to evaluate the memory required for processing picture.
RETURNED VALUE String The resized picture.

THROWS ZDKException 'gd' extension not loaded (GEN-003), file unknown (GEN-004), file extension invalid (GEN-005), picture size too big (GEN-006).

VERSION >= 2.6
EXAMPLE
<?php
$resizedPicture = \General::reducePictureSize('mypicture.jpg', 260, 220);
?>

 Method writeErrorLog()

DESCRIPTION Add an error entry in the ZnetDK error log.
PARAMETERS
$origin String Text specifying the origin of the error.
$textError String Text of the error.
EXAMPLE
<?php
\General::writeErrorLog('MYAPP', 'Error detected...');
?>

Class \Convert

base64UrlToBinary(), binaryToBase64Url(), toISO88591(), toMoney(), W3CtoLocaleDate(),

 Method base64UrlToBinary()

DESCRIPTION Converts a base64 URL to a binary value.
PARAMETERS
$base64Url String The base64 URL.
RETURNED VALUE String The converted binary value or an empty string if the parameter value is an empty string or NULL if conversion failed.
VERSION >= 2.6
EXAMPLE
<?php
$binaryValue = \Convert::base64UrlToBinary($base64UrlValue);
?>

 Method binaryToBase64Url()

DESCRIPTION Converts a binary value to a Base64 URL.
PARAMETERS
$binaryValue String The binary value to convert.
RETURNED VALUE String The converted value or an empty string if the parameter value is an empty string or NULL if conversion failed.
VERSION >= 2.6
EXAMPLE
<?php
$base64UrlValue = \Convert::binaryToBase64Url($binVal);
?>

 Method toISO88591()

DESCRIPTION Converts the specified string from UTF-8 to ISO-8859-1 encoding.
PARAMETERS
$string String UTF-8 string to convert.
RETURNED VALUE String Converted string in ISO-8859-1.
VERSION >= 3.0
EXAMPLE
<?php
$myIso88591String = \Convert::toISO88591($myUtf8String);
?>

 Method toMoney()

DESCRIPTION Format the specified number for display as money.
PARAMETERS
$number mixed Number to convert as a string or a numeric value.
$withCurrencySymbol Boolean Specifies whether the currency symbol is to be added to the formatted number (added by default).
$numberOfDecimals Integer Number of decimals of the converted number.
RETURNED VALUE String Number formated as a money.
EXAMPLE
<?php
$myMoney = \Convert::toMoney(3451.7399);
?>

 Method W3CtoLocaleDate()

DESCRIPTION Formats the specified W3C string date using the locale settings of the application.
If the date is followed by a time, this time is kept as is.
PARAMETERS
$W3CDate String Date formatted in W3C format ('Y-m-d').
RETURNED VALUE String Date formatted according to the current locale settings.
EXAMPLE
<?php
$myDate = \Convert::W3CtoLocaleDate('2013-04-22');
?>

ZnetDK constants

The following PHP constants can be used in the views and in the controllers to get absolute or relative path of specific ZnetDK folders.

Path constants

ZNETDK_APP_NAME, ZNETDK_APP_ROOT, ZNETDK_APP_URI, ZNETDK_ROOT, ZNETDK_ROOT_URI, ZNETDK_CORE_ROOT, ZNETDK_MOD_ROOT, CFG_ZNETDK_IMG_DIR

 Constant ZNETDK_APP_NAME

Name of the subfolder containing the source code and the documents of the running application.

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_APP_NAME; // Display of default
?>

 Constant ZNETDK_APP_ROOT

Absolute path of the folder containing the files of the running application.

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_APP_ROOT; // Display of /home/hosting999/www/znetdk/applications/default
?>

 Constant ZNETDK_APP_URI

Relative file path of the directory containing the web resources of the application.

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_APP_URI; // Display of /znetdk/applications/default/public/
?>

 Constant ZNETDK_ROOT

Abdolute file path of the root directory of ZnetDK (installation folder).

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_ROOT; // Display of /home/hosting999/www/znetdk/
?>

 Constant ZNETDK_ROOT_URI

Relative path of the root directory of ZnetDK (installation folder).

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_ROOT_URI; // Display of /znetdk/
?>

 Constant ZNETDK_CORE_ROOT

Abdolute file path of the core directory of ZnetDK.

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_CORE_ROOT; // Display of /home/hosting999/www/znetdk/engine/core
?>

 Constant ZNETDK_MOD_ROOT

Abdolute file path of the modules directory of ZnetDK.

EXAMPLE
<?php
/* If ZnetDK is installed into the /home/hosting999/www/znetdk/ folder
    and if the Starter Application is currently running... */
echo ZNETDK_MOD_ROOT; // Display of /home/hosting999/www/znetdk/engine/modules
?>

 Constant CFG_ZNETDK_IMG_DIR

Relative file path of the images directory of ZnetDK.

EXAMPLE
<?php
echo CFG_ZNETDK_IMG_DIR; // Display of engine/public/images
?>

Search

Sort order