- md5
- 5748e7ea4cfa429268353c78a3a51b84
- sha1
- cf5ae5af9ff07d1808d25adc3058073c58c10f08
- sha256
- 047763338882a673e4664a93ca3ec3c804d615b88d5c8290d5e1083c0a2e696a
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
<?php
/**
* @version $Id: admin.weblinks.php 5025 2006-09-13 12:36:21Z friesengeist $
* @package Joomla
* @subpackage Weblinks
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// ensure user has access to this function
if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' )
| $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_weblinks' ))) {
mosRedirect( 'index2.php', _NOT_AUTH );
}
require_once( $mainframe->getPath( 'admin_html' ) );
require_once( $mainframe->getPath( 'class' ) );
$cid = josGetArrayInts( 'cid' );
switch ($task) {
case 'new':
editWeblink( $option, 0 );
break;
case 'edit':
editWeblink( $option, $cid[0] );
break;
case 'editA':
editWeblink( $option, $id );
break;
case 'save':
saveWeblink( $option );
break;
case 'remove':
removeWeblinks( $cid, $option );
break;
case 'publish':
publishWeblinks( $cid, 1, $option );
break;
case 'unpublish':
publishWeblinks( $cid, 0, $option );
break;
case 'approve':
break;
case 'cancel':
cancelWeblink( $option );
break;
case 'orderup':
orderWeblinks( intval( $cid[0] ), -1, $option );
break;
case 'orderdown':
orderWeblinks( intval( $cid[0] ), 1, $option );
break;
default:
showWeblinks( $option );
break;
}
/**
* Compiles a list of records
* @param database A database connector object
*/
function showWeblinks( $option ) {
global $database, $mainframe, $mosConfig_list_limit;
$catid = intval( $mainframe->getUserStateFromRequest( "catid{$option}", 'catid', 0 ) );
$limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ) );
$limitstart = intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) );
$search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' );
if (get_magic_quotes_gpc()) {
$search = stripslashes( $search );
}
$where = array();
if ($catid > 0) {
$where[] = "a.catid = " . (int) $catid;
}
if ($search) {
$where[] = "LOWER(a.title) LIKE '%" . $database->getEscaped( trim( strtolower( $search ) ) ) . "%'";
}
// get the total number of records
$query = "SELECT COUNT(*)"
. "\n FROM #__weblinks AS a"
. (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "")
;
$database->setQuery( $query );
$total = $database->loadResult();
require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );
$pageNav = new mosPageNav( $total, $limitstart, $limit );
$query = "SELECT a.*, cc.name AS category, u.name AS editor"
. "\n FROM #__weblinks AS a"
. "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
. "\n LEFT JOIN #__users AS u ON u.id = a.checked_out"
. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "")
. "\n ORDER BY a.catid, a.ordering"
;
$database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
$rows = $database->loadObjectList();
if ($database->getErrorNum()) {
echo $database->stderr();
return false;
}
// build list of categories
$javascript = 'onchange="document.adminForm.submit();"';
$lists['catid'] = mosAdminMenus::ComponentCategory( 'catid', $option, intval( $catid ), $javascript );
HTML_weblinks::showWeblinks( $option, $rows, $lists, $search, $pageNav );
}
/**
* Compiles information to add or edit
* @param integer The unique id of the record to edit (0 if new)
*/
function editWeblink( $option, $id ) {
global $database, $my, $mosConfig_absolute_path;
$lists = array();
$row = new mosWeblink( $database );
// load the row from the db table
$row->load( (int)$id );
// fail if checked out not by 'me'
if ($row->isCheckedOut( $my->id )) {
mosRedirect( 'index2.php?option='. $option, 'The module $row->title is currently being edited by another administrator.' );
}
if ($id) {
$row->checkout( $my->id );
} else {
// initialise new record
$row->published = 1;
$row->approved = 1;
$row->order = 0;
$row->catid = intval( mosGetParam( $_POST, 'catid', 0 ) );
}
// build the html select list for ordering
$query = "SELECT ordering AS value, title AS text"
. "\n FROM #__weblinks"
. "\n WHERE catid = " . (int) $row->catid
. "\n ORDER BY ordering"
;
$lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $id, $query, 1 );
// build list of categories
$lists['catid'] = mosAdminMenus::ComponentCategory( 'catid', $option, intval( $row->catid ) );
// build the html select list
$lists['published'] = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published );
$file = $mosConfig_absolute_path .'/administrator/components/com_weblinks/weblinks_item.xml';
$params = new mosParameters( $row->params, $file, 'component' );
HTML_weblinks::editWeblink( $row, $lists, $params, $option );
}
/**
* Saves the record on an edit form submit
* @param database A database connector object
*/
function saveWeblink( $option ) {
global $database, $my;
$row = new mosWeblink( $database );
if (!$row->bind( $_POST )) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
// save params
$params = mosGetParam( $_POST, 'params', '' );
if (is_array( $params )) {
$txt = array();
foreach ( $params as $k=>$v) {
$txt[] = "$k=$v";
}
$row->params = implode( "\n", $txt );
}
$row->date = date( 'Y-m-d H:i:s' );
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( "catid = " . (int) $row->catid );
mosRedirect( "index2.php?option=$option" );
}
/**
* Deletes one or more records
* @param array An array of unique category id numbers
* @param string The current url option
*/
function removeWeblinks( $cid, $option ) {
global $database;
if (!is_array( $cid ) || count( $cid ) < 1) {
echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
exit;
}
if (count( $cid )) {
mosArrayToInts( $cid );
$cids = 'id=' . implode( ' OR id=', $cid );
$query = "DELETE FROM #__weblinks"
. "\n WHERE ( $cids )"
;
$database->setQuery( $query );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
}
}
mosRedirect( "index2.php?option=$option" );
}
/**
* Publishes or Unpublishes one or more records
* @param array An array of unique category id numbers
* @param integer 0 if unpublishing, 1 if publishing
* @param string The current url option
*/
function publishWeblinks( $cid=null, $publish=1, $option ) {
global $database, $my;
if (!is_array( $cid ) || count( $cid ) < 1) {
$action = $publish ? 'publish' : 'unpublish';
echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n";
exit;
}
mosArrayToInts( $cid );
$cids = 'id=' . implode( ' OR id=', $cid );
$query = "UPDATE #__weblinks"
. "\n SET published = " . (int) $publish
. "\n WHERE ( $cids )"
. "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"
;
$database->setQuery( $query );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
if (count( $cid ) == 1) {
$row = new mosWeblink( $database );
$row->checkin( $cid[0] );
}
mosRedirect( "index2.php?option=$option" );
}
/**
* Moves the order of a record
* @param integer The increment to reorder by
*/
function orderWeblinks( $uid, $inc, $option ) {
global $database;
$row = new mosWeblink( $database );
$row->load( (int)$uid );
$row->updateOrder();
$row->move( $inc, "published >= 0" );
$row->updateOrder();
mosRedirect( "index2.php?option=$option" );
}
/**
* Cancels an edit operation
* @param string The current url option
*/
function cancelWeblink( $option ) {
global $database;
$row = new mosWeblink( $database );
$row->bind( $_POST );
$row->checkin();
mosRedirect( "index2.php?option=$option" );
}
?>
No other release has this exact content. See every version of this file.