/**
  * Get the latest requests and updates the values avaliable to the model/view.
  * @author Bobby Allen (ballen@bobbyallen.me)
  */
 public function Init()
 {
     //Set class varables
     $this->vars_get = array($_GET);
     $this->vars_post = array($_POST);
     $this->vars_session = array($_SESSION);
     $this->vars_cookie = array($_COOKIE);
     //Here we get the users information
     $user = ctrl_users::GetUserDetail();
     if (!isset($this->vars_session[0]['zpuid'])) {
         ui_module::GetLoginTemplate();
     }
     if (isset($this->vars_get[0]['module'])) {
         ui_module::getModule($this->GetCurrentModule());
     }
     if (isset($this->vars_get[0]['action'])) {
         if (ctrl_groups::CheckGroupModulePermissions($user['usergroupid'], ui_module::GetModuleID())) {
             if (class_exists('module_controller', FALSE) && method_exists('module_controller', 'do' . $this->vars_get[0]['action'])) {
                 call_user_func(array('module_controller', 'do' . $this->vars_get[0]['action']));
             } else {
                 echo ui_sysmessage::shout("No 'do" . runtime_xss::xssClean($this->vars_get[0]['action']) . "' class exists - Please create it to enable controller actions and runtime placeholders within your module.");
             }
         }
     }
     return;
 }
Beispiel #2
0
 /**
  * Checks that the module exists.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @param string $name Name of the module to check that exists.
  * @return boolean
  */
 static function CheckModuleExists($name)
 {
     $user = ctrl_users::GetUserDetail();
     if (file_exists("modules/" . $name . "/module.zpm")) {
         if (ctrl_groups::CheckGroupModulePermissions($user['usergroupid'], self::GetModuleID())) {
             return true;
         }
     }
     return false;
 }
 static function getConfigModules()
 {
     global $zdbh;
     global $controller;
     $line = "<h2>" . ui_language::translate("Configure Modules") . "</h2>";
     $modsql = "SELECT COUNT(*) FROM x_modules";
     if ($nummodsql = $zdbh->query($modsql)) {
         if ($nummodsql->fetchColumn() > 0) {
             $modsql = $zdbh->prepare("SELECT * FROM x_modules WHERE mo_folder_vc <> 'zpx_core_module' ORDER BY mo_name_vc ASC");
             $modsql->execute();
             $line .= "<form action=\"./?module=moduleadmin&action=EditModule\" method=\"post\">";
             $line .= "<table class=\"table table-striped\">";
             $line .= "<tr>";
             $line .= "<th></th>";
             $line .= "<th>" . ui_language::translate("Module") . "</th>";
             $line .= "<th>" . ui_language::translate("On") . "/" . ui_language::translate("Off") . "</th>";
             $line .= "<th>" . ui_language::translate("Category") . "</th>";
             $line .= "<th style=\"text-align:center\">" . ui_language::translate("Up-to-date?") . "</th>";
             $groupssql = $zdbh->query("SELECT * FROM x_groups ORDER BY ug_name_vc ASC");
             while ($groups = $groupssql->fetch()) {
                 $line .= "<th style=\"text-align:center\">" . $groups['ug_name_vc'] . "</th>";
             }
             $line .= "</tr>";
             $numline = 0;
             while ($modules = $modsql->fetch()) {
                 if ($numline == 20) {
                     $line .= "<tr>";
                     $line .= "<th></th>";
                     $line .= "<th>" . ui_language::translate("Module") . "</th>";
                     $line .= "<th>" . ui_language::translate("On") . "/" . ui_language::translate("Off") . "</th>";
                     $line .= "<th>" . ui_language::translate("Category") . "</th>";
                     $line .= "<th style=\"text-align:center\">" . ui_language::translate("Up-to-date?") . "</th>";
                     $groupssql = $zdbh->query("SELECT * FROM x_groups ORDER BY ug_name_vc ASC");
                     while ($groups = $groupssql->fetch()) {
                         $line .= "<th style=\"text-align:center\">" . $groups['ug_name_vc'] . "</th>";
                     }
                     $line .= "</tr>";
                 }
                 $ismodadmin = 0;
                 $line .= "<tr>";
                 $line .= "<td>" . self::ModuleStatusIcon($modules['mo_id_pk']) . "</td>";
                 $line .= "<td><a href=\"./?module=moduleadmin&showinfo=" . $modules['mo_folder_vc'] . "\">" . ui_language::translate($modules['mo_name_vc']) . "</a></td>";
                 $line .= "<td>";
                 if ($modules['mo_type_en'] != "system") {
                     $line .= "<select style=\"min-width:85px;\" name=\"inDisable_" . $modules['mo_id_pk'] . "\" id=\"inDisable_" . $modules['mo_id_pk'] . "\">";
                 } else {
                     $line .= "<select style=\"min-width:85px;\" name=\"inDisable_" . $modules['mo_id_pk'] . "\" id=\"inDisable_" . $modules['mo_id_pk'] . "\" disabled=\"disabled\">";
                 }
                 if ($modules['mo_enabled_en'] == 'true') {
                     $selected = "SELECTED";
                 } else {
                     $selected = "";
                 }
                 if ($modules['mo_name_vc'] == 'Module Admin') {
                     $ismodadmin = 1;
                     $disabled = "disabled=\"disabled\"";
                 } else {
                     $disabled = "";
                 }
                 $line .= "<option value=\"true\" " . $selected . " >" . ui_language::translate("Enabled") . "</option>";
                 if ($modules['mo_enabled_en'] == 'false') {
                     $selected = "SELECTED";
                 } else {
                     $selected = "";
                 }
                 $line .= "<option value=\"false\" " . $selected . " " . $disabled . ">" . ui_language::translate("Disabled") . "</option>";
                 $line .= "</select></td>";
                 $line .= "<td>";
                 if ($modules['mo_type_en'] == "user") {
                     $line .= "<select style=\"min-width:175px;\" name=\"inCategory_" . $modules['mo_id_pk'] . "\" id=\"inCategory_" . $modules['mo_id_pk'] . "\">";
                     $catssql = $zdbh->query("SELECT * FROM x_modcats ORDER BY mc_name_vc ASC");
                     while ($modulecats = $catssql->fetch()) {
                         $selected = "";
                         if ($modules['mo_category_fk'] == $modulecats['mc_id_pk']) {
                             $selected = "selected";
                         }
                         $line .= "<option value=\"" . $modulecats['mc_id_pk'] . "\" " . $selected . ">" . $modulecats['mc_name_vc'] . "</option>";
                     }
                     $line .= "</select>";
                 } elseif ($modules['mo_type_en'] == "modadmin") {
                     $line .= "" . ui_language::translate("N/A (Module Admin)") . "";
                 } else {
                     $line .= "" . ui_language::translate("N/A (System Module)") . "";
                 }
                 $line .= "</td><td style=\"text-align:center\">";
                 if (ui_module::GetModuleHasUpdates($modules['mo_folder_vc'])) {
                     $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\"><br>" . ui_language::translate("Latest version") . ": <a href=\"" . $modules['mo_updateurl_tx'] . "\" target=\"_blank\">" . $modules['mo_updatever_vc'] . "</a>";
                 } else {
                     $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">";
                 }
                 /**
                  * --
                  */
                 $line .= "</td>";
                 $groupssql = $zdbh->query("SELECT * FROM x_groups ORDER BY ug_name_vc ASC");
                 while ($groups = $groupssql->fetch()) {
                     if ($groups['ug_name_vc'] == 'Administrators' && $ismodadmin == 1) {
                         $line .= "<input type=\"hidden\" value=\"1\" name=\"inEnable_" . $groups['ug_id_pk'] . "_" . $modules['mo_id_pk'] . "\" id=\"inEnable_" . $groups['ug_id_pk'] . "_" . $modules['mo_id_pk'] . "\"/>";
                         $disabled = "disabled=\"disabled\"";
                     } else {
                         $disabled = "";
                     }
                     $ischeck = 0;
                     if (ctrl_groups::CheckGroupModulePermissions($groups['ug_id_pk'], $modules['mo_id_pk'])) {
                         $ischeck = "checked=\"checked\" ";
                     }
                     if ($modules['mo_type_en'] != "system") {
                         $line .= "<td style=\"text-align:center\"><input type=\"checkbox\" value=\"1\" name=\"inEnable_" . $groups['ug_id_pk'] . "_" . $modules['mo_id_pk'] . "\" id=\"inEnable_" . $groups['ug_id_pk'] . "_" . $modules['mo_id_pk'] . "\" " . $ischeck . " " . $disabled . "/></td>";
                     } else {
                         $disabled = "disabled=\"disabled\"";
                         $line .= "<td style=\"text-align:center\"><input type=\"checkbox\" value=\"1\" name=\"inEnable_" . $groups['ug_id_pk'] . "_" . $modules['mo_id_pk'] . "\" id=\"inEnable_" . $groups['ug_id_pk'] . "_" . $modules['mo_id_pk'] . "\" " . $ischeck . " " . $disabled . " /></td>";
                     }
                 }
                 $line .= "</tr>";
                 $numline++;
                 if ($numline == 21) {
                     $numline = 0;
                 }
             }
             $line .= "</table><br>";
             $line .= "<button class=\"button-loader btn btn-primary\" type=\"submit\" id=\"button\" name=\"inSave\" value=\"inSave\">" . ui_language::translate("Save changes") . "</button></form>";
         } else {
             $line .= ui_language::translate("You have no administration modules at this time.");
         }
     }
     return $line;
 }
Beispiel #4
0
 /**
  * Gets the module list as an array from a given category ID.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @global db_driver $zdbh The ZPX database handle.
  * @param int $catid The name of the module category to get the list of modules from.
  * @return array Array containing the list of modules for the category ID supplied.
  */
 static function GetModuleList($catid = "")
 {
     global $zdbh;
     $user = ctrl_users::GetUserDetail();
     if ($catid == "") {
         $sql = "SELECT * FROM x_modules";
     } else {
         $sql = "SELECT * FROM x_modules WHERE mo_category_fk = :catid AND mo_type_en = 'user' AND mo_enabled_en = 'true' ORDER BY mo_name_vc";
     }
     $numrows = $zdbh->prepare($sql);
     $numrows->bindParam(':catid', $catid);
     $numrows->execute();
     if ($numrows->fetchColumn() != 0) {
         $sql = $zdbh->prepare($sql);
         $sql->bindParam(':catid', $catid);
         $res = array();
         $sql->execute();
         while ($row = $sql->fetch()) {
             if (ctrl_groups::CheckGroupModulePermissions($user['usergroupid'], $row['mo_id_pk'])) {
                 array_push($res, array('mo_id_pk' => $row['mo_id_pk'], 'mo_category_fk' => $row['mo_category_fk'], 'mo_name_vc' => $row['mo_name_vc'], 'mo_version_in' => $row['mo_version_in'], 'mo_folder_vc' => $row['mo_folder_vc'], 'mo_type_en' => $row['mo_type_en'], 'mo_desc_tx' => $row['mo_desc_tx'], 'mo_installed_ts' => $row['mo_installed_ts'], 'mo_enabled_en' => $row['mo_enabled_en'], 'mo_updatever_vc' => $row['mo_updatever_vc'], 'mo_updateurl_tx' => $row['mo_updateurl_tx']));
             }
         }
         return $res;
     } else {
         return false;
     }
 }