Source for file admin.weblinks.php
Documentation is available at admin.weblinks.php
* @copyright Refer to copyright.php
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author Mambo Foundation Inc see README.php
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// 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', T_('You are not authorized to view this resource.') );
require_once( $mainframe->getPath( 'admin_html' ) );
require_once( $mainframe->getPath( 'class' ) );
* Compiles a list of records
* @param database A database connector object
global $database, $mainframe, $mosConfig_list_limit;
$catid =
$mainframe->getUserStateFromRequest( "catid{$option}", 'catid', 0 );
$limit =
$mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );
$limitstart =
$mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
$search =
$mainframe->getUserStateFromRequest( "search{$option}", 'search', '' );
$where[] =
"a.catid='$catid'";
$where[] =
"LOWER(a.title) LIKE '%$search%'";
// get the total number of records
$database->setQuery( "SELECT count(*) FROM #__weblinks AS a"
.
(count( $where ) ?
"\nWHERE " .
implode( ' AND ', $where ) :
"")
$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"
.
"\n LIMIT $pageNav->limitstart, $pageNav->limit"
$database->setQuery( $query );
$rows =
$database->loadObjectList();
if ($database->getErrorNum()) {
echo
$database->stderr();
// build list of categories
$javascript =
'onchange="document.adminForm.submit();"';
* Compiles information to add or edit
* @param integer The unique id of the record to edit (0 if new)
global $database, $my, $mosConfig_absolute_path, $mosConfig_live_site;
// load the row from the db table
// fail if checked out not by 'me'
if ($row->checked_out &&
$row->checked_out <>
$my->id) {
mosRedirect( 'index2.php?option='.
$option, sprintf(T_('The module %s is currently being edited by another administrator.'), $row->title) );
$row->checkout( $my->id );
// build the html select list for ordering
$query =
"SELECT ordering AS value, title AS text"
.
"\n WHERE catid='$row->catid'"
// build list of categories
// build the html select list
// build the html select list
$file =
$mosConfig_absolute_path .
'/administrator/components/com_weblink_items/weblink_items.xml';
* Saves the record on an edit form submit
* @param database A database connector object
if (!$row->bind( $_POST )) {
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
foreach ( $params as $k=>
$v) {
$row->params =
implode( "\n", $txt );
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
$row->updateOrder( "catid='$row->catid'" );
* Deletes one or more records
* @param array An array of unique category id numbers
* @param string The current url option
echo
"<script> alert('".
T_('Select an item to delete').
"'); window.history.go(-1);</script>\n";
$database->setQuery( "DELETE FROM #__weblinks WHERE id IN ($cids)" );
if (!$database->query()) {
echo
"<script> alert('".
$database->getErrorMsg().
"'); window.history.go(-1); </script>\n";
* 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
$action =
$publish ?
T_('publish') :
T_('unpublish');
echo
"<script> alert('".
sprintf(T_('Select an item to %s'), $action).
"'); window.history.go(-1);</script>\n";
$database->setQuery( "UPDATE #__weblinks SET published='$publish'"
.
"\nWHERE id IN ($cids) AND (checked_out=0 OR (checked_out='$my->id'))"
if (!$database->query()) {
echo
"<script> alert('".
$database->getErrorMsg().
"'); window.history.go(-1); </script>\n";
if (count( $cid ) ==
1) {
$row->checkin( $cid[0] );
* Moves the order of a record
* @param integer The increment to reorder by
$row->move( $inc, "published >= 0" );
* Cancels an edit operation
* @param string The current url option
Documentation generated on Mon, 05 May 2008 16:16:41 +0400 by phpDocumentor 1.4.0