| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* @version $Id: admin.mambots.php,v 1.1 2005/07/22 01:52:34 eddieajau Exp $ |
* @package Mambo Open Source |
|
* @package Mambo |
|
| 4 |
* @subpackage Mambots |
* @subpackage Mambots |
| 5 |
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
| 6 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 7 |
|
* |
| 8 |
|
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 9 |
|
* that Mambo remained free Open Source software owned and managed by the community. |
| 10 |
* Mambo is Free Software |
* Mambo is Free Software |
| 11 |
*/ |
*/ |
| 12 |
|
|
| 16 |
// ensure user has access to this function |
// ensure user has access to this function |
| 17 |
if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'mambots', 'all' ) |
if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'mambots', 'all' ) |
| 18 |
| $acl->acl_check( 'administration', 'install', 'users', $my->usertype, 'mambots', 'all' ))) { |
| $acl->acl_check( 'administration', 'install', 'users', $my->usertype, 'mambots', 'all' ))) { |
| 19 |
mosRedirect( 'index2.php', _NOT_AUTH ); |
mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') ); |
| 20 |
} |
} |
| 21 |
|
|
| 22 |
require_once( $mainframe->getPath( 'admin_html' ) ); |
require_once( $mainframe->getPath( 'admin_html' ) ); |
| 136 |
. "\n GROUP BY folder" |
. "\n GROUP BY folder" |
| 137 |
. "\n ORDER BY folder" |
. "\n ORDER BY folder" |
| 138 |
; |
; |
| 139 |
$types[] = mosHTML::makeOption( '0', _SEL_TYPE ); |
$types[] = mosHTML::makeOption( '0', T_('- All Types -') ); |
| 140 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 141 |
$types = array_merge( $types, $database->loadObjectList() ); |
$types = array_merge( $types, $database->loadObjectList() ); |
| 142 |
$lists['type'] = mosHTML::selectList( $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type ); |
$lists['type'] = mosHTML::selectList( $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type ); |
| 183 |
|
|
| 184 |
switch ( $task ) { |
switch ( $task ) { |
| 185 |
case 'apply': |
case 'apply': |
| 186 |
$msg = 'Successfully Saved changes to Mambot: '. $row->name; |
$msg = sprintf(T_('Successfully Saved changes to Mambot: %s'), $row->name); |
| 187 |
mosRedirect( 'index2.php?option='. $option .'&client='. $client .'&task=editA&hidemainmenu=1&id='. $row->id, $msg ); |
mosRedirect( 'index2.php?option='. $option .'&client='. $client .'&task=editA&hidemainmenu=1&id='. $row->id, $msg ); |
| 188 |
|
|
| 189 |
case 'save': |
case 'save': |
| 190 |
default: |
default: |
| 191 |
$msg = 'Successfully Saved Mambot: '. $row->name; |
$msg = sprintf(T_('Successfully Saved Mambot: %s'), $row->name); |
| 192 |
mosRedirect( 'index2.php?option='. $option .'&client='. $client, $msg ); |
mosRedirect( 'index2.php?option='. $option .'&client='. $client, $msg ); |
| 193 |
break; |
break; |
| 194 |
} |
} |
| 211 |
|
|
| 212 |
// fail if checked out not by 'me' |
// fail if checked out not by 'me' |
| 213 |
if ($row->checked_out && $row->checked_out <> $my->id) { |
if ($row->checked_out && $row->checked_out <> $my->id) { |
| 214 |
echo "<script>alert('The module $row->title is currently being edited by another administrator'); document.location.href='index2.php?option=$option'</script>\n"; |
echo "<script>alert(".sprintf(T_('The module %s is currently being edited by another administrator'), $row->title)."); document.location.href='index2.php?option=$option'</script>\n"; |
| 215 |
exit(0); |
exit(0); |
| 216 |
} |
} |
| 217 |
|
|
| 223 |
|
|
| 224 |
// get list of groups |
// get list of groups |
| 225 |
if ($row->access == 99 || $row->client_id == 1) { |
if ($row->access == 99 || $row->client_id == 1) { |
| 226 |
$lists['access'] = 'Administrator<input type="hidden" name="access" value="99" />'; |
$lists['access'] = T_('Administrator').'<input type="hidden" name="access" value="99" />'; |
| 227 |
} else { |
} else { |
| 228 |
// build the html select list for the group access |
// build the html select list for the group access |
| 229 |
$lists['access'] = mosAdminMenus::Access( $row ); |
$lists['access'] = mosAdminMenus::Access( $row ); |
| 246 |
$order = mosGetOrderingList( $query ); |
$order = mosGetOrderingList( $query ); |
| 247 |
$lists['ordering'] = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); |
$lists['ordering'] = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); |
| 248 |
} else { |
} else { |
| 249 |
$lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />This mambot cannot be reordered'; |
$lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'.T_('This mambot cannot be reordered'); |
| 250 |
} |
} |
| 251 |
$lists['folder'] = '<input type="hidden" name="folder" value="'. $row->folder .'" />'. $row->folder; |
$lists['folder'] = '<input type="hidden" name="folder" value="'. $row->folder .'" />'. $row->folder; |
| 252 |
|
|
| 268 |
} |
} |
| 269 |
} |
} |
| 270 |
$lists['folder'] = mosHTML::selectList( $folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null ); |
$lists['folder'] = mosHTML::selectList( $folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null ); |
| 271 |
$lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />New items default to the last place. Ordering can be changed after this item is saved.'; |
$lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'.T_('New items default to the last place. Ordering can be changed after this item is saved.').''; |
| 272 |
} |
} |
| 273 |
|
|
| 274 |
$lists['published'] = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published ); |
$lists['published'] = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published ); |
| 289 |
global $database, $my; |
global $database, $my; |
| 290 |
|
|
| 291 |
if (count( $cid ) < 1) { |
if (count( $cid ) < 1) { |
| 292 |
echo "<script> alert('Select a module to delete'); window.history.go(-1);</script>\n"; |
echo "<script> alert(".T_('Select a module to delete')."); window.history.go(-1);</script>\n"; |
| 293 |
exit; |
exit; |
| 294 |
} |
} |
| 295 |
|
|
| 305 |
global $database, $my; |
global $database, $my; |
| 306 |
|
|
| 307 |
if (count( $cid ) < 1) { |
if (count( $cid ) < 1) { |
| 308 |
$action = $publish ? 'publish' : 'unpublish'; |
$action = $publish ? T_('publish') : T_('unpublish'); |
| 309 |
echo "<script> alert('Select a mambot to $action'); window.history.go(-1);</script>\n"; |
echo "<script> alert(".sprintf(T_('Select a mambot to %s'), $action)."); window.history.go(-1);</script>\n"; |
| 310 |
exit; |
exit; |
| 311 |
} |
} |
| 312 |
|
|
| 401 |
|
|
| 402 |
function saveOrder( &$cid ) { |
function saveOrder( &$cid ) { |
| 403 |
global $database; |
global $database; |
|
|
|
|
$total = count( $cid ); |
|
| 404 |
$order = mosGetParam( $_POST, 'order', array(0) ); |
$order = mosGetParam( $_POST, 'order', array(0) ); |
| 405 |
$row = new mosMambot( $database ); |
$row = new mosMenu( $database ); |
| 406 |
$conditions = array(); |
$folders = array(); |
|
|
|
| 407 |
// update ordering values |
// update ordering values |
| 408 |
for ( $i=0; $i < $total; $i++ ) { |
foreach ($cid as $i=>$ciditem) { |
| 409 |
$row->load( $cid[$i] ); |
$row->load( $ciditem ); |
| 410 |
if ($row->ordering != $order[$i]) { |
if ($row->ordering != $order[$i]) { |
| 411 |
$row->ordering = $order[$i]; |
$row->ordering = $order[$i]; |
| 412 |
if (!$row->store()) { |
if (!$row->store()) { |
| 413 |
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
| 414 |
exit(); |
exit(); |
| 415 |
} // if |
} |
| 416 |
// remember to updateOrder this group |
// remember to updateOrder this group |
| 417 |
$condition = "folder='$row->folder' AND ordering > -10000 AND ordering < 10000 AND client_id='$row->client_id'"; |
$folders[$row->folder][$row->client_id] = $row->id; |
| 418 |
$found = false; |
} |
| 419 |
foreach ( $conditions as $cond ) |
} |
|
if ($cond[1]==$condition) { |
|
|
$found = true; |
|
|
break; |
|
|
} // if |
|
|
if (!$found) $conditions[] = array($row->id, $condition); |
|
|
} // if |
|
|
} // for |
|
|
|
|
| 420 |
// execute updateOrder for each group |
// execute updateOrder for each group |
| 421 |
foreach ( $conditions as $cond ) { |
foreach ($folders as $folder=>$clients) { |
| 422 |
$row->load( $cond[0] ); |
foreach ($clients as $client=>$rowid) { |
| 423 |
$row->updateOrder( $cond[1] ); |
$row->updateOrder("folder = '$folder' AND ordering > -10000 AND ordering < 10000 AND client_id = '$client'"); |
| 424 |
|
} |
| 425 |
} // foreach |
} // foreach |
| 426 |
|
|
| 427 |
$msg = 'New ordering saved'; |
$msg = T_('New ordering saved'); |
| 428 |
mosRedirect( 'index2.php?option=com_mambots', $msg ); |
mosRedirect( 'index2.php?option=com_mambots', $msg ); |
| 429 |
} // saveOrder |
} // saveOrder |
| 430 |
|
|