Current File : //root/panel/dryden/ui/tpl/modulelistjson.class.php
<?php

/**
 * @copyright 2014-2015 Sentora Project (http://www.sentora.org/) 
 * Sentora is a GPL fork of the ZPanel Project whose original header follows:
 *
 * Generic template place holder class.
 * @package zpanelx
 * @subpackage dryden -> ui -> tpl
 * @version 1.1.0
 * @author Jason Davis (jason.davis.fl@gmail.com)
 * @copyright ZPanel Project (http://www.zpanelcp.com/)
 * @link http://www.zpanelcp.com/
 * @license GPL (http://www.gnu.org/licenses/gpl.html)
 */
class ui_tpl_modulelistjson {

    public static function Template() {
        global $zdbh;
	global $controller;
        /* Get Modules */
	$currentuser = ctrl_users::GetUserDetail();
	if($currentuser['userid']==1)
        $sql = 'SELECT  DISTINCT a.mo_name_vc, a.mo_folder_vc FROM `x_modules` a,`x_permissions` b  WHERE a.`mo_enabled_en` = "true" AND b.pe_module_fk=a.mo_id_pk AND b.pe_group_fk=1';
	else 
	 $sql = 'SELECT DISTINCT a.mo_name_vc, a.mo_folder_vc FROM `x_modules` a,`x_permissions` b  WHERE a.`mo_enabled_en` = "true" AND b.pe_module_fk=a.mo_id_pk AND b.pe_group_fk=3';
        $dbh = $zdbh->prepare($sql);
        $dbh->execute();
        $line = '';

        // Build Module list Array
        if ($dbh->fetch() !== 0) {

            $result = array();
            while ($row = $dbh->fetch()) {
                $result[] = array(
                    'name' => htmlentities($row['mo_name_vc'], ENT_QUOTES),
                    'url' => $row['mo_folder_vc']
                );
            }

        } else {
            $line .= 'No Modules Exist!';
        }

        // Build and Retun a JSON Object
        $line .= json_encode($result);

        return $line;
    }

}
?>