function orderModule($uid, $inc, $option, $client = 'admin') { global $database; $row = new mosModule($database); $row->load((int) $uid); if ($client == 'admin') { $where = "client_id = 1"; } else { $where = "client_id = 0"; } $row->move($inc, "position = " . $database->Quote($row->position) . " AND ( {$where} )"); mosCache::cleanCache('com_content'); $redirect = mosGetParam($_REQUEST, 'redirect', 'index2.php?option=' . $option . '&client=' . $client); mosRedirect($redirect); }
function saveOrder(&$cid, $client) { global $database; josSpoofCheck(); $total = count($cid); $order = josGetArrayInts('order'); $row = new mosModule($database); $conditions = array(); // update ordering values for ($i = 0; $i < $total; $i++) { $row->load((int) $cid[$i]); if ($row->ordering != $order[$i]) { $row->ordering = $order[$i]; if (!$row->store()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } // if // remember to updateOrder this group $condition = "position = " . $database->Quote($row->position) . " AND client_id = " . (int) $row->client_id; $found = false; foreach ($conditions as $cond) { if ($cond[1] == $condition) { $found = true; break; } } // if if (!$found) { $conditions[] = array($row->id, $condition); } } // if } // for // execute updateOrder for each group foreach ($conditions as $cond) { $row->load($cond[0]); $row->updateOrder($cond[1]); } // foreach mosCache::cleanCache('com_content'); $msg = 'New ordering saved'; mosRedirect('index2.php?option=com_modules&client=' . $client, $msg); }
function saveOrder(&$cid, $client) { global $database; $order = mosGetParam($_POST, 'order', array(0)); $row = new mosModule($database); $positions = array(); // update ordering values foreach ($cid as $i => $ciditem) { $row->load($ciditem); if ($row->ordering != $order[$i]) { $row->ordering = $order[$i]; if (!$row->store()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } // remember to updateOrder this group $positions[$row->position][$row->client_id] = $row->id; } } // execute updateOrder for each group foreach ($positions as $position => $clients) { foreach ($clients as $client => $rowid) { $row->updateOrder("position = '{$position}' AND client_id = '{$client}'"); } } // foreach $msg = T_('New ordering saved'); mosRedirect('index2.php?option=com_modules&client=' . $client, $msg); }
/** * Copies a complete menu, all its items and creates a new module, using the name speified */ function copyMenu($option, $cid, $menu_name, $type) { global $database, $adminLanguage; $mids = mosGetParam($_POST, 'mids', ''); // create the module copy foreach ($cid as $id) { $row = new mosModule($database); $row->load($id); $row->title = $menu_name; $row->iscore = 0; $row->published = 0; $row->position = "left"; $row->module = "mod_mainmenu"; $row->params = "menutype=" . $menu_name . ""; if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); $row->updateOrder("position='" . $row->position . "'"); } $total = count($mids); $copy = new mosMenu($database); $original = new mosMenu($database); foreach ($mids as $mid) { $original->load($mid); $copy = $original; $copy->id = NULL; $copy->menutype = $menu_name; if (!$copy->check()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$copy->store()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } } $msg = $adminLanguage->A_COMP_MENU_COPY_OF . " `" . $type . "` " . $adminLanguage->A_COMP_MENU_CONSIST . " " . $total . " " . $adminLanguage->A_COMP_ITEMS; mosRedirect("index2.php?option=com_menumanager&mosmsg=" . $msg . ""); }
/** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu($uid, $access, $option, $client) { global $database; switch ($access) { case 'accesspublic': $access = 0; break; case 'accessregistered': $access = 1; break; case 'accessspecial': $access = 2; break; } $row = new mosModule($database); $row->load($uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } mosRedirect('index2.php?option=' . $option . '&client=' . $client); }
/** * Copies a complete menu, all its items and creates a new module, using the name speified */ function copyMenu($option, $cid, $type) { global $database; josSpoofCheck(); $menu_name = stripslashes(strval(mosGetParam($_POST, 'menu_name', 'New Menu'))); $module_name = stripslashes(strval(mosGetParam($_POST, 'module_name', 'New Module'))); // check for unique menutype for new menu copy $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'"; $database->setQuery($query); $menus = $database->loadResultArray(); foreach ($menus as $menu) { $params = mosParseParams($menu); if ($params->menutype == $menu_name) { echo "<script> alert('A menu already exists with that name - you must enter a unique Menu Name'); window.history.go(-1); </script>\n"; exit; } } // copy the menu items $mids = josGetArrayInts('mids'); $total = count($mids); $copy = new mosMenu($database); $original = new mosMenu($database); sort($mids); $a_ids = array(); foreach ($mids as $mid) { $original->load($mid); $copy = $original; $copy->id = NULL; $copy->parent = $a_ids[$original->parent]; $copy->menutype = $menu_name; if (!$copy->check()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$copy->store()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } $a_ids[$original->id] = $copy->id; } // create the module copy $row = new mosModule($database); $row->load(0); $row->title = $module_name; $row->iscore = 0; $row->published = 1; $row->position = 'left'; $row->module = 'mod_mainmenu'; $row->params = 'menutype=' . $menu_name; if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); $row->updateOrder('position=' . $database->Quote($row->position)); // module assigned to show on All pages by default // ToDO: Changed to become a Joomla! db-object $query = "INSERT INTO #__modules_menu VALUES ( " . (int) $row->id . ", 0 )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } // clean any existing cache files mosCache::cleanCache('com_content'); $msg = 'Copy of Menu `' . $type . '` created, consisting of ' . $total . ' items'; mosRedirect('index2.php?option=' . $option, $msg); }
/** * Copies a complete menu, all its items and creates a new module, using the name speified */ function copyMenu($option, $cid, $type) { global $database; $menu_name = mosGetParam($_POST, 'menu_name', 'New Menu'); $module_name = mosGetParam($_POST, 'module_name', 'New Module'); // check for unique menutype for new menu copy $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'"; $database->setQuery($query); $menus = $database->loadResultArray(); foreach ($menus as $menu) { $pparser = new mosParameters($menu); $params = $pparser->getParams(); if ($params->menutype == $menu_name) { echo "<script> alert('" . T_('A menu with that name already exists - you must enter a unique Menu Name') . "'); window.history.go(-1); </script>\n"; exit; } } // copy the menu items $mids = mosGetParam($_POST, 'mids', ''); $total = count($mids); $copy = new mosMenu($database); $original = new mosMenu($database); sort($mids); $a_ids = array(); foreach ($mids as $mid) { $original->load($mid); $copy = $original; $copy->id = NULL; $copy->parent = $a_ids[$original->parent]; $copy->menutype = $menu_name; if (!$copy->check()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$copy->store()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } $a_ids[$original->id] = $copy->id; } // create the module copy $row = new mosModule($database); $row->load(0); $row->title = $module_name; $row->iscore = 0; $row->published = 1; $row->position = 'left'; $row->module = 'mod_mainmenu'; $row->params = 'menutype=' . $menu_name; if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); $row->updateOrder("position='" . $row->position . "'"); // module assigned to show on All pages by default // ToDO: Changed to become a mambo db-object $query = "INSERT INTO #__modules_menu VALUES ( {$row->id}, 0 )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } $msg = sprintf(Tn_('Copy of Menu `%s` created, consisting of %d item', 'Copy of Menu `%s` created, consisting of %d items', $total), $type, $total); mosRedirect('index2.php?option=' . $option, $msg); }