/** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu($uid, $access, $option, $client) { global $database; josSpoofCheck(); switch ($access) { case 'accesspublic': $access = 0; break; case 'accessregistered': $access = 1; break; case 'accessspecial': $access = 2; break; } $row = new mosModule($database); $row->load((int) $uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } mosCache::cleanCache('com_content'); 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, $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 . ""); }
/** * 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); }