Ejemplo n.º 1
0
 JxPlugin::doHook('indexTop', $null);
 // Decide if we are running a default module or a sub-module
 $jaxClass = JxUri::getClass();
 if (file_exists($jaxModulePath . '/' . $jaxModule . '/' . $jaxClass . '.php')) {
     $jaxModuleFile = $jaxClass;
     // we are running a sub-module
 } else {
     $jaxModuleFile = $jaxModule;
 }
 if (JxModule::isValid($jaxModule)) {
     require_once $jaxModulePath . '/' . $jaxModule . '/config.php';
     require_once $jaxModulePath . '/' . $jaxModule . '/' . $jaxModuleFile . '.php';
     $module =& new $jaxModuleFile();
     // Possibly not used ... grep came up negative
     // $GLOBALS['jax_user'] = & new JxUser($_COOKIE['jax_userID']);
     if (!JxModule::isError($module)) {
         // They don't have proper perms to access this module
         if (!$module->authenticate()) {
             if (defined('JX_LOGIN_URL')) {
                 $go = JX_LOGIN_URL;
             } else {
                 $go = $_SERVER['SCRIPT_NAME'] . '/users/login';
             }
             $go .= '?pg=' . urldecode($_SERVER['REQUEST_URI']);
             JxHttp::redirect($go);
         } else {
             // If the module *must* be ran via SSL (ie. checkout) and
             // we are being requested at port 80 we need to redirect.
             if ($module->forceSSL && JX_HTTP_PROTOCOL != 'https') {
                 $go = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
                 JxHttp::redirect($go);
Ejemplo n.º 2
0
 function render()
 {
     $sql = "SELECT *\n              FROM menu_categories\n              ORDER BY sort";
     $result = $this->db->query($sql);
     if (!DB::isError($result) && $result->numRows()) {
         $cat_sort = 0;
         while ($row = $result->fetchRow()) {
             $sql = "UPDATE menu_categories\n                  SET sort='" . $cat_sort . "'\n                  WHERE contentID='" . $row['contentID'] . "'";
             ++$cat_sort;
             $link_sort = 0;
             $sql = "SELECT *\n                  FROM menu_links\n                  WHERE categoryID='" . $row['contentID'] . "'\n                  ORDER BY sort";
             $lresult = $this->db->query($sql);
             if (!DB::isError($lresult) && $lresult->numRows()) {
                 while ($lrow = $lresult->fetchRow()) {
                     $sql = "UPDATE menu_links\n                      SET sort='" . $link_sort . "'\n                      WHERE contentID='" . $lrow['contentID'] . "'";
                     $this->db->query($sql);
                     ++$link_sort;
                 }
             }
             $this->db->query($sql);
         }
     }
     if (strlen($_GET['categoryID']) && !strlen($_GET['linkID']) && strlen($_GET['new']) && strlen($_GET['old'])) {
         $sql = array();
         $sql[] = "UPDATE menu_categories\n                  SET sort='" . $_GET['old'] . "'\n                  WHERE sort='" . $_GET['new'] . "'";
         $sql[] = "UPDATE menu_categories\n                  SET sort='" . $_GET['new'] . "'\n                  WHERE contentID='" . $_GET['categoryID'] . "'";
         for ($i = 0; $i < count($sql); ++$i) {
             // echo '<pre>'.$sql[$i].'</pre>';
             $this->db->query($sql[$i]);
         }
     }
     if (strlen($_GET['categoryID']) && strlen($_GET['linkID']) && strlen($_GET['new']) && strlen($_GET['old'])) {
         $sql = array();
         $sql[] = "UPDATE menu_links\n                  SET sort='" . $_GET['old'] . "'\n                  WHERE sort='" . $_GET['new'] . "' AND\n                        categoryID='" . $_GET['categoryID'] . "'";
         $sql[] = "UPDATE menu_links\n                  SET sort='" . $_GET['new'] . "'\n                  WHERE contentID='" . $_GET['linkID'] . "' AND\n                        categoryID='" . $_GET['categoryID'] . "'";
         for ($i = 0; $i < count($sql); ++$i) {
             // echo '<pre>'.$sql[$i].'</pre>';
             $this->db->query($sql[$i]);
         }
     }
     $template =& new JxTemplate(JX_MODULE_PATH . '/menu/tpl');
     $template->assign('module', JxModule::getModule($_GET['module']));
     $sql = "SELECT *\n              FROM menu_categories\n              ORDER BY sort";
     $result = $this->db->query($sql);
     if (!DB::isError($result) && $result->numRows()) {
         $menu = array();
         $i = 0;
         while ($row = $result->fetchRow()) {
             if ($i == 0) {
                 $row['up'] = $result->numRows() - 1;
             } else {
                 $row['up'] = $row['sort'] - 1;
             }
             if ($i + 1 == $result->numRows()) {
                 $row['down'] = 0;
             } else {
                 $row['down'] = $row['sort'] + 1;
             }
             $row['links'] = array();
             $sql = "SELECT *\n                  FROM menu_links\n                  WHERE categoryID='" . $row['contentID'] . "'\n                  ORDER BY sort";
             $lresult = $this->db->query($sql);
             if (!DB::isError($lresult) && $lresult->numRows()) {
                 $n = 0;
                 while ($lrow = $lresult->fetchRow()) {
                     if ($n == 0) {
                         $lrow['up'] = $lresult->numRows() - 1;
                     } else {
                         $lrow['up'] = $lrow['sort'] - 1;
                     }
                     if ($n + 1 == $lresult->numRows()) {
                         $lrow['down'] = 0;
                     } else {
                         $lrow['down'] = $lrow['sort'] + 1;
                     }
                     $row['links'][] = $lrow;
                     ++$n;
                 }
             }
             $menu[] = $row;
             ++$i;
         }
         $template->assign('menu', $menu);
     }
     return $template->fetch('adminMenuSort.tpl');
 }
Ejemplo n.º 3
0
Archivo: jax.php Proyecto: joestump/jax
 function module()
 {
     $sql = "SELECT M.*,\n              SUM((CONV(R.permissions,8,10) & CONV(" . JX_USER_R . ",8,2))) AS r,\n              SUM((CONV(R.permissions,8,10) & CONV(" . JX_USER_W . ",8,2))) AS w,\n              SUM((CONV(R.permissions,8,10) & CONV(" . JX_USER_X . ",8,2))) AS x\n              FROM modules AS M, modules_groups AS R\n              WHERE M.moduleID=R.moduleID AND \n                    R.groupID IN (" . implode(',', $this->user->groupIds) . ") AND\n                    (CONV(R.permissions,8,10) & CONV(" . JX_USER_W . ",8,2)) > 0 AND\n                    M.available > 0 AND\n                    M.name='" . $_GET['module'] . "'\n              GROUP BY M.moduleID\n              ORDER BY M.title";
     $result = $this->db->query($sql);
     if (!DB::isError($result) && $result->numRows()) {
         $this->templateFile = 'module.tpl';
         $this->setData('info', JxModule::getModule($_GET['module']));
     } else {
         $this->templateFile = 'noperms.tpl';
     }
 }