/** * 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; }
/** * 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 doEditModule() { global $zdbh; global $controller; $currentuser = ctrl_users::GetUserDetail(); $sql = "SELECT COUNT(*) FROM x_modules"; if ($numrows = $zdbh->query($sql)) { if ($numrows->fetchColumn() != 0) { $sql = $zdbh->prepare("SELECT * FROM x_modules WHERE mo_type_en <> 'system' ORDER BY mo_name_vc ASC"); $sql->execute(); while ($rowmodule = $sql->fetch()) { $groupssql = $zdbh->query("SELECT * FROM x_groups ORDER BY ug_name_vc ASC"); while ($groups = $groupssql->fetch()) { if (isset($_POST['inEnable_' . $groups['ug_id_pk'] . '_' . $rowmodule['mo_id_pk'] . ''])) { ctrl_groups::AddGroupModulePermissions($groups['ug_id_pk'], $rowmodule['mo_id_pk']); } else { ctrl_groups::DeleteGroupModulePermissions($groups['ug_id_pk'], $rowmodule['mo_id_pk']); } } $sql2 = $zdbh->prepare("UPDATE x_modules SET mo_enabled_en = :enabled, mo_category_fk = :category WHERE mo_id_pk = :moduleid"); $disable = $controller->GetControllerRequest('FORM', 'inDisable_' . $rowmodule['mo_id_pk'] . ''); $category = $controller->GetControllerRequest('FORM', 'inCategory_' . $rowmodule['mo_id_pk'] . ''); $sql2->bindParam(':enabled', $disable); $sql2->bindParam(':category', $category); $sql2->bindParam(':moduleid', $rowmodule['mo_id_pk']); $sql2->execute(); } self::$ok = TRUE; return; } } self::$error = TRUE; return; }
/** * 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; } }