diff --git a/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc b/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc
index 520f1ac7..6744cfe6 100644
--- a/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc
+++ b/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc
@@ -1,4 +1,6 @@
-a:3:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:1:{s:7:"version";s:3:"2.0";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:1:{s:0:"";a:1:{s:7:"channel";a:1:{i:0;a:6:{s:4:"data";s:50:"
+a:4:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:3:"
+
+";s:7:"attribs";a:1:{s:0:"";a:1:{s:7:"version";s:3:"2.0";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:1:{s:0:"";a:1:{s:7:"channel";a:1:{i:0;a:6:{s:4:"data";s:50:"
@@ -15,7 +17,7 @@ a:3:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:0:"";s:7:
- ";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:3:{s:0:"";a:7:{s:5:"title";a:1:{i:0;a:5:{s:4:"data";s:38:"Joomla! Developer - Vulnerability News";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:11:"description";a:1:{i:0;a:5:{s:4:"data";s:274:"Not only is Joomla! easy to use, but it is easy to add extra functionality through a flexible and powerful developer framework. The Joomla! Framework allows you to build exceptional extensions for Joomla! including components, modules, plugins, templates and language packs.";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"link";a:1:{i:0;a:5:{s:4:"data";s:46:"http://developer.joomla.org/security/news.html";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:13:"lastBuildDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Sat, 05 Jun 2010 16:48:57 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:9:"generator";a:1:{i:0;a:5:{s:4:"data";s:44:"Joomla! 1.5 - Open Source Content Management";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:8:"language";a:1:{i:0;a:5:{s:4:"data";s:5:"en-gb";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"item";a:10:{i:0;a:6:{s:4:"data";s:31:"
+ ";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:3:{s:0:"";a:7:{s:5:"title";a:1:{i:0;a:5:{s:4:"data";s:38:"Joomla! Developer - Vulnerability News";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:11:"description";a:1:{i:0;a:5:{s:4:"data";s:274:"Not only is Joomla! easy to use, but it is easy to add extra functionality through a flexible and powerful developer framework. The Joomla! Framework allows you to build exceptional extensions for Joomla! including components, modules, plugins, templates and language packs.";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"link";a:1:{i:0;a:5:{s:4:"data";s:46:"http://developer.joomla.org/security/news.html";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:13:"lastBuildDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Tue, 15 Jun 2010 03:48:58 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:9:"generator";a:1:{i:0;a:5:{s:4:"data";s:44:"Joomla! 1.5 - Open Source Content Management";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:8:"language";a:1:{i:0;a:5:{s:4:"data";s:5:"en-gb";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"item";a:10:{i:0;a:6:{s:4:"data";s:31:"
@@ -287,4 +289,4 @@ a:3:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:0:"";s:7:
\n";
+ }
+
+ function _getOptions($e, &$parent, $purl=null)
+ {
+ if (!$purl) {
+ $purl = 'url[option]=com_'.$this->_com;
+
+ // No metadata xml file in component root
+ if (!$e) {
+ return false;
+ }
+ }
+
+ // Does the metadata file say no options available?
+ if ($e->attributes('options') == 'none') {
+ unset($node);
+ $node = new iLinkNode($e->attributes('name'), $purl, $e->attributes('msg'));
+ $parent->addChild($node);
+ return true;
+ }
+
+ // Do we have defined options available?
+ $options = &$e->getElementByPath('options');
+ if ($options) {
+ $children = $options->children();
+ foreach ($children as $child)
+ {
+ if ($child->name() == 'option') {
+ $url = $purl.'&url['.$options->attributes('var').']='.$child->attributes('value');
+ unset($node);
+ $node = new iLinkNode($child->attributes('name'), $url, $child->attributes('msg'));
+ $parent->addChild($node);
+ } elseif ($child->name() == 'default') {
+ unset($node);
+ $node = new iLinkNode($child->attributes('name'), $purl, $child->attributes('msg'));
+ $parent->addChild($node);
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @access private
+ */
+ function _getViews()
+ {
+ $return = false;
+ $path = JPATH_SITE.DS.'components'.DS.'com_'.$this->_com.DS.'views';
+
+ if (JFolder::exists($path)) {
+ $views = JFolder::folders($path);
+ } else {
+ return $return;
+ }
+
+ if (is_array($views) && count($views))
+ {
+ //$this->addChild(new iLinkNode('Views', null, 'Select the view'), true);
+ $return = true;
+ foreach ($views as $view)
+ {
+ if (strpos($view, '_') === false) {
+ // Load view metadata if it exists
+ $xmlpath = $path.DS.$view.DS.'metadata.xml';
+ if (JFile::exists($xmlpath)) {
+ $data = $this->_getXML($xmlpath, 'view');
+ } else {
+ $data = null;
+ }
+
+ $url = 'url[option]=com_'.$this->_com.'&url[view]='.$view;
+ if ($data) {
+ if ($data->attributes('hidden') != 'true') {
+ $m = $data->getElementByPath('message');
+ if ($m) {
+ $message = $m->data();
+ }
+ unset($node);
+ $node = new iLinkNode($data->attributes('title'), $url, $message);
+ $this->addChild($node);
+ if ($options = $data->getElementByPath('options')) {
+ $this->_getOptions($data, $node, $url);
+ } else {
+ $this->_getLayouts(dirname($xmlpath), $node);
+ }
+ }
+ } else {
+ $onclick = null;
+ unset($node);
+ $node = new iLinkNode(ucfirst($view), $url);
+ $this->addChild($node);
+ $this->_getLayouts(dirname($xmlpath), $node);
+ }
+ }
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * @access private
+ */
+ function _getLayouts($path, &$node)
+ {
+ $return = false;
+ $folder = $path.DS.'tmpl';
+ if (is_dir( $folder ))
+ {
+ $files = JFolder::files($folder, '.php$');
+ if (count($files)) {
+ foreach ($files as $file)
+ {
+ if (strpos($file, '_') === false) {
+ // Load view metadata if it exists
+ $layout = JFile::stripext($file);
+ $xmlpath = $path.DS.'tmpl'.DS.$layout.'.xml';
+ if (JFile::exists($xmlpath)) {
+ $data = $this->_getXML($xmlpath, 'layout');
+ } else {
+ $data = null;
+ }
+
+ if ($layout != 'default') {
+ $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path).'&url[layout]='.$layout;
+ } else {
+ $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path);
+ }
+ if ($data) {
+ if ($data->attributes('hidden') != 'true') {
+ $m = $data->getElementByPath('message');
+ if ($m) {
+ $message = $m->data();
+ }
+ unset($child);
+ $child = new iLinkNode($data->attributes('title'), $url, $message);
+ $node->addChild($child);
+ }
+ } else {
+ // Add default info for the layout
+ unset($child);
+ $child = new iLinkNode(ucfirst($layout).' '.JText::_('Layout'), $url);
+ $node->addChild($child);
+ }
+ }
+ }
+ }
+ }
+ return $return;
+ }
+
+ function _getXML($path, $xpath='control')
+ {
+ // Initialize variables
+ $result = null;
+ // load the xml metadata
+ if (file_exists( $path )) {
+ $xml =& JFactory::getXMLParser('Simple');
+ if ($xml->loadFile($path)) {
+ if (isset( $xml->document )) {
+ $result = $xml->document->getElementByPath($xpath);
+ }
+ }
+ return $result;
+ }
+ return $result;
+ }
+
+ function _findNodes(&$node)
+ {
+ foreach ($node->children() as $step)
+ {
+ /*
+ * For each child we need to see if it is an include and if so we
+ * need to get those children and process them as well (break out into
+ * another method). Then we need to create the objects in the _steps
+ * array for each child of type step. For now we aren't going to handle
+ * nested includes.
+ */
+ if ($step->name() == 'include') {
+ // Handle include
+ $this->_getIncludedSteps($step, $node);
+ } elseif ($step->name() == 'step') {
+ // Include step to array
+ $this->_nodes[] = $step;
+ } else {
+ // Do nothing
+ continue;
+ }
+ }
+ }
+
+ function _getIncludedSteps($include, &$parent)
+ {
+ $tags = array();
+ $source = $include->attributes('source');
+ $path = $include->attributes('path');
+
+ preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags);
+ if (isset( $tags[1] )) {
+ $n = count( $tags[1] );
+ for ($i=0; $i < $n; $i++)
+ {
+ $source = str_replace($tags[0][$i], @$this->_vars[$tags[1][$i]], $source);
+ }
+ }
+
+ // load the source xml file
+ if (file_exists( JPATH_ROOT.$source ))
+ {
+ $xml = & JFactory::getXMLParser('Simple');
+ if ($xml->loadFile(JPATH_ROOT.$source))
+ {
+ $document = &$xml->document;
+ $steps = $document->getElementByPath($path);
+
+ foreach($steps->children() as $step)
+ {
+ if ($step->name() == 'include') {
+ // Handle include
+ } elseif ($step->name() == 'step') {
+ // Include step to array
+ $node->addChild('step', $step->attributes(), $node->level()+1);
+ } else {
+ // Do nothing
+ continue;
+ }
+ }
+ }
+ }
+ }
+}
+
+class iLinkNode extends JNode
+{
+ /**
+ * Node Title
+ */
+ var $title = null;
+
+ /**
+ * Node URL
+ */
+ var $url = null;
+
+ /**
+ * Node message
+ */
+ var $msg = null;
+
+ function __construct($title, $url = null, $msg = null)
+ {
+ $this->title = trim($title);
+ $this->url = $url;
+ $this->msg = trim($msg);
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/controller.php b/oss/joomla/trunk/administrator/components/com_menus/controller.php
index effb106d..3290c5b7 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/controller.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/controller.php
@@ -1,797 +1,799 @@
-getModel( 'Item' );
- $view =& $this->getView( 'Item' );
- $view->setModel( $model, true );
-
- // Set the layout and display
- $view->setLayout('type');
- $view->type();
- }
- /**
- * Edit menu item wizard
- */
-
- function type()
- {
- JRequest::setVar( 'edit', true );
- $model =& $this->getModel( 'Item' );
- $view =& $this->getView( 'Item' );
- $view->setModel( $model, true );
-
- // Set the layout and display
- $view->setLayout('type');
- $view->type();
- }
-
- /**
- * Edits a menu item
- */
- function edit()
- {
- JRequest::setVar( 'edit', true );
- $model =& $this->getModel( 'Item' );
- $model->checkout();
-
- $view =& $this->getView( 'Item' );
- $view->setModel( $model, true );
- // Set the layout and display
- $view->setLayout('form');
- $view->edit();
- }
-
- /**
- * Saves a menu item
- */
- function save()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $model =& $this->getModel( 'Item' );
- $post = JRequest::get('post');
- // allow name only to contain html
- $post['name'] = JRequest::getVar( 'name', '', 'post', 'string', JREQUEST_ALLOWHTML );
- $model->setState( 'request', $post );
-
- if ($model->store()) {
- $msg = JText::_( 'Menu item Saved' );
- } else {
- $msg = JText::_( 'Error Saving Menu item' );
- }
-
- $item =& $model->getItem();
- switch ( $this->_task ) {
- case 'apply':
- $this->setRedirect( 'index.php?option=com_menus&menutype='.$item->menutype.'&task=edit&cid[]='.$item->id.'' , $msg );
- break;
-
- case 'save':
- default:
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$item->menutype, $msg );
- break;
- }
- }
-
- /**
- * Cancels an edit operation
- */
- function cancelItem()
- {
- global $mainframe;
-
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
-
- $model = $this->getModel('item');
- $model->checkin();
-
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menutype);
- }
-
- /**
- * Cancels an edit operation
- */
- function cancel()
- {
- $this->setRedirect( 'index.php?option=com_menus');
- }
-
- /**
- * Form for copying item(s) to a specific menu
- */
- function copy()
- {
- $model =& $this->getModel( 'List' );
- $view =& $this->getView( 'List' );
- $view->setModel( $model, true );
- $view->copyForm();
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function doCopy()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getString( 'menu', '', 'post');
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- //Check to see of a menu was selected to copy the items too
- if (empty($menu))
- {
- $msg = JText::_('Please select a menu from the list');
- $mainframe->enqueueMessage($msg, 'message');
- return $this->execute('copy');
- }
-
- $model =& $this->getModel( 'List' );
-
- if ($model->copy($cid, $menu)) {
- $msg = JText::sprintf( 'Menu Items Copied to', count( $cid ), $menu );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Form for moving item(s) to a specific menu
- */
- function move()
- {
- $model =& $this->getModel( 'List');
- $view =& $this->getView( 'List' );
- $view->setModel( $model, true );
- $view->moveForm();
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function doMove()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menu', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- //Check to see if a menu was selected to copy the items too
- if (empty($menu))
- {
- $msg = JText::_('Please select a menu from the list');
- $mainframe->enqueueMessage($msg, 'message');
- return $this->execute('move');
- }
-
- $model =& $this->getModel( 'List' );
-
- if ($model->move($cid, $menu)) {
- $msg = JText::sprintf( 'Menu Items Moved to', count( $cid ), $menu );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function publish()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $model =& $this->getModel( 'List' );
- if ($model->setItemState($cid, 1)) {
- $msg = JText::sprintf( 'Menu Items Published', count( $cid ) );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function unpublish()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $model =& $this->getModel( 'List' );
- if ($model->setItemState($cid, 0)) {
- $msg = JText::sprintf( 'Menu Items Unpublished', count( $cid ) );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function orderup()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (isset($cid[0]) && $cid[0]) {
- $id = $cid[0];
- } else {
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
- return false;
- }
-
- $model =& $this->getModel( 'List' );
- if ($model->orderItem($id, -1)) {
- $msg = JText::_( 'Menu Item Moved Up' );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function orderdown()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (isset($cid[0]) && $cid[0]) {
- $id = $cid[0];
- } else {
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
- return false;
- }
-
- $model =& $this->getModel( 'List' );
- if ($model->orderItem($id, 1)) {
- $msg = JText::_( 'Menu Item Moved Down' );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function saveorder()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $model =& $this->getModel( 'List' );
- if ($model->setOrder($cid, $menu)) {
- $msg = JText::_( 'New ordering saved' );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function accesspublic()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $model =& $this->getModel( 'List' );
- if ($model->setAccess($cid, 0)) {
- $msg = JText::sprintf( 'Menu Items Set Public', count( $cid ) );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function accessregistered()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $model =& $this->getModel( 'List' );
- if ($model->setAccess($cid, 1)) {
- $msg = JText::sprintf( 'Menu Items Set Registered', count( $cid ) );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function accessspecial()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $model =& $this->getModel( 'List' );
- if ($model->setAccess($cid, 2)) {
- $msg = JText::sprintf( 'Menu Items Set Special', count( $cid ) );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function setdefault()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (isset($cid[0]) && $cid[0]) {
- $id = $cid[0];
- } else {
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
- return false;
- }
-
- $item =& JTable::getInstance( 'menu' );
- $item->load($id);
- if(!$item->get('published')) {
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('The Default Menu Item Must Be Published') );
- return false;
- }
-
- $model =& $this->getModel( 'List' );
- if ($model->setHome($id)) {
- $msg = JText::_( 'Default Menu Item Set' );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- function remove()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Get some variables from the request
- $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (!count($cid)) {
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
- return false;
- }
-
- $model =& $this->getModel( 'List' );
- if ($n = $model->toTrash($cid)) {
- $msg = JText::sprintf( 'Item(s) sent to the Trash', $n );
- } else {
- $msg = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function view()
- {
- $model =& $this->getModel( 'List' );
- $view =& $this->getView( 'List' );
- $view->setModel( $model, true );
- $view->display();
- }
-
-
- /**
- * Controller for view listing menu types and related statical info
- * @param string The URL option
- */
- function viewMenus()
- {
-
- $view =& $this->getView( 'Menus');
- $model =& $this->getModel( 'Menutype' );
- $view->setModel( $model, true );
- $view->display();
- }
-
-
- /**
- * Controller for view to edit a menu type
- */
- function editMenu()
- {
- $view =& $this->getView( 'Menus' );
- $model =& $this->getModel( 'Menutype' );
- $view->setModel( $model, true );
- $view->editForm(true,null);
-
- }
-
- /**
- * Controller for view to create a menu type
- */
- function addMenu()
- {
- $view =& $this->getView( 'Menus' );
- $model =& $this->getModel( 'Menutype' );
- $view->setModel( $model, true );
- $view->editForm(false,null);
- }
-
- /**
- * Controller for saving a menu type
- */
- function saveMenu()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
- $id = JRequest::getVar( 'id', 0, 'post', 'int' );
-
- $oldType =& JTable::getInstance('menutypes' );
- $oldType->load( $id );
-
- $menuType =& JTable::getInstance('menutypes');
- $menuType->bind( JRequest::get( 'post' ) );
-
- $isNew = ($menuType->id == 0);
- $isChanged = ($oldType->menutype != $menuType->menutype);
-
- if (!$menuType->check()) {
- JError::raiseWarning( 500, $menuType->getError() );
- $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' );
- return false;
- }
-
- if (!$menuType->store()) {
- JError::raiseWarning( 500, $menuType->getError() );
- $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' );
- return false;
- }
-
- if ($isNew)
- {
- if ($title = JRequest::getVar( 'module_title', $menuType->menutype, 'post', 'string' ))
- {
- $module =& JTable::getInstance( 'module');
- $module->title = $title;
- $module->position = 'left';
- $module->module = 'mod_mainmenu';
- $module->published = 0;
- $module->iscore = 0;
- $module->params = 'menutype='. $menuType->menutype;
-
- // check then store data in db
- if (!$module->check()) {
- return JError::raiseWarning( 500, $module->getError() );
- }
- if (!$module->store()) {
- return JError::raiseWarning( 500, $module->getError() );
- }
- $module->checkin();
- $module->reorder( 'position='.$db->Quote($module->position) );
-
- // module assigned to show on All pages by default
- // Clean up possible garbage first
- $query = 'DELETE FROM #__modules_menu WHERE moduleid = '.(int) $module->id;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getError() );
- }
-
- // ToDO: Changed to become a Joomla! db-object
- $query = 'INSERT INTO #__modules_menu VALUES ( '.(int) $module->id.', 0 )';
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getError() );
- }
- }
-
- $msg = JText::sprintf( 'New Menu created', $menuType->menutype );
- }
- else if ($isChanged)
- {
- $oldTerm = $oldType->menutype;
- $newTerm = $menuType->menutype;
-
- // change menutype being of all mod_mainmenu modules calling old menutype
- $query = 'SELECT id'
- . ' FROM #__modules'
- . ' WHERE module = "mod_mainmenu"'
- . ' AND params LIKE "%menutype='.$db->getEscaped($oldTerm).'%"'
- ;
- $db->setQuery( $query );
- $modules = $db->loadResultArray();
-
- foreach ($modules as $id)
- {
- $row =& JTable::getInstance('module');
- $row->load( $id );
-
- $row->params = str_replace( $oldTerm, $newTerm, $row->params );
-
- // check then store data in db
- if ( !$row->check() ) {
- return JError::raiseWarning( 500, $db->getError() );
- }
- if ( !$row->store() ) {
- return JError::raiseWarning( 500, $db->getError() );
- }
- $row->checkin();
- }
-
- // change menutype of all menuitems using old menutype
- $query = 'UPDATE #__menu'
- . ' SET menutype = '.$db->Quote($newTerm)
- . ' WHERE menutype = '.$db->Quote($oldTerm)
- ;
- $db->setQuery( $query );
- $db->query();
-
- $msg = JText::_( 'Menu Items & Modules updated' );
- }
-
- $this->setRedirect( 'index.php?option=com_menus', $msg );
- }
-
- /**
- * Controller for a view to confirm the deletion of a menu type
- */
- function deleteMenu()
- {
- $view =& $this->getView( 'Menus' );
- $model =& $this->getModel( 'Menutype' );
- $view->setModel( $model, true );
- $view->deleteForm();
- }
-
- /**
- * Delete a menu
- */
- function doDeleteMenu()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $id = JRequest::getVar( 'id', 0, '', 'int' );
- if ($id <= 0) {
- JError::raiseWarning( 500, JText::_( 'Invalid ID provided' ) );
- $this->setRedirect( 'index.php?option=com_menus' );
- return false;
- }
-
- $model =& $this->getModel( 'Menutype' );
- if (!$model->canDelete()) {
- JError::raiseWarning( 500, $model->getError() );
- $this->setRedirect( 'index.php?option=com_menus' );
- return false;
- }
- $err = null;
- if (!$model->delete()) {
- $err = $model->getError();
- }
- $this->setRedirect( 'index.php?option=com_menus', $err );
- }
-
- /**
- * Compiles a list of the articles you have selected to Copy
- */
- function copyMenu()
- {
- $view =& $this->getView( 'Menus' );
- $model =& $this->getModel( 'Menutype' );
- $view->setModel( $model, true );
- $view->copyForm();
- }
-
- /**
- * Copies a complete menu, all its items and creates a new module, using the name speified
- */
- function doCopyMenu()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
- $type = JRequest::getVar( 'type', '', 'post', 'string' );
- $menu_name = JRequest::getVar( 'menu_name', 'New Menu', 'post', 'string' );
- $module_name = JRequest::getVar( 'module_name', 'New Module', 'post', 'string' );
-
- // check for unique menutype for new menu copy
- $query = 'SELECT params' .
- ' FROM #__modules' .
- ' WHERE module = "mod_mainmenu"';
- $db->setQuery( $query );
- $menus = $db->loadResultArray();
-
- foreach ( $menus as $menu )
- {
- $params = new JParameter( $menu );
- if ( $params->get('menutype') == $menu_name ) {
- JError::raiseWarning( 500, JText::_( 'ERRORMENUNAMEEXISTS' ) );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- }
- }
-
- // copy the menu items
- $mids = JRequest::getVar( 'mids', array(), 'post', 'array' );
- JArrayHelper::toInteger($mids);
- $total = count( $mids );
- $copy =& JTable::getInstance('menu');
- $original =& JTable::getInstance('menu');
- 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;
- $copy->home = 0;
-
- if ( !$copy->check() ) {
- JError::raiseWarning( 500, $copy->getError() );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- }
- if ( !$copy->store() ) {
- JError::raiseWarning( 500, $copy->getError() );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- }
- $a_ids[$original->id] = $copy->id;
- }
-
- // create the module copy
- $row =& JTable::getInstance('module');
- $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()) {
- JError::raiseWarning( 500, $db->getError() );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- }
- if (!$row->store()) {
- JError::raiseWarning( 500, $db->getError() );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- }
- $row->checkin();
- $row->reorder( 'position='.$db->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 )';
- $db->setQuery( $query );
- if ( !$db->query() ) {
- JError::raiseWarning( 500, $db->getErrorMsg(true) );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- //echo "\n";
- //$mainframe->close();
- }
-
- // Insert the menu type
- $query = 'INSERT INTO `#__menu_types` ( `menutype` , `title` , `description` ) ' .
- ' VALUES ( '.$db->Quote($menu_name).', '.$db->Quote($menu_name).', "")';
- $db->setQuery( $query );
- if ( !$db->query() ) {
- JError::raiseWarning( 500, $db->getErrorMsg(true) );
- $this->setRedirect( 'index.php?option=com_menus' );
- return;
- //echo "\n";
- //$mainframe->close();
- }
-
- $msg = JText::sprintf( 'Copy of Menu created', $type, $total );
- $mainframe->redirect( 'index.php?option=com_menus', $msg );
- }
-}
+getModel( 'Item' );
+ $view =& $this->getView( 'Item' );
+ $view->setModel( $model, true );
+
+ // Set the layout and display
+ $view->setLayout('type');
+ $view->type();
+ }
+ /**
+ * Edit menu item wizard
+ */
+
+ function type()
+ {
+ JRequest::setVar( 'edit', true );
+ $model =& $this->getModel( 'Item' );
+ $view =& $this->getView( 'Item' );
+ $view->setModel( $model, true );
+
+ // Set the layout and display
+ $view->setLayout('type');
+ $view->type();
+ }
+
+ /**
+ * Edits a menu item
+ */
+ function edit()
+ {
+ JRequest::setVar( 'edit', true );
+ $model =& $this->getModel( 'Item' );
+ $model->checkout();
+
+ $view =& $this->getView( 'Item' );
+ $view->setModel( $model, true );
+ // Set the layout and display
+ $view->setLayout('form');
+ $view->edit();
+ }
+
+ /**
+ * Saves a menu item
+ */
+ function save()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $model =& $this->getModel( 'Item' );
+ $post = JRequest::get('post');
+ // allow name only to contain html
+ $post['name'] = JRequest::getVar( 'name', '', 'post', 'string', JREQUEST_ALLOWHTML );
+ $model->setState( 'request', $post );
+
+ if ($model->store()) {
+ $msg = JText::_( 'Menu item Saved' );
+ } else {
+ $msg = JText::_( 'Error Saving Menu item' );
+ }
+
+ $item =& $model->getItem();
+ switch ( $this->_task ) {
+ case 'apply':
+ $this->setRedirect( 'index.php?option=com_menus&menutype='.$item->menutype.'&task=edit&cid[]='.$item->id.'' , $msg );
+ break;
+
+ case 'save':
+ default:
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$item->menutype, $msg );
+ break;
+ }
+ }
+
+ /**
+ * Cancels an edit operation
+ */
+ function cancelItem()
+ {
+ global $mainframe;
+
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
+
+ $model = $this->getModel('item');
+ $model->checkin();
+
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menutype);
+ }
+
+ /**
+ * Cancels an edit operation
+ */
+ function cancel()
+ {
+ $this->setRedirect( 'index.php?option=com_menus');
+ }
+
+ /**
+ * Form for copying item(s) to a specific menu
+ */
+ function copy()
+ {
+ $model =& $this->getModel( 'List' );
+ $view =& $this->getView( 'List' );
+ $view->setModel( $model, true );
+ $view->copyForm();
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function doCopy()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getString( 'menu', '', 'post');
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ //Check to see of a menu was selected to copy the items too
+ if (empty($menu))
+ {
+ $msg = JText::_('Please select a menu from the list');
+ $mainframe->enqueueMessage($msg, 'message');
+ return $this->execute('copy');
+ }
+
+ $model =& $this->getModel( 'List' );
+
+ if ($model->copy($cid, $menu)) {
+ $msg = JText::sprintf( 'Menu Items Copied to', count( $cid ), $menu );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Form for moving item(s) to a specific menu
+ */
+ function move()
+ {
+ $model =& $this->getModel( 'List');
+ $view =& $this->getView( 'List' );
+ $view->setModel( $model, true );
+ $view->moveForm();
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function doMove()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menu', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ //Check to see if a menu was selected to copy the items too
+ if (empty($menu))
+ {
+ $msg = JText::_('Please select a menu from the list');
+ $mainframe->enqueueMessage($msg, 'message');
+ return $this->execute('move');
+ }
+
+ $model =& $this->getModel( 'List' );
+
+ if ($model->move($cid, $menu)) {
+ $msg = JText::sprintf( 'Menu Items Moved to', count( $cid ), $menu );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function publish()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setItemState($cid, 1)) {
+ $msg = JText::sprintf( 'Menu Items Published', count( $cid ) );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function unpublish()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setItemState($cid, 0)) {
+ $msg = JText::sprintf( 'Menu Items Unpublished', count( $cid ) );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function orderup()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (isset($cid[0]) && $cid[0]) {
+ $id = $cid[0];
+ } else {
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
+ return false;
+ }
+
+ $model =& $this->getModel( 'List' );
+ if ($model->orderItem($id, -1)) {
+ $msg = JText::_( 'Menu Item Moved Up' );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function orderdown()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (isset($cid[0]) && $cid[0]) {
+ $id = $cid[0];
+ } else {
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
+ return false;
+ }
+
+ $model =& $this->getModel( 'List' );
+ if ($model->orderItem($id, 1)) {
+ $msg = JText::_( 'Menu Item Moved Down' );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function saveorder()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setOrder($cid, $menu)) {
+ $msg = JText::_( 'New ordering saved' );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function accesspublic()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setAccess($cid, 0)) {
+ $msg = JText::sprintf( 'Menu Items Set Public', count( $cid ) );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function accessregistered()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setAccess($cid, 1)) {
+ $msg = JText::sprintf( 'Menu Items Set Registered', count( $cid ) );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function accessspecial()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setAccess($cid, 2)) {
+ $msg = JText::sprintf( 'Menu Items Set Special', count( $cid ) );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function setdefault()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (isset($cid[0]) && $cid[0]) {
+ $id = $cid[0];
+ } else {
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
+ return false;
+ }
+
+ $item =& JTable::getInstance( 'menu' );
+ $item->load($id);
+ if(!$item->get('published')) {
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('The Default Menu Item Must Be Published') );
+ return false;
+ }
+
+ $model =& $this->getModel( 'List' );
+ if ($model->setHome($id)) {
+ $msg = JText::_( 'Default Menu Item Set' );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ function remove()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Get some variables from the request
+ $menu = JRequest::getVar( 'menutype', '', 'post', 'string' );
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (!count($cid)) {
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') );
+ return false;
+ }
+
+ $model =& $this->getModel( 'List' );
+ if ($n = $model->toTrash($cid)) {
+ $msg = JText::sprintf( 'Item(s) sent to the Trash', $n );
+ } else {
+ $msg = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg );
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function view()
+ {
+ $model =& $this->getModel( 'List' );
+ $view =& $this->getView( 'List' );
+ $view->setModel( $model, true );
+ $view->display();
+ }
+
+
+ /**
+ * Controller for view listing menu types and related statical info
+ * @param string The URL option
+ */
+ function viewMenus()
+ {
+
+ $view =& $this->getView( 'Menus');
+ $model =& $this->getModel( 'Menutype' );
+ $view->setModel( $model, true );
+ $view->display();
+ }
+
+
+ /**
+ * Controller for view to edit a menu type
+ */
+ function editMenu()
+ {
+ $view =& $this->getView( 'Menus' );
+ $model =& $this->getModel( 'Menutype' );
+ $view->setModel( $model, true );
+ $view->editForm(true,null);
+
+ }
+
+ /**
+ * Controller for view to create a menu type
+ */
+ function addMenu()
+ {
+ $view =& $this->getView( 'Menus' );
+ $model =& $this->getModel( 'Menutype' );
+ $view->setModel( $model, true );
+ $view->editForm(false,null);
+ }
+
+ /**
+ * Controller for saving a menu type
+ */
+ function saveMenu()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $id = JRequest::getVar( 'id', 0, 'post', 'int' );
+
+ $oldType =& JTable::getInstance('menutypes' );
+ $oldType->load( $id );
+
+ $menuType =& JTable::getInstance('menutypes');
+ $menuType->bind( JRequest::get( 'post' ) );
+
+ $isNew = ($menuType->id == 0);
+ $isChanged = ($oldType->menutype != $menuType->menutype);
+
+ if (!$menuType->check()) {
+ JError::raiseWarning( 500, $menuType->getError() );
+ $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' );
+ return false;
+ }
+
+ if (!$menuType->store()) {
+ JError::raiseWarning( 500, $menuType->getError() );
+ $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' );
+ return false;
+ }
+
+ if ($isNew)
+ {
+ if ($title = JRequest::getVar( 'module_title', $menuType->menutype, 'post', 'string' ))
+ {
+ $module =& JTable::getInstance( 'module');
+ $module->title = $title;
+ $module->position = 'left';
+ $module->module = 'mod_mainmenu';
+ $module->published = 0;
+ $module->iscore = 0;
+ $module->params = 'menutype='. $menuType->menutype;
+
+ // check then store data in db
+ if (!$module->check()) {
+ return JError::raiseWarning( 500, $module->getError() );
+ }
+ if (!$module->store()) {
+ return JError::raiseWarning( 500, $module->getError() );
+ }
+ $module->checkin();
+ $module->reorder( 'position='.$db->Quote($module->position) );
+
+ // module assigned to show on All pages by default
+ // Clean up possible garbage first
+ $query = 'DELETE FROM #__modules_menu WHERE moduleid = '.(int) $module->id;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+
+ // ToDO: Changed to become a Joomla! db-object
+ $query = 'INSERT INTO #__modules_menu VALUES ( '.(int) $module->id.', 0 )';
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+ }
+
+ $msg = JText::sprintf( 'New Menu created', $menuType->menutype );
+ }
+ else if ($isChanged)
+ {
+ $oldTerm = $oldType->menutype;
+ $newTerm = $menuType->menutype;
+
+ // change menutype being of all mod_mainmenu modules calling old menutype
+ $query = 'SELECT id'
+ . ' FROM #__modules'
+ . ' WHERE module = "mod_mainmenu"'
+ . ' AND params LIKE "%menutype='.$db->getEscaped($oldTerm).'%"'
+ ;
+ $db->setQuery( $query );
+ $modules = $db->loadResultArray();
+
+ foreach ($modules as $id)
+ {
+ $row =& JTable::getInstance('module');
+ $row->load( $id );
+
+ $row->params = str_replace( $oldTerm, $newTerm, $row->params );
+
+ // check then store data in db
+ if ( !$row->check() ) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+ if ( !$row->store() ) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+ $row->checkin();
+ }
+
+ // change menutype of all menuitems using old menutype
+ $query = 'UPDATE #__menu'
+ . ' SET menutype = '.$db->Quote($newTerm)
+ . ' WHERE menutype = '.$db->Quote($oldTerm)
+ ;
+ $db->setQuery( $query );
+ $db->query();
+
+ $msg = JText::_( 'Menu Items & Modules updated' );
+ }
+
+ $this->setRedirect( 'index.php?option=com_menus', $msg );
+ }
+
+ /**
+ * Controller for a view to confirm the deletion of a menu type
+ */
+ function deleteMenu()
+ {
+ $view =& $this->getView( 'Menus' );
+ $model =& $this->getModel( 'Menutype' );
+ $view->setModel( $model, true );
+ $view->deleteForm();
+ }
+
+ /**
+ * Delete a menu
+ */
+ function doDeleteMenu()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $id = JRequest::getVar( 'id', 0, '', 'int' );
+ if ($id <= 0) {
+ JError::raiseWarning( 500, JText::_( 'Invalid ID provided' ) );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return false;
+ }
+
+ $model =& $this->getModel( 'Menutype' );
+ if (!$model->canDelete()) {
+ JError::raiseWarning( 500, $model->getError() );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return false;
+ }
+ $err = null;
+ if (!$model->delete()) {
+ $err = $model->getError();
+ }
+ $this->setRedirect( 'index.php?option=com_menus', $err );
+ }
+
+ /**
+ * Compiles a list of the articles you have selected to Copy
+ */
+ function copyMenu()
+ {
+ $view =& $this->getView( 'Menus' );
+ $model =& $this->getModel( 'Menutype' );
+ $view->setModel( $model, true );
+ $view->copyForm();
+ }
+
+ /**
+ * Copies a complete menu, all its items and creates a new module, using the name speified
+ */
+ function doCopyMenu()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $type = JRequest::getVar( 'type', '', 'post', 'string' );
+ $menu_name = JRequest::getVar( 'menu_name', 'New Menu', 'post', 'string' );
+ $module_name = JRequest::getVar( 'module_name', 'New Module', 'post', 'string' );
+
+ // check for unique menutype for new menu copy
+ $query = 'SELECT params' .
+ ' FROM #__modules' .
+ ' WHERE module = "mod_mainmenu"';
+ $db->setQuery( $query );
+ $menus = $db->loadResultArray();
+
+ foreach ( $menus as $menu )
+ {
+ $params = new JParameter( $menu );
+ if ( $params->get('menutype') == $menu_name ) {
+ JError::raiseWarning( 500, JText::_( 'ERRORMENUNAMEEXISTS' ) );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ }
+ }
+
+ // copy the menu items
+ $mids = JRequest::getVar( 'mids', array(), 'post', 'array' );
+ JArrayHelper::toInteger($mids);
+ $total = count( $mids );
+ $copy =& JTable::getInstance('menu');
+ $original =& JTable::getInstance('menu');
+ sort( $mids );
+ $a_ids = array();
+
+ foreach( $mids as $mid )
+ {
+ $original->load( $mid );
+ $parent = $original->parent;
+ $id = $original->id;
+ $copy = $original;
+ $copy->id = NULL;
+ $copy->parent = $a_ids[$parent];
+ $copy->menutype = $menu_name;
+ $copy->home = 0;
+
+ if ( !$copy->check() ) {
+ JError::raiseWarning( 500, $copy->getError() );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ }
+ if ( !$copy->store() ) {
+ JError::raiseWarning( 500, $copy->getError() );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ }
+ $a_ids[$id] = $copy->id;
+ }
+
+ // create the module copy
+ $row =& JTable::getInstance('module');
+ $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()) {
+ JError::raiseWarning( 500, $db->getError() );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ }
+ if (!$row->store()) {
+ JError::raiseWarning( 500, $db->getError() );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ }
+ $row->checkin();
+ $row->reorder( 'position='.$db->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 )';
+ $db->setQuery( $query );
+ if ( !$db->query() ) {
+ JError::raiseWarning( 500, $db->getErrorMsg(true) );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ //echo "\n";
+ //$mainframe->close();
+ }
+
+ // Insert the menu type
+ $query = 'INSERT INTO `#__menu_types` ( `menutype` , `title` , `description` ) ' .
+ ' VALUES ( '.$db->Quote($menu_name).', '.$db->Quote($menu_name).', "")';
+ $db->setQuery( $query );
+ if ( !$db->query() ) {
+ JError::raiseWarning( 500, $db->getErrorMsg(true) );
+ $this->setRedirect( 'index.php?option=com_menus' );
+ return;
+ //echo "\n";
+ //$mainframe->close();
+ }
+
+ $msg = JText::sprintf( 'Copy of Menu created', $type, $total );
+ $mainframe->redirect( 'index.php?option=com_menus', $msg );
+ }
+}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php b/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php
index 87093b8f..3aebe442 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php
@@ -1,171 +1,171 @@
-setQuery( $query );
- return $db->loadObjectList();
- }
-
- /**
- * Get a list of the menutypes
- * @return array An array of menu type names
- */
- function getMenuTypes()
- {
- $db = &JFactory::getDBO();
- $query = 'SELECT menutype' .
- ' FROM #__menu_types';
- $db->setQuery( $query );
- return $db->loadResultArray();
- }
-
- /**
- * Gets a list of components that can link to the menu
- */
- function getComponentList()
- {
- $db = &JFactory::getDBO();
- $query = 'SELECT c.id, c.name, c.link, c.option' .
- ' FROM #__components AS c' .
- ' WHERE c.link <> "" AND parent = 0' .
- ' ORDER BY c.name';
- $db->setQuery( $query );
- $result = $db->loadObjectList( );
- return $result;
- }
-
- /**
- * Build the select list for parent menu item
- */
- function Parent( &$row )
- {
- $db =& JFactory::getDBO();
-
- // If a not a new item, lets set the menu item id
- if ( $row->id ) {
- $id = ' AND id != '.(int) $row->id;
- } else {
- $id = null;
- }
-
- // In case the parent was null
- if (!$row->parent) {
- $row->parent = 0;
- }
-
- // get a list of the menu items
- // excluding the current menu item and its child elements
- $query = 'SELECT m.*' .
- ' FROM #__menu m' .
- ' WHERE menutype = '.$db->Quote($row->menutype) .
- ' AND published != -2' .
- $id .
- ' ORDER BY parent, ordering';
- $db->setQuery( $query );
- $mitems = $db->loadObjectList();
-
- // establish the hierarchy of the menu
- $children = array();
-
- if ( $mitems )
- {
- // first pass - collect children
- foreach ( $mitems as $v )
- {
- $pt = $v->parent;
- $list = @$children[$pt] ? $children[$pt] : array();
- array_push( $list, $v );
- $children[$pt] = $list;
- }
- }
-
- // second pass - get an indent list of the items
- $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 );
-
- // assemble menu items to the array
- $mitems = array();
- $mitems[] = JHTML::_('select.option', '0', JText::_( 'Top' ) );
-
- foreach ( $list as $item ) {
- $mitems[] = JHTML::_('select.option', $item->id, ' '. $item->treename );
- }
-
- $output = JHTML::_('select.genericlist', $mitems, 'parent', 'class="inputbox" size="10"', 'value', 'text', $row->parent );
-
- return $output;
- }
-
- /**
- * build the select list for target window
- */
- function Target( &$row )
- {
- $click[] = JHTML::_('select.option', '0', JText::_( 'Parent Window With Browser Navigation' ) );
- $click[] = JHTML::_('select.option', '1', JText::_( 'New Window With Browser Navigation' ) );
- $click[] = JHTML::_('select.option', '2', JText::_( 'New Window Without Browser Navigation' ) );
- $target = JHTML::_('select.genericlist', $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) );
-
- return $target;
- }
-
- /**
- * build the select list for target window
- */
- function Published( &$row )
- {
- $put[] = JHTML::_('select.option', '0', JText::_( 'No' ));
- $put[] = JHTML::_('select.option', '1', JText::_( 'Yes' ));
-
- // If not a new item, trash is not an option
- if ( !$row->id ) {
- $row->published = 1;
- }
- $published = JHTML::_('select.radiolist', $put, 'published', '', 'value', 'text', $row->published );
- return $published;
- }
-
- /**
- * clean system cache
- */
- function cleanCache()
- {
- global $mainframe;
-
- if ($mainframe->getCfg('caching')) {
- // clean system cache
- $cache =& JFactory::getCache('_system');
- $cache->clean();
-
- // clean mod_mainmenu cache
- $cache2 =& JFactory::getCache('mod_mainmenu');
- $cache2->clean();
- }
- }
-}
+setQuery( $query );
+ return $db->loadObjectList();
+ }
+
+ /**
+ * Get a list of the menutypes
+ * @return array An array of menu type names
+ */
+ function getMenuTypes()
+ {
+ $db = &JFactory::getDBO();
+ $query = 'SELECT menutype' .
+ ' FROM #__menu_types';
+ $db->setQuery( $query );
+ return $db->loadResultArray();
+ }
+
+ /**
+ * Gets a list of components that can link to the menu
+ */
+ function getComponentList()
+ {
+ $db = &JFactory::getDBO();
+ $query = 'SELECT c.id, c.name, c.link, c.option' .
+ ' FROM #__components AS c' .
+ ' WHERE c.link <> "" AND parent = 0 AND enabled = 1' .
+ ' ORDER BY c.name';
+ $db->setQuery( $query );
+ $result = $db->loadObjectList( );
+ return $result;
+ }
+
+ /**
+ * Build the select list for parent menu item
+ */
+ function Parent( &$row )
+ {
+ $db =& JFactory::getDBO();
+
+ // If a not a new item, lets set the menu item id
+ if ( $row->id ) {
+ $id = ' AND id != '.(int) $row->id;
+ } else {
+ $id = null;
+ }
+
+ // In case the parent was null
+ if (!$row->parent) {
+ $row->parent = 0;
+ }
+
+ // get a list of the menu items
+ // excluding the current menu item and its child elements
+ $query = 'SELECT m.*' .
+ ' FROM #__menu m' .
+ ' WHERE menutype = '.$db->Quote($row->menutype) .
+ ' AND published != -2' .
+ $id .
+ ' ORDER BY parent, ordering';
+ $db->setQuery( $query );
+ $mitems = $db->loadObjectList();
+
+ // establish the hierarchy of the menu
+ $children = array();
+
+ if ( $mitems )
+ {
+ // first pass - collect children
+ foreach ( $mitems as $v )
+ {
+ $pt = $v->parent;
+ $list = @$children[$pt] ? $children[$pt] : array();
+ array_push( $list, $v );
+ $children[$pt] = $list;
+ }
+ }
+
+ // second pass - get an indent list of the items
+ $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 );
+
+ // assemble menu items to the array
+ $mitems = array();
+ $mitems[] = JHTML::_('select.option', '0', JText::_( 'Top' ) );
+
+ foreach ( $list as $item ) {
+ $mitems[] = JHTML::_('select.option', $item->id, ' '. $item->treename );
+ }
+
+ $output = JHTML::_('select.genericlist', $mitems, 'parent', 'class="inputbox" size="10"', 'value', 'text', $row->parent );
+
+ return $output;
+ }
+
+ /**
+ * build the select list for target window
+ */
+ function Target( &$row )
+ {
+ $click[] = JHTML::_('select.option', '0', JText::_( 'Parent Window With Browser Navigation' ) );
+ $click[] = JHTML::_('select.option', '1', JText::_( 'New Window With Browser Navigation' ) );
+ $click[] = JHTML::_('select.option', '2', JText::_( 'New Window Without Browser Navigation' ) );
+ $target = JHTML::_('select.genericlist', $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) );
+
+ return $target;
+ }
+
+ /**
+ * build the select list for target window
+ */
+ function Published( &$row )
+ {
+ $put[] = JHTML::_('select.option', '0', JText::_( 'No' ));
+ $put[] = JHTML::_('select.option', '1', JText::_( 'Yes' ));
+
+ // If not a new item, trash is not an option
+ if ( !$row->id ) {
+ $row->published = 1;
+ }
+ $published = JHTML::_('select.radiolist', $put, 'published', '', 'value', 'text', $row->published );
+ return $published;
+ }
+
+ /**
+ * clean system cache
+ */
+ function cleanCache()
+ {
+ global $mainframe;
+
+ if ($mainframe->getCfg('caching')) {
+ // clean system cache
+ $cache =& JFactory::getCache('_system');
+ $cache->clean();
+
+ // clean mod_mainmenu cache
+ $cache2 =& JFactory::getCache('mod_mainmenu');
+ $cache2->clean();
+ }
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/menus.xml b/oss/joomla/trunk/administrator/components/com_menus/menus.xml
index 876a799c..8e79833c 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/menus.xml
+++ b/oss/joomla/trunk/administrator/components/com_menus/menus.xml
@@ -1,12 +1,12 @@
-
-
- Menus Manager
- Joomla! Project
- 2006
- Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.5.0
- Menu Manager
-
+
+
+ Menus Manager
+ Joomla! Project
+ 2006
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5.0
+ Menu Manager
+
diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/item.php b/oss/joomla/trunk/administrator/components/com_menus/models/item.php
index a4ba5427..983fd036 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/models/item.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/models/item.php
@@ -1,792 +1,792 @@
-_url = 'index.php?option='.$url['option'];
- unset($url['option']);
- if (count($url)) {
- foreach ($url as $k => $v)
- {
- $this->_url .= '&'.$k.'='.$v;
- }
- }
- }
-
- $this->setId();
- }
-
- function setId()
- {
- $array = JRequest::getVar('cid', array(0), '', 'array');
- $this->_id = (int) $array[0];
-
- if (!$this->_id) {
- $this->_id = JRequest::getInt('id', 0);
- }
- }
-
- function &getItem()
- {
- static $item;
- if (isset($item)) {
- return $item;
- }
-
- $table =& $this->_getTable();
-
- // Load the current item if it has been defined
- $edit = JRequest::getVar('edit',true);
- $cid = JRequest::getVar( 'cid', array(0), '', 'array' );
- JArrayHelper::toInteger($cid, array(0));
- if ($edit) {
- $table->load($cid[0]);
- }
-
- // Override the current item's type field if defined in the request
- if ($type = JRequest::getString('type')) {
- $table->type = $type;
- }
-
- // Override the current item's menutype field if defined in the request
- if ($menu_type = JRequest::getString('menutype')) {
- $table->menutype = $menu_type;
- }
-
- switch ($table->type)
- {
- case 'separator':
- $table->link = null;
- $table->componentid = 0;
- break;
- case 'url':
- $table->componentid = 0;
- break;
- case 'menulink':
- $table->componentid = 0;
- break;
- case 'component':
- // Override the current item's link field if defined in the request
- if (!is_null($this->_url)) {
- $table->link = $this->_url;
- }
- $url = str_replace('index.php?', '', $table->link);
- $url = str_replace('&', '&', $url);
- $table->linkparts = null;
- if(strpos($url, '&') !== false)
- {
- $url = str_replace('&','&',$url);
- }
-
- parse_str($url, $table->linkparts);
-
- $db = &$this->getDBO();
- if ($component = @$table->linkparts['option']) {
- $query = 'SELECT `id`' .
- ' FROM `#__components`' .
- ' WHERE `link` <> \'\'' .
- ' AND `parent` = 0' .
- ' AND `option` = "'.$db->getEscaped($component).'"';
- $db->setQuery( $query );
- $table->componentid = $db->loadResult();
- }
- break;
- }
-
- $item = $table;
- return $item;
- }
-
- function &getExpansion()
- {
- $item = &$this->getItem();
- $return['option'] = JRequest::getCmd('expand');
- $menutype = JRequest::getString('menutype');
-
- if ($return['option'])
- {
- require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'classes'.DS.'ilink.php');
- $handler = new iLink($return['option'], $item->id, $menutype);
- $return['html'] = $handler->getTree();
- return $return;
- } else {
- $return['html'] = null;
- }
- return $return;
- }
-
- function &getUrlParams()
- {
- // Get the state parameters
- $item =& $this->getItem();
- $params = new JParameter('');
-
- if ($state =& $this->_getStateXML())
- {
- if (is_a($state, 'JSimpleXMLElement'))
- {
- $sp =& $state->getElementByPath('url');
- $params->setXML($sp);
- if (isset($item->linkparts) && is_array($item->linkparts)) {
- $params->loadArray($item->linkparts);
- }
- }
- }
- return $params;
- }
-
- function &getStateParams()
- {
- // Get the state parameters
- $item =& $this->getItem();
- $params = new JParameter($item->params);
-
- if ($state =& $this->_getStateXML())
- {
- if (is_a($state, 'JSimpleXMLElement'))
- {
- $sp =& $state->getElementByPath('params');
- $params->setXML($sp);
- }
- }
- return $params;
- }
-
- function &getAdvancedParams()
- {
- // Get the state parameters
- $item =& $this->getItem();
- $params = new JParameter($item->params);
-
- if ($state =& $this->_getStateXML())
- {
- if (is_a($state, 'JSimpleXMLElement'))
- {
- $ap =& $state->getElementByPath('advanced');
- $params->setXML($ap);
- }
- }
- return $params;
- }
-
- function &getComponentParams()
- {
- // Initialize variables
- $params = null;
- $item = &$this->getItem();
-
- if ($item->type == 'component')
- {
- $comp = &$this->getComponent();
- $option = preg_replace( '#\W#', '', $comp->option );
- $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml';
-
- $params = new JParameter( $item->params );
- if (file_exists( $path ))
- {
- $xml =& JFactory::getXMLParser('Simple');
- if ($xml->loadFile($path))
- {
- $document =& $xml->document;
-
- // if hide is set, don't show the component configuration while editing menu item
- $menu = $document->attributes('menu');
- if ( isset($menu) && $menu == 'hide' )
- {
- $params = null;
- return $params;
- }
-
- if (isset($document->params[0]->param))
- {
- // We will collect the hidden elements in an array
- // loop will mess up if we do it within the loop
- $hide = array();
- for ($i=0,$n=count($document->params[0]->param); $i<$n; $i++)
- {
- if ($document->params[0]->param[$i]->attributes('menu') == 'hide')
- {
- $hide[] = &$document->params[0]->param[$i];
- }
- else if ($document->params[0]->param[$i]->attributes('type') == 'radio' || $document->params[0]->param[$i]->attributes('type') == 'list') {
- $document->params[0]->param[$i]->addAttribute('default', '');
- $document->params[0]->param[$i]->addAttribute('type', 'list');
- $child = &$document->params[0]->param[$i]->addChild('option', array('value' => ''));
- $child->setData('Use Global');
- }
- }
- // Now remove any hidden elements
- for ($i = 0, $n = count( $hide ); $i < $n; $i++) {
- $document->params[0]->removeChild( $hide[$i] );
- }
- }
- $params->setXML( $document->params[0] );
- }
- }
- }
- return $params;
- }
-
- function &getSystemParams()
- {
- // Initialize variables
- $params = null;
- $item = &$this->getItem();
-
- $params = new JParameter( $item->params );
- if ($item->type == 'component') {
- $path = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'component.xml';
- if (file_exists( $path )) {
- $xml =& JFactory::getXMLParser('Simple');
- if ($xml->loadFile($path)) {
- $document =& $xml->document;
- $params->setXML($document->getElementByPath('state/params'));
- }
- }
- }
- return $params;
- }
-
- /**
- * Get the name of the current menu item
- *
- * @return string
- * @access public
- * @since 1.5
- */
- function getStateName()
- {
- $state =& $this->_getStateXML();
-
- if ( ! is_a($state, 'JSimpleXMLElement'))
- {
- return null;
- }
-
- $name = null;
- $sn =& $state->getElementByPath('name');
- if ($sn) {
- $name = $sn->data();
- }
-
- return JText::_($name);
- }
-
- /**
- * Get the description of the current menu item
- *
- * @return string
- * @access public
- * @since 1.5
- */
- function getStateDescription()
- {
- $state =& $this->_getStateXML();
-
-
- if ( ! is_a($state, 'JSimpleXMLElement'))
- {
- return null;
- }
-
- $description = null;
- $sd =& $state->getElementByPath('description');
- if ($sd) {
- $description = $sd->data();
- }
-
- return JText::_($description);
- }
-
- /**
- * Gets the componet table object related to this menu item
- */
- function &getComponent()
- {
- $item =& $this->getItem();
- $id = $item->componentid;
- $component = & JTable::getInstance( 'component');
- $component->load( $id );
- return $component;
- }
-
- function checkout($uid = null)
- {
- $id = JRequest::getVar('cid', array(0), '', 'array');
- JArrayHelper::toInteger( $id, array(0) );
-
- // Make sure we have a user id to checkout the article with
- if (is_null($uid)) {
- $user =& JFactory::getUser();
- $uid = $user->get('id');
- }
-
- // Lets get to it and checkout the thing...
- $item =& $this->getItem();
- if(!$item->checkout($uid, $id[0])) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- return true;
- }
-
- function checkin()
- {
- if ($this->_id) {
- $item =& $this->_getTable();
-
- if(!$item->checkin($this->_id)) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- return true;
- }
-
- return false;
- }
-
- function store()
- {
- // Initialize variables
- $db =& JFactory::getDBO();
- $row =& $this->getItem();
- $post = $this->_state->get( 'request' );
-
- switch ($post['type'])
- {
- case 'separator':
- break;
- case 'url':
- break;
- case 'menulink':
- $post['link'] = 'index.php?Itemid='.$post['params']['menu_item'];
- break;
- case 'component':
- break;
- }
- if (!$row->bind( $post )) {
- echo "\n";
- return false;
- }
-
- if ($row->id > 0)
- {
- // existing item
- $query = 'SELECT menutype FROM #__menu WHERE id = '.(int) $row->id;
- $this->_db->setQuery( $query );
- $oldType = $this->_db->loadResult();
- if ($oldType != $row->menutype) {
- // moved to another menu, disconnect the old parent
- $row->parent = 0;
- }
- $query = 'SELECT parent FROM #__menu WHERE id = '.(int) $row->id;
- $this->_db->setQuery( $query );
- $oldParent = $this->_db->loadResult();
- if ($oldParent != $row->parent) {
- // we have changed parents, so we have to fix the submenu values
- if ($row->parent != 0) {
- $query = 'SELECT sublevel FROM #__menu WHERE id = '.(int) $row->parent;
- $this->_db->setQuery( $query );
- $sublevel = $this->_db->loadResult() + 1;
- } else {
- $sublevel = 0;
- }
- $row->sublevel = $sublevel;
- $this->_setSubLevel( array( (int) $row->id ), $sublevel );
- }
- }
- else
- {
- // if new item order last in appropriate group
- $where = "menutype = " . $db->Quote($row->menutype) . " AND published >= 0 AND parent = ".(int) $row->parent;
- $row->ordering = $row->getNextOrder( $where );
-
- if( $row->parent != 0 ) {
- $query = 'SELECT sublevel FROM #__menu WHERE id = '. (int) $row->parent;
- $this->_db->setQuery($query);
- $row->sublevel = $this->_db->loadResult() + 1;
- }
- }
-
- if (isset($post['urlparams']) && is_array($post['urlparams']))
- {
- $pos = strpos( $row->link, '?' );
- if ($pos !== false)
- {
- $prefix = substr( $row->link, 0, $pos );
- $query = substr( $row->link, $pos+1 );
-
- $temp = array();
- if(strpos($query, '&') !== false) {
- $query = str_replace('&', '&', $query);
- }
- parse_str( $query, $temp );
- $temp2 = array_merge( $temp, $post['urlparams'] );
-
- $temp3 = array();
- foreach ($temp2 as $k => $v)
- {
- if ( $k && strlen($v) )
- {
- $temp3[] = $k.'='.$v;
- }
- }
- $url = null;
- $row->link = $prefix . '?' . implode( '&', $temp3 );
- }
- }
-
- if (!$row->check())
- {
- echo "\n";
- return false;
- }
-
- if (!$row->store())
- {
- echo "\n";
- return false;
- }
-
- $row->checkin();
- $row->reorder( 'menutype='.$db->Quote( $row->menutype ).' AND parent='.(int)$row->parent );
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
-
-
- /**
- * Delete one or more menu items
- * @param mixed int or array of id values
- */
- function delete( $ids )
- {
- JArrayHelper::toInteger($ids);
-
- $db = &$this->getDBO();
-
- if (count( $ids ))
- {
- // Delete associated module and template mappings
- $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids );
-
- $query = 'DELETE FROM #__modules_menu '
- . $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $menuTable->getErrorMsg() );
- return false;
- }
-
- $query = 'DELETE FROM #__templates_menu '
- . $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $menuTable->getErrorMsg() );
- return false;
- }
-
- // Set any alias menu types to not point to missing menu items
- $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')';
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
-
- // Delete the menu items
- $where = 'WHERE id = ' . implode( ' OR id = ', $ids );
-
- $query = 'DELETE FROM #__menu ' . $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- /**
- * Delete menu items by type
- */
- function deleteByType( $type = '' )
- {
- $db = &$this->getDBO();
-
- $query = 'SELECT id' .
- ' FROM #__menu' .
- ' WHERE menutype = ' . $db->Quote( $type );
- $db->setQuery( $query );
- $ids = $db->loadResultArray();
-
- if ($db->getErrorNum())
- {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
-
- return $this->delete( $ids );
- }
-
- /**
- * Returns the internal table object
- * @return JTable
- */
- function &_getTable()
- {
- if ($this->_table == null) {
- $this->_table =& JTable::getInstance( 'menu');
- }
- return $this->_table;
- }
-
- function &_getStateXML()
- {
- static $xml;
-
- if (isset($xml)) {
- return $xml;
- }
- $xml = null;
- $xmlpath = null;
- $item = &$this->getItem();
-
- switch ($item->type)
- {
- case 'separator':
- $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'separator.xml';
- break;
- case 'url':
- $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'url.xml';
- break;
- case 'menulink':
- $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'menulink.xml';
- break;
- case 'component':
- default:
- if (isset($item->linkparts['view']))
- {
- // View is set... so we konw to look in view file
- if (isset($item->linkparts['layout'])) {
- $layout = $item->linkparts['layout'];
- } else {
- $layout = 'default';
- }
- $lpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'tmpl'.DS.$layout.'.xml';
- $vpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'metadata.xml';
- if (file_exists($lpath)) {
- $xmlpath = $lpath;
- } elseif (file_exists($vpath)) {
- $xmlpath = $vpath;
- }
- }
- if (!$xmlpath && isset($item->linkparts['option'])) {
- $xmlpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'metadata.xml';
- if(!file_exists($xmlpath)) {
- $xmlpath = JApplicationHelper::getPath('com_xml', $item->linkparts['option']);
- }
- }
- break;
- }
-
- if (file_exists($xmlpath))
- {
- $xml =& JFactory::getXMLParser('Simple');
- if ($xml->loadFile($xmlpath)) {
- $this->_xml = &$xml;
- $document =& $xml->document;
-
- /*
- * HANDLE NO OPTION CASE
- */
- $menus =& $document->getElementByPath('menu');
- if (is_a($menus, 'JSimpleXMLElement') && $menus->attributes('options') == 'none') {
- $xml =& $menus->getElementByPath('state');
- } else {
- $xml =& $document->getElementByPath('state');
- }
-
- // Handle error case... path doesn't exist
- if (!is_a($xml, 'JSimpleXMLElement')) {
- return $document;
- }
-
- /*
- * HANDLE A SWITCH IF IT EXISTS
- */
- if ($switch = $xml->attributes('switch'))
- {
- $default = $xml->attributes('default');
- // Handle switch
- $switchVal = (isset($item->linkparts[$switch]))? $item->linkparts[$switch] : 'default';
- $found = false;
-
- foreach ($xml->children() as $child) {
- if ($child->name() == $switchVal) {
- $xml =& $child;
- $found = true;
- break;
- }
- }
-
- if (!$found) {
- foreach ($xml->children() as $child) {
- if ($child->name() == $default) {
- $xml =& $child;
- break;
- }
- }
- }
- }
-
- /*
- * HANDLE INCLUDED PARAMS
- */
- $children = $xml->children();
- if (count($children) == 1)
- {
- if ($children[0]->name() == 'include') {
- $ret =& $this->_getIncludedParams($children[0]);
- if ($ret) {
- $xml =& $ret;
- }
- }
- }
-
- if ($switch = $xml->attributes('switch'))
- {
- $default = $xml->attributes('default');
- // Handle switch
- $switchVal = ($item->linkparts[$switch])? $item->linkparts[$switch] : 'default';
- $found = false;
-
- foreach ($xml->children() as $child) {
- if ($child->name() == $switchVal) {
- $xml =& $child;
- $found = true;
- break;
- }
- }
-
- if (!$found) {
- foreach ($xml->children() as $child) {
- if ($child->name() == $default) {
- $xml =& $child;
- break;
- }
- }
- }
- }
- }
- }
- return $xml;
- }
-
- function &_getIncludedParams($include)
- {
- $tags = array();
- $state = null;
- $source = $include->attributes('source');
- $path = $include->attributes('path');
- $item = &$this->getItem();
-
- preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags);
- if (isset($tags[1])) {
- for ($i=0;$ilinkparts[$tags[1][$i]], $source);
- }
- }
-
- // load the source xml file
- if (file_exists( JPATH_ROOT.$source ))
- {
- $xml = & JFactory::getXMLParser('Simple');
-
- if ($xml->loadFile(JPATH_ROOT.$source)) {
- $document = &$xml->document;
- $state = $document->getElementByPath($path);
- }
- }
- return $state;
- }
-
- /**
- * Sets the sublevel for menu items
- *
- * @param array id values to set
- * @param int level to assign to the sublevel
- */
- function _setSubLevel( $cid, $level )
- {
- JArrayHelper::toInteger($cid, array(0));
-
- $ids = implode( ',', $cid );
-
- $query = 'UPDATE #__menu SET sublevel = '.(int) $level
- .' WHERE id IN ('.$ids.')';
- $this->_db->setQuery( $query );
- $this->_db->query();
-
- $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')';
- $this->_db->setQuery( $query );
- $cids = $this->_db->loadResultArray( 0 );
-
- if (!empty( $cids )) {
- $this->_setSubLevel( $cids, $level + 1 );
- }
- }
-}
+_url = 'index.php?option='.$url['option'];
+ unset($url['option']);
+ if (count($url)) {
+ foreach ($url as $k => $v)
+ {
+ $this->_url .= '&'.$k.'='.$v;
+ }
+ }
+ }
+
+ $this->setId();
+ }
+
+ function setId()
+ {
+ $array = JRequest::getVar('cid', array(0), '', 'array');
+ $this->_id = (int) $array[0];
+
+ if (!$this->_id) {
+ $this->_id = JRequest::getInt('id', 0);
+ }
+ }
+
+ function &getItem()
+ {
+ static $item;
+ if (isset($item)) {
+ return $item;
+ }
+
+ $table =& $this->_getTable();
+
+ // Load the current item if it has been defined
+ $edit = JRequest::getVar('edit',true);
+ $cid = JRequest::getVar( 'cid', array(0), '', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+ if ($edit) {
+ $table->load($cid[0]);
+ }
+
+ // Override the current item's type field if defined in the request
+ if ($type = JRequest::getString('type')) {
+ $table->type = $type;
+ }
+
+ // Override the current item's menutype field if defined in the request
+ if ($menu_type = JRequest::getString('menutype')) {
+ $table->menutype = $menu_type;
+ }
+
+ switch ($table->type)
+ {
+ case 'separator':
+ $table->link = null;
+ $table->componentid = 0;
+ break;
+ case 'url':
+ $table->componentid = 0;
+ break;
+ case 'menulink':
+ $table->componentid = 0;
+ break;
+ case 'component':
+ // Override the current item's link field if defined in the request
+ if (!is_null($this->_url)) {
+ $table->link = $this->_url;
+ }
+ $url = str_replace('index.php?', '', $table->link);
+ $url = str_replace('&', '&', $url);
+ $table->linkparts = null;
+ if(strpos($url, '&') !== false)
+ {
+ $url = str_replace('&','&',$url);
+ }
+
+ parse_str($url, $table->linkparts);
+
+ $db = &$this->getDBO();
+ if ($component = @$table->linkparts['option']) {
+ $query = 'SELECT `id`' .
+ ' FROM `#__components`' .
+ ' WHERE `link` <> \'\'' .
+ ' AND `parent` = 0' .
+ ' AND `option` = "'.$db->getEscaped($component).'"';
+ $db->setQuery( $query );
+ $table->componentid = $db->loadResult();
+ }
+ break;
+ }
+
+ $item = $table;
+ return $item;
+ }
+
+ function &getExpansion()
+ {
+ $item = &$this->getItem();
+ $return['option'] = JRequest::getCmd('expand');
+ $menutype = JRequest::getString('menutype');
+
+ if ($return['option'])
+ {
+ require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'classes'.DS.'ilink.php');
+ $handler = new iLink($return['option'], $item->id, $menutype);
+ $return['html'] = $handler->getTree();
+ return $return;
+ } else {
+ $return['html'] = null;
+ }
+ return $return;
+ }
+
+ function &getUrlParams()
+ {
+ // Get the state parameters
+ $item =& $this->getItem();
+ $params = new JParameter('');
+
+ if ($state =& $this->_getStateXML())
+ {
+ if (is_a($state, 'JSimpleXMLElement'))
+ {
+ $sp =& $state->getElementByPath('url');
+ $params->setXML($sp);
+ if (isset($item->linkparts) && is_array($item->linkparts)) {
+ $params->loadArray($item->linkparts);
+ }
+ }
+ }
+ return $params;
+ }
+
+ function &getStateParams()
+ {
+ // Get the state parameters
+ $item =& $this->getItem();
+ $params = new JParameter($item->params);
+
+ if ($state =& $this->_getStateXML())
+ {
+ if (is_a($state, 'JSimpleXMLElement'))
+ {
+ $sp =& $state->getElementByPath('params');
+ $params->setXML($sp);
+ }
+ }
+ return $params;
+ }
+
+ function &getAdvancedParams()
+ {
+ // Get the state parameters
+ $item =& $this->getItem();
+ $params = new JParameter($item->params);
+
+ if ($state =& $this->_getStateXML())
+ {
+ if (is_a($state, 'JSimpleXMLElement'))
+ {
+ $ap =& $state->getElementByPath('advanced');
+ $params->setXML($ap);
+ }
+ }
+ return $params;
+ }
+
+ function &getComponentParams()
+ {
+ // Initialize variables
+ $params = null;
+ $item = &$this->getItem();
+
+ if ($item->type == 'component')
+ {
+ $comp = &$this->getComponent();
+ $option = preg_replace( '#\W#', '', $comp->option );
+ $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml';
+
+ $params = new JParameter( $item->params );
+ if (file_exists( $path ))
+ {
+ $xml =& JFactory::getXMLParser('Simple');
+ if ($xml->loadFile($path))
+ {
+ $document =& $xml->document;
+
+ // if hide is set, don't show the component configuration while editing menu item
+ $menu = $document->attributes('menu');
+ if ( isset($menu) && $menu == 'hide' )
+ {
+ $params = null;
+ return $params;
+ }
+
+ if (isset($document->params[0]->param))
+ {
+ // We will collect the hidden elements in an array
+ // loop will mess up if we do it within the loop
+ $hide = array();
+ for ($i=0,$n=count($document->params[0]->param); $i<$n; $i++)
+ {
+ if ($document->params[0]->param[$i]->attributes('menu') == 'hide')
+ {
+ $hide[] = &$document->params[0]->param[$i];
+ }
+ else if ($document->params[0]->param[$i]->attributes('type') == 'radio' || $document->params[0]->param[$i]->attributes('type') == 'list') {
+ $document->params[0]->param[$i]->addAttribute('default', '');
+ $document->params[0]->param[$i]->addAttribute('type', 'list');
+ $child = &$document->params[0]->param[$i]->addChild('option', array('value' => ''));
+ $child->setData('Use Global');
+ }
+ }
+ // Now remove any hidden elements
+ for ($i = 0, $n = count( $hide ); $i < $n; $i++) {
+ $document->params[0]->removeChild( $hide[$i] );
+ }
+ }
+ $params->setXML( $document->params[0] );
+ }
+ }
+ }
+ return $params;
+ }
+
+ function &getSystemParams()
+ {
+ // Initialize variables
+ $params = null;
+ $item = &$this->getItem();
+
+ $params = new JParameter( $item->params );
+ if ($item->type == 'component') {
+ $path = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'component.xml';
+ if (file_exists( $path )) {
+ $xml =& JFactory::getXMLParser('Simple');
+ if ($xml->loadFile($path)) {
+ $document =& $xml->document;
+ $params->setXML($document->getElementByPath('state/params'));
+ }
+ }
+ }
+ return $params;
+ }
+
+ /**
+ * Get the name of the current menu item
+ *
+ * @return string
+ * @access public
+ * @since 1.5
+ */
+ function getStateName()
+ {
+ $state =& $this->_getStateXML();
+
+ if ( ! is_a($state, 'JSimpleXMLElement'))
+ {
+ return null;
+ }
+
+ $name = null;
+ $sn =& $state->getElementByPath('name');
+ if ($sn) {
+ $name = $sn->data();
+ }
+
+ return JText::_($name);
+ }
+
+ /**
+ * Get the description of the current menu item
+ *
+ * @return string
+ * @access public
+ * @since 1.5
+ */
+ function getStateDescription()
+ {
+ $state =& $this->_getStateXML();
+
+
+ if ( ! is_a($state, 'JSimpleXMLElement'))
+ {
+ return null;
+ }
+
+ $description = null;
+ $sd =& $state->getElementByPath('description');
+ if ($sd) {
+ $description = $sd->data();
+ }
+
+ return JText::_($description);
+ }
+
+ /**
+ * Gets the componet table object related to this menu item
+ */
+ function &getComponent()
+ {
+ $item =& $this->getItem();
+ $id = $item->componentid;
+ $component = & JTable::getInstance( 'component');
+ $component->load( $id );
+ return $component;
+ }
+
+ function checkout($uid = null)
+ {
+ $id = JRequest::getVar('cid', array(0), '', 'array');
+ JArrayHelper::toInteger( $id, array(0) );
+
+ // Make sure we have a user id to checkout the article with
+ if (is_null($uid)) {
+ $user =& JFactory::getUser();
+ $uid = $user->get('id');
+ }
+
+ // Lets get to it and checkout the thing...
+ $item =& $this->getItem();
+ if(!$item->checkout($uid, $id[0])) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ return true;
+ }
+
+ function checkin()
+ {
+ if ($this->_id) {
+ $item =& $this->_getTable();
+
+ if(!$item->checkin($this->_id)) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ function store()
+ {
+ // Initialize variables
+ $db =& JFactory::getDBO();
+ $row =& $this->getItem();
+ $post = $this->_state->get( 'request' );
+
+ switch ($post['type'])
+ {
+ case 'separator':
+ break;
+ case 'url':
+ break;
+ case 'menulink':
+ $post['link'] = 'index.php?Itemid='.$post['params']['menu_item'];
+ break;
+ case 'component':
+ break;
+ }
+ if (!$row->bind( $post )) {
+ echo "\n";
+ return false;
+ }
+
+ if ($row->id > 0)
+ {
+ // existing item
+ $query = 'SELECT menutype FROM #__menu WHERE id = '.(int) $row->id;
+ $this->_db->setQuery( $query );
+ $oldType = $this->_db->loadResult();
+ if ($oldType != $row->menutype) {
+ // moved to another menu, disconnect the old parent
+ $row->parent = 0;
+ }
+ $query = 'SELECT parent FROM #__menu WHERE id = '.(int) $row->id;
+ $this->_db->setQuery( $query );
+ $oldParent = $this->_db->loadResult();
+ if ($oldParent != $row->parent) {
+ // we have changed parents, so we have to fix the submenu values
+ if ($row->parent != 0) {
+ $query = 'SELECT sublevel FROM #__menu WHERE id = '.(int) $row->parent;
+ $this->_db->setQuery( $query );
+ $sublevel = $this->_db->loadResult() + 1;
+ } else {
+ $sublevel = 0;
+ }
+ $row->sublevel = $sublevel;
+ $this->_setSubLevel( array( (int) $row->id ), $sublevel );
+ }
+ }
+ else
+ {
+ // if new item order last in appropriate group
+ $where = "menutype = " . $db->Quote($row->menutype) . " AND published >= 0 AND parent = ".(int) $row->parent;
+ $row->ordering = $row->getNextOrder( $where );
+
+ if( $row->parent != 0 ) {
+ $query = 'SELECT sublevel FROM #__menu WHERE id = '. (int) $row->parent;
+ $this->_db->setQuery($query);
+ $row->sublevel = $this->_db->loadResult() + 1;
+ }
+ }
+
+ if (isset($post['urlparams']) && is_array($post['urlparams']))
+ {
+ $pos = strpos( $row->link, '?' );
+ if ($pos !== false)
+ {
+ $prefix = substr( $row->link, 0, $pos );
+ $query = substr( $row->link, $pos+1 );
+
+ $temp = array();
+ if(strpos($query, '&') !== false) {
+ $query = str_replace('&', '&', $query);
+ }
+ parse_str( $query, $temp );
+ $temp2 = array_merge( $temp, $post['urlparams'] );
+
+ $temp3 = array();
+ foreach ($temp2 as $k => $v)
+ {
+ if ( $k && strlen($v) )
+ {
+ $temp3[] = $k.'='.$v;
+ }
+ }
+ $url = null;
+ $row->link = $prefix . '?' . implode( '&', $temp3 );
+ }
+ }
+
+ if (!$row->check())
+ {
+ echo "\n";
+ return false;
+ }
+
+ if (!$row->store())
+ {
+ echo "\n";
+ return false;
+ }
+
+ $row->checkin();
+ $row->reorder( 'menutype='.$db->Quote( $row->menutype ).' AND parent='.(int)$row->parent );
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+
+
+ /**
+ * Delete one or more menu items
+ * @param mixed int or array of id values
+ */
+ function delete( $ids )
+ {
+ JArrayHelper::toInteger($ids);
+
+ $db = &$this->getDBO();
+
+ if (count( $ids ))
+ {
+ // Delete associated module and template mappings
+ $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids );
+
+ $query = 'DELETE FROM #__modules_menu '
+ . $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $menuTable->getErrorMsg() );
+ return false;
+ }
+
+ $query = 'DELETE FROM #__templates_menu '
+ . $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $menuTable->getErrorMsg() );
+ return false;
+ }
+
+ // Set any alias menu types to not point to missing menu items
+ $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')';
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+
+ // Delete the menu items
+ $where = 'WHERE id = ' . implode( ' OR id = ', $ids );
+
+ $query = 'DELETE FROM #__menu ' . $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Delete menu items by type
+ */
+ function deleteByType( $type = '' )
+ {
+ $db = &$this->getDBO();
+
+ $query = 'SELECT id' .
+ ' FROM #__menu' .
+ ' WHERE menutype = ' . $db->Quote( $type );
+ $db->setQuery( $query );
+ $ids = $db->loadResultArray();
+
+ if ($db->getErrorNum())
+ {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+
+ return $this->delete( $ids );
+ }
+
+ /**
+ * Returns the internal table object
+ * @return JTable
+ */
+ function &_getTable()
+ {
+ if ($this->_table == null) {
+ $this->_table =& JTable::getInstance( 'menu');
+ }
+ return $this->_table;
+ }
+
+ function &_getStateXML()
+ {
+ static $xml;
+
+ if (isset($xml)) {
+ return $xml;
+ }
+ $xml = null;
+ $xmlpath = null;
+ $item = &$this->getItem();
+
+ switch ($item->type)
+ {
+ case 'separator':
+ $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'separator.xml';
+ break;
+ case 'url':
+ $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'url.xml';
+ break;
+ case 'menulink':
+ $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'menulink.xml';
+ break;
+ case 'component':
+ default:
+ if (isset($item->linkparts['view']))
+ {
+ // View is set... so we konw to look in view file
+ if (isset($item->linkparts['layout'])) {
+ $layout = $item->linkparts['layout'];
+ } else {
+ $layout = 'default';
+ }
+ $lpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'tmpl'.DS.$layout.'.xml';
+ $vpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'metadata.xml';
+ if (file_exists($lpath)) {
+ $xmlpath = $lpath;
+ } elseif (file_exists($vpath)) {
+ $xmlpath = $vpath;
+ }
+ }
+ if (!$xmlpath && isset($item->linkparts['option'])) {
+ $xmlpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'metadata.xml';
+ if(!file_exists($xmlpath)) {
+ $xmlpath = JApplicationHelper::getPath('com_xml', $item->linkparts['option']);
+ }
+ }
+ break;
+ }
+
+ if (file_exists($xmlpath))
+ {
+ $xml =& JFactory::getXMLParser('Simple');
+ if ($xml->loadFile($xmlpath)) {
+ $this->_xml = &$xml;
+ $document =& $xml->document;
+
+ /*
+ * HANDLE NO OPTION CASE
+ */
+ $menus =& $document->getElementByPath('menu');
+ if (is_a($menus, 'JSimpleXMLElement') && $menus->attributes('options') == 'none') {
+ $xml =& $menus->getElementByPath('state');
+ } else {
+ $xml =& $document->getElementByPath('state');
+ }
+
+ // Handle error case... path doesn't exist
+ if (!is_a($xml, 'JSimpleXMLElement')) {
+ return $document;
+ }
+
+ /*
+ * HANDLE A SWITCH IF IT EXISTS
+ */
+ if ($switch = $xml->attributes('switch'))
+ {
+ $default = $xml->attributes('default');
+ // Handle switch
+ $switchVal = (isset($item->linkparts[$switch]))? $item->linkparts[$switch] : 'default';
+ $found = false;
+
+ foreach ($xml->children() as $child) {
+ if ($child->name() == $switchVal) {
+ $xml =& $child;
+ $found = true;
+ break;
+ }
+ }
+
+ if (!$found) {
+ foreach ($xml->children() as $child) {
+ if ($child->name() == $default) {
+ $xml =& $child;
+ break;
+ }
+ }
+ }
+ }
+
+ /*
+ * HANDLE INCLUDED PARAMS
+ */
+ $children = $xml->children();
+ if (count($children) == 1)
+ {
+ if ($children[0]->name() == 'include') {
+ $ret =& $this->_getIncludedParams($children[0]);
+ if ($ret) {
+ $xml =& $ret;
+ }
+ }
+ }
+
+ if ($switch = $xml->attributes('switch'))
+ {
+ $default = $xml->attributes('default');
+ // Handle switch
+ $switchVal = ($item->linkparts[$switch])? $item->linkparts[$switch] : 'default';
+ $found = false;
+
+ foreach ($xml->children() as $child) {
+ if ($child->name() == $switchVal) {
+ $xml =& $child;
+ $found = true;
+ break;
+ }
+ }
+
+ if (!$found) {
+ foreach ($xml->children() as $child) {
+ if ($child->name() == $default) {
+ $xml =& $child;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $xml;
+ }
+
+ function &_getIncludedParams($include)
+ {
+ $tags = array();
+ $state = null;
+ $source = $include->attributes('source');
+ $path = $include->attributes('path');
+ $item = &$this->getItem();
+
+ preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags);
+ if (isset($tags[1])) {
+ for ($i=0;$ilinkparts[$tags[1][$i]], $source);
+ }
+ }
+
+ // load the source xml file
+ if (file_exists( JPATH_ROOT.$source ))
+ {
+ $xml = & JFactory::getXMLParser('Simple');
+
+ if ($xml->loadFile(JPATH_ROOT.$source)) {
+ $document = &$xml->document;
+ $state = $document->getElementByPath($path);
+ }
+ }
+ return $state;
+ }
+
+ /**
+ * Sets the sublevel for menu items
+ *
+ * @param array id values to set
+ * @param int level to assign to the sublevel
+ */
+ function _setSubLevel( $cid, $level )
+ {
+ JArrayHelper::toInteger($cid, array(0));
+
+ $ids = implode( ',', $cid );
+
+ $query = 'UPDATE #__menu SET sublevel = '.(int) $level
+ .' WHERE id IN ('.$ids.')';
+ $this->_db->setQuery( $query );
+ $this->_db->query();
+
+ $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')';
+ $this->_db->setQuery( $query );
+ $cids = $this->_db->loadResultArray( 0 );
+
+ if (!empty( $cids )) {
+ $this->_setSubLevel( $cids, $level + 1 );
+ }
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/list.php b/oss/joomla/trunk/administrator/components/com_menus/models/list.php
index 25d842f7..4702f1b9 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/models/list.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/models/list.php
@@ -1,749 +1,752 @@
-_table == null)
- {
- $this->_table =& JTable::getInstance( 'menu');
- }
- return $this->_table;
- }
-
- function &getItems()
- {
- global $mainframe;
-
- static $items;
-
- if (isset($items)) {
- return $items;
- }
-
- $db =& $this->getDBO();
-
- $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' );
- $filter_order = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order', 'filter_order', 'm.ordering', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word' );
- $filter_state = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_state', 'filter_state', '', 'word' );
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg( 'list_limit' ), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.limitstart', 'limitstart', 0, 'int' );
- $levellimit = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.levellimit', 'levellimit', 10, 'int' );
- $search = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.search', 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $and = '';
- if ( $filter_state )
- {
- if ( $filter_state == 'P' ) {
- $and = ' AND m.published = 1';
- } else if ($filter_state == 'U' ) {
- $and = ' AND m.published = 0';
- }
- }
-
- // just in case filter_order get's messed up
- if ($filter_order) {
- $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', m.parent, m.ordering';
- } else {
- $orderby = ' ORDER BY m.parent, m.ordering';
- }
-
- // select the records
- // note, since this is a tree we have to do the limits code-side
- if ($search) {
- $query = 'SELECT m.id' .
- ' FROM #__menu AS m' .
- ' WHERE menutype = '.$db->Quote($menutype) .
- ' AND LOWER( m.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) .
- $and;
- $db->setQuery( $query );
- $search_rows = $db->loadResultArray();
- }
-
- $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name' .
- ' FROM #__menu AS m' .
- ' LEFT JOIN #__users AS u ON u.id = m.checked_out' .
- ' LEFT JOIN #__groups AS g ON g.id = m.access' .
- ' LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type = "content_typed"' .
- ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "component"' .
- ' WHERE m.menutype = '.$db->Quote($menutype) .
- ' AND m.published != -2' .
- $and .
- $orderby;
- $db->setQuery( $query );
- $rows = $db->loadObjectList();
-
- // establish the hierarchy of the menu
- $children = array();
- // first pass - collect children
- foreach ($rows as $v )
- {
- $pt = $v->parent;
- $list = @$children[$pt] ? $children[$pt] : array();
- array_push( $list, $v );
- $children[$pt] = $list;
- }
- // second pass - get an indent list of the items
- $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, max( 0, $levellimit-1 ) );
- // eventually only pick out the searched items.
- if ($search) {
- $list1 = array();
-
- foreach ($search_rows as $sid )
- {
- foreach ($list as $item)
- {
- if ($item->id == $sid) {
- $list1[] = $item;
- }
- }
- }
- // replace full list with found items
- $list = $list1;
- }
-
- $total = count( $list );
-
- jimport('joomla.html.pagination');
- $this->_pagination = new JPagination( $total, $limitstart, $limit );
-
- // slice out elements based on limits
- $list = array_slice( $list, $this->_pagination->limitstart, $this->_pagination->limit );
-
- $i = 0;
- $query = array();
- foreach ( $list as $mitem )
- {
- $edit = '';
- switch ( $mitem->type )
- {
- case 'separator':
- $list[$i]->descrip = JText::_('Separator');
- break;
-
- case 'url':
- $list[$i]->descrip = JText::_('URL');
- break;
-
- case 'menulink':
- $list[$i]->descrip = JText::_('Menu Link');
- break;
-
- case 'component':
- $list[$i]->descrip = JText::_('Component');
- $query = parse_url($list[$i]->link);
- $view = array();
- if(isset($query['query'])) {
- if(strpos($query['query'], '&') !== false)
- {
- $query['query'] = str_replace('&','&',$query['query']);
- }
- parse_str($query['query'], $view);
- }
- $list[$i]->view = $list[$i]->com_name;
- if (isset($view['view']))
- {
- $list[$i]->view .= ' » '.JText::_(ucfirst($view['view']));
- }
- if (isset($view['layout']))
- {
- $list[$i]->view .= ' / '.JText::_(ucfirst($view['layout']));
- }
- if (isset($view['task']) && !isset($view['view']))
- {
- $list[$i]->view .= ' :: '.JText::_(ucfirst($view['task']));
- }
- break;
-
- default:
- $list[$i]->descrip = JText::_('Unknown');
- break;
- }
- $i++;
- }
-
- $items = $list;
- return $items;
- }
-
- function &getPagination()
- {
- if ($this->_pagination == null) {
- $this->getItems();
- }
- return $this->_pagination;
- }
-
- /**
- * Form for copying item(s) to a specific menu
- */
- function getItemsFromRequest()
- {
- static $items;
-
- if (isset($items)) {
- return $items;
- }
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (count($cid) < 1) {
- $this->setError(JText::_( 'Select an item to move'));
- return false;
- }
-
- // Query to list the selected menu items
- $db =& $this->getDBO();
- $cids = implode( ',', $cid );
- $query = 'SELECT `id`, `name`' .
- ' FROM `#__menu`' .
- ' WHERE `id` IN ( '.$cids.' )';
-
- $db->setQuery( $query );
- $items = $db->loadObjectList();
-
- return $items;
- }
-
- /**
- * Gets the componet table object related to this menu item
- */
- function &getComponent()
- {
- $id = $this->_table->componentid;
- $component = & JTable::getInstance( 'component');
- $component->load( $id );
- return $component;
- }
-
- /**
- * Save the item(s) to the menu selected
- */
- function copy( $items, $menu )
- {
- $curr =& JTable::getInstance('menu');
- $itemref = array();
- foreach ($items as $id)
- {
- $curr->load( $id );
- $curr->id = NULL;
- $curr->home = 0;
- if ( !$curr->store() ) {
- $this->setError($curr->getError());
- return false;
- }
- $itemref[] = array($id, $curr->id);
- }
- foreach ($itemref as $ref)
- {
- $curr->load( $ref[1] );
- if ($curr->parent!=0) {
- $found = false;
- foreach ( $itemref as $ref2 )
- {
- if ($curr->parent == $ref2[0]) {
- $curr->parent = $ref2[1];
- $found = true;
- break;
- } // if
- }
- if (!$found && $curr->menutype!=$menu) {
- $curr->parent = 0;
- }
- }
- $curr->menutype = $menu;
- $curr->ordering = '9999';
- $curr->home = 0;
- if ( !$curr->store() ) {
- $this->setError($curr->getError());
- return false;
- }
- $curr->reorder( 'menutype = '.$this->_db->Quote($curr->menutype).' AND parent = '.(int) $curr->parent );
- } // foreach
-
- //Now, we need to rebuild sublevels...
- $this->_rebuildSubLevel();
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- function move($items, $menu)
- {
- // Add all children to the list
- foreach ($items as $id)
- {
- $this->_addChildren($id, $items);
- }
-
- $row =& $this->getTable();
- $ordering = 1000000;
- $firstroot = 0;
- foreach ($items as $id) {
- $row->load( $id );
-
- // is it moved together with his parent?
- $found = false;
- if ($row->parent != 0) {
- foreach ($items as $idx)
- {
- if ($idx == $row->parent) {
- $found = true;
- break;
- } // if
- }
- }
- if (!$found) {
- $row->parent = 0;
- $row->ordering = $ordering++;
- if (!$firstroot) $firstroot = $row->id;
- } // if
-
- $row->menutype = $menu;
- if ( !$row->store() ) {
- $this->setError($row->getError());
- return false;
- } // if
- } // foreach
-
- if ($firstroot) {
- $row->load( $firstroot );
- $row->reorder( 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent );
- } // if
-
- //Rebuild sublevel
- $this->_rebuildSubLevel();
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- function toTrash($items)
- {
- $db =& $this->getDBO();
- $nd = $db->getNullDate();
- $state = -2;
- $row =& $this->getTable();
- $default = 0;
-
- // Add all children to the list
- foreach ($items as $id)
- {
- //Check if it's the default item
- $row->load( $id );
- if ($row->home != 1) {
- $this->_addChildren($id, $items);
- } else {
- unset($items[$default]);
- JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot trash the default menu item'));
- }
- $default++;
- }
- if (!empty($items)) {
- // Sent menu items to the trash
- JArrayHelper::toInteger($items, array(0));
- $where = ' WHERE (id = ' . implode( ' OR id = ', $items ) . ') AND home = 0';
- $query = 'UPDATE #__menu' .
- ' SET published = '.(int) $state.', parent = 0, ordering = 0, checked_out = 0, checked_out_time = '.$db->Quote($nd) .
- $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return count($items);
- }
-
- function fromTrash($items)
- {
- $db =& $this->getDBO();
- $nd = $db->getNullDate();
- $state = 0;
-
- // Add all children to the list
- foreach ($items as $id)
- {
- $this->_addChildren($id, $items);
- }
-
- // Sent menu items to the trash
- JArrayHelper::toInteger($items, array(0));
- $where = ' WHERE id = ' . implode( ' OR id = ', $items );
- $query = 'UPDATE #__menu' .
- ' SET published = '.(int) $state.', parent = 0, ordering = 99999, checked_out = 0, checked_out_time = '.$db->Quote($nd) .
- $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
-
- // clean cache (require helper because method can be called from com_trash)
- require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' );
- MenusHelper::cleanCache();
-
- return count($items);
- }
-
- /**
- * Set the state of selected menu items
- */
- function setHome( $item )
- {
- $db =& $this->getDBO();
-
- // Clear home field for all other items
- $query = 'UPDATE #__menu' .
- ' SET home = 0' .
- ' WHERE 1';
- $db->setQuery( $query );
- if ( !$db->query() ) {
- $this->setError($db->getErrorMsg());
- return false;
- }
-
- // Set the given item to home
- $query = 'UPDATE #__menu' .
- ' SET home = 1' .
- ' WHERE id = '.(int) $item;
- $db->setQuery( $query );
- if ( !$db->query() ) {
- $this->setError($db->getErrorMsg());
- return false;
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- /**
- * Set the state of selected menu items
- */
- function setItemState( $items, $state )
- {
- if(is_array($items))
- {
- $row =& $this->getTable();
- foreach ($items as $id)
- {
- $row->load( $id );
-
- if ($row->home != 1) {
- $row->published = $state;
-
- if ($state != 1) {
- // Set any alias menu types to not point to unpublished menu items
- $db = &$this->getDBO();
- $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND link = '.(int)$id;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
- }
-
- if (!$row->check()) {
- $this->setError($row->getError());
- return false;
- }
- if (!$row->store()) {
- $this->setError($row->getError());
- return false;
- }
- } else {
- JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot unpublish the default menu item'));
- return false;
- }
- }
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- /**
- * Set the access of selected menu items
- */
- function setAccess( $items, $access )
- {
- $row =& $this->getTable();
- foreach ($items as $id)
- {
- $row->load( $id );
- $row->access = $access;
-
- // Set any alias menu types to not point to unpublished menu items
- $db = &$this->getDBO();
- $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND access < '.(int)$access.' AND link = '.(int)$id;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
-
- if (!$row->check()) {
- $this->setError($row->getError());
- return false;
- }
- if (!$row->store()) {
- $this->setError($row->getError());
- return false;
- }
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- function orderItem($item, $movement)
- {
- $row =& $this->getTable();
- $row->load( $item );
- if (!$row->move( $movement, 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent )) {
- $this->setError($row->getError());
- return false;
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- function setOrder($items, $menutype)
- {
- $total = count( $items );
- $row =& $this->getTable();
- $groupings = array();
-
- $order = JRequest::getVar( 'order', array(), 'post', 'array' );
- JArrayHelper::toInteger($order);
-
- // update ordering values
- for( $i=0; $i < $total; $i++ ) {
- $row->load( $items[$i] );
- // track parents
- $groupings[] = $row->parent;
- if ($row->ordering != $order[$i]) {
- $row->ordering = $order[$i];
- if (!$row->store()) {
- $this->setError($row->getError());
- return false;
- }
- } // if
- } // for
-
- // execute updateOrder for each parent group
- $groupings = array_unique( $groupings );
- foreach ($groupings as $group){
- $row->reorder('menutype = '.$this->_db->Quote($menutype).' AND parent = '.(int) $group.' AND published >=0');
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- /**
- * Delete one or more menu items
- * @param mixed int or array of id values
- */
- function delete( $ids )
- {
- JArrayHelper::toInteger($ids);
-
- if (!empty( $ids )) {
-
- // Add all children to the list
- foreach ($ids as $id)
- {
- $this->_addChildren($id, $ids);
- }
-
- $db = &$this->getDBO();
-
- // Delete associated module and template mappings
- $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids );
-
- $query = 'DELETE FROM #__modules_menu '
- . $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $menuTable->getErrorMsg() );
- return false;
- }
-
- $query = 'DELETE FROM #__templates_menu '
- . $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $menuTable->getErrorMsg() );
- return false;
- }
-
- // Set any alias menu types to not point to missing menu items
- $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')';
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
-
- // Delete the menu items
- $where = 'WHERE id = ' . implode( ' OR id = ', $ids );
-
- $query = 'DELETE FROM #__menu ' . $where;
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-
- /**
- * Delete menu items by type
- */
- function deleteByType( $type = '' )
- {
- $db = &$this->getDBO();
-
- $query = 'SELECT id' .
- ' FROM #__menu' .
- ' WHERE menutype = ' . $db->Quote( $type );
- $db->setQuery( $query );
- $ids = $db->loadResultArray();
-
- if ($db->getErrorNum()) {
- $this->setError( $db->getErrorMsg() );
- return false;
- }
-
- return $this->delete( $ids );
- }
-
- function _addChildren($id, &$list)
- {
- // Initialize variables
- $return = true;
-
- // Get all rows with parent of $id
- $db =& $this->getDBO();
- $query = 'SELECT id' .
- ' FROM #__menu' .
- ' WHERE parent = '.(int) $id;
- $db->setQuery( $query );
- $rows = $db->loadObjectList();
-
- // Make sure there aren't any errors
- if ($db->getErrorNum()) {
- $this->setError($db->getErrorMsg());
- return false;
- }
-
- // Recursively iterate through all children... kinda messy
- // TODO: Cleanup this method
- foreach ($rows as $row)
- {
- $found = false;
- foreach ($list as $idx)
- {
- if ($idx == $row->id) {
- $found = true;
- break;
- }
- }
- if (!$found) {
- $list[] = $row->id;
- }
- $return = $this->_addChildren($row->id, $list);
- }
- return $return;
- }
-
- /*
- * Rebuild the sublevel field for items in the menu (if called with 2nd param = 0 or no params, it will rebuild entire menu tree's sublevel
- * @param array of menu item ids to change level to
- * @param int level to set the menu items to (based on parent
- */
- function _rebuildSubLevel($cid = array(0), $level = 0)
- {
- JArrayHelper::toInteger($cid, array(0));
- $db =& $this->getDBO();
- $ids = implode( ',', $cid );
- $cids = array();
- if($level == 0) {
- $query = 'UPDATE #__menu SET sublevel = 0 WHERE parent = 0';
- $db->setQuery($query);
- $db->query();
- $query = 'SELECT id FROM #__menu WHERE parent = 0';
- $db->setQuery($query);
- $cids = $db->loadResultArray(0);
- } else {
- $query = 'UPDATE #__menu SET sublevel = '.(int) $level
- .' WHERE parent IN ('.$ids.')';
- $db->setQuery( $query );
- $db->query();
- $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')';
- $db->setQuery( $query );
- $cids = $db->loadResultArray( 0 );
- }
- if (!empty( $cids )) {
- $this->_rebuildSubLevel( $cids, $level + 1 );
- }
- }
-}
+_table == null)
+ {
+ $this->_table =& JTable::getInstance( 'menu');
+ }
+ return $this->_table;
+ }
+
+ function &getItems()
+ {
+ global $mainframe;
+
+ static $items;
+
+ if (isset($items)) {
+ return $items;
+ }
+
+ $db =& $this->getDBO();
+
+ $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' );
+ $filter_order = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order', 'filter_order', 'm.ordering', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word' );
+ $filter_state = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_state', 'filter_state', '', 'word' );
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg( 'list_limit' ), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.limitstart', 'limitstart', 0, 'int' );
+ $levellimit = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.levellimit', 'levellimit', 10, 'int' );
+ $search = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.search', 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $and = '';
+ if ( $filter_state )
+ {
+ if ( $filter_state == 'P' ) {
+ $and = ' AND m.published = 1';
+ } else if ($filter_state == 'U' ) {
+ $and = ' AND m.published = 0';
+ }
+ }
+
+ // just in case filter_order get's messed up
+ if ($filter_order) {
+ $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', m.parent, m.ordering';
+ } else {
+ $orderby = ' ORDER BY m.parent, m.ordering';
+ }
+
+ // select the records
+ // note, since this is a tree we have to do the limits code-side
+ if ($search) {
+ $query = 'SELECT m.id' .
+ ' FROM #__menu AS m' .
+ ' WHERE menutype = '.$db->Quote($menutype) .
+ ' AND LOWER( m.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) .
+ $and;
+ $db->setQuery( $query );
+ $search_rows = $db->loadResultArray();
+ }
+
+ $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name' .
+ ' FROM #__menu AS m' .
+ ' LEFT JOIN #__users AS u ON u.id = m.checked_out' .
+ ' LEFT JOIN #__groups AS g ON g.id = m.access' .
+ ' LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type = "content_typed"' .
+ ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "component"' .
+ ' WHERE m.menutype = '.$db->Quote($menutype) .
+ ' AND m.published != -2' .
+ $and .
+ $orderby;
+ $db->setQuery( $query );
+ $rows = $db->loadObjectList();
+
+ // establish the hierarchy of the menu
+ $children = array();
+ // first pass - collect children
+ foreach ($rows as $v )
+ {
+ $pt = $v->parent;
+ $list = @$children[$pt] ? $children[$pt] : array();
+ array_push( $list, $v );
+ $children[$pt] = $list;
+ }
+ // second pass - get an indent list of the items
+ $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, max( 0, $levellimit-1 ) );
+ // eventually only pick out the searched items.
+ if ($search) {
+ $list1 = array();
+
+ foreach ($search_rows as $sid )
+ {
+ foreach ($list as $item)
+ {
+ if ($item->id == $sid) {
+ $list1[] = $item;
+ }
+ }
+ }
+ // replace full list with found items
+ $list = $list1;
+ }
+
+ $total = count( $list );
+
+ jimport('joomla.html.pagination');
+ $this->_pagination = new JPagination( $total, $limitstart, $limit );
+
+ // slice out elements based on limits
+ $list = array_slice( $list, $this->_pagination->limitstart, $this->_pagination->limit );
+
+ $i = 0;
+ $query = array();
+ foreach ( $list as $mitem )
+ {
+ $edit = '';
+ switch ( $mitem->type )
+ {
+ case 'separator':
+ $list[$i]->descrip = JText::_('Separator');
+ break;
+
+ case 'url':
+ $list[$i]->descrip = JText::_('URL');
+ break;
+
+ case 'menulink':
+ $list[$i]->descrip = JText::_('Menu Link');
+ break;
+
+ case 'component':
+ $list[$i]->descrip = JText::_('Component');
+ $query = parse_url($list[$i]->link);
+ $view = array();
+ if(isset($query['query'])) {
+ if(strpos($query['query'], '&') !== false)
+ {
+ $query['query'] = str_replace('&','&',$query['query']);
+ }
+ parse_str($query['query'], $view);
+ }
+ $list[$i]->view = JText::_($list[$i]->com_name);
+ if (isset($view['view']))
+ {
+ $list[$i]->view .= ' » '.JText::_(ucfirst($view['view']));
+ }
+ if (isset($view['layout']))
+ {
+ $list[$i]->view .= ' / '.JText::_(ucfirst($view['layout']));
+ }
+ if (isset($view['task']) && !isset($view['view']))
+ {
+ $list[$i]->view .= ' :: '.JText::_(ucfirst($view['task']));
+ }
+ break;
+
+ default:
+ $list[$i]->descrip = JText::_('Unknown');
+ break;
+ }
+ $i++;
+ }
+
+ $items = $list;
+ return $items;
+ }
+
+ function &getPagination()
+ {
+ if ($this->_pagination == null) {
+ $this->getItems();
+ }
+ return $this->_pagination;
+ }
+
+ /**
+ * Form for copying item(s) to a specific menu
+ */
+ function getItemsFromRequest()
+ {
+ static $items;
+
+ if (isset($items)) {
+ return $items;
+ }
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (count($cid) < 1) {
+ $this->setError(JText::_( 'Select an item to move'));
+ return false;
+ }
+
+ // Query to list the selected menu items
+ $db =& $this->getDBO();
+ $cids = implode( ',', $cid );
+ $query = 'SELECT `id`, `name`' .
+ ' FROM `#__menu`' .
+ ' WHERE `id` IN ( '.$cids.' )';
+
+ $db->setQuery( $query );
+ $items = $db->loadObjectList();
+
+ return $items;
+ }
+
+ /**
+ * Gets the componet table object related to this menu item
+ */
+ function &getComponent()
+ {
+ $id = $this->_table->componentid;
+ $component = & JTable::getInstance( 'component');
+ $component->load( $id );
+ return $component;
+ }
+
+ /**
+ * Save the item(s) to the menu selected
+ */
+ function copy( $items, $menu )
+ {
+ $curr =& JTable::getInstance('menu');
+ $itemref = array();
+ foreach ($items as $id)
+ {
+ $curr->load( $id );
+ $curr->id = NULL;
+ $curr->home = 0;
+ if ( !$curr->store() ) {
+ $this->setError($curr->getError());
+ return false;
+ }
+ $itemref[] = array($id, $curr->id);
+ }
+ foreach ($itemref as $ref)
+ {
+ $curr->load( $ref[1] );
+ if ($curr->parent!=0) {
+ $found = false;
+ foreach ( $itemref as $ref2 )
+ {
+ if ($curr->parent == $ref2[0]) {
+ $curr->parent = $ref2[1];
+ $found = true;
+ break;
+ } // if
+ }
+ if (!$found && $curr->menutype!=$menu) {
+ $curr->parent = 0;
+ }
+ }
+ $curr->menutype = $menu;
+ $curr->ordering = '9999';
+ $curr->home = 0;
+ if ( !$curr->store() ) {
+ $this->setError($curr->getError());
+ return false;
+ }
+ $curr->reorder( 'menutype = '.$this->_db->Quote($curr->menutype).' AND parent = '.(int) $curr->parent );
+ } // foreach
+
+ //Now, we need to rebuild sublevels...
+ $this->_rebuildSubLevel();
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ function move($items, $menu)
+ {
+ // Add all children to the list
+ foreach ($items as $id)
+ {
+ $this->_addChildren($id, $items);
+ }
+
+ $row =& $this->getTable();
+ $ordering = 1000000;
+ $firstroot = 0;
+ foreach ($items as $id) {
+ $row->load( $id );
+
+ // is it moved together with his parent?
+ $found = false;
+ if ($row->parent != 0) {
+ foreach ($items as $idx)
+ {
+ if ($idx == $row->parent) {
+ $found = true;
+ break;
+ } // if
+ }
+ }
+ if (!$found) {
+ $row->parent = 0;
+ $row->ordering = $ordering++;
+ if (!$firstroot) $firstroot = $row->id;
+ } // if
+
+ $row->menutype = $menu;
+ if ( !$row->store() ) {
+ $this->setError($row->getError());
+ return false;
+ } // if
+ } // foreach
+
+ if ($firstroot) {
+ $row->load( $firstroot );
+ $row->reorder( 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent );
+ } // if
+
+ //Rebuild sublevel
+ $this->_rebuildSubLevel();
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ function toTrash($items)
+ {
+ $db =& $this->getDBO();
+ $nd = $db->getNullDate();
+ $state = -2;
+ $row =& $this->getTable();
+ $default = 0;
+
+ // Add all children to the list
+ foreach ($items as $id)
+ {
+ //Check if it's the default item
+ $row->load( $id );
+ if ($row->home != 1) {
+ $this->_addChildren($id, $items);
+ } else {
+ unset($items[$default]);
+ JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot trash the default menu item'));
+ }
+ $default++;
+ }
+ if (!empty($items)) {
+ // Sent menu items to the trash
+ JArrayHelper::toInteger($items, array(0));
+ $where = ' WHERE (id = ' . implode( ' OR id = ', $items ) . ') AND home = 0';
+ $query = 'UPDATE #__menu' .
+ ' SET published = '.(int) $state.', parent = 0, ordering = 0, checked_out = 0, checked_out_time = '.$db->Quote($nd) .
+ $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return count($items);
+ }
+
+ function fromTrash($items)
+ {
+ $db =& $this->getDBO();
+ $nd = $db->getNullDate();
+ $state = 0;
+
+ // Add all children to the list
+ foreach ($items as $id)
+ {
+ $this->_addChildren($id, $items);
+ }
+
+ // Sent menu items to the trash
+ JArrayHelper::toInteger($items, array(0));
+ $where = ' WHERE id = ' . implode( ' OR id = ', $items );
+ $query = 'UPDATE #__menu' .
+ ' SET published = '.(int) $state.', parent = 0, ordering = 99999, checked_out = 0, checked_out_time = '.$db->Quote($nd) .
+ $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+
+ // clean cache (require helper because method can be called from com_trash)
+ require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' );
+ MenusHelper::cleanCache();
+
+ return count($items);
+ }
+
+ /**
+ * Set the state of selected menu items
+ */
+ function setHome( $item )
+ {
+ $db =& $this->getDBO();
+
+ // Clear home field for all other items
+ $query = 'UPDATE #__menu' .
+ ' SET home = 0' .
+ ' WHERE 1';
+ $db->setQuery( $query );
+ if ( !$db->query() ) {
+ $this->setError($db->getErrorMsg());
+ return false;
+ }
+
+ // Set the given item to home
+ $query = 'UPDATE #__menu' .
+ ' SET home = 1' .
+ ' WHERE id = '.(int) $item;
+ $db->setQuery( $query );
+ if ( !$db->query() ) {
+ $this->setError($db->getErrorMsg());
+ return false;
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Set the state of selected menu items
+ */
+ function setItemState( $items, $state )
+ {
+ if(is_array($items))
+ {
+ $row =& $this->getTable();
+ foreach ($items as $id)
+ {
+ $row->load( $id );
+
+ if ($row->home != 1) {
+ $row->published = $state;
+
+ if ($state != 1) {
+ // Set any alias menu types to not point to unpublished menu items
+ $db = &$this->getDBO();
+ $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND link = '.(int)$id;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+ }
+
+ if (!$row->check()) {
+ $this->setError($row->getError());
+ return false;
+ }
+ if (!$row->store()) {
+ $this->setError($row->getError());
+ return false;
+ }
+ } else {
+ JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot unpublish the default menu item'));
+ return false;
+ }
+ }
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Set the access of selected menu items
+ */
+ function setAccess( $items, $access )
+ {
+ $row =& $this->getTable();
+ foreach ($items as $id)
+ {
+ $row->load( $id );
+ $row->access = $access;
+
+ // Set any alias menu types to not point to unpublished menu items
+ $db = &$this->getDBO();
+ $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND access < '.(int)$access.' AND link = '.(int)$id;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+
+ if (!$row->check()) {
+ $this->setError($row->getError());
+ return false;
+ }
+ if (!$row->store()) {
+ $this->setError($row->getError());
+ return false;
+ }
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ function orderItem($item, $movement)
+ {
+ $row =& $this->getTable();
+ $row->load( $item );
+ if (!$row->move( $movement, 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent )) {
+ $this->setError($row->getError());
+ return false;
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ function setOrder($items, $menutype)
+ {
+ $total = count( $items );
+ $row =& $this->getTable();
+ $groupings = array();
+
+ $order = JRequest::getVar( 'order', array(), 'post', 'array' );
+ JArrayHelper::toInteger($order);
+
+ // update ordering values
+ for( $i=0; $i < $total; $i++ ) {
+ $row->load( $items[$i] );
+ // track parents
+ $groupings[] = $row->parent;
+ if ($row->ordering != $order[$i]) {
+ $row->ordering = $order[$i];
+ if (!$row->store()) {
+ $this->setError($row->getError());
+ return false;
+ }
+ } // if
+ } // for
+
+ // execute updateOrder for each parent group
+ $groupings = array_unique( $groupings );
+ foreach ($groupings as $group){
+ $row->reorder('menutype = '.$this->_db->Quote($menutype).' AND parent = '.(int) $group.' AND published >=0');
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Delete one or more menu items
+ * @param mixed int or array of id values
+ */
+ function delete( $ids )
+ {
+ JArrayHelper::toInteger($ids);
+
+ if (!empty( $ids )) {
+
+ // Add all children to the list
+ foreach ($ids as $id)
+ {
+ $this->_addChildren($id, $ids);
+ }
+
+ $db = &$this->getDBO();
+
+ // Delete associated module and template mappings
+ $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids );
+
+ $query = 'DELETE FROM #__modules_menu '
+ . $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $menuTable->getErrorMsg() );
+ return false;
+ }
+
+ $query = 'DELETE FROM #__templates_menu '
+ . $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $menuTable->getErrorMsg() );
+ return false;
+ }
+
+ // Set any alias menu types to not point to missing menu items
+ $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')';
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+
+ // Delete the menu items
+ $where = 'WHERE id = ' . implode( ' OR id = ', $ids );
+
+ $query = 'DELETE FROM #__menu ' . $where;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Delete menu items by type
+ */
+ function deleteByType( $type = '' )
+ {
+ $db = &$this->getDBO();
+
+ $query = 'SELECT id' .
+ ' FROM #__menu' .
+ ' WHERE menutype = ' . $db->Quote( $type );
+ $db->setQuery( $query );
+ $ids = $db->loadResultArray();
+
+ if ($db->getErrorNum()) {
+ $this->setError( $db->getErrorMsg() );
+ return false;
+ }
+
+ return $this->delete( $ids );
+ }
+
+ function _addChildren($id, &$list)
+ {
+ // Initialize variables
+ $return = true;
+
+ // Get all rows with parent of $id
+ $db =& $this->getDBO();
+ $query = 'SELECT id' .
+ ' FROM #__menu' .
+ ' WHERE parent = '.(int) $id;
+ $db->setQuery( $query );
+ $rows = $db->loadObjectList();
+
+ // Make sure there aren't any errors
+ if ($db->getErrorNum()) {
+ $this->setError($db->getErrorMsg());
+ return false;
+ }
+
+ // Recursively iterate through all children... kinda messy
+ // TODO: Cleanup this method
+ foreach ($rows as $row)
+ {
+ $found = false;
+ foreach ($list as $idx)
+ {
+ if ($idx == $row->id) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $list[] = $row->id;
+ }
+ $return = $this->_addChildren($row->id, $list);
+ }
+ return $return;
+ }
+
+ /*
+ * Rebuild the sublevel field for items in the menu (if called with 2nd param = 0 or no params, it will rebuild entire menu tree's sublevel
+ * @param array of menu item ids to change level to
+ * @param int level to set the menu items to (based on parent
+ */
+ function _rebuildSubLevel($cid = array(0), $level = 0)
+ {
+ JArrayHelper::toInteger($cid, array(0));
+ $db =& $this->getDBO();
+ $ids = implode( ',', $cid );
+ $cids = array();
+ if($level == 0) {
+ $query = 'UPDATE #__menu SET sublevel = 0 WHERE parent = 0';
+ $db->setQuery($query);
+ $db->query();
+ $query = 'SELECT id FROM #__menu WHERE parent = 0';
+ $db->setQuery($query);
+ $cids = $db->loadResultArray(0);
+ } else {
+ $query = 'UPDATE #__menu SET sublevel = '.(int) $level
+ .' WHERE parent IN ('.$ids.')';
+ $db->setQuery( $query );
+ $db->query();
+ $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')';
+ $db->setQuery( $query );
+ $cids = $db->loadResultArray( 0 );
+ }
+ if (!empty( $cids )) {
+ $this->_rebuildSubLevel( $cids, $level + 1 );
+ }
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php b/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php
index 89ad3aab..51f2fe87 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php
@@ -1,280 +1,280 @@
-_table == null) {
- $this->_table = & JTable::getInstance('menuTypes');
- if ($id = JRequest::getVar('id', false, '', 'int')) {
- $this->_table->load($id);
- }
- }
- return $this->_table;
- }
-
- /**
- * Get a list of the menu records associated with the type
- *
- * @param string The menu type
- * @return array An array of records as objects
- */
- function getMenus()
- {
- global $mainframe;
-
- $menus= array();
- $db = &$this->getDBO();
-
- // Preselect some aggregate data
-
- // Query to get published menu item counts
- $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' .
- ' FROM #__menu AS a' .
- ' WHERE a.published = 1' .
- ' GROUP BY a.menutype';
- $db->setQuery( $query );
- $published = $db->loadObjectList( 'menutype' );
-
- // Query to get unpublished menu item counts
- $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' .
- ' FROM #__menu AS a' .
- ' WHERE a.published = 0' .
- ' GROUP BY a.menutype';
- $db->setQuery( $query );
- $unpublished = $db->loadObjectList( 'menutype' );
-
- // Query to get trash menu item counts
- $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' .
- ' FROM #__menu AS a' .
- ' WHERE a.published = -2' .
- ' GROUP BY a.menutype';
- $db->setQuery( $query );
- $trash = $db->loadObjectList( 'menutype' );
-
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' );
-
- $query = 'SELECT a.*, SUM(b.home) AS home' .
- ' FROM #__menu_types AS a' .
- ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' .
- ' GROUP BY a.id';
- $db->setQuery( $query, $limitstart, $limit );
- $menuTypes = $db->loadObjectList();
-
- $total = count( $menuTypes );
- $i = 0;
- for ($i = 0; $i < $total; $i++) {
- $row = &$menuTypes[$i];
-
- // query to get number of modules for menutype
- $query = 'SELECT count( id )' .
- ' FROM #__modules' .
- ' WHERE module = "mod_mainmenu"' .
- ' AND params LIKE '.$db->Quote('%menutype='.$row->menutype.'%');
- $db->setQuery( $query );
- $modules = $db->loadResult();
-
- if ( !$modules ) {
- $modules = '-';
- }
- $row->modules = $modules;
- $row->published = @$published[$row->menutype]->num ? $published[$row->menutype]->num : '-' ;
- $row->unpublished = @$unpublished[$row->menutype]->num ? $unpublished[$row->menutype]->num : '-';
- $row->trash = @$trash[$row->menutype]->num ? $trash[$row->menutype]->num : '-';
- $menus[] = $row;
- }
- return $menus;
- }
-
- /**
- * Get a list of the menu records associated with the type
- *
- * @param string The menu type
- * @return array An array of records as objects
- */
- function getPagination()
- {
- global $mainframe;
-
- $menutypes = MenusHelper::getMenuTypeList();
- $total = count( $menutypes );
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' );
-
- jimport('joomla.html.pagination');
- $pagination = new JPagination( $total, $limitstart, $limit );
- return $pagination;
- }
-
- /**
- * Get a list of the menu records associated with the type
- * @param string The menu type
- * @return array An array of records as objects
- */
- function getMenuItems()
- {
- $table = & $this->getTable();
- if ($table->menutype == '') {
- $table->menutype = JRequest::getString('menutype');
- }
-
- $db = &$this->getDBO();
- $query = 'SELECT a.name, a.id' .
- ' FROM #__menu AS a' .
- ' WHERE a.menutype = ' . $db->Quote( $table->menutype ) .
- ' ORDER BY a.name';
- $db->setQuery( $query );
- $result = $db->loadObjectList();
- return $result;
- }
-
- /**
- * Get a list of the menu records associated with the type
- * @param string The menu type
- * @return array An array of records as objects
- */
- function getModules( $type='' )
- {
- if ($type == '') {
- $type = $this->_table->menutype;
- }
-
- $db = &$this->getDBO();
- $query = 'SELECT id, title, params' .
- ' FROM #__modules' .
- ' WHERE module = "mod_mainmenu"' .
- ' AND params LIKE ' . $db->Quote( '%menutype=' . $type . '%' );
- $db->setQuery( $query );
- $temp = $db->loadObjectList();
-
- $result = array();
- $n = count( $temp );
- for ($i = 0; $i < $n; $i++)
- {
- $params = new JParameter( $temp[$i]->params );
- if ($params->get( 'menutype' ) == $type) {
- $result[] = $temp[$i];
- }
- }
- return $result;
- }
-
- /**
- * Checks if the menu can be deleted
- * @param string The menu type
- * @return boolean
- */
- function canDelete( $type='' )
- {
- if ($type == '') {
- $type = $this->_table->menutype;
- }
- if ($type == 'mainmenu') {
- $this->setError( JText::_( 'WARNDELMAINMENU' ) );
- return false;
- }
- return true;
- }
-
- /**
- * Deletes menu type and associations
- * @param string The id of the menu type
- * @return boolean
- */
- function delete( $id = 0 )
- {
- $table = &$this->getTable();
- if ($id != 0) {
- $table->load( $id );
- }
-
- $db = &$this->getDBO();
-
- // Delete Associations
- if (!$this->deleteByType( $table->menutype )) {
- $this->setError( $this->getError() );
- return false;
- }
-
- // TODO: Should invoke JModuleModel::delete to delete the actual module
- $moduleTable= &JTable::getInstance( 'module');
- $items = &$this->getModules( $table->menutype );
- $modulesIds = array();
- foreach ($items as $item)
- {
- if (!$moduleTable->delete( $item->id )) {
- $this->setError( $moduleTable->getErrorMsg() );
- return false;
- }
- $modulesIds[] = (int) $item->id;
- }
-
- if (count( $modulesIds )) {
- $query = 'DELETE FROM #__modules_menu' .
- ' WHERE menuid = '.implode( ' OR moduleid = ', $modulesIds );
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $menuTable->getErrorMsg() );
- return false;
- }
- }
-
- $result = $table->delete();
-
- return $result;
- }
-
- /**
- * Delete menu items by type
- */
- function deleteByType( $type = '' )
- {
- if (!$type) {
- return false;
- }
- $db = &$this->getDBO();
- $query = 'DELETE FROM #__menu' .
- ' WHERE menutype = '.$db->Quote( $type );
- $db->setQuery( $query );
- if (!$db->query()) {
- $this->setError( $menuTable->getErrorMsg() );
- return false;
- }
-
- // clean cache
- MenusHelper::cleanCache();
-
- return true;
- }
-}
+_table == null) {
+ $this->_table = & JTable::getInstance('menuTypes');
+ if ($id = JRequest::getVar('id', false, '', 'int')) {
+ $this->_table->load($id);
+ }
+ }
+ return $this->_table;
+ }
+
+ /**
+ * Get a list of the menu records associated with the type
+ *
+ * @param string The menu type
+ * @return array An array of records as objects
+ */
+ function getMenus()
+ {
+ global $mainframe;
+
+ $menus= array();
+ $db = &$this->getDBO();
+
+ // Preselect some aggregate data
+
+ // Query to get published menu item counts
+ $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' .
+ ' FROM #__menu AS a' .
+ ' WHERE a.published = 1' .
+ ' GROUP BY a.menutype';
+ $db->setQuery( $query );
+ $published = $db->loadObjectList( 'menutype' );
+
+ // Query to get unpublished menu item counts
+ $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' .
+ ' FROM #__menu AS a' .
+ ' WHERE a.published = 0' .
+ ' GROUP BY a.menutype';
+ $db->setQuery( $query );
+ $unpublished = $db->loadObjectList( 'menutype' );
+
+ // Query to get trash menu item counts
+ $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' .
+ ' FROM #__menu AS a' .
+ ' WHERE a.published = -2' .
+ ' GROUP BY a.menutype';
+ $db->setQuery( $query );
+ $trash = $db->loadObjectList( 'menutype' );
+
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' );
+
+ $query = 'SELECT a.*, SUM(b.home) AS home' .
+ ' FROM #__menu_types AS a' .
+ ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' .
+ ' GROUP BY a.id';
+ $db->setQuery( $query, $limitstart, $limit );
+ $menuTypes = $db->loadObjectList();
+
+ $total = count( $menuTypes );
+ $i = 0;
+ for ($i = 0; $i < $total; $i++) {
+ $row = &$menuTypes[$i];
+
+ // query to get number of modules for menutype
+ $query = 'SELECT count( id )' .
+ ' FROM #__modules' .
+ ' WHERE module = "mod_mainmenu"' .
+ ' AND params LIKE '.$db->Quote('%menutype='.$row->menutype.'%');
+ $db->setQuery( $query );
+ $modules = $db->loadResult();
+
+ if ( !$modules ) {
+ $modules = '-';
+ }
+ $row->modules = $modules;
+ $row->published = @$published[$row->menutype]->num ? $published[$row->menutype]->num : '-' ;
+ $row->unpublished = @$unpublished[$row->menutype]->num ? $unpublished[$row->menutype]->num : '-';
+ $row->trash = @$trash[$row->menutype]->num ? $trash[$row->menutype]->num : '-';
+ $menus[] = $row;
+ }
+ return $menus;
+ }
+
+ /**
+ * Get a list of the menu records associated with the type
+ *
+ * @param string The menu type
+ * @return array An array of records as objects
+ */
+ function getPagination()
+ {
+ global $mainframe;
+
+ $menutypes = MenusHelper::getMenuTypeList();
+ $total = count( $menutypes );
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' );
+
+ jimport('joomla.html.pagination');
+ $pagination = new JPagination( $total, $limitstart, $limit );
+ return $pagination;
+ }
+
+ /**
+ * Get a list of the menu records associated with the type
+ * @param string The menu type
+ * @return array An array of records as objects
+ */
+ function getMenuItems()
+ {
+ $table = & $this->getTable();
+ if ($table->menutype == '') {
+ $table->menutype = JRequest::getString('menutype');
+ }
+
+ $db = &$this->getDBO();
+ $query = 'SELECT a.name, a.id' .
+ ' FROM #__menu AS a' .
+ ' WHERE a.menutype = ' . $db->Quote( $table->menutype ) .
+ ' ORDER BY a.name';
+ $db->setQuery( $query );
+ $result = $db->loadObjectList();
+ return $result;
+ }
+
+ /**
+ * Get a list of the menu records associated with the type
+ * @param string The menu type
+ * @return array An array of records as objects
+ */
+ function getModules( $type='' )
+ {
+ if ($type == '') {
+ $type = $this->_table->menutype;
+ }
+
+ $db = &$this->getDBO();
+ $query = 'SELECT id, title, params' .
+ ' FROM #__modules' .
+ ' WHERE module = "mod_mainmenu"' .
+ ' AND params LIKE ' . $db->Quote( '%menutype=' . $type . '%' );
+ $db->setQuery( $query );
+ $temp = $db->loadObjectList();
+
+ $result = array();
+ $n = count( $temp );
+ for ($i = 0; $i < $n; $i++)
+ {
+ $params = new JParameter( $temp[$i]->params );
+ if ($params->get( 'menutype' ) == $type) {
+ $result[] = $temp[$i];
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Checks if the menu can be deleted
+ * @param string The menu type
+ * @return boolean
+ */
+ function canDelete( $type='' )
+ {
+ if ($type == '') {
+ $type = $this->_table->menutype;
+ }
+ if ($type == 'mainmenu') {
+ $this->setError( JText::_( 'WARNDELMAINMENU' ) );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Deletes menu type and associations
+ * @param string The id of the menu type
+ * @return boolean
+ */
+ function delete( $id = 0 )
+ {
+ $table = &$this->getTable();
+ if ($id != 0) {
+ $table->load( $id );
+ }
+
+ $db = &$this->getDBO();
+
+ // Delete Associations
+ if (!$this->deleteByType( $table->menutype )) {
+ $this->setError( $this->getError() );
+ return false;
+ }
+
+ // TODO: Should invoke JModuleModel::delete to delete the actual module
+ $moduleTable= &JTable::getInstance( 'module');
+ $items = &$this->getModules( $table->menutype );
+ $modulesIds = array();
+ foreach ($items as $item)
+ {
+ if (!$moduleTable->delete( $item->id )) {
+ $this->setError( $moduleTable->getErrorMsg() );
+ return false;
+ }
+ $modulesIds[] = (int) $item->id;
+ }
+
+ if (count( $modulesIds )) {
+ $query = 'DELETE FROM #__modules_menu' .
+ ' WHERE menuid = '.implode( ' OR moduleid = ', $modulesIds );
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $menuTable->getErrorMsg() );
+ return false;
+ }
+ }
+
+ $result = $table->delete();
+
+ return $result;
+ }
+
+ /**
+ * Delete menu items by type
+ */
+ function deleteByType( $type = '' )
+ {
+ if (!$type) {
+ return false;
+ }
+ $db = &$this->getDBO();
+ $query = 'DELETE FROM #__menu' .
+ ' WHERE menutype = '.$db->Quote( $type );
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ $this->setError( $menuTable->getErrorMsg() );
+ return false;
+ }
+
+ // clean cache
+ MenusHelper::cleanCache();
+
+ return true;
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php
index 97d44214..c8a44934 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php
@@ -1,204 +1,206 @@
-
-
-
-
+
+
+
+
diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php
index 059de3c3..a34d7fcb 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php
@@ -1,187 +1,187 @@
-_layout = 'form';
-
- $item = &$this->get('Item');
-
- // clean item data
- JFilterOutput::objectHTMLSafe( $item, ENT_QUOTES, '' );
-
- // Set toolbar items for the page
- if (!$item->id) {
- JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' );
- } else {
- JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'Edit' ) .' ]', 'menu.png' );
- }
- JToolBarHelper::save();
- JToolBarHelper::apply();
- if ($item->id) {
- // for existing items the button is renamed `close`
- JToolBarHelper::cancel( 'cancelItem', 'Close' );
- } else {
- JToolBarHelper::cancel('cancelItem');
- }
- JToolBarHelper::help( 'screen.menus.edit' );
-
- // Load component language files
- $component = &$this->get('Component');
- $lang->load($component->option, JPATH_ADMINISTRATOR);
-
- // Initialize variables
- $urlparams = $this->get( 'UrlParams' );
- $params = $this->get( 'StateParams' );
- $sysparams = $this->get( 'SystemParams' );
- $advanced = $this->get( 'AdvancedParams' );
- $component = $this->get( 'ComponentParams' );
- $name = $this->get( 'StateName' );
- $description = $this->get( 'StateDescription' );
- $menuTypes = MenusHelper::getMenuTypeList();
- $components = MenusHelper::getComponentList();
-
- JHTML::_('behavior.tooltip');
-
- $document = & JFactory::getDocument();
- if ($item->id) {
- $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']');
- } else {
- $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']');
- }
-
- // Was showing up null in some cases....
- if (!$item->published) {
- $item->published = 0;
- }
- $lists = new stdClass();
- $lists->published = MenusHelper::Published($item);
- $lists->disabled = ($item->type != 'url' ? 'readonly="true"' : '');
-
- $item->expansion = null;
- if ($item->type != 'url') {
- $lists->disabled = 'readonly="true"';
- $item->linkfield = '';
- if (($item->id) && ($item->type == 'component') && (isset($item->linkparts['option']))) {
- $item->expansion = '&expand='.trim(str_replace('com_', '', $item->linkparts['option']));
- }
- } else {
- $lists->disabled = null;
- $item->linkfield = null;
- }
-
- $this->assignRef('lists' , $lists);
- $this->assignRef('item' , $item);
- $this->assignRef('urlparams', $urlparams);
- $this->assignRef('sysparams', $sysparams);
- $this->assignRef('params' , $params);
- $this->assignRef('advanced' , $advanced);
- $this->assignRef('comp' , $component);
- $this->assignRef('menutypes', $menuTypes);
- $this->assignRef('name' , $name);
- $this->assignRef('description', $description);
-
- // Add slider pane
- // TODO: allowAllClose should default true in J!1.6, so remove the array when it does.
- $pane = &JPane::getInstance('sliders', array('allowAllClose' => true));
- $this->assignRef('pane', $pane);
-
- parent::display($tpl);
- }
-
- function type($tpl = null)
- {
- JRequest::setVar( 'hidemainmenu', 1 );
-
- global $mainframe;
-
- $lang =& JFactory::getLanguage();
- $this->_layout = 'type';
-
- $item = &$this->get('Item');
-
- // Set toolbar items for the page
- if (!$item->id) {
- JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' );
- } else {
- JToolBarHelper::title( JText::_( 'Change Menu Item' ), 'menu.png' );
- }
-
- // Set toolbar items for the page
- JToolBarHelper::cancel('view');
- JToolBarHelper::help( 'screen.menus.edit' );
-
- // Add scripts and stylesheets to the document
- $document = & JFactory::getDocument();
-
- if($lang->isRTL()){
- $document->addStyleSheet('components/com_menus/assets/type_rtl.css');
- } else {
- $document->addStyleSheet('components/com_menus/assets/type.css');
- }
- JHTML::_('behavior.tooltip');
-
- // Load component language files
- $components = MenusHelper::getComponentList();
- $n = count($components);
- for($i = 0; $i < $n; $i++)
- {
- $path = JPATH_SITE.DS.'components'.DS.$components[$i]->option.DS.'views';
- $components[$i]->legacy = !is_dir($path);
-
- $lang->load($components[$i]->option, JPATH_ADMINISTRATOR);
- }
-
- // Initialize variables
- $item = &$this->get('Item');
- $expansion = &$this->get('Expansion');
- $component = &$this->get('Component');
- $name = $this->get( 'StateName' );
- $description = $this->get( 'StateDescription' );
- $menuTypes = MenusHelper::getMenuTypeList();
-
- // Set document title
- if ($item->id) {
- $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']');
- } else {
- $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']');
- }
-
- $this->assignRef('item', $item);
- $this->assignRef('components', $components);
- $this->assignRef('expansion', $expansion);
-
- parent::display($tpl);
- }
-}
+_layout = 'form';
+
+ $item = &$this->get('Item');
+
+ // clean item data
+ JFilterOutput::objectHTMLSafe( $item, ENT_QUOTES, '' );
+
+ // Set toolbar items for the page
+ if (!$item->id) {
+ JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' );
+ } else {
+ JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'Edit' ) .' ]', 'menu.png' );
+ }
+ JToolBarHelper::save();
+ JToolBarHelper::apply();
+ if ($item->id) {
+ // for existing items the button is renamed `close`
+ JToolBarHelper::cancel( 'cancelItem', 'Close' );
+ } else {
+ JToolBarHelper::cancel('cancelItem');
+ }
+ JToolBarHelper::help( 'screen.menus.edit' );
+
+ // Load component language files
+ $component = &$this->get('Component');
+ $lang->load($component->option, JPATH_ADMINISTRATOR);
+
+ // Initialize variables
+ $urlparams = $this->get( 'UrlParams' );
+ $params = $this->get( 'StateParams' );
+ $sysparams = $this->get( 'SystemParams' );
+ $advanced = $this->get( 'AdvancedParams' );
+ $component = $this->get( 'ComponentParams' );
+ $name = $this->get( 'StateName' );
+ $description = $this->get( 'StateDescription' );
+ $menuTypes = MenusHelper::getMenuTypeList();
+ $components = MenusHelper::getComponentList();
+
+ JHTML::_('behavior.tooltip');
+
+ $document = & JFactory::getDocument();
+ if ($item->id) {
+ $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']');
+ } else {
+ $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']');
+ }
+
+ // Was showing up null in some cases....
+ if (!$item->published) {
+ $item->published = 0;
+ }
+ $lists = new stdClass();
+ $lists->published = MenusHelper::Published($item);
+ $lists->disabled = ($item->type != 'url' ? 'readonly="true"' : '');
+
+ $item->expansion = null;
+ if ($item->type != 'url') {
+ $lists->disabled = 'readonly="true"';
+ $item->linkfield = '';
+ if (($item->id) && ($item->type == 'component') && (isset($item->linkparts['option']))) {
+ $item->expansion = '&expand='.trim(str_replace('com_', '', $item->linkparts['option']));
+ }
+ } else {
+ $lists->disabled = null;
+ $item->linkfield = null;
+ }
+
+ $this->assignRef('lists' , $lists);
+ $this->assignRef('item' , $item);
+ $this->assignRef('urlparams', $urlparams);
+ $this->assignRef('sysparams', $sysparams);
+ $this->assignRef('params' , $params);
+ $this->assignRef('advanced' , $advanced);
+ $this->assignRef('comp' , $component);
+ $this->assignRef('menutypes', $menuTypes);
+ $this->assignRef('name' , $name);
+ $this->assignRef('description', $description);
+
+ // Add slider pane
+ // TODO: allowAllClose should default true in J!1.6, so remove the array when it does.
+ $pane = &JPane::getInstance('sliders', array('allowAllClose' => true));
+ $this->assignRef('pane', $pane);
+
+ parent::display($tpl);
+ }
+
+ function type($tpl = null)
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+
+ global $mainframe;
+
+ $lang =& JFactory::getLanguage();
+ $this->_layout = 'type';
+
+ $item = &$this->get('Item');
+
+ // Set toolbar items for the page
+ if (!$item->id) {
+ JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' );
+ } else {
+ JToolBarHelper::title( JText::_( 'Change Menu Item' ), 'menu.png' );
+ }
+
+ // Set toolbar items for the page
+ JToolBarHelper::cancel('view');
+ JToolBarHelper::help( 'screen.menus.edit' );
+
+ // Add scripts and stylesheets to the document
+ $document = & JFactory::getDocument();
+
+ if($lang->isRTL()){
+ $document->addStyleSheet('components/com_menus/assets/type_rtl.css');
+ } else {
+ $document->addStyleSheet('components/com_menus/assets/type.css');
+ }
+ JHTML::_('behavior.tooltip');
+
+ // Load component language files
+ $components = MenusHelper::getComponentList();
+ $n = count($components);
+ for($i = 0; $i < $n; $i++)
+ {
+ $path = JPATH_SITE.DS.'components'.DS.$components[$i]->option.DS.'views';
+ $components[$i]->legacy = !is_dir($path);
+
+ $lang->load($components[$i]->option, JPATH_ADMINISTRATOR);
+ }
+
+ // Initialize variables
+ $item = &$this->get('Item');
+ $expansion = &$this->get('Expansion');
+ $component = &$this->get('Component');
+ $name = $this->get( 'StateName' );
+ $description = $this->get( 'StateDescription' );
+ $menuTypes = MenusHelper::getMenuTypeList();
+
+ // Set document title
+ if ($item->id) {
+ $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']');
+ } else {
+ $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']');
+ }
+
+ $this->assignRef('item', $item);
+ $this->assignRef('components', $components);
+ $this->assignRef('expansion', $expansion);
+
+ parent::display($tpl);
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php
index b4cc545b..f4166478 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php
@@ -1,130 +1,130 @@
-
-
-
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php
index 872c5b82..b7b5c9f5 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php
@@ -1,188 +1,191 @@
-_layout = 'default';
-
- /*
- * Set toolbar items for the page
- */
- $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
-
- JToolBarHelper::title( JText::_( 'MENU ITEM MANAGER' ) .': ['.$menutype.']', 'menu.png' );
-
- $bar =& JToolBar::getInstance('toolbar');
- $bar->appendButton( 'Link', 'menus', 'Menus', "index.php?option=com_menus" );
-
- JToolBarHelper::makeDefault( 'setdefault' );
- JToolBarHelper::publishList();
- JToolBarHelper::unpublishList();
- JToolBarHelper::customX( 'move', 'move.png', 'move_f2.png', 'Move', true );
- JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true );
- JToolBarHelper::trash();
- JToolBarHelper::editListX();
- JToolBarHelper::addNewX('newItem');
- JToolBarHelper::help( 'screen.menus' );
-
- $document = & JFactory::getDocument();
- $document->setTitle(JText::_('View Menu Items'));
-
- $limitstart = JRequest::getVar('limitstart', '0', '', 'int');
- $items = &$this->get('Items');
- $pagination = &$this->get('Pagination');
- $lists = &$this->_getViewLists();
- $user = &JFactory::getUser();
-
- // Ensure ampersands and double quotes are encoded in item titles
- foreach ($items as $i => $item) {
- $treename = $item->treename;
- $treename = JFilterOutput::ampReplace($treename);
- $treename = str_replace('"', '"', $treename);
- $items[$i]->treename = $treename;
- }
-
- //Ordering allowed ?
- $ordering = ($lists['order'] == 'm.ordering');
-
- JHTML::_('behavior.tooltip');
-
- $this->assignRef('items', $items);
- $this->assignRef('pagination', $pagination);
- $this->assignRef('lists', $lists);
- $this->assignRef('user', $user);
- $this->assignRef('menutype', $menutype);
- $this->assignRef('ordering', $ordering);
- $this->assignRef('limitstart', $limitstart);
-
- parent::display($tpl);
- }
-
- function copyForm($tpl=null)
- {
- global $mainframe;
-
- $this->_layout = 'copy';
-
- /*
- * Set toolbar items for the page
- */
- JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Copy' ) .' ]' );
- JToolBarHelper::custom( 'doCopy', 'copy.png', 'copy_f2.png', 'Copy', false );
- JToolBarHelper::cancel('cancelItem');
- JToolBarHelper::help( 'screen.menus' );
-
- $document = & JFactory::getDocument();
- $document->setTitle(JText::_('Copy Menu Items'));
-
- $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
-
- // Build the menutypes select list
- $menuTypes = MenusHelper::getMenuTypes();
- foreach ( $menuTypes as $menuType ) {
- $menu[] = JHTML::_('select.option', $menuType, $menuType );
- }
- $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null );
-
- $items = &$this->get('ItemsFromRequest');
-
- $this->assignRef('menutype', $menutype);
- $this->assignRef('items', $items);
- $this->assignRef('menutypes', $menuTypes);
- $this->assignRef('MenuList', $MenuList);
-
- parent::display($tpl);
- }
-
- function moveForm($tpl=null)
- {
- global $mainframe;
-
- $this->_layout = 'move';
-
- /*
- * Set toolbar items for the page
- */
- JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Move' ) .' ]' );
- JToolBarHelper::custom( 'doMove', 'move.png', 'move_f2.png', 'Move', false );
- JToolBarHelper::cancel('cancelItem');
- JToolBarHelper::help( 'screen.menus' );
-
- $document = & JFactory::getDocument();
- $document->setTitle(JText::_('Move Menu Items'));
-
- $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
-
- // Build the menutypes select list
- $menuTypes = MenusHelper::getMenuTypes();
- foreach ( $menuTypes as $menuType ) {
- $menu[] = JHTML::_('select.option', $menuType, $menuType );
- }
- $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null );
-
- $items = &$this->get('ItemsFromRequest');
-
- $this->assignRef('menutype', $menutype);
- $this->assignRef('items', $items);
- $this->assignRef('menutypes', $menuTypes);
- $this->assignRef('MenuList', $MenuList);
-
- parent::display($tpl);
- }
-
- function &_getViewLists()
- {
- global $mainframe;
- $db =& JFactory::getDBO();
-
- $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' );
- $filter_order = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order", 'filter_order', 'm.ordering', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order_Dir", 'filter_order_Dir', 'ASC', 'word' );
- $filter_state = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_state", 'filter_state', '', 'word' );
- $levellimit = $mainframe->getUserStateFromRequest( "com_menus.$menutype.levellimit", 'levellimit', 10, 'int' );
- $search = $mainframe->getUserStateFromRequest( "com_menus.$menutype.search", 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- // level limit filter
- $lists['levellist'] = JHTML::_('select.integerlist', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit );
-
- // state filter
- $lists['state'] = JHTML::_('grid.state', $filter_state );
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- return $lists;
- }
-}
+_layout = 'default';
+
+ /*
+ * Set toolbar items for the page
+ */
+ $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
+
+ JToolBarHelper::title( JText::_( 'MENU ITEM MANAGER' ) .': ['.$menutype.']', 'menu.png' );
+
+ $bar =& JToolBar::getInstance('toolbar');
+ $bar->appendButton( 'Link', 'menus', 'Menus', "index.php?option=com_menus" );
+
+ JToolBarHelper::makeDefault( 'setdefault' );
+ JToolBarHelper::publishList();
+ JToolBarHelper::unpublishList();
+ JToolBarHelper::customX( 'move', 'move.png', 'move_f2.png', 'Move', true );
+ JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true );
+ JToolBarHelper::trash();
+ JToolBarHelper::editListX();
+ JToolBarHelper::addNewX('newItem');
+ JToolBarHelper::help( 'screen.menus' );
+
+ $document = & JFactory::getDocument();
+ $document->setTitle(JText::_('View Menu Items'));
+
+ $limitstart = JRequest::getVar('limitstart', '0', '', 'int');
+ $items = &$this->get('Items');
+ $pagination = &$this->get('Pagination');
+ $lists = &$this->_getViewLists();
+ $user = &JFactory::getUser();
+
+ // Ensure ampersands and double quotes are encoded in item titles
+ foreach ($items as $i => $item) {
+ $treename = $item->treename;
+ $treename = JFilterOutput::ampReplace($treename);
+ $treename = str_replace('"', '"', $treename);
+ $items[$i]->treename = $treename;
+ }
+
+ //Ordering allowed ?
+ $ordering = ($lists['order'] == 'm.ordering');
+
+ JHTML::_('behavior.tooltip');
+
+ $this->assignRef('items', $items);
+ $this->assignRef('pagination', $pagination);
+ $this->assignRef('lists', $lists);
+ $this->assignRef('user', $user);
+ $this->assignRef('menutype', $menutype);
+ $this->assignRef('ordering', $ordering);
+ $this->assignRef('limitstart', $limitstart);
+
+ parent::display($tpl);
+ }
+
+ function copyForm($tpl=null)
+ {
+ global $mainframe;
+
+ $this->_layout = 'copy';
+
+ /*
+ * Set toolbar items for the page
+ */
+ JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Copy' ) .' ]' );
+ JToolBarHelper::custom( 'doCopy', 'copy.png', 'copy_f2.png', 'Copy', false );
+ JToolBarHelper::cancel('cancelItem');
+ JToolBarHelper::help( 'screen.menus' );
+
+ $document = & JFactory::getDocument();
+ $document->setTitle(JText::_('Copy Menu Items'));
+
+ $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
+
+ // Build the menutypes select list
+ $menuTypes = MenusHelper::getMenuTypes();
+ foreach ( $menuTypes as $menuType ) {
+ $menu[] = JHTML::_('select.option', $menuType, $menuType );
+ }
+ $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null );
+
+ $items = &$this->get('ItemsFromRequest');
+
+ $this->assignRef('menutype', $menutype);
+ $this->assignRef('items', $items);
+ $this->assignRef('menutypes', $menuTypes);
+ $this->assignRef('MenuList', $MenuList);
+
+ parent::display($tpl);
+ }
+
+ function moveForm($tpl=null)
+ {
+ global $mainframe;
+
+ $this->_layout = 'move';
+
+ /*
+ * Set toolbar items for the page
+ */
+ JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Move' ) .' ]' );
+ JToolBarHelper::custom( 'doMove', 'move.png', 'move_f2.png', 'Move', false );
+ JToolBarHelper::cancel('cancelItem');
+ JToolBarHelper::help( 'screen.menus' );
+
+ $document = & JFactory::getDocument();
+ $document->setTitle(JText::_('Move Menu Items'));
+
+ $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' );
+
+ // Build the menutypes select list
+ $menuTypes = MenusHelper::getMenuTypes();
+ foreach ( $menuTypes as $menuType ) {
+ $menu[] = JHTML::_('select.option', $menuType, $menuType );
+ }
+ $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null );
+
+ $items = &$this->get('ItemsFromRequest');
+
+ $this->assignRef('menutype', $menutype);
+ $this->assignRef('items', $items);
+ $this->assignRef('menutypes', $menuTypes);
+ $this->assignRef('MenuList', $MenuList);
+
+ parent::display($tpl);
+ }
+
+ function &_getViewLists()
+ {
+ global $mainframe;
+ $db =& JFactory::getDBO();
+
+ $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' );
+ $filter_order = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order", 'filter_order', 'm.ordering', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order_Dir", 'filter_order_Dir', 'ASC', 'word' );
+ $filter_state = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_state", 'filter_state', '', 'word' );
+ $levellimit = $mainframe->getUserStateFromRequest( "com_menus.$menutype.levellimit", 'levellimit', 10, 'int' );
+ $search = $mainframe->getUserStateFromRequest( "com_menus.$menutype.search", 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ // level limit filter
+ $lists['levellist'] = JHTML::_('select.integerlist', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit );
+
+ // state filter
+ $lists['state'] = JHTML::_('grid.state', $filter_state );
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ return $lists;
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php
index f1ba5c36..f5deaae0 100644
--- a/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php
+++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php
@@ -1,142 +1,142 @@
-_layout = 'default';
-
- // Set toolbar items for the page
- JToolBarHelper::title( JText::_( 'Menu Manager' ), 'menumgr.png' );
- JToolBarHelper::customX( 'copyMenu', 'copy.png', 'copy_f2.png', 'Copy', true );
- JToolBarHelper::customX( 'deleteMenu', 'delete.png', 'delete_f2.png', 'Delete', true );
- JToolBarHelper::editListX('editMenu');
- JToolBarHelper::addNewX('addMenu');
- JToolBarHelper::help( 'screen.menumanager' );
-
- $document = & JFactory::getDocument();
- $document->setTitle(JText::_('View Menus'));
-
- $limitstart = JRequest::getVar('limitstart', '0', '', 'int');
-
- $menus = &$this->get('Menus');
- $pagination = &$this->get('Pagination');
-
- $this->assignRef('menus', $menus);
- $this->assignRef('pagination', $pagination);
- $this->assignRef('limitstart', $limitstart);
-
- JHTML::_('behavior.tooltip');
-
- parent::display($tpl);
- }
-
- function copyForm($tpl=null)
- {
- global $mainframe;
-
- $this->_layout = 'copy';
-
- // view data
- $table = $this->get('Table');
- $items = $this->get('MenuItems');
-
- /*
- * Set toolbar items for the page
- */
- JToolBarHelper::title( JText::_( 'Copy Menu' ) );
- JToolBarHelper::custom( 'doCopyMenu', 'copy.png', 'copy_f2.png', 'Copy', false );
- JToolBarHelper::cancel();
- JToolBarHelper::help( 'screen.menumanager' );
-
- $document = & JFactory::getDocument();
- $document->setTitle(JText::_('Copy Menu Items'));
-
- $this->assignRef('items', $items);
- $this->assignRef('table', $table);
-
- parent::display($tpl);
- }
-
- function deleteForm($tpl=null)
- {
- global $mainframe;
-
- $this->_layout = 'delete';
-
- /*
- * Set toolbar items for the page
- */
- JToolBarHelper::title( JText::_( 'Menu' ) . ': [ '. JText::_( 'Delete' ) .' ]' );
- JToolBarHelper::custom( 'doDeleteMenu', 'delete.png', 'delete_f2.png', 'Delete', false );
- JToolBarHelper::cancel();
- JToolBarHelper::help( 'screen.menumanager.delete' );
-
- // view data
- $table = $this->get('Table');
- $modules = $this->get('Modules');
- $menuItems = $this->get('MenuItems');
-
- $document = & JFactory::getDocument();
- $document->setTitle(JText::_('Confirm Delete Menu Type') . ': ' . $table->menutype );
-
-
- $this->assignRef('table', $table);
- $this->assignRef('modules', $modules);
- $this->assignRef('menuItems', $menuItems);
-
- parent::display($tpl);
- }
-
- function editForm($edit,$tpl=null)
- {
- JRequest::setVar( 'hidemainmenu', 1 );
-
- global $mainframe;
-
- $this->_layout = 'edit';
- if($edit)
- $table = &$this->get('Table');
- else
- $table=& JTable::getInstance('menuTypes');
- /*
- * Set toolbar items for the page
- */
- $text = ( ($table->id != 0) ? JText::_( 'Edit' ) : JText::_( 'New' ) );
- JToolBarHelper::title( JText::_( 'Menu Details' ).': [ '. $text.' ]', 'menumgr.png' );
- JToolBarHelper::custom( 'savemenu', 'save.png', 'save_f2.png', 'Save', false );
- JToolBarHelper::cancel();
- JToolBarHelper::help( 'screen.menumanager.new' );
-
- $this->assignRef('row', $table);
- $this->assign('isnew', ($table->id == 0));
-
- JHTML::_('behavior.tooltip');
-
- parent::display($tpl);
- }
-}
+_layout = 'default';
+
+ // Set toolbar items for the page
+ JToolBarHelper::title( JText::_( 'Menu Manager' ), 'menumgr.png' );
+ JToolBarHelper::customX( 'copyMenu', 'copy.png', 'copy_f2.png', 'Copy', true );
+ JToolBarHelper::customX( 'deleteMenu', 'delete.png', 'delete_f2.png', 'Delete', true );
+ JToolBarHelper::editListX('editMenu');
+ JToolBarHelper::addNewX('addMenu');
+ JToolBarHelper::help( 'screen.menumanager' );
+
+ $document = & JFactory::getDocument();
+ $document->setTitle(JText::_('View Menus'));
+
+ $limitstart = JRequest::getVar('limitstart', '0', '', 'int');
+
+ $menus = &$this->get('Menus');
+ $pagination = &$this->get('Pagination');
+
+ $this->assignRef('menus', $menus);
+ $this->assignRef('pagination', $pagination);
+ $this->assignRef('limitstart', $limitstart);
+
+ JHTML::_('behavior.tooltip');
+
+ parent::display($tpl);
+ }
+
+ function copyForm($tpl=null)
+ {
+ global $mainframe;
+
+ $this->_layout = 'copy';
+
+ // view data
+ $table = $this->get('Table');
+ $items = $this->get('MenuItems');
+
+ /*
+ * Set toolbar items for the page
+ */
+ JToolBarHelper::title( JText::_( 'Copy Menu' ) );
+ JToolBarHelper::custom( 'doCopyMenu', 'copy.png', 'copy_f2.png', 'Copy', false );
+ JToolBarHelper::cancel();
+ JToolBarHelper::help( 'screen.menumanager' );
+
+ $document = & JFactory::getDocument();
+ $document->setTitle(JText::_('Copy Menu Items'));
+
+ $this->assignRef('items', $items);
+ $this->assignRef('table', $table);
+
+ parent::display($tpl);
+ }
+
+ function deleteForm($tpl=null)
+ {
+ global $mainframe;
+
+ $this->_layout = 'delete';
+
+ /*
+ * Set toolbar items for the page
+ */
+ JToolBarHelper::title( JText::_( 'Menu' ) . ': [ '. JText::_( 'Delete' ) .' ]' );
+ JToolBarHelper::custom( 'doDeleteMenu', 'delete.png', 'delete_f2.png', 'Delete', false );
+ JToolBarHelper::cancel();
+ JToolBarHelper::help( 'screen.menumanager.delete' );
+
+ // view data
+ $table = $this->get('Table');
+ $modules = $this->get('Modules');
+ $menuItems = $this->get('MenuItems');
+
+ $document = & JFactory::getDocument();
+ $document->setTitle(JText::_('Confirm Delete Menu Type') . ': ' . $table->menutype );
+
+
+ $this->assignRef('table', $table);
+ $this->assignRef('modules', $modules);
+ $this->assignRef('menuItems', $menuItems);
+
+ parent::display($tpl);
+ }
+
+ function editForm($edit,$tpl=null)
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+
+ global $mainframe;
+
+ $this->_layout = 'edit';
+ if($edit)
+ $table = &$this->get('Table');
+ else
+ $table=& JTable::getInstance('menuTypes');
+ /*
+ * Set toolbar items for the page
+ */
+ $text = ( ($table->id != 0) ? JText::_( 'Edit' ) : JText::_( 'New' ) );
+ JToolBarHelper::title( JText::_( 'Menu Details' ).': [ '. $text.' ]', 'menumgr.png' );
+ JToolBarHelper::custom( 'savemenu', 'save.png', 'save_f2.png', 'Save', false );
+ JToolBarHelper::cancel();
+ JToolBarHelper::help( 'screen.menumanager.new' );
+
+ $this->assignRef('row', $table);
+ $this->assign('isnew', ($table->id == 0));
+
+ JHTML::_('behavior.tooltip');
+
+ parent::display($tpl);
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php b/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php
index 09f8cb6c..ec3c93dd 100644
--- a/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php
+++ b/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php
@@ -1,296 +1,296 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ getUserStateFromRequest( $context.'.filter_order', 'filter_order', 'a.date_time', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'.filter_order_Dir','filter_order_Dir', 'DESC', 'word' );
- $filter_state = $mainframe->getUserStateFromRequest( $context.'.filter_state', 'filter_state', '', 'word' );
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( $context.'.limitstart', 'limitstart', 0, 'int' );
- $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $where = array();
- $where[] = ' a.user_id_to='.(int) $user->get('id');
-
- if ($search != '') {
- $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
- $where[] = '( a.subject LIKE '.$searchEscaped.' OR a.message LIKE '.$searchEscaped.' )';
- }
- if ( $filter_state ) {
- if ( $filter_state == 'P' ) {
- $where[] = 'a.state = 1';
- } else if ($filter_state == 'U' ) {
- $where[] = 'a.state = 0';
- }
- }
-
- $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
- $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.date_time DESC';
-
- $query = 'SELECT COUNT(*)'
- . ' FROM #__messages AS a'
- . ' INNER JOIN #__users AS u ON u.id = a.user_id_from'
- . $where
- ;
- $db->setQuery( $query );
- $total = $db->loadResult();
-
- jimport('joomla.html.pagination');
- $pageNav = new JPagination( $total, $limitstart, $limit );
-
- $query = 'SELECT a.*, u.name AS user_from'
- . ' FROM #__messages AS a'
- . ' INNER JOIN #__users AS u ON u.id = a.user_id_from'
- . $where
- . $orderby
- ;
- $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
- $rows = $db->loadObjectList();
- if ($db->getErrorNum()) {
- echo $db->stderr();
- return false;
- }
-
- // state filter
- $lists['state'] = JHTML::_('grid.state', $filter_state, 'Read', 'Unread' );
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- HTML_messages::showMessages( $rows, $pageNav, $option, $lists );
-}
-
-function editConfig( $option )
-{
- $db =& JFactory::getDBO();
- $user =& JFactory::getUser();
-
- $query = 'SELECT cfg_name, cfg_value'
- . ' FROM #__messages_cfg'
- . ' WHERE user_id = '.(int) $user->get('id')
- ;
- $db->setQuery( $query );
- $data = $db->loadObjectList( 'cfg_name' );
-
- // initialize values if they do not exist
- if (!isset($data['lock']->cfg_value)) {
- $data['lock']->cfg_value = 0;
- }
- if (!isset($data['mail_on_new']->cfg_value)) {
- $data['mail_on_new']->cfg_value = 0;
- }
- if (!isset($data['auto_purge']->cfg_value)) {
- $data['auto_purge']->cfg_value = 7;
- }
-
- $vars = array();
- $vars['lock'] = JHTML::_('select.booleanlist', "vars[lock]", '', $data['lock']->cfg_value, 'yes', 'no', 'varslock' );
- $vars['mail_on_new'] = JHTML::_('select.booleanlist', "vars[mail_on_new]", '', $data['mail_on_new']->cfg_value, 'yes', 'no', 'varsmail_on_new' );
- $vars['auto_purge'] = $data['auto_purge']->cfg_value;
-
- HTML_messages::editConfig( $vars, $option );
-
-}
-
-function saveConfig( $option )
-{
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
- $user =& JFactory::getUser();
-
- $query = 'DELETE FROM #__messages_cfg'
- . ' WHERE user_id = '.(int) $user->get('id')
- ;
- $db->setQuery( $query );
- $db->query();
-
- $vars = JRequest::getVar( 'vars', array(), 'post', 'array' );
- foreach ($vars as $k=>$v) {
- $v = $db->getEscaped( $v );
- $query = 'INSERT INTO #__messages_cfg'
- . ' ( user_id, cfg_name, cfg_value )'
- . ' VALUES ( '.(int) $user->get('id').', '.$db->Quote($k).', '.$db->Quote($v).' )'
- ;
- $db->setQuery( $query );
- $db->query();
- }
- $mainframe->redirect( "index.php?option=$option" );
-}
-
-function newMessage( $option, $user, $subject )
-{
- $db =& JFactory::getDBO();
- $acl =& JFactory::getACL();
-
- // get available backend user groups
- $gid = $acl->get_group_id( 'Public Backend', 'ARO' );
- $gids = $acl->get_group_children( $gid, 'ARO', 'RECURSE' );
- JArrayHelper::toInteger($gids, array(0));
- $gids = implode( ',', $gids );
-
- // get list of usernames
- $recipients = array( JHTML::_('select.option', '0', '- '. JText::_( 'Select User' ) .' -' ) );
- $query = 'SELECT id AS value, username AS text FROM #__users'
- . ' WHERE gid IN ( '.$gids.' )'
- . ' ORDER BY name'
- ;
- $db->setQuery( $query );
- $recipients = array_merge( $recipients, $db->loadObjectList() );
-
- $recipientslist =
- JHTML::_('select.genericlist', $recipients, 'user_id_to', 'class="inputbox" size="1"', 'value', 'text', $user);
- HTML_messages::newMessage($option, $recipientslist, $subject );
-}
-
-function saveMessage( $option )
-{
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- require_once(dirname(__FILE__).DS.'tables'.DS.'message.php');
-
- $db =& JFactory::getDBO();
- $row = new TableMessage( $db );
-
- if (!$row->bind(JRequest::get('post'))) {
- JError::raiseError(500, $row->getError() );
- }
-
- if (!$row->check()) {
- JError::raiseError(500, $row->getError() );
- }
-
- if (!$row->send()) {
- $mainframe->redirect( "index.php?option=com_messages", $row->getError() );
- }
- $mainframe->redirect( "index.php?option=com_messages" );
-}
-
-function viewMessage( $uid='0', $option )
-{
- $db =& JFactory::getDBO();
-
- $query = 'SELECT a.*, u.name AS user_from'
- . ' FROM #__messages AS a'
- . ' INNER JOIN #__users AS u ON u.id = a.user_id_from'
- . ' WHERE a.message_id = '.(int) $uid
- . ' ORDER BY date_time DESC'
- ;
- $db->setQuery( $query );
- $row = $db->loadObject();
-
- $query = 'UPDATE #__messages'
- . ' SET state = 1'
- . ' WHERE message_id = '.(int) $uid
- ;
- $db->setQuery( $query );
- $db->query();
-
- HTML_messages::viewMessage( $row, $option );
-}
-
-function removeMessage( $cid, $option )
-{
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
-
- JArrayHelper::toInteger($cid);
-
- if (count( $cid ) < 1) {
- JError::raiseError(500, JText::_( 'Select an item to delete' ) );
- }
-
- if (count( $cid ))
- {
- $cids = implode( ',', $cid );
- $query = 'DELETE FROM #__messages'
- . ' WHERE message_id IN ( '. $cids .' )'
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- echo "\n";
- }
- }
-
- $limit = JRequest::getVar( 'limit', 10, '', 'int' );
- $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' );
-
- $mainframe->redirect( 'index.php?option='.$option.'&limit='.$limit.'&limitstart='.$limitstart );
-}
+getUserStateFromRequest( $context.'.filter_order', 'filter_order', 'a.date_time', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'.filter_order_Dir','filter_order_Dir', 'DESC', 'word' );
+ $filter_state = $mainframe->getUserStateFromRequest( $context.'.filter_state', 'filter_state', '', 'word' );
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( $context.'.limitstart', 'limitstart', 0, 'int' );
+ $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $where = array();
+ $where[] = ' a.user_id_to='.(int) $user->get('id');
+
+ if ($search != '') {
+ $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ $where[] = '( a.subject LIKE '.$searchEscaped.' OR a.message LIKE '.$searchEscaped.' )';
+ }
+ if ( $filter_state ) {
+ if ( $filter_state == 'P' ) {
+ $where[] = 'a.state = 1';
+ } else if ($filter_state == 'U' ) {
+ $where[] = 'a.state = 0';
+ }
+ }
+
+ $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
+ $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.date_time DESC';
+
+ $query = 'SELECT COUNT(*)'
+ . ' FROM #__messages AS a'
+ . ' INNER JOIN #__users AS u ON u.id = a.user_id_from'
+ . $where
+ ;
+ $db->setQuery( $query );
+ $total = $db->loadResult();
+
+ jimport('joomla.html.pagination');
+ $pageNav = new JPagination( $total, $limitstart, $limit );
+
+ $query = 'SELECT a.*, u.name AS user_from'
+ . ' FROM #__messages AS a'
+ . ' INNER JOIN #__users AS u ON u.id = a.user_id_from'
+ . $where
+ . $orderby
+ ;
+ $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
+ $rows = $db->loadObjectList();
+ if ($db->getErrorNum()) {
+ echo $db->stderr();
+ return false;
+ }
+
+ // state filter
+ $lists['state'] = JHTML::_('grid.state', $filter_state, 'Read', 'Unread' );
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ HTML_messages::showMessages( $rows, $pageNav, $option, $lists );
+}
+
+function editConfig( $option )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ $query = 'SELECT cfg_name, cfg_value'
+ . ' FROM #__messages_cfg'
+ . ' WHERE user_id = '.(int) $user->get('id')
+ ;
+ $db->setQuery( $query );
+ $data = $db->loadObjectList( 'cfg_name' );
+
+ // initialize values if they do not exist
+ if (!isset($data['lock']->cfg_value)) {
+ $data['lock']->cfg_value = 0;
+ }
+ if (!isset($data['mail_on_new']->cfg_value)) {
+ $data['mail_on_new']->cfg_value = 0;
+ }
+ if (!isset($data['auto_purge']->cfg_value)) {
+ $data['auto_purge']->cfg_value = 7;
+ }
+
+ $vars = array();
+ $vars['lock'] = JHTML::_('select.booleanlist', "vars[lock]", '', $data['lock']->cfg_value, 'yes', 'no', 'varslock' );
+ $vars['mail_on_new'] = JHTML::_('select.booleanlist', "vars[mail_on_new]", '', $data['mail_on_new']->cfg_value, 'yes', 'no', 'varsmail_on_new' );
+ $vars['auto_purge'] = $data['auto_purge']->cfg_value;
+
+ HTML_messages::editConfig( $vars, $option );
+
+}
+
+function saveConfig( $option )
+{
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ $query = 'DELETE FROM #__messages_cfg'
+ . ' WHERE user_id = '.(int) $user->get('id')
+ ;
+ $db->setQuery( $query );
+ $db->query();
+
+ $vars = JRequest::getVar( 'vars', array(), 'post', 'array' );
+ foreach ($vars as $k=>$v) {
+ $v = $db->getEscaped( $v );
+ $query = 'INSERT INTO #__messages_cfg'
+ . ' ( user_id, cfg_name, cfg_value )'
+ . ' VALUES ( '.(int) $user->get('id').', '.$db->Quote($k).', '.$db->Quote($v).' )'
+ ;
+ $db->setQuery( $query );
+ $db->query();
+ }
+ $mainframe->redirect( "index.php?option=$option" );
+}
+
+function newMessage( $option, $user, $subject )
+{
+ $db =& JFactory::getDBO();
+ $acl =& JFactory::getACL();
+
+ // get available backend user groups
+ $gid = $acl->get_group_id( 'Public Backend', 'ARO' );
+ $gids = $acl->get_group_children( $gid, 'ARO', 'RECURSE' );
+ JArrayHelper::toInteger($gids, array(0));
+ $gids = implode( ',', $gids );
+
+ // get list of usernames
+ $recipients = array( JHTML::_('select.option', '0', '- '. JText::_( 'Select User' ) .' -' ) );
+ $query = 'SELECT id AS value, username AS text FROM #__users'
+ . ' WHERE gid IN ( '.$gids.' )'
+ . ' ORDER BY name'
+ ;
+ $db->setQuery( $query );
+ $recipients = array_merge( $recipients, $db->loadObjectList() );
+
+ $recipientslist =
+ JHTML::_('select.genericlist', $recipients, 'user_id_to', 'class="inputbox" size="1"', 'value', 'text', $user);
+ HTML_messages::newMessage($option, $recipientslist, $subject );
+}
+
+function saveMessage( $option )
+{
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ require_once(dirname(__FILE__).DS.'tables'.DS.'message.php');
+
+ $db =& JFactory::getDBO();
+ $row = new TableMessage( $db );
+
+ if (!$row->bind(JRequest::get('post'))) {
+ JError::raiseError(500, $row->getError() );
+ }
+
+ if (!$row->check()) {
+ JError::raiseError(500, $row->getError() );
+ }
+
+ if (!$row->send()) {
+ $mainframe->redirect( "index.php?option=com_messages", $row->getError() );
+ }
+ $mainframe->redirect( "index.php?option=com_messages" );
+}
+
+function viewMessage( $uid='0', $option )
+{
+ $db =& JFactory::getDBO();
+
+ $query = 'SELECT a.*, u.name AS user_from'
+ . ' FROM #__messages AS a'
+ . ' INNER JOIN #__users AS u ON u.id = a.user_id_from'
+ . ' WHERE a.message_id = '.(int) $uid
+ . ' ORDER BY date_time DESC'
+ ;
+ $db->setQuery( $query );
+ $row = $db->loadObject();
+
+ $query = 'UPDATE #__messages'
+ . ' SET state = 1'
+ . ' WHERE message_id = '.(int) $uid
+ ;
+ $db->setQuery( $query );
+ $db->query();
+
+ HTML_messages::viewMessage( $row, $option );
+}
+
+function removeMessage( $cid, $option )
+{
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+
+ JArrayHelper::toInteger($cid);
+
+ if (count( $cid ) < 1) {
+ JError::raiseError(500, JText::_( 'Select an item to delete' ) );
+ }
+
+ if (count( $cid ))
+ {
+ $cids = implode( ',', $cid );
+ $query = 'DELETE FROM #__messages'
+ . ' WHERE message_id IN ( '. $cids .' )'
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ echo "\n";
+ }
+ }
+
+ $limit = JRequest::getVar( 'limit', 10, '', 'int' );
+ $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' );
+
+ $mainframe->redirect( 'index.php?option='.$option.'&limit='.$limit.'&limitstart='.$limitstart );
+}
diff --git a/oss/joomla/trunk/administrator/components/com_messages/messages.xml b/oss/joomla/trunk/administrator/components/com_messages/messages.xml
index 72497e2b..dde7e71d 100644
--- a/oss/joomla/trunk/administrator/components/com_messages/messages.xml
+++ b/oss/joomla/trunk/administrator/components/com_messages/messages.xml
@@ -1,12 +1,12 @@
-
-
- Messaging
- Joomla! Project
- 2006
- Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.5.0
- Messaging
-
+
+
+ Messaging
+ Joomla! Project
+ 2006
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5.0
+ Messaging
+
diff --git a/oss/joomla/trunk/administrator/components/com_messages/tables/message.php b/oss/joomla/trunk/administrator/components/com_messages/tables/message.php
index 4cfbcd53..f6d9ca22 100644
--- a/oss/joomla/trunk/administrator/components/com_messages/tables/message.php
+++ b/oss/joomla/trunk/administrator/components/com_messages/tables/message.php
@@ -1,187 +1,187 @@
-user_id_from;
- $toId = $toId ? $toId : $this->user_id_to;
- $subject = $subject ? $subject : $this->subject;
- $message = $message ? $message : $this->message;
- }
-
- $query = 'SELECT cfg_name, cfg_value' .
- ' FROM #__messages_cfg' .
- ' WHERE user_id = '.(int) $toId;
- $db->setQuery($query);
-
- $config = $db->loadObjectList('cfg_name');
- $locked = @ $config['lock']->cfg_value;
- $domail = @ $config['mail_on_new']->cfg_value;
-
- if (!$locked)
- {
- $this->user_id_from = $fromId;
- $this->user_id_to = $toId;
- $this->subject = $subject;
- $this->message = $message;
- $date =& JFactory::getDate();
- $this->date_time = $date->toMySQL();
-
- if ($this->store())
- {
- if ($domail)
- {
- $query = 'SELECT name, email' .
- ' FROM #__users' .
- ' WHERE id = '.(int) $fromId;
- $db->setQuery($query);
- $fromObject = $db->loadObject();
- $fromname = $fromObject->name;
- $mailfrom = $fromObject->email;
- $siteURL = JURI::base();
- $sitename = $mainframe->getCfg( 'sitename' );
-
- $query = 'SELECT email' .
- ' FROM #__users' .
- ' WHERE id = '.(int) $toId;
- $db->setQuery($query);
- $recipient = $db->loadResult();
-
- $subject = sprintf (JText::_('A new private message has arrived'), $sitename);
- $msg = sprintf (JText::_('Please login to read your message'), $siteURL);
-
- JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $msg);
- }
- return true;
- }
- }
- else
- {
- if (is_object($this)) {
- $this->setError(JText::_('MESSAGE_FAILED'));
- }
- }
- return false;
- }
-}
+user_id_from;
+ $toId = $toId ? $toId : $this->user_id_to;
+ $subject = $subject ? $subject : $this->subject;
+ $message = $message ? $message : $this->message;
+ }
+
+ $query = 'SELECT cfg_name, cfg_value' .
+ ' FROM #__messages_cfg' .
+ ' WHERE user_id = '.(int) $toId;
+ $db->setQuery($query);
+
+ $config = $db->loadObjectList('cfg_name');
+ $locked = @ $config['lock']->cfg_value;
+ $domail = @ $config['mail_on_new']->cfg_value;
+
+ if (!$locked)
+ {
+ $this->user_id_from = $fromId;
+ $this->user_id_to = $toId;
+ $this->subject = $subject;
+ $this->message = $message;
+ $date =& JFactory::getDate();
+ $this->date_time = $date->toMySQL();
+
+ if ($this->store())
+ {
+ if ($domail)
+ {
+ $query = 'SELECT name, email' .
+ ' FROM #__users' .
+ ' WHERE id = '.(int) $fromId;
+ $db->setQuery($query);
+ $fromObject = $db->loadObject();
+ $fromname = $fromObject->name;
+ $mailfrom = $fromObject->email;
+ $siteURL = JURI::base();
+ $sitename = $mainframe->getCfg( 'sitename' );
+
+ $query = 'SELECT email' .
+ ' FROM #__users' .
+ ' WHERE id = '.(int) $toId;
+ $db->setQuery($query);
+ $recipient = $db->loadResult();
+
+ $subject = sprintf (JText::_('A new private message has arrived'), $sitename);
+ $msg = sprintf (JText::_('Please login to read your message'), $siteURL);
+
+ JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $msg);
+ }
+ return true;
+ }
+ }
+ else
+ {
+ if (is_object($this)) {
+ $this->setError(JText::_('MESSAGE_FAILED'));
+ }
+ }
+ return false;
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php b/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php
index e9c072bd..d2c62723 100644
--- a/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php
+++ b/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php
@@ -1,55 +1,55 @@
-
-
- $row is passed with the id
- * property set to 0.
- * @param JTableCategory The category object
- * @param array
The modules of the left side. The array elements are in the form
- * $leftorder[order] = label
- * where order is the module order from the db table and label is a
- * text label associciated with the order.
- * @param array See notes for leftorder
- * @param array An array of select lists
- * @param object Parameters
- */
- function edit( &$model, &$row, &$orders2, &$lists, &$params, $client )
- {
- JRequest::setVar( 'hidemainmenu', 1 );
-
- // clean item data
- JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' );
-
- // Check for component metadata.xml file
- //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module );
- //$params = new JParameter( $row->params, $path );
- $document =& JFactory::getDocument();
-
- JHTML::_('behavior.combobox');
-
- jimport('joomla.html.pane');
- // TODO: allowAllClose should default true in J!1.6, so remove the array when it does.
- $pane = &JPane::getInstance('sliders', array('allowAllClose' => true));
- $editor =& JFactory::getEditor();
-
- JHTML::_('behavior.tooltip');
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ $row is passed with the id
+ * property set to 0.
+ * @param JTableCategory The category object
+ * @param array
The modules of the left side. The array elements are in the form
+ * $leftorder[order] = label
+ * where order is the module order from the db table and label is a
+ * text label associciated with the order.
+ * @param array See notes for leftorder
+ * @param array An array of select lists
+ * @param object Parameters
+ */
+ function edit( &$model, &$row, &$orders2, &$lists, &$params, $client )
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+
+ // clean item data
+ JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' );
+
+ // Check for component metadata.xml file
+ //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module );
+ //$params = new JParameter( $row->params, $path );
+ $document =& JFactory::getDocument();
+
+ JHTML::_('behavior.combobox');
+
+ jimport('joomla.html.pane');
+ // TODO: allowAllClose should default true in J!1.6, so remove the array when it does.
+ $pane = &JPane::getInstance('sliders', array('allowAllClose' => true));
+ $editor =& JFactory::getEditor();
+
+ JHTML::_('behavior.tooltip');
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ authorize( 'com_modules', 'manage' )) {
- $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
-}
-
-// Require the base controller
-require_once (JPATH_COMPONENT.DS.'controller.php');
-
-// Create the controller
-$controller = new ModulesController( array( 'default_task' => 'view' ));
-
-// Perform the Request task
-$controller->execute( JRequest::getCmd('task', 'view') );
-
-// Redirect if set by the controller
-$controller->redirect();
+authorize( 'com_modules', 'manage' )) {
+ $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
+}
+
+// Require the base controller
+require_once (JPATH_COMPONENT.DS.'controller.php');
+
+// Create the controller
+$controller = new ModulesController( array( 'default_task' => 'view' ));
+
+// Perform the Request task
+$controller->execute( JRequest::getCmd('task', 'view') );
+
+// Redirect if set by the controller
+$controller->redirect();
diff --git a/oss/joomla/trunk/administrator/components/com_modules/controller.php b/oss/joomla/trunk/administrator/components/com_modules/controller.php
index 2ae42ac4..4d1c4619 100644
--- a/oss/joomla/trunk/administrator/components/com_modules/controller.php
+++ b/oss/joomla/trunk/administrator/components/com_modules/controller.php
@@ -1,830 +1,833 @@
-registerTask( 'apply', 'save' );
- $this->registerTask( 'unpublish', 'publish' );
- $this->registerTask( 'orderup', 'reorder' );
- $this->registerTask( 'orderdown', 'reorder' );
- $this->registerTask( 'accesspublic', 'access' );
- $this->registerTask( 'accessregistered','access' );
- $this->registerTask( 'accessspecial', 'access' );
- }
-
- /**
- * Compiles a list of installed or defined modules
- */
- function view()
- {
- global $mainframe;
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $option = 'com_modules';
-
- $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'm.position', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
- $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
- $filter_position = $mainframe->getUserStateFromRequest( $option.'filter_position', 'filter_position', '', 'cmd' );
- $filter_type = $mainframe->getUserStateFromRequest( $option.'filter_type', 'filter_type', '', 'cmd' );
- $filter_assigned = $mainframe->getUserStateFromRequest( $option.'filter_assigned', 'filter_assigned', '', 'cmd' );
- $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
-
- $where[] = 'm.client_id = '.(int) $client->id;
-
- $joins[] = 'LEFT JOIN #__users AS u ON u.id = m.checked_out';
- $joins[] = 'LEFT JOIN #__groups AS g ON g.id = m.access';
- $joins[] = 'LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id';
-
- // used by filter
- if ( $filter_assigned ) {
- $joins[] = 'LEFT JOIN #__templates_menu AS t ON t.menuid = mm.menuid';
- $where[] = 't.template = '.$db->Quote($filter_assigned);
- }
- if ( $filter_position ) {
- $where[] = 'm.position = '.$db->Quote($filter_position);
- }
- if ( $filter_type ) {
- $where[] = 'm.module = '.$db->Quote($filter_type);
- }
- if ( $search ) {
- $where[] = 'LOWER( m.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
- }
- if ( $filter_state ) {
- if ( $filter_state == 'P' ) {
- $where[] = 'm.published = 1';
- } else if ($filter_state == 'U' ) {
- $where[] = 'm.published = 0';
- }
- }
-
- $where = ' WHERE ' . implode( ' AND ', $where );
- $join = ' ' . implode( ' ', $joins );
- if ($filter_order == 'm.ordering') {
- $orderby = ' ORDER BY m.position, m.ordering '. $filter_order_Dir;
- } else {
- $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', m.ordering ASC';
- }
-
- // get the total number of records
- $query = 'SELECT COUNT(DISTINCT m.id)'
- . ' FROM #__modules AS m'
- . $join
- . $where
- ;
- $db->setQuery( $query );
- $total = $db->loadResult();
-
- jimport('joomla.html.pagination');
- $pageNav = new JPagination( $total, $limitstart, $limit );
-
- $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages'
- . ' FROM #__modules AS m'
- . $join
- . $where
- . ' GROUP BY m.id'
- . $orderby
- ;
- $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
- $rows = $db->loadObjectList();
- if ($db->getErrorNum()) {
- echo $db->stderr();
- return false;
- }
-
- // get list of Positions for dropdown filter
- $query = 'SELECT m.position AS value, m.position AS text'
- . ' FROM #__modules as m'
- . ' WHERE m.client_id = '.(int) $client->id
- . ' GROUP BY m.position'
- . ' ORDER BY m.position'
- ;
- $positions[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Position' ) .' -' );
- $db->setQuery( $query );
- $positions = array_merge( $positions, $db->loadObjectList() );
- $lists['position'] = JHTML::_('select.genericlist', $positions, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_position" );
-
- // get list of Positions for dropdown filter
- $query = 'SELECT module AS value, module AS text'
- . ' FROM #__modules'
- . ' WHERE client_id = '.(int) $client->id
- . ' GROUP BY module'
- . ' ORDER BY module'
- ;
- $db->setQuery( $query );
- $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Type' ) .' -' );
- $types = array_merge( $types, $db->loadObjectList() );
- $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_type" );
-
- // state filter
- $lists['state'] = JHTML::_('grid.state', $filter_state );
-
- // template assignment filter
- $query = 'SELECT DISTINCT(template) AS text, template AS value'.
- ' FROM #__templates_menu' .
- ' WHERE client_id = '.(int) $client->id;
- $db->setQuery( $query );
- $assigned[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Template' ) .' -' );
- $assigned = array_merge( $assigned, $db->loadObjectList() );
- $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_assigned" );
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- require_once( JApplicationHelper::getPath( 'admin_html' ) );
- HTML_modules::view( $rows, $client, $pageNav, $lists );
- }
-
- /**
- * Compiles information to add or edit a module
- * @param string The current GET/POST option
- * @param integer The unique id of the record to edit
- */
- function copy()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- $n = count( $cid );
-
- if ($n == 0) {
- return JError::raiseWarning( 500, JText::_( 'No items selected' ) );
- }
-
- $row =& JTable::getInstance('module');
- $tuples = array();
-
- foreach ($cid as $id)
- {
- // load the row from the db table
- $row->load( (int) $id );
- $row->title = JText::sprintf( 'Copy of', $row->title );
- $row->id = 0;
- $row->iscore = 0;
- $row->published = 0;
-
- if (!$row->check()) {
- return JError::raiseWarning( 500, $row->getError() );
- }
- if (!$row->store()) {
- return JError::raiseWarning( 500, $row->getError() );
- }
- $row->checkin();
-
- $row->reorder( 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id );
-
- $query = 'SELECT menuid'
- . ' FROM #__modules_menu'
- . ' WHERE moduleid = '.(int) $cid[0]
- ;
- $db->setQuery( $query );
- $rows = $db->loadResultArray();
-
- foreach ($rows as $menuid) {
- $tuples[] = '('.(int) $row->id.','.(int) $menuid.')';
- }
- }
-
- if (!empty( $tuples ))
- {
- // Module-Menu Mapping: Do it in one query
- $query = 'INSERT INTO #__modules_menu (moduleid,menuid) VALUES '.implode( ',', $tuples );
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getError() );
- }
- }
-
- $msg = JText::sprintf( 'Items Copied', $n );
- $this->setRedirect( 'index.php?option=com_modules&client='. $client->id, $msg );
- }
-
- /**
- * Saves the module after an edit form submit
- */
- function save()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- global $mainframe;
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $post = JRequest::get( 'post' );
- // fix up special html fields
- $post['content'] = JRequest::getVar( 'content', '', 'post', 'string', JREQUEST_ALLOWRAW );
- $post['client_id'] = $client->id;
-
- $row =& JTable::getInstance('module');
-
- if (!$row->bind( $post, 'selections' )) {
- return JError::raiseWarning( 500, $row->getError() );
- }
-
- if (!$row->check()) {
- return JError::raiseWarning( 500, $row->getError() );
- }
-
- // if new item, order last in appropriate group
- if (!$row->id) {
- $where = 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ;
- $row->ordering = $row->getNextOrder( $where );
- }
-
- if (!$row->store()) {
- return JError::raiseWarning( 500, $row->getError() );
- }
- $row->checkin();
-
- $menus = JRequest::getVar( 'menus', '', 'post', 'word' );
- $selections = JRequest::getVar( 'selections', array(), 'post', 'array' );
- JArrayHelper::toInteger($selections);
-
- // delete old module to menu item associations
- $query = 'DELETE FROM #__modules_menu'
- . ' WHERE moduleid = '.(int) $row->id
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getError() );
- }
-
- // check needed to stop a module being assigned to `All`
- // and other menu items resulting in a module being displayed twice
- if ( $menus == 'all' ) {
- // assign new module to `all` menu item associations
- $query = 'INSERT INTO #__modules_menu'
- . ' SET moduleid = '.(int) $row->id.' , menuid = 0'
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getError() );
- }
- }
- else
- {
- foreach ($selections as $menuid)
- {
- // this check for the blank spaces in the select box that have been added for cosmetic reasons
- if ( (int) $menuid >= 0 ) {
- // assign new module to menu item associations
- $query = 'INSERT INTO #__modules_menu'
- . ' SET moduleid = '.(int) $row->id .', menuid = '.(int) $menuid
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getError() );
- }
- }
- }
- }
-
- // clean cache for all 3 front-end user groups (guest, reg, special)
- $cache =& JFactory::getCache();
- $cache->remove($row->id . '0', $row->module);
- $cache->remove($row->id . '1', $row->module);
- $cache->remove($row->id . '2', $row->module);
- // clean content cache because of loadposition plugin
- $cache->clean( 'com_content' );
-
- $this->setMessage( JText::_( 'Item saved' ) );
- switch ($this->getTask())
- {
- case 'apply':
- $this->setRedirect( 'index.php?option=com_modules&client='. $client->id .'&task=edit&id='. $row->id );
- break;
- }
- }
-
- /**
- * Compiles information to add or edit a module
- * @param string The current GET/POST option
- * @param integer The unique id of the record to edit
- */
- function edit( )
- {
- // Initialize some variables
- $db =& JFactory::getDBO();
- $user =& JFactory::getUser();
-
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $module = JRequest::getVar( 'module', '', '', 'cmd' );
- $id = JRequest::getVar( 'id', 0, 'method', 'int' );
- $cid = JRequest::getVar( 'cid', array( $id ), 'method', 'array' );
- JArrayHelper::toInteger($cid, array(0));
-
- $model = &$this->getModel('module');
- $model->setState( 'id', $cid[0] );
- $model->setState( 'clientId', $client->id );
-
- $lists = array();
- $row =& JTable::getInstance('module');
- // load the row from the db table
- $row->load( (int) $cid[0] );
- // fail if checked out not by 'me'
- if ($row->isCheckedOut( $user->get('id') )) {
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
- return JError::raiseWarning( 500, JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The module' ), $row->title ) );
- }
-
- $row->content = htmlspecialchars($row->content, ENT_COMPAT, 'UTF-8');
-
- if ( $cid[0] ) {
- $row->checkout( $user->get('id') );
- }
- // if a new record we must still prime the JTableModel object with a default
- // position and the order; also add an extra item to the order list to
- // place the 'new' record in last position if desired
- if ($cid[0] == 0) {
- $row->position = 'left';
- $row->showtitle = true;
- $row->published = 1;
- //$row->ordering = $l;
-
- $row->module = $module;
- }
-
- if ($client->id == 1)
- {
- $where = 'client_id = 1';
- $lists['client_id'] = 1;
- $path = 'mod1_xml';
- }
- else
- {
- $where = 'client_id = 0';
- $lists['client_id'] = 0;
- $path = 'mod0_xml';
- }
-
- $query = 'SELECT position, ordering, showtitle, title'
- . ' FROM #__modules'
- . ' WHERE '. $where
- . ' ORDER BY ordering'
- ;
- $db->setQuery( $query );
- $orders = $db->loadObjectList();
- if ($db->getErrorNum()) {
- echo $db->stderr();
- return false;
- }
-
- $orders2 = array();
-
- $l = 0;
- $r = 0;
- for ($i=0, $n=count( $orders ); $i < $n; $i++) {
- $ord = 0;
- if (array_key_exists( $orders[$i]->position, $orders2 )) {
- $ord =count( array_keys( $orders2[$orders[$i]->position] ) ) + 1;
- }
-
- $orders2[$orders[$i]->position][] = JHTML::_('select.option', $ord, $ord.'::'.addslashes( $orders[$i]->title ) );
- }
-
- // get selected pages for $lists['selections']
- if ( $cid[0] ) {
- $query = 'SELECT menuid AS value'
- . ' FROM #__modules_menu'
- . ' WHERE moduleid = '.(int) $row->id
- ;
- $db->setQuery( $query );
- $lookup = $db->loadObjectList();
- if (empty( $lookup )) {
- $lookup = array( JHTML::_('select.option', '-1' ) );
- $row->pages = 'none';
- } elseif (count($lookup) == 1 && $lookup[0]->value == 0) {
- $row->pages = 'all';
- } else {
- $row->pages = null;
- }
- } else {
- $lookup = array( JHTML::_('select.option', 0, JText::_( 'All' ) ) );
- $row->pages = 'all';
- }
-
- if ( $row->access == 99 || $row->client_id == 1 || $lists['client_id'] ) {
- $lists['access'] = 'Administrator';
- $lists['showtitle'] = 'N/A ';
- $lists['selections'] = 'N/A';
- } else {
- if ( $client->id == '1' ) {
- $lists['access'] = 'N/A';
- $lists['selections'] = 'N/A';
- } else {
- $lists['access'] = JHTML::_('list.accesslevel', $row );
-
- $selections = JHTML::_('menu.linkoptions');
- $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' );
- }
- $lists['showtitle'] = JHTML::_('select.booleanlist', 'showtitle', 'class="inputbox"', $row->showtitle );
- }
-
- // build the html select list for published
- $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published );
-
- $row->description = '';
-
- $lang =& JFactory::getLanguage();
- if ( $client->id != '1' ) {
- $lang->load( trim($row->module), JPATH_SITE );
- } else {
- $lang->load( trim($row->module) );
- }
-
- // xml file for module
- if ($row->module == 'custom') {
- $xmlfile = JApplicationHelper::getPath( $path, 'mod_custom' );
- } else {
- $xmlfile = JApplicationHelper::getPath( $path, $row->module );
- }
-
- $data = JApplicationHelper::parseXMLInstallFile($xmlfile);
- if ($data)
- {
- foreach($data as $key => $value) {
- $row->$key = $value;
- }
- }
-
- // get params definitions
- $params = new JParameter( $row->params, $xmlfile, 'module' );
-
- require_once( JApplicationHelper::getPath( 'admin_html' ) );
- HTML_modules::edit( $model, $row, $orders2, $lists, $params, $client );
- }
-
- /**
- * Displays a list to select the creation of a new module
- */
- function add()
- {
- global $mainframe;
-
- // Initialize some variables
- $modules = array();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
-
- // path to search for modules
- if ($client->id == '1') {
- $path = JPATH_ADMINISTRATOR.DS.'modules';
- $langbase = JPATH_ADMINISTRATOR;
- } else {
- $path = JPATH_ROOT.DS.'modules';
- $langbase = JPATH_ROOT;
- }
-
- jimport('joomla.filesystem.folder');
- $dirs = JFolder::folders( $path );
- $lang =& JFactory::getLanguage();
-
- foreach ($dirs as $dir)
- {
- if (substr( $dir, 0, 4 ) == 'mod_')
- {
- $files = JFolder::files( $path.DS.$dir, '^([_A-Za-z0-9]*)\.xml$' );
- $module = new stdClass;
- $module->file = $files[0];
- $module->module = str_replace( '.xml', '', $files[0] );
- $module->path = $path.DS.$dir;
- $modules[] = $module;
-
- $lang->load( $module->module, $langbase );
- }
- }
-
- require_once( JPATH_COMPONENT.DS.'helpers'.DS.'xml.php' );
- ModulesHelperXML::parseXMLModuleFile( $modules, $client );
-
- $n = count($modules);
- for ($i = 0; $i < $n; $i++) {
- $modules[$i]->name = JText::_(stripslashes($modules[$i]->name));
- }
-
- // sort array of objects alphabetically by name
- JArrayHelper::sortObjects( $modules, 'name' );
-
- require_once( JApplicationHelper::getPath( 'admin_html' ) );
- HTML_modules::add( $modules, $client );
- }
-
- /**
- * Deletes one or more modules
- *
- * Also deletes associated entries in the #__module_menu table.
- * @param array An array of unique category id numbers
- */
- function remove()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger( $cid );
-
- if (empty( $cid )) {
- return JError::raiseWarning( 500, 'No items selected' );
- }
-
- $cids = implode( ',', $cid );
-
- // pasamio: Disabled this as it breaks the uninstall ability!
- /*$query = 'SELECT id, module, title, iscore, params'
- . ' FROM #__modules WHERE id IN ('.$cids.')'
- ;
- $db->setQuery( $query );
- if (!($rows = $db->loadObjectList())) {
- return JError::raiseError( 500, $db->getErrorMsg() );
- }*/
-
- // remove mappings first (lest we leave orphans)
- $query = 'DELETE FROM #__modules_menu'
- . ' WHERE moduleid IN ( '.$cids.' )'
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseError( 500, $db->getErrorMsg() );
- }
- // remove module
- $query = 'DELETE FROM #__modules'
- . ' WHERE id IN ('.$cids.')'
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseError( 500, $db->getErrorMsg() );
- }
-
- $this->setMessage( JText::sprintf( 'Items removed', count( $cid ) ) );
- }
-
- /**
- * Publishes or Unpublishes one or more modules
- */
- function publish()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $user =& JFactory::getUser();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $cache = & JFactory::getCache();
- $cache->clean( 'com_content' );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $task = $this->getTask();
- $publish = ($task == 'publish');
-
- if (empty( $cid )) {
- return JError::raiseWarning( 500, 'No items selected' );
- }
-
- $cids = implode( ',', $cid );
-
- $query = 'UPDATE #__modules'
- . ' SET published = ' . intval( $publish )
- . ' WHERE id IN ( '.$cids.' )'
- . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'
- ;
- $db->setQuery( $query );
- if (!$db->query()) {
- return JError::raiseWarning( 500, $db->getErrorMsg() );
- }
-
- if (count( $cid ) == 1) {
- $row =& JTable::getInstance('module');
- $row->checkin( $cid[0] );
- }
- }
-
- /**
- * Cancels an edit operation
- */
- function cancel()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $row =& JTable::getInstance('module');
- // ignore array elements
- $row->bind(JRequest::get('post'), 'selections params' );
- $row->checkin();
- }
-
- /**
- * Moves the order of a record
- */
- function reorder()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $task = $this->getTask();
- $inc = ($task == 'orderup' ? -1 : 1);
-
- if (empty( $cid )) {
- return JError::raiseWarning( 500, 'No items selected' );
- }
-
- $row =& JTable::getInstance('module');
- $row->load( (int) $cid[0] );
-
- $row->move( $inc, 'position = '.$db->Quote( $row->position ).' AND client_id='.(int) $client->id );
- }
-
- /**
- * Changes the access level of a record
- */
- function access()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- $task = JRequest::getCmd( 'task' );
-
- if (empty( $cid )) {
- return JError::raiseWarning( 500, 'No items selected' );
- }
-
- switch ( $task )
- {
- case 'accesspublic':
- $access = 0;
- break;
-
- case 'accessregistered':
- $access = 1;
- break;
-
- case 'accessspecial':
- $access = 2;
- break;
- }
-
- $row =& JTable::getInstance('module');
- $row->load( (int) $cid[0] );
- $row->access = $access;
-
- if ( !$row->check() ) {
- JError::raiseWarning( 500, $row->getError() );
- }
- if ( !$row->store() ) {
- JError::raiseWarning( 500, $row->getError() );
- }
- }
-
- /**
- * Saves the orders of the supplied list
- */
- function saveOrder()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db =& JFactory::getDBO();
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (empty( $cid )) {
- return JError::raiseWarning( 500, 'No items selected' );
- }
-
- $total = count( $cid );
- $row =& JTable::getInstance('module');
- $groupings = array();
-
- $order = JRequest::getVar( 'order', array(0), 'post', 'array' );
- JArrayHelper::toInteger($order);
-
- // update ordering values
- for ($i = 0; $i < $total; $i++)
- {
- $row->load( (int) $cid[$i] );
- // track postions
- $groupings[] = $row->position;
-
- if ($row->ordering != $order[$i])
- {
- $row->ordering = $order[$i];
- if (!$row->store()) {
- return JError::raiseWarning( 500, $db->getErrorMsg() );
- }
- }
- }
-
- // execute updateOrder for each parent group
- $groupings = array_unique( $groupings );
- foreach ($groupings as $group){
- $row->reorder('position = '.$db->Quote($group).' AND client_id = '.(int) $client->id);
- }
-
- $this->setMessage (JText::_( 'New ordering saved' ));
- }
-
- function preview()
- {
- $document =& JFactory::getDocument();
- $document->setTitle(JText::_('Module Preview'));
-
- require_once( JApplicationHelper::getPath( 'admin_html' ) );
- HTML_modules::preview( );
- }
-}
+registerTask( 'apply', 'save' );
+ $this->registerTask( 'unpublish', 'publish' );
+ $this->registerTask( 'orderup', 'reorder' );
+ $this->registerTask( 'orderdown', 'reorder' );
+ $this->registerTask( 'accesspublic', 'access' );
+ $this->registerTask( 'accessregistered','access' );
+ $this->registerTask( 'accessspecial', 'access' );
+ }
+
+ /**
+ * Compiles a list of installed or defined modules
+ */
+ function view()
+ {
+ global $mainframe;
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $option = 'com_modules';
+
+ $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'm.position', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
+ $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
+ $filter_position = $mainframe->getUserStateFromRequest( $option.'filter_position', 'filter_position', '', 'cmd' );
+ $filter_type = $mainframe->getUserStateFromRequest( $option.'filter_type', 'filter_type', '', 'cmd' );
+ $filter_assigned = $mainframe->getUserStateFromRequest( $option.'filter_assigned', 'filter_assigned', '', 'cmd' );
+ $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
+
+ $where[] = 'm.client_id = '.(int) $client->id;
+
+ $joins[] = 'LEFT JOIN #__users AS u ON u.id = m.checked_out';
+ $joins[] = 'LEFT JOIN #__groups AS g ON g.id = m.access';
+ $joins[] = 'LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id';
+
+ // used by filter
+ if ( $filter_assigned ) {
+ $joins[] = 'LEFT JOIN #__templates_menu AS t ON t.menuid = mm.menuid';
+ $where[] = 't.template = '.$db->Quote($filter_assigned);
+ }
+ if ( $filter_position ) {
+ $where[] = 'm.position = '.$db->Quote($filter_position);
+ }
+ if ( $filter_type ) {
+ $where[] = 'm.module = '.$db->Quote($filter_type);
+ }
+ if ( $search ) {
+ $where[] = 'LOWER( m.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ }
+ if ( $filter_state ) {
+ if ( $filter_state == 'P' ) {
+ $where[] = 'm.published = 1';
+ } else if ($filter_state == 'U' ) {
+ $where[] = 'm.published = 0';
+ }
+ }
+
+ $where = ' WHERE ' . implode( ' AND ', $where );
+ $join = ' ' . implode( ' ', $joins );
+ if ($filter_order == 'm.ordering') {
+ $orderby = ' ORDER BY m.position, m.ordering '. $filter_order_Dir;
+ } else {
+ $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', m.ordering ASC';
+ }
+
+ // get the total number of records
+ $query = 'SELECT COUNT(DISTINCT m.id)'
+ . ' FROM #__modules AS m'
+ . $join
+ . $where
+ ;
+ $db->setQuery( $query );
+ $total = $db->loadResult();
+
+ jimport('joomla.html.pagination');
+ $pageNav = new JPagination( $total, $limitstart, $limit );
+
+ $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages'
+ . ' FROM #__modules AS m'
+ . $join
+ . $where
+ . ' GROUP BY m.id'
+ . $orderby
+ ;
+ $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
+ $rows = $db->loadObjectList();
+ if ($db->getErrorNum()) {
+ echo $db->stderr();
+ return false;
+ }
+
+ // get list of Positions for dropdown filter
+ $query = 'SELECT m.position AS value, m.position AS text'
+ . ' FROM #__modules as m'
+ . ' WHERE m.client_id = '.(int) $client->id
+ . ' GROUP BY m.position'
+ . ' ORDER BY m.position'
+ ;
+ $positions[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Position' ) .' -' );
+ $db->setQuery( $query );
+ $positions = array_merge( $positions, $db->loadObjectList() );
+ $lists['position'] = JHTML::_('select.genericlist', $positions, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_position" );
+
+ // get list of Positions for dropdown filter
+ $query = 'SELECT module AS value, module AS text'
+ . ' FROM #__modules'
+ . ' WHERE client_id = '.(int) $client->id
+ . ' GROUP BY module'
+ . ' ORDER BY module'
+ ;
+ $db->setQuery( $query );
+ $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Type' ) .' -' );
+ $types = array_merge( $types, $db->loadObjectList() );
+ $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_type" );
+
+ // state filter
+ $lists['state'] = JHTML::_('grid.state', $filter_state );
+
+ // template assignment filter
+ $query = 'SELECT DISTINCT(template) AS text, template AS value'.
+ ' FROM #__templates_menu' .
+ ' WHERE client_id = '.(int) $client->id;
+ $db->setQuery( $query );
+ $assigned[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Template' ) .' -' );
+ $assigned = array_merge( $assigned, $db->loadObjectList() );
+ $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_assigned" );
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ require_once( JApplicationHelper::getPath( 'admin_html' ) );
+ HTML_modules::view( $rows, $client, $pageNav, $lists );
+ }
+
+ /**
+ * Compiles information to add or edit a module
+ * @param string The current GET/POST option
+ * @param integer The unique id of the record to edit
+ */
+ function copy()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ $n = count( $cid );
+
+ if ($n == 0) {
+ return JError::raiseWarning( 500, JText::_( 'No items selected' ) );
+ }
+
+ $row =& JTable::getInstance('module');
+ $tuples = array();
+
+ foreach ($cid as $id)
+ {
+ // load the row from the db table
+ $row->load( (int) $id );
+ $row->title = JText::sprintf( 'Copy of', $row->title );
+ $row->id = 0;
+ $row->iscore = 0;
+ $row->published = 0;
+
+ if (!$row->check()) {
+ return JError::raiseWarning( 500, $row->getError() );
+ }
+ if (!$row->store()) {
+ return JError::raiseWarning( 500, $row->getError() );
+ }
+ $row->checkin();
+
+ $row->reorder( 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id );
+
+ $query = 'SELECT menuid'
+ . ' FROM #__modules_menu'
+ . ' WHERE moduleid = '.(int) $cid[0]
+ ;
+ $db->setQuery( $query );
+ $rows = $db->loadResultArray();
+
+ foreach ($rows as $menuid) {
+ $tuples[] = '('.(int) $row->id.','.(int) $menuid.')';
+ }
+ }
+
+ if (!empty( $tuples ))
+ {
+ // Module-Menu Mapping: Do it in one query
+ $query = 'INSERT INTO #__modules_menu (moduleid,menuid) VALUES '.implode( ',', $tuples );
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+ }
+
+ $msg = JText::sprintf( 'Items Copied', $n );
+ $this->setRedirect( 'index.php?option=com_modules&client='. $client->id, $msg );
+ }
+
+ /**
+ * Saves the module after an edit form submit
+ */
+ function save()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ global $mainframe;
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $post = JRequest::get( 'post' );
+ // fix up special html fields
+ $post['content'] = JRequest::getVar( 'content', '', 'post', 'string', JREQUEST_ALLOWRAW );
+ $post['client_id'] = $client->id;
+
+ $row =& JTable::getInstance('module');
+
+ if (!$row->bind( $post, 'selections' )) {
+ return JError::raiseWarning( 500, $row->getError() );
+ }
+
+ if (!$row->check()) {
+ return JError::raiseWarning( 500, $row->getError() );
+ }
+
+ // if new item, order last in appropriate group
+ if (!$row->id) {
+ $where = 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ;
+ $row->ordering = $row->getNextOrder( $where );
+ }
+
+ if (!$row->store()) {
+ return JError::raiseWarning( 500, $row->getError() );
+ }
+ $row->checkin();
+
+ $menus = JRequest::getVar( 'menus', '', 'post', 'word' );
+ $selections = JRequest::getVar( 'selections', array(), 'post', 'array' );
+ JArrayHelper::toInteger($selections);
+
+ // delete old module to menu item associations
+ $query = 'DELETE FROM #__modules_menu'
+ . ' WHERE moduleid = '.(int) $row->id
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+
+ // check needed to stop a module being assigned to `All`
+ // and other menu items resulting in a module being displayed twice
+ if ( $menus == 'all' ) {
+ // assign new module to `all` menu item associations
+ $query = 'INSERT INTO #__modules_menu'
+ . ' SET moduleid = '.(int) $row->id.' , menuid = 0'
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+ }
+ else
+ {
+ foreach ($selections as $menuid)
+ {
+ // this check for the blank spaces in the select box that have been added for cosmetic reasons
+ if ( (int) $menuid >= 0 ) {
+ // assign new module to menu item associations
+ $query = 'INSERT INTO #__modules_menu'
+ . ' SET moduleid = '.(int) $row->id .', menuid = '.(int) $menuid
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getError() );
+ }
+ }
+ }
+ }
+
+ // clean cache for all 3 front-end user groups (guest, reg, special)
+ $cache =& JFactory::getCache();
+ $cache->remove($row->id . '0', $row->module);
+ $cache->remove($row->id . '1', $row->module);
+ $cache->remove($row->id . '2', $row->module);
+ // clean content cache because of loadposition plugin
+ $cache->clean( 'com_content' );
+
+ $this->setMessage( JText::_( 'Item saved' ) );
+ switch ($this->getTask())
+ {
+ case 'apply':
+ $this->setRedirect( 'index.php?option=com_modules&client='. $client->id .'&task=edit&id='. $row->id );
+ break;
+ }
+ }
+
+ /**
+ * Compiles information to add or edit a module
+ * @param string The current GET/POST option
+ * @param integer The unique id of the record to edit
+ */
+ function edit( )
+ {
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $module = JRequest::getVar( 'module', '', '', 'cmd' );
+ $id = JRequest::getVar( 'id', 0, 'method', 'int' );
+ $cid = JRequest::getVar( 'cid', array( $id ), 'method', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+
+ $model = &$this->getModel('module');
+ $model->setState( 'id', $cid[0] );
+ $model->setState( 'clientId', $client->id );
+
+ $lists = array();
+ $row =& JTable::getInstance('module');
+ // load the row from the db table
+ $row->load( (int) $cid[0] );
+ // fail if checked out not by 'me'
+ if ($row->isCheckedOut( $user->get('id') )) {
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+ return JError::raiseWarning( 500, JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The module' ), $row->title ) );
+ }
+
+ $row->content = htmlspecialchars($row->content, ENT_COMPAT, 'UTF-8');
+
+ if ( $cid[0] ) {
+ $row->checkout( $user->get('id') );
+ }
+ // if a new record we must still prime the JTableModel object with a default
+ // position and the order; also add an extra item to the order list to
+ // place the 'new' record in last position if desired
+ if ($cid[0] == 0) {
+ $row->position = 'left';
+ $row->showtitle = true;
+ $row->published = 1;
+ //$row->ordering = $l;
+
+ $row->module = $module;
+ }
+
+ if ($client->id == 1)
+ {
+ $where = 'client_id = 1';
+ $lists['client_id'] = 1;
+ $path = 'mod1_xml';
+ }
+ else
+ {
+ $where = 'client_id = 0';
+ $lists['client_id'] = 0;
+ $path = 'mod0_xml';
+ }
+
+ $query = 'SELECT position, ordering, showtitle, title'
+ . ' FROM #__modules'
+ . ' WHERE '. $where
+ . ' ORDER BY ordering'
+ ;
+ $db->setQuery( $query );
+ $orders = $db->loadObjectList();
+ if ($db->getErrorNum()) {
+ echo $db->stderr();
+ return false;
+ }
+
+ $orders2 = array();
+
+ $l = 0;
+ $r = 0;
+ for ($i=0, $n=count( $orders ); $i < $n; $i++) {
+ $ord = 0;
+ if (array_key_exists( $orders[$i]->position, $orders2 )) {
+ $ord =count( array_keys( $orders2[$orders[$i]->position] ) ) + 1;
+ }
+
+ $orders2[$orders[$i]->position][] = JHTML::_('select.option', $ord, $ord.'::'.addslashes( $orders[$i]->title ) );
+ }
+
+ // get selected pages for $lists['selections']
+ if ( $cid[0] ) {
+ $query = 'SELECT menuid AS value'
+ . ' FROM #__modules_menu'
+ . ' WHERE moduleid = '.(int) $row->id
+ ;
+ $db->setQuery( $query );
+ $lookup = $db->loadObjectList();
+ if (empty( $lookup )) {
+ $lookup = array( JHTML::_('select.option', '-1' ) );
+ $row->pages = 'none';
+ } elseif (count($lookup) == 1 && $lookup[0]->value == 0) {
+ $row->pages = 'all';
+ } else {
+ $row->pages = null;
+ }
+ } else {
+ $lookup = array( JHTML::_('select.option', 0, JText::_( 'All' ) ) );
+ $row->pages = 'all';
+ }
+
+ if ( $row->access == 99 || $row->client_id == 1 || $lists['client_id'] ) {
+ $lists['access'] = 'Administrator';
+ $lists['showtitle'] = 'N/A ';
+ $lists['selections'] = 'N/A';
+ } else {
+ if ( $client->id == '1' ) {
+ $lists['access'] = 'N/A';
+ $lists['selections'] = 'N/A';
+ } else {
+ $lists['access'] = JHTML::_('list.accesslevel', $row );
+
+ $selections = JHTML::_('menu.linkoptions');
+ $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' );
+ }
+ $lists['showtitle'] = JHTML::_('select.booleanlist', 'showtitle', 'class="inputbox"', $row->showtitle );
+ }
+
+ // build the html select list for published
+ $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published );
+
+ $row->description = '';
+
+ $lang =& JFactory::getLanguage();
+ if ( $client->id != '1' ) {
+ $lang->load( trim($row->module), JPATH_SITE );
+ } else {
+ $lang->load( trim($row->module) );
+ }
+
+ // xml file for module
+ if ($row->module == 'custom') {
+ $xmlfile = JApplicationHelper::getPath( $path, 'mod_custom' );
+ } else {
+ $xmlfile = JApplicationHelper::getPath( $path, $row->module );
+ }
+
+ $data = JApplicationHelper::parseXMLInstallFile($xmlfile);
+ if ($data)
+ {
+ foreach($data as $key => $value) {
+ $row->$key = $value;
+ }
+ }
+
+ // get params definitions
+ $params = new JParameter( $row->params, $xmlfile, 'module' );
+
+ require_once( JApplicationHelper::getPath( 'admin_html' ) );
+ HTML_modules::edit( $model, $row, $orders2, $lists, $params, $client );
+ }
+
+ /**
+ * Displays a list to select the creation of a new module
+ */
+ function add()
+ {
+ global $mainframe;
+
+ // Initialize some variables
+ $modules = array();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+
+ // path to search for modules
+ if ($client->id == '1') {
+ $path = JPATH_ADMINISTRATOR.DS.'modules';
+ $langbase = JPATH_ADMINISTRATOR;
+ } else {
+ $path = JPATH_ROOT.DS.'modules';
+ $langbase = JPATH_ROOT;
+ }
+
+ jimport('joomla.filesystem.folder');
+ $dirs = JFolder::folders( $path );
+ $lang =& JFactory::getLanguage();
+
+ foreach ($dirs as $dir)
+ {
+ if (substr( $dir, 0, 4 ) == 'mod_')
+ {
+ $files = JFolder::files( $path.DS.$dir, '^([_A-Za-z0-9]*)\.xml$' );
+ $module = new stdClass;
+ $module->file = $files[0];
+ $module->module = str_replace( '.xml', '', $files[0] );
+ $module->path = $path.DS.$dir;
+ $modules[] = $module;
+
+ $lang->load( $module->module, $langbase );
+ }
+ }
+
+ require_once( JPATH_COMPONENT.DS.'helpers'.DS.'xml.php' );
+ ModulesHelperXML::parseXMLModuleFile( $modules, $client );
+
+ $n = count($modules);
+ for ($i = 0; $i < $n; $i++) {
+ $modules[$i]->name = JText::_(stripslashes($modules[$i]->name));
+ }
+
+ // sort array of objects alphabetically by name
+ JArrayHelper::sortObjects( $modules, 'name' );
+
+ require_once( JApplicationHelper::getPath( 'admin_html' ) );
+ HTML_modules::add( $modules, $client );
+ }
+
+ /**
+ * Deletes one or more modules
+ *
+ * Also deletes associated entries in the #__module_menu table.
+ * @param array An array of unique category id numbers
+ */
+ function remove()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger( $cid );
+
+ if (empty( $cid )) {
+ return JError::raiseWarning( 500, 'No items selected' );
+ }
+
+ $cids = implode( ',', $cid );
+
+ // pasamio: Disabled this as it breaks the uninstall ability!
+ /*$query = 'SELECT id, module, title, iscore, params'
+ . ' FROM #__modules WHERE id IN ('.$cids.')'
+ ;
+ $db->setQuery( $query );
+ if (!($rows = $db->loadObjectList())) {
+ return JError::raiseError( 500, $db->getErrorMsg() );
+ }*/
+
+ // remove mappings first (lest we leave orphans)
+ $query = 'DELETE FROM #__modules_menu'
+ . ' WHERE moduleid IN ( '.$cids.' )'
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseError( 500, $db->getErrorMsg() );
+ }
+ // remove module
+ $query = 'DELETE FROM #__modules'
+ . ' WHERE id IN ('.$cids.')'
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseError( 500, $db->getErrorMsg() );
+ }
+
+ $this->setMessage( JText::sprintf( 'Items removed', count( $cid ) ) );
+ }
+
+ /**
+ * Publishes or Unpublishes one or more modules
+ */
+ function publish()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $cache = & JFactory::getCache();
+ $cache->clean( 'com_content' );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $task = $this->getTask();
+ $publish = ($task == 'publish');
+
+ if (empty( $cid )) {
+ return JError::raiseWarning( 500, 'No items selected' );
+ }
+
+ $cids = implode( ',', $cid );
+
+ $query = 'UPDATE #__modules'
+ . ' SET published = ' . intval( $publish )
+ . ' WHERE id IN ( '.$cids.' )'
+ . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ return JError::raiseWarning( 500, $db->getErrorMsg() );
+ }
+
+ if (count( $cid ) == 1) {
+ $row =& JTable::getInstance('module');
+ $row->checkin( $cid[0] );
+ }
+ }
+
+ /**
+ * Cancels an edit operation
+ */
+ function cancel()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $row =& JTable::getInstance('module');
+ // ignore array elements
+ $row->bind(JRequest::get('post'), 'selections params' );
+ $row->checkin();
+ }
+
+ /**
+ * Moves the order of a record
+ */
+ function reorder()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $task = $this->getTask();
+ $inc = ($task == 'orderup' ? -1 : 1);
+
+ if (empty( $cid )) {
+ return JError::raiseWarning( 500, 'No items selected' );
+ }
+
+ $row =& JTable::getInstance('module');
+ $row->load( (int) $cid[0] );
+
+ $row->move( $inc, 'position = '.$db->Quote( $row->position ).' AND client_id='.(int) $client->id );
+ }
+
+ /**
+ * Changes the access level of a record
+ */
+ function access()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ $task = JRequest::getCmd( 'task' );
+
+ if (empty( $cid )) {
+ return JError::raiseWarning( 500, 'No items selected' );
+ }
+
+ switch ( $task )
+ {
+ case 'accesspublic':
+ $access = 0;
+ break;
+
+ case 'accessregistered':
+ $access = 1;
+ break;
+
+ case 'accessspecial':
+ $access = 2;
+ break;
+ }
+
+ $row =& JTable::getInstance('module');
+ $row->load( (int) $cid[0] );
+ $row->access = $access;
+
+ if ( !$row->check() ) {
+ JError::raiseWarning( 500, $row->getError() );
+ }
+ if ( !$row->store() ) {
+ JError::raiseWarning( 500, $row->getError() );
+ }
+ }
+
+ /**
+ * Saves the orders of the supplied list
+ */
+ function saveOrder()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db =& JFactory::getDBO();
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $this->setRedirect( 'index.php?option=com_modules&client='.$client->id );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (empty( $cid )) {
+ return JError::raiseWarning( 500, 'No items selected' );
+ }
+
+ $total = count( $cid );
+ $row =& JTable::getInstance('module');
+ $groupings = array();
+
+ $order = JRequest::getVar( 'order', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($order);
+
+ // update ordering values
+ for ($i = 0; $i < $total; $i++)
+ {
+ $row->load( (int) $cid[$i] );
+ // track postions
+ $groupings[] = $row->position;
+
+ if ($row->ordering != $order[$i])
+ {
+ $row->ordering = $order[$i];
+ if (!$row->store()) {
+ return JError::raiseWarning( 500, $db->getErrorMsg() );
+ }
+ }
+ }
+
+ // execute updateOrder for each parent group
+ $groupings = array_unique( $groupings );
+ foreach ($groupings as $group){
+ $row->reorder('position = '.$db->Quote($group).' AND client_id = '.(int) $client->id);
+ }
+
+ $this->setMessage (JText::_( 'New ordering saved' ));
+ }
+
+ function preview()
+ {
+ $document =& JFactory::getDocument();
+ $document->setTitle(JText::_('Module Preview'));
+
+ require_once( JApplicationHelper::getPath( 'admin_html' ) );
+ HTML_modules::preview( );
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php b/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php
index c75479bb..95afc91e 100644
--- a/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php
+++ b/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php
@@ -1,46 +1,46 @@
- $row)
- {
- if ($row->module == '')
- {
- $rows[$i]->name = 'custom';
- $rows[$i]->module = 'custom';
- $rows[$i]->descrip = 'Custom created module, using Module Manager `New` function';
- }
- else
- {
- $data = JApplicationHelper::parseXMLInstallFile( $row->path.DS.$row->file);
-
- if ( $data['type'] == 'module' )
- {
- $rows[$i]->name = $data['name'];
- $rows[$i]->descrip = $data['description'];
- }
- }
- }
- }
+ $row)
+ {
+ if ($row->module == '')
+ {
+ $rows[$i]->name = 'custom';
+ $rows[$i]->module = 'custom';
+ $rows[$i]->descrip = 'Custom created module, using Module Manager `New` function';
+ }
+ else
+ {
+ $data = JApplicationHelper::parseXMLInstallFile( $row->path.DS.$row->file);
+
+ if ( $data['type'] == 'module' )
+ {
+ $rows[$i]->name = $data['name'];
+ $rows[$i]->descrip = $data['description'];
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_modules/models/module.php b/oss/joomla/trunk/administrator/components/com_modules/models/module.php
index 495e0de4..95ebe865 100644
--- a/oss/joomla/trunk/administrator/components/com_modules/models/module.php
+++ b/oss/joomla/trunk/administrator/components/com_modules/models/module.php
@@ -1,170 +1,170 @@
-getTable( 'Module', 'JTable' );
- if ($id = $this->getState( 'id' )) {
- $instance->load( (int) $id );
- }
- }
- return $instance;
- }
-
- function &_getXML()
- {
- if (!$this->_xml)
- {
- $clientId = $this->getState( 'clientId', 0 );
- $path = ($clientId == 1) ? 'mod1_xml' : 'mod0_xml';
- $module = &$this->getModule();
-
- if ($module->module == 'custom') {
- $xmlpath = JApplicationHelper::getPath( $path, 'mod_custom' );
- } else {
- $xmlpath = JApplicationHelper::getPath( $path, $module->module );
- }
-
- if (file_exists($xmlpath))
- {
- $xml =& JFactory::getXMLParser('Simple');
- if ($xml->loadFile($xmlpath)) {
- $this->_xml = &$xml;
- }
- }
- }
- return $this->_xml;
- }
-
- function &getParams()
- {
- // Get the state parameters
- $module =& $this->getModule();
- $params = new JParameter($module->params);
-
- if ($xml =& $this->_getXML())
- {
- if ($ps = & $xml->document->params) {
- foreach ($ps as $p)
- {
- $params->setXML( $p );
- }
- }
- }
- return $params;
- }
-
- function getPositions()
- {
- jimport('joomla.filesystem.folder');
-
- $client =& JApplicationHelper::getClientInfo($this->getState('clientId'));
- if ($client === false) {
- return false;
- }
-
- //Get the database object
- $db =& JFactory::getDBO();
-
- // template assignment filter
- $query = 'SELECT DISTINCT(template) AS text, template AS value'.
- ' FROM #__templates_menu' .
- ' WHERE client_id = '.(int) $client->id;
- $db->setQuery( $query );
- $templates = $db->loadObjectList();
-
- // Get a list of all module positions as set in the database
- $query = 'SELECT DISTINCT(position)'.
- ' FROM #__modules' .
- ' WHERE client_id = '.(int) $client->id;
- $db->setQuery( $query );
- $positions = $db->loadResultArray();
- $positions = (is_array($positions)) ? $positions : array();
-
- // Get a list of all template xml files for a given application
-
- // Get the xml parser first
- for ($i = 0, $n = count($templates); $i < $n; $i++ )
- {
- $path = $client->path.DS.'templates'.DS.$templates[$i]->value;
-
- $xml =& JFactory::getXMLParser('Simple');
- if ($xml->loadFile($path.DS.'templateDetails.xml'))
- {
- $p =& $xml->document->getElementByPath('positions');
- if (is_a($p, 'JSimpleXMLElement') && count($p->children()))
- {
- foreach ($p->children() as $child)
- {
- if (!in_array($child->data(), $positions)) {
- $positions[] = $child->data();
- }
- }
- }
- }
- }
-
- if(defined('_JLEGACY') && _JLEGACY == '1.0')
- {
- $positions[] = 'left';
- $positions[] = 'right';
- $positions[] = 'top';
- $positions[] = 'bottom';
- $positions[] = 'inset';
- $positions[] = 'banner';
- $positions[] = 'header';
- $positions[] = 'footer';
- $positions[] = 'newsflash';
- $positions[] = 'legals';
- $positions[] = 'pathway';
- $positions[] = 'breadcrumb';
- $positions[] = 'user1';
- $positions[] = 'user2';
- $positions[] = 'user3';
- $positions[] = 'user4';
- $positions[] = 'user5';
- $positions[] = 'user6';
- $positions[] = 'user7';
- $positions[] = 'user8';
- $positions[] = 'user9';
- $positions[] = 'advert1';
- $positions[] = 'advert2';
- $positions[] = 'advert3';
- $positions[] = 'debug';
- $positions[] = 'syndicate';
- }
-
- $positions = array_unique($positions);
- sort($positions);
-
- return $positions;
- }
-}
+getTable( 'Module', 'JTable' );
+ if ($id = $this->getState( 'id' )) {
+ $instance->load( (int) $id );
+ }
+ }
+ return $instance;
+ }
+
+ function &_getXML()
+ {
+ if (!$this->_xml)
+ {
+ $clientId = $this->getState( 'clientId', 0 );
+ $path = ($clientId == 1) ? 'mod1_xml' : 'mod0_xml';
+ $module = &$this->getModule();
+
+ if ($module->module == 'custom') {
+ $xmlpath = JApplicationHelper::getPath( $path, 'mod_custom' );
+ } else {
+ $xmlpath = JApplicationHelper::getPath( $path, $module->module );
+ }
+
+ if (file_exists($xmlpath))
+ {
+ $xml =& JFactory::getXMLParser('Simple');
+ if ($xml->loadFile($xmlpath)) {
+ $this->_xml = &$xml;
+ }
+ }
+ }
+ return $this->_xml;
+ }
+
+ function &getParams()
+ {
+ // Get the state parameters
+ $module =& $this->getModule();
+ $params = new JParameter($module->params);
+
+ if ($xml =& $this->_getXML())
+ {
+ if ($ps = & $xml->document->params) {
+ foreach ($ps as $p)
+ {
+ $params->setXML( $p );
+ }
+ }
+ }
+ return $params;
+ }
+
+ function getPositions()
+ {
+ jimport('joomla.filesystem.folder');
+
+ $client =& JApplicationHelper::getClientInfo($this->getState('clientId'));
+ if ($client === false) {
+ return false;
+ }
+
+ //Get the database object
+ $db =& JFactory::getDBO();
+
+ // template assignment filter
+ $query = 'SELECT DISTINCT(template) AS text, template AS value'.
+ ' FROM #__templates_menu' .
+ ' WHERE client_id = '.(int) $client->id;
+ $db->setQuery( $query );
+ $templates = $db->loadObjectList();
+
+ // Get a list of all module positions as set in the database
+ $query = 'SELECT DISTINCT(position)'.
+ ' FROM #__modules' .
+ ' WHERE client_id = '.(int) $client->id;
+ $db->setQuery( $query );
+ $positions = $db->loadResultArray();
+ $positions = (is_array($positions)) ? $positions : array();
+
+ // Get a list of all template xml files for a given application
+
+ // Get the xml parser first
+ for ($i = 0, $n = count($templates); $i < $n; $i++ )
+ {
+ $path = $client->path.DS.'templates'.DS.$templates[$i]->value;
+
+ $xml =& JFactory::getXMLParser('Simple');
+ if ($xml->loadFile($path.DS.'templateDetails.xml'))
+ {
+ $p =& $xml->document->getElementByPath('positions');
+ if (is_a($p, 'JSimpleXMLElement') && count($p->children()))
+ {
+ foreach ($p->children() as $child)
+ {
+ if (!in_array($child->data(), $positions)) {
+ $positions[] = $child->data();
+ }
+ }
+ }
+ }
+ }
+
+ if(defined('_JLEGACY') && _JLEGACY == '1.0')
+ {
+ $positions[] = 'left';
+ $positions[] = 'right';
+ $positions[] = 'top';
+ $positions[] = 'bottom';
+ $positions[] = 'inset';
+ $positions[] = 'banner';
+ $positions[] = 'header';
+ $positions[] = 'footer';
+ $positions[] = 'newsflash';
+ $positions[] = 'legals';
+ $positions[] = 'pathway';
+ $positions[] = 'breadcrumb';
+ $positions[] = 'user1';
+ $positions[] = 'user2';
+ $positions[] = 'user3';
+ $positions[] = 'user4';
+ $positions[] = 'user5';
+ $positions[] = 'user6';
+ $positions[] = 'user7';
+ $positions[] = 'user8';
+ $positions[] = 'user9';
+ $positions[] = 'advert1';
+ $positions[] = 'advert2';
+ $positions[] = 'advert3';
+ $positions[] = 'debug';
+ $positions[] = 'syndicate';
+ }
+
+ $positions = array_unique($positions);
+ sort($positions);
+
+ return $positions;
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_modules/modules.xml b/oss/joomla/trunk/administrator/components/com_modules/modules.xml
index ec6e6321..fc839d50 100644
--- a/oss/joomla/trunk/administrator/components/com_modules/modules.xml
+++ b/oss/joomla/trunk/administrator/components/com_modules/modules.xml
@@ -1,12 +1,12 @@
-
-
- Module Manager
- Joomla! Project
- 2006
- Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.5.0
- Module Manager
-
+
+
+ Module Manager
+ Joomla! Project
+ 2006
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5.0
+ Module Manager
+
diff --git a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php
index 0b69be78..1dcd37cf 100644
--- a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php
+++ b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php
@@ -1,73 +1,73 @@
-[ '. JText::_( 'New' ) .' ]', 'module.png' );
- JToolBarHelper::customX( 'edit', 'forward.png', 'forward_f2.png', 'Next', true );
- JToolBarHelper::cancel();
- if ($client->name == 'site') {
- JToolBarHelper::help( 'screen.modulessite.edit' );
- }
- else {
- JToolBarHelper::help( 'screen.modulesadministrator.edit');
- }
- }
-
- /**
- * Draws the menu for Editing an existing module
- */
- function _EDIT( $client )
- {
- $moduleType = JRequest::getCmd( 'module' );
- $cid = JRequest::getVar( 'cid', array(0), '', 'array' );
- JArrayHelper::toInteger($cid, array(0));
-
- JToolBarHelper::title( JText::_( 'Module' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'module.png' );
-
- if($moduleType == 'custom') {
- JToolBarHelper::Preview('index.php?option=com_modules&tmpl=component&client='.$client->id.'&pollid='.$cid[0]);
- }
-
- JToolBarHelper::save();
- JToolBarHelper::apply();
- if ( $cid[0] ) {
- // for existing items the button is renamed `close`
- JToolBarHelper::cancel( 'cancel', 'Close' );
- } else {
- JToolBarHelper::cancel();
- }
- JToolBarHelper::help( 'screen.modules.edit' );
- }
-
- function _DEFAULT($client)
- {
- JToolBarHelper::title( JText::_( 'Module Manager' ), 'module.png' );
- JToolBarHelper::publishList();
- JToolBarHelper::unpublishList();
- JToolBarHelper::custom( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true );
- JToolBarHelper::deleteList();
- JToolBarHelper::editListX();
- JToolBarHelper::addNewX();
- JToolBarHelper::help( 'screen.modules' );
- }
-}
+[ '. JText::_( 'New' ) .' ]', 'module.png' );
+ JToolBarHelper::customX( 'edit', 'forward.png', 'forward_f2.png', 'Next', true );
+ JToolBarHelper::cancel();
+ if ($client->name == 'site') {
+ JToolBarHelper::help( 'screen.modulessite.edit' );
+ }
+ else {
+ JToolBarHelper::help( 'screen.modulesadministrator.edit');
+ }
+ }
+
+ /**
+ * Draws the menu for Editing an existing module
+ */
+ function _EDIT( $client )
+ {
+ $moduleType = JRequest::getCmd( 'module' );
+ $cid = JRequest::getVar( 'cid', array(0), '', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+
+ JToolBarHelper::title( JText::_( 'Module' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'module.png' );
+
+ if($moduleType == 'custom') {
+ JToolBarHelper::Preview('index.php?option=com_modules&tmpl=component&client='.$client->id.'&pollid='.$cid[0]);
+ }
+
+ JToolBarHelper::save();
+ JToolBarHelper::apply();
+ if ( $cid[0] ) {
+ // for existing items the button is renamed `close`
+ JToolBarHelper::cancel( 'cancel', 'Close' );
+ } else {
+ JToolBarHelper::cancel();
+ }
+ JToolBarHelper::help( 'screen.modules.edit' );
+ }
+
+ function _DEFAULT($client)
+ {
+ JToolBarHelper::title( JText::_( 'Module Manager' ), 'module.png' );
+ JToolBarHelper::publishList();
+ JToolBarHelper::unpublishList();
+ JToolBarHelper::custom( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true );
+ JToolBarHelper::deleteList();
+ JToolBarHelper::editListX();
+ JToolBarHelper::addNewX();
+ JToolBarHelper::help( 'screen.modules' );
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php
index 568baa64..f08c22cf 100644
--- a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php
+++ b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php
@@ -1,36 +1,36 @@
-
-
-
-
-
-
- '. JText::_( 'Writable' ) .'';
- $unwriteable = ''. JText::_( 'Unwritable' ) .'';
-
- echo '
+
+
+ path .DS. 'templates' .DS. $template .DS. 'index.php';
+?>
+
+
+
+ path.DS.'templates'.DS.$template.DS.'css'.DS.$filename;
+
+?>
+
+ authorize('com_templates', 'manage')) {
- $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH'));
-}
-
-// Set the table directory
-JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_templates'.DS.'tables');
-
-// Import file dependencies
-require_once (JPATH_COMPONENT.DS.'helpers'.DS.'template.php');
-require_once (JPATH_COMPONENT.DS.'controller.php');
-
-$task = JRequest::getCmd('task');
-
-$client = JRequest::getVar('client', 0, '', 'int');
-
-if ($client == 1) {
- JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0');
- JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1', true);
-} elseif ($client == 0 && !$task) {
- JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0', true);
- JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1');
-} else {
- JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0');
- JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1');
-}
-
-switch ($task)
-{
- case 'edit' :
- TemplatesController::editTemplate();
- break;
-
- case 'save' :
- case 'apply' :
- TemplatesController::saveTemplate();
- break;
-
- case 'edit_source' :
- TemplatesController::editTemplateSource();
- break;
-
- case 'save_source' :
- case 'apply_source' :
- TemplatesController::saveTemplateSource();
- break;
-
- case 'choose_css' :
- TemplatesController::chooseTemplateCSS();
- break;
-
- case 'edit_css' :
- TemplatesController::editTemplateCSS();
- break;
-
- case 'save_css' :
- case 'apply_css' :
- TemplatesController::saveTemplateCSS();
- break;
-
- case 'publish' :
- case 'default' :
- TemplatesController::publishTemplate();
- break;
-
- case 'cancel' :
- TemplatesController::cancelTemplate();
- break;
-
- case 'save_positions' :
- TemplatesController::savePositions();
- break;
-
- case 'preview' :
- TemplatesController::previewTemplate();
- break;
-
- default :
- TemplatesController::viewTemplates();
- break;
+authorize('com_templates', 'manage')) {
+ $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH'));
+}
+
+// Set the table directory
+JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_templates'.DS.'tables');
+
+// Import file dependencies
+require_once (JPATH_COMPONENT.DS.'helpers'.DS.'template.php');
+require_once (JPATH_COMPONENT.DS.'controller.php');
+
+$task = JRequest::getCmd('task');
+
+$client = JRequest::getVar('client', 0, '', 'int');
+
+if ($client == 1) {
+ JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0');
+ JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1', true);
+} elseif ($client == 0 && !$task) {
+ JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0', true);
+ JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1');
+} else {
+ JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0');
+ JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1');
+}
+
+switch ($task)
+{
+ case 'edit' :
+ TemplatesController::editTemplate();
+ break;
+
+ case 'save' :
+ case 'apply' :
+ TemplatesController::saveTemplate();
+ break;
+
+ case 'edit_source' :
+ TemplatesController::editTemplateSource();
+ break;
+
+ case 'save_source' :
+ case 'apply_source' :
+ TemplatesController::saveTemplateSource();
+ break;
+
+ case 'choose_css' :
+ TemplatesController::chooseTemplateCSS();
+ break;
+
+ case 'edit_css' :
+ TemplatesController::editTemplateCSS();
+ break;
+
+ case 'save_css' :
+ case 'apply_css' :
+ TemplatesController::saveTemplateCSS();
+ break;
+
+ case 'publish' :
+ case 'default' :
+ TemplatesController::publishTemplate();
+ break;
+
+ case 'cancel' :
+ TemplatesController::cancelTemplate();
+ break;
+
+ case 'save_positions' :
+ TemplatesController::savePositions();
+ break;
+
+ case 'preview' :
+ TemplatesController::previewTemplate();
+ break;
+
+ default :
+ TemplatesController::viewTemplates();
+ break;
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_templates/controller.php b/oss/joomla/trunk/administrator/components/com_templates/controller.php
index c5fa8fb9..d419d5f5 100644
--- a/oss/joomla/trunk/administrator/components/com_templates/controller.php
+++ b/oss/joomla/trunk/administrator/components/com_templates/controller.php
@@ -1,500 +1,500 @@
-getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
- $limitstart = $mainframe->getUserStateFromRequest($option.'.'.$client->id.'.limitstart', 'limitstart', 0, 'int');
-
- $select[] = JHTML::_('select.option', '0', JText::_('Site'));
- $select[] = JHTML::_('select.option', '1', JText::_('Administrator'));
- $lists['client'] = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id);
-
- $tBaseDir = $client->path.DS.'templates';
-
- //get template xml file info
- $rows = array();
- $rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);
-
- // set dynamic template information
- for($i = 0; $i < count($rows); $i++) {
- $rows[$i]->assigned = TemplatesHelper::isTemplateAssigned($rows[$i]->directory);
- $rows[$i]->published = TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id);
- }
-
- jimport('joomla.html.pagination');
- $page = new JPagination(count($rows), $limitstart, $limit);
-
- $rows = array_slice($rows, $page->limitstart, $page->limit);
-
- require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
- TemplatesView::showTemplates($rows, $lists, $page, $option, $client);
- }
-
- /**
- * Show the template with module position in an iframe
- */
- function previewTemplate()
- {
- $template = JRequest::getVar('id', '', 'method', 'cmd');
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
-
- if (!$template)
- {
- return JError::raiseWarning( 500, JText::_('Template not specified') );
- }
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- JClientHelper::setCredentialsFromRequest('ftp');
-
- require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
- TemplatesView::previewTemplate($template, true, $client, $option);
- }
-
- /**
- * Publish, or make current, the selected template
- */
- function publishTemplate()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db = & JFactory::getDBO();
- $cid = JRequest::getVar('cid', array(), 'method', 'array');
- $cid = array(JFilterInput::clean(@$cid[0], 'cmd'));
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
-
- if ($cid[0])
- {
- $query = 'DELETE FROM #__templates_menu' .
- ' WHERE client_id = '.(int) $client->id .
- ' AND (menuid = 0 OR template = '.$db->Quote($cid[0]).')';
- $db->setQuery($query);
- $db->query();
-
- $query = 'INSERT INTO #__templates_menu' .
- ' SET client_id = '.(int) $client->id .', template = '.$db->Quote($cid[0]).', menuid = 0';
- $db->setQuery($query);
- $db->query();
- }
-
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id);
- }
-
- function editTemplate()
- {
- jimport('joomla.filesystem.path');
-
- // Initialize some variables
- $db = & JFactory::getDBO();
- $cid = JRequest::getVar('cid', array(), 'method', 'array');
- $cid = array(JFilterInput::clean(@$cid[0], 'cmd'));
- $template = $cid[0];
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
-
- if (!$cid[0]) {
- return JError::raiseWarning( 500, JText::_('Template not specified') );
- }
-
- $tBaseDir = JPath::clean($client->path.DS.'templates');
-
- if (!is_dir( $tBaseDir . DS . $template )) {
- return JError::raiseWarning( 500, JText::_('Template not found') );
- }
- $lang =& JFactory::getLanguage();
- $lang->load( 'tpl_'.$template, JPATH_ADMINISTRATOR );
-
- $ini = $client->path.DS.'templates'.DS.$template.DS.'params.ini';
- $xml = $client->path.DS.'templates'.DS.$template.DS.'templateDetails.xml';
- $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $template);
-
- jimport('joomla.filesystem.file');
- // Read the ini file
- if (JFile::exists($ini)) {
- $content = JFile::read($ini);
- } else {
- $content = null;
- }
-
- $params = new JParameter($content, $xml, 'template');
-
- $assigned = TemplatesHelper::isTemplateAssigned($row->directory);
- $default = TemplatesHelper::isTemplateDefault($row->directory, $client->id);
-
- if($client->id == '1') {
- $lists['selections'] = JText::_('Cannot assign an administrator template');
- } else {
- $lists['selections'] = TemplatesHelper::createMenuList($template);
- }
-
- if ($default) {
- $row->pages = 'all';
- } elseif (!$assigned) {
- $row->pages = 'none';
- } else {
- $row->pages = null;
- }
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
-
- require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
- TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template);
- }
-
- function saveTemplate()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $db = & JFactory::getDBO();
-
- $template = JRequest::getVar('id', '', 'method', 'cmd');
- $option = JRequest::getVar('option', '', '', 'cmd');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $menus = JRequest::getVar('selections', array(), 'post', 'array');
- $params = JRequest::getVar('params', array(), 'post', 'array');
- $default = JRequest::getBool('default');
- JArrayHelper::toInteger($menus);
-
- if (!$template) {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
- }
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- JClientHelper::setCredentialsFromRequest('ftp');
- $ftp = JClientHelper::getCredentials('ftp');
-
- $file = $client->path.DS.'templates'.DS.$template.DS.'params.ini';
-
- jimport('joomla.filesystem.file');
- if (JFile::exists($file) && count($params))
- {
- $registry = new JRegistry();
- $registry->loadArray($params);
- $txt = $registry->toString();
-
- // Try to make the params file writeable
- if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
- JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable'));
- }
-
- $return = JFile::write($file, $txt);
-
- // Try to make the params file unwriteable
- if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
- JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable'));
- }
-
- if (!$return) {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
- }
- }
-
- // Reset all existing assignments
- $query = 'DELETE FROM #__templates_menu' .
- ' WHERE client_id = 0' .
- ' AND template = '.$db->Quote( $template );
- $db->setQuery($query);
- $db->query();
-
- if ($default) {
- $menus = array( 0 );
- }
-
- foreach ($menus as $menuid)
- {
- // If 'None' is not in array
- if ((int) $menuid >= 0)
- {
- // check if there is already a template assigned to this menu item
- $query = 'DELETE FROM #__templates_menu' .
- ' WHERE client_id = 0' .
- ' AND menuid = '.(int) $menuid;
- $db->setQuery($query);
- $db->query();
-
- $query = 'INSERT INTO #__templates_menu' .
- ' SET client_id = 0, template = '. $db->Quote( $template ) .', menuid = '.(int) $menuid;
- $db->setQuery($query);
- $db->query();
- }
- }
-
- $task = JRequest::getCmd('task');
- if($task == 'apply') {
- $mainframe->redirect('index.php?option='.$option.'&task=edit&cid[]='.$template.'&client='.$client->id);
- } else {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id);
- }
- }
-
- function cancelTemplate()
- {
- global $mainframe;
-
- // Initialize some variables
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- JClientHelper::setCredentialsFromRequest('ftp');
-
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id);
- }
-
- function editTemplateSource()
- {
- global $mainframe;
-
- // Initialize some variables
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $template = JRequest::getVar('id', '', 'method', 'cmd');
- $file = $client->path.DS.'templates'.DS.$template.DS.'index.php';
-
- // Read the source file
- jimport('joomla.filesystem.file');
- $content = JFile::read($file);
-
- if ($content !== false)
- {
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
-
- $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
- require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
- TemplatesView::editTemplateSource($template, $content, $option, $client, $ftp);
- } else {
- $msg = JText::sprintf('Operation Failed Could not open', $file);
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg);
- }
- }
-
- function saveTemplateSource()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $template = JRequest::getVar('id', '', 'method', 'cmd');
- $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
-
- if (!$template) {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
- }
-
- if (!$filecontent) {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));
- }
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- JClientHelper::setCredentialsFromRequest('ftp');
- $ftp = JClientHelper::getCredentials('ftp');
-
- $file = $client->path.DS.'templates'.DS.$template.DS.'index.php';
-
- // Try to make the template file writeable
- if (!$ftp['enabled'] && !JPath::setPermissions($file, '0755')) {
- JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file writable'));
- }
-
- jimport('joomla.filesystem.file');
- $return = JFile::write($file, $filecontent);
-
- // Try to make the template file unwriteable
- if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) {
- JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file unwritable'));
- }
-
- if ($return)
- {
- $task = JRequest::getCmd('task');
- switch($task)
- {
- case 'apply_source':
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_source&id='.$template, JText::_('Template source saved'));
- break;
-
- case 'save_source':
- default:
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('Template source saved'));
- break;
- }
- }
- else {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
- }
- }
-
- function chooseTemplateCSS()
- {
- global $mainframe;
-
- // Initialize some variables
- $option = JRequest::getCmd('option');
- $template = JRequest::getVar('id', '', 'method', 'cmd');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
-
- // Determine template CSS directory
- $dir = $client->path.DS.'templates'.DS.$template.DS.'css';
-
- // List template .css files
- jimport('joomla.filesystem.folder');
- $files = JFolder::files($dir, '\.css$', false, false);
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- JClientHelper::setCredentialsFromRequest('ftp');
-
- require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
- TemplatesView::chooseCSSFiles($template, $dir, $files, $option, $client);
- }
-
- function editTemplateCSS()
- {
- global $mainframe;
-
- // Initialize some variables
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $template = JRequest::getVar('id', '', 'method', 'cmd');
- $filename = JRequest::getVar('filename', '', 'method', 'cmd');
-
- jimport('joomla.filesystem.file');
-
- if (JFile::getExt($filename) !== 'css') {
- $msg = JText::_('Wrong file type given, only CSS files can be edited.');
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=choose_css&id='.$template, $msg, 'error');
- }
-
- $content = JFile::read($client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename);
-
- if ($content !== false)
- {
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
-
- $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
- require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
- TemplatesView::editCSSSource($template, $filename, $content, $option, $client, $ftp);
- }
- else
- {
- $msg = JText::sprintf('Operation Failed Could not open', $client->path.$filename);
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg);
- }
- }
-
- function saveTemplateCSS()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Initialize some variables
- $option = JRequest::getCmd('option');
- $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
- $template = JRequest::getVar('id', '', 'post', 'cmd');
- $filename = JRequest::getVar('filename', '', 'post', 'cmd');
- $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
-
- if (!$template) {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
- }
-
- if (!$filecontent) {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));
- }
-
- // Set FTP credentials, if given
- jimport('joomla.client.helper');
- JClientHelper::setCredentialsFromRequest('ftp');
- $ftp = JClientHelper::getCredentials('ftp');
-
- $file = $client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename;
-
- // Try to make the css file writeable
- if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
- JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable'));
- }
-
- jimport('joomla.filesystem.file');
- $return = JFile::write($file, $filecontent);
-
- // Try to make the css file unwriteable
- if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
- JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable'));
- }
-
- if ($return)
- {
- $task = JRequest::getCmd('task');
- switch($task)
- {
- case 'apply_css':
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename, JText::_('File Saved'));
- break;
-
- case 'save_css':
- default:
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('File Saved'));
- break;
- }
- }
- else {
- $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
- }
- }
-}
+getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
+ $limitstart = $mainframe->getUserStateFromRequest($option.'.'.$client->id.'.limitstart', 'limitstart', 0, 'int');
+
+ $select[] = JHTML::_('select.option', '0', JText::_('Site'));
+ $select[] = JHTML::_('select.option', '1', JText::_('Administrator'));
+ $lists['client'] = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id);
+
+ $tBaseDir = $client->path.DS.'templates';
+
+ //get template xml file info
+ $rows = array();
+ $rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);
+
+ // set dynamic template information
+ for($i = 0; $i < count($rows); $i++) {
+ $rows[$i]->assigned = TemplatesHelper::isTemplateAssigned($rows[$i]->directory);
+ $rows[$i]->published = TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id);
+ }
+
+ jimport('joomla.html.pagination');
+ $page = new JPagination(count($rows), $limitstart, $limit);
+
+ $rows = array_slice($rows, $page->limitstart, $page->limit);
+
+ require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
+ TemplatesView::showTemplates($rows, $lists, $page, $option, $client);
+ }
+
+ /**
+ * Show the template with module position in an iframe
+ */
+ function previewTemplate()
+ {
+ $template = JRequest::getVar('id', '', 'method', 'cmd');
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+
+ if (!$template)
+ {
+ return JError::raiseWarning( 500, JText::_('Template not specified') );
+ }
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ JClientHelper::setCredentialsFromRequest('ftp');
+
+ require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
+ TemplatesView::previewTemplate($template, true, $client, $option);
+ }
+
+ /**
+ * Publish, or make current, the selected template
+ */
+ function publishTemplate()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db = & JFactory::getDBO();
+ $cid = JRequest::getVar('cid', array(), 'method', 'array');
+ $cid = array(JFilterInput::clean(@$cid[0], 'cmd'));
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+
+ if ($cid[0])
+ {
+ $query = 'DELETE FROM #__templates_menu' .
+ ' WHERE client_id = '.(int) $client->id .
+ ' AND (menuid = 0 OR template = '.$db->Quote($cid[0]).')';
+ $db->setQuery($query);
+ $db->query();
+
+ $query = 'INSERT INTO #__templates_menu' .
+ ' SET client_id = '.(int) $client->id .', template = '.$db->Quote($cid[0]).', menuid = 0';
+ $db->setQuery($query);
+ $db->query();
+ }
+
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id);
+ }
+
+ function editTemplate()
+ {
+ jimport('joomla.filesystem.path');
+
+ // Initialize some variables
+ $db = & JFactory::getDBO();
+ $cid = JRequest::getVar('cid', array(), 'method', 'array');
+ $cid = array(JFilterInput::clean(@$cid[0], 'cmd'));
+ $template = $cid[0];
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+
+ if (!$cid[0]) {
+ return JError::raiseWarning( 500, JText::_('Template not specified') );
+ }
+
+ $tBaseDir = JPath::clean($client->path.DS.'templates');
+
+ if (!is_dir( $tBaseDir . DS . $template )) {
+ return JError::raiseWarning( 500, JText::_('Template not found') );
+ }
+ $lang =& JFactory::getLanguage();
+ $lang->load( 'tpl_'.$template, JPATH_ADMINISTRATOR );
+
+ $ini = $client->path.DS.'templates'.DS.$template.DS.'params.ini';
+ $xml = $client->path.DS.'templates'.DS.$template.DS.'templateDetails.xml';
+ $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $template);
+
+ jimport('joomla.filesystem.file');
+ // Read the ini file
+ if (JFile::exists($ini)) {
+ $content = JFile::read($ini);
+ } else {
+ $content = null;
+ }
+
+ $params = new JParameter($content, $xml, 'template');
+
+ $assigned = TemplatesHelper::isTemplateAssigned($row->directory);
+ $default = TemplatesHelper::isTemplateDefault($row->directory, $client->id);
+
+ if($client->id == '1') {
+ $lists['selections'] = JText::_('Cannot assign an administrator template');
+ } else {
+ $lists['selections'] = TemplatesHelper::createMenuList($template);
+ }
+
+ if ($default) {
+ $row->pages = 'all';
+ } elseif (!$assigned) {
+ $row->pages = 'none';
+ } else {
+ $row->pages = null;
+ }
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
+
+ require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
+ TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template);
+ }
+
+ function saveTemplate()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $db = & JFactory::getDBO();
+
+ $template = JRequest::getVar('id', '', 'method', 'cmd');
+ $option = JRequest::getVar('option', '', '', 'cmd');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $menus = JRequest::getVar('selections', array(), 'post', 'array');
+ $params = JRequest::getVar('params', array(), 'post', 'array');
+ $default = JRequest::getBool('default');
+ JArrayHelper::toInteger($menus);
+
+ if (!$template) {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
+ }
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ JClientHelper::setCredentialsFromRequest('ftp');
+ $ftp = JClientHelper::getCredentials('ftp');
+
+ $file = $client->path.DS.'templates'.DS.$template.DS.'params.ini';
+
+ jimport('joomla.filesystem.file');
+ if (JFile::exists($file) && count($params))
+ {
+ $registry = new JRegistry();
+ $registry->loadArray($params);
+ $txt = $registry->toString();
+
+ // Try to make the params file writeable
+ if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
+ JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable'));
+ }
+
+ $return = JFile::write($file, $txt);
+
+ // Try to make the params file unwriteable
+ if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
+ JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable'));
+ }
+
+ if (!$return) {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
+ }
+ }
+
+ // Reset all existing assignments
+ $query = 'DELETE FROM #__templates_menu' .
+ ' WHERE client_id = 0' .
+ ' AND template = '.$db->Quote( $template );
+ $db->setQuery($query);
+ $db->query();
+
+ if ($default) {
+ $menus = array( 0 );
+ }
+
+ foreach ($menus as $menuid)
+ {
+ // If 'None' is not in array
+ if ((int) $menuid >= 0)
+ {
+ // check if there is already a template assigned to this menu item
+ $query = 'DELETE FROM #__templates_menu' .
+ ' WHERE client_id = 0' .
+ ' AND menuid = '.(int) $menuid;
+ $db->setQuery($query);
+ $db->query();
+
+ $query = 'INSERT INTO #__templates_menu' .
+ ' SET client_id = 0, template = '. $db->Quote( $template ) .', menuid = '.(int) $menuid;
+ $db->setQuery($query);
+ $db->query();
+ }
+ }
+
+ $task = JRequest::getCmd('task');
+ if($task == 'apply') {
+ $mainframe->redirect('index.php?option='.$option.'&task=edit&cid[]='.$template.'&client='.$client->id);
+ } else {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id);
+ }
+ }
+
+ function cancelTemplate()
+ {
+ global $mainframe;
+
+ // Initialize some variables
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ JClientHelper::setCredentialsFromRequest('ftp');
+
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id);
+ }
+
+ function editTemplateSource()
+ {
+ global $mainframe;
+
+ // Initialize some variables
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $template = JRequest::getVar('id', '', 'method', 'cmd');
+ $file = $client->path.DS.'templates'.DS.$template.DS.'index.php';
+
+ // Read the source file
+ jimport('joomla.filesystem.file');
+ $content = JFile::read($file);
+
+ if ($content !== false)
+ {
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
+
+ $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
+ require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
+ TemplatesView::editTemplateSource($template, $content, $option, $client, $ftp);
+ } else {
+ $msg = JText::sprintf('Operation Failed Could not open', $file);
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg);
+ }
+ }
+
+ function saveTemplateSource()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $template = JRequest::getVar('id', '', 'method', 'cmd');
+ $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
+
+ if (!$template) {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
+ }
+
+ if (!$filecontent) {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));
+ }
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ JClientHelper::setCredentialsFromRequest('ftp');
+ $ftp = JClientHelper::getCredentials('ftp');
+
+ $file = $client->path.DS.'templates'.DS.$template.DS.'index.php';
+
+ // Try to make the template file writeable
+ if (!$ftp['enabled'] && !JPath::setPermissions($file, '0755')) {
+ JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file writable'));
+ }
+
+ jimport('joomla.filesystem.file');
+ $return = JFile::write($file, $filecontent);
+
+ // Try to make the template file unwriteable
+ if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) {
+ JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file unwritable'));
+ }
+
+ if ($return)
+ {
+ $task = JRequest::getCmd('task');
+ switch($task)
+ {
+ case 'apply_source':
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_source&id='.$template, JText::_('Template source saved'));
+ break;
+
+ case 'save_source':
+ default:
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('Template source saved'));
+ break;
+ }
+ }
+ else {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
+ }
+ }
+
+ function chooseTemplateCSS()
+ {
+ global $mainframe;
+
+ // Initialize some variables
+ $option = JRequest::getCmd('option');
+ $template = JRequest::getVar('id', '', 'method', 'cmd');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+
+ // Determine template CSS directory
+ $dir = $client->path.DS.'templates'.DS.$template.DS.'css';
+
+ // List template .css files
+ jimport('joomla.filesystem.folder');
+ $files = JFolder::files($dir, '\.css$', false, false);
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ JClientHelper::setCredentialsFromRequest('ftp');
+
+ require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
+ TemplatesView::chooseCSSFiles($template, $dir, $files, $option, $client);
+ }
+
+ function editTemplateCSS()
+ {
+ global $mainframe;
+
+ // Initialize some variables
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $template = JRequest::getVar('id', '', 'method', 'cmd');
+ $filename = JRequest::getVar('filename', '', 'method', 'cmd');
+
+ jimport('joomla.filesystem.file');
+
+ if (JFile::getExt($filename) !== 'css') {
+ $msg = JText::_('Wrong file type given, only CSS files can be edited.');
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=choose_css&id='.$template, $msg, 'error');
+ }
+
+ $content = JFile::read($client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename);
+
+ if ($content !== false)
+ {
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
+
+ $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
+ require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');
+ TemplatesView::editCSSSource($template, $filename, $content, $option, $client, $ftp);
+ }
+ else
+ {
+ $msg = JText::sprintf('Operation Failed Could not open', $client->path.$filename);
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg);
+ }
+ }
+
+ function saveTemplateCSS()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Initialize some variables
+ $option = JRequest::getCmd('option');
+ $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
+ $template = JRequest::getVar('id', '', 'post', 'cmd');
+ $filename = JRequest::getVar('filename', '', 'post', 'cmd');
+ $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
+
+ if (!$template) {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
+ }
+
+ if (!$filecontent) {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));
+ }
+
+ // Set FTP credentials, if given
+ jimport('joomla.client.helper');
+ JClientHelper::setCredentialsFromRequest('ftp');
+ $ftp = JClientHelper::getCredentials('ftp');
+
+ $file = $client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename;
+
+ // Try to make the css file writeable
+ if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
+ JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable'));
+ }
+
+ jimport('joomla.filesystem.file');
+ $return = JFile::write($file, $filecontent);
+
+ // Try to make the css file unwriteable
+ if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
+ JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable'));
+ }
+
+ if ($return)
+ {
+ $task = JRequest::getCmd('task');
+ switch($task)
+ {
+ case 'apply_css':
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename, JText::_('File Saved'));
+ break;
+
+ case 'save_css':
+ default:
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('File Saved'));
+ break;
+ }
+ }
+ else {
+ $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
+ }
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php b/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php
index 99ae4328..3d6e3157 100644
--- a/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php
+++ b/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php
@@ -1,120 +1,120 @@
-setQuery($query);
- $defaultemplate = $db->loadResult();
-
- return $defaultemplate == $template ? 1 : 0;
- }
-
- function isTemplateAssigned($template)
- {
- $db =& JFactory::getDBO();
-
- // check if template is assigned
- $query = 'SELECT COUNT(*)' .
- ' FROM #__templates_menu' .
- ' WHERE client_id = 0' .
- ' AND template = '.$db->Quote($template) .
- ' AND menuid <> 0';
- $db->setQuery($query);
- return $db->loadResult() ? 1 : 0;
- }
-
- function parseXMLTemplateFiles($templateBaseDir)
- {
- // Read the template folder to find templates
- jimport('joomla.filesystem.folder');
- $templateDirs = JFolder::folders($templateBaseDir);
-
- $rows = array();
-
- // Check that the directory contains an xml file
- foreach ($templateDirs as $templateDir)
- {
- if(!$data = TemplatesHelper::parseXMLTemplateFile($templateBaseDir, $templateDir)){
- continue;
- } else {
- $rows[] = $data;
- }
- }
-
- return $rows;
- }
-
- function parseXMLTemplateFile($templateBaseDir, $templateDir)
- {
- // Check of the xml file exists
- if(!is_file($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml')) {
- return false;
- }
-
- $xml = JApplicationHelper::parseXMLInstallFile($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml');
-
- if ($xml['type'] != 'template') {
- return false;
- }
-
- $data = new StdClass();
- $data->directory = $templateDir;
-
- foreach($xml as $key => $value) {
- $data->$key = $value;
- }
-
- $data->checked_out = 0;
- $data->mosname = JString::strtolower(str_replace(' ', '_', $data->name));
-
- return $data;
- }
-
- function createMenuList($template)
- {
- $db =& JFactory::getDBO();
-
- // get selected pages for $menulist
- $query = 'SELECT menuid AS value' .
- ' FROM #__templates_menu' .
- ' WHERE client_id = 0' .
- ' AND template = '.$db->Quote($template);
- $db->setQuery($query);
- $lookup = $db->loadObjectList();
- if (empty( $lookup )) {
- $lookup = array( JHTML::_('select.option', '-1' ) );
- }
-
- // build the html select list
- $options = JHTML::_('menu.linkoptions');
- $result = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' );
- return $result;
- }
+setQuery($query);
+ $defaultemplate = $db->loadResult();
+
+ return $defaultemplate == $template ? 1 : 0;
+ }
+
+ function isTemplateAssigned($template)
+ {
+ $db =& JFactory::getDBO();
+
+ // check if template is assigned
+ $query = 'SELECT COUNT(*)' .
+ ' FROM #__templates_menu' .
+ ' WHERE client_id = 0' .
+ ' AND template = '.$db->Quote($template) .
+ ' AND menuid <> 0';
+ $db->setQuery($query);
+ return $db->loadResult() ? 1 : 0;
+ }
+
+ function parseXMLTemplateFiles($templateBaseDir)
+ {
+ // Read the template folder to find templates
+ jimport('joomla.filesystem.folder');
+ $templateDirs = JFolder::folders($templateBaseDir);
+
+ $rows = array();
+
+ // Check that the directory contains an xml file
+ foreach ($templateDirs as $templateDir)
+ {
+ if(!$data = TemplatesHelper::parseXMLTemplateFile($templateBaseDir, $templateDir)){
+ continue;
+ } else {
+ $rows[] = $data;
+ }
+ }
+
+ return $rows;
+ }
+
+ function parseXMLTemplateFile($templateBaseDir, $templateDir)
+ {
+ // Check of the xml file exists
+ if(!is_file($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml')) {
+ return false;
+ }
+
+ $xml = JApplicationHelper::parseXMLInstallFile($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml');
+
+ if ($xml['type'] != 'template') {
+ return false;
+ }
+
+ $data = new StdClass();
+ $data->directory = $templateDir;
+
+ foreach($xml as $key => $value) {
+ $data->$key = $value;
+ }
+
+ $data->checked_out = 0;
+ $data->mosname = JString::strtolower(str_replace(' ', '_', $data->name));
+
+ return $data;
+ }
+
+ function createMenuList($template)
+ {
+ $db =& JFactory::getDBO();
+
+ // get selected pages for $menulist
+ $query = 'SELECT menuid AS value' .
+ ' FROM #__templates_menu' .
+ ' WHERE client_id = 0' .
+ ' AND template = '.$db->Quote($template);
+ $db->setQuery($query);
+ $lookup = $db->loadObjectList();
+ if (empty( $lookup )) {
+ $lookup = array( JHTML::_('select.option', '-1' ) );
+ }
+
+ // build the html select list
+ $options = JHTML::_('menu.linkoptions');
+ $result = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' );
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_templates/templates.xml b/oss/joomla/trunk/administrator/components/com_templates/templates.xml
index bdb42ed4..5f6e766b 100644
--- a/oss/joomla/trunk/administrator/components/com_templates/templates.xml
+++ b/oss/joomla/trunk/administrator/components/com_templates/templates.xml
@@ -1,12 +1,12 @@
-
-
- Template Manager
- Joomla! Project
- 2006
- Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.5.0
- Template Manager
-
+
+
+ Template Manager
+ Joomla! Project
+ 2006
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5.0
+ Template Manager
+
diff --git a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php
index 04b9ee68..bfbe946a 100644
--- a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php
+++ b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php
@@ -1,77 +1,77 @@
-id == '1') {
- JToolBarHelper::makeDefault('publish');
- } else {
- JToolBarHelper::makeDefault();
- }
- JToolBarHelper::editListX( 'edit', 'Edit' );
- //JToolBarHelper::addNew();
- JToolBarHelper::help( 'screen.templates' );
- }
- function _VIEW(&$client){
-
- JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' );
- JToolBarHelper::back();
- }
-
- function _EDIT_SOURCE(&$client){
-
- JToolBarHelper::title( JText::_( 'Template HTML Editor' ), 'thememanager' );
- JToolBarHelper::save( 'save_source' );
- JToolBarHelper::apply( 'apply_source' );
- JToolBarHelper::cancel('edit');
- JToolBarHelper::help( 'screen.templates' );
- }
-
- function _EDIT(&$client){
- JToolBarHelper::title( JText::_( 'Template' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'thememanager' );
- JToolBarHelper::custom('preview', 'preview.png', 'preview_f2.png', 'Preview', false, false);
- JToolBarHelper::custom( 'edit_source', 'html.png', 'html_f2.png', 'Edit HTML', false, false );
- JToolBarHelper::custom( 'choose_css', 'css.png', 'css_f2.png', 'Edit CSS', false, false );
- JToolBarHelper::save( 'save' );
- JToolBarHelper::apply();
- JToolBarHelper::cancel( 'cancel', 'Close' );
- JToolBarHelper::help( 'screen.templates' );
- }
-
- function _CHOOSE_CSS(&$client){
- JToolBarHelper::title( JText::_( 'Template CSS Editor' ), 'thememanager' );
- JToolBarHelper::custom( 'edit_css', 'edit.png', 'edit_f2.png', 'Edit', true );
- JToolBarHelper::cancel('edit');
- JToolBarHelper::help( 'screen.templates' );
- }
-
- function _EDIT_CSS(&$client){
- JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' );
- JToolBarHelper::save( 'save_css' );
- JToolBarHelper::apply( 'apply_css');
- JToolBarHelper::cancel('choose_css');
- JToolBarHelper::help( 'screen.templates' );
- }
+id == '1') {
+ JToolBarHelper::makeDefault('publish');
+ } else {
+ JToolBarHelper::makeDefault();
+ }
+ JToolBarHelper::editListX( 'edit', 'Edit' );
+ //JToolBarHelper::addNew();
+ JToolBarHelper::help( 'screen.templates' );
+ }
+ function _VIEW(&$client){
+
+ JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' );
+ JToolBarHelper::back();
+ }
+
+ function _EDIT_SOURCE(&$client){
+
+ JToolBarHelper::title( JText::_( 'Template HTML Editor' ), 'thememanager' );
+ JToolBarHelper::save( 'save_source' );
+ JToolBarHelper::apply( 'apply_source' );
+ JToolBarHelper::cancel('edit');
+ JToolBarHelper::help( 'screen.templates' );
+ }
+
+ function _EDIT(&$client){
+ JToolBarHelper::title( JText::_( 'Template' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'thememanager' );
+ JToolBarHelper::custom('preview', 'preview.png', 'preview_f2.png', 'Preview', false, false);
+ JToolBarHelper::custom( 'edit_source', 'html.png', 'html_f2.png', 'Edit HTML', false, false );
+ JToolBarHelper::custom( 'choose_css', 'css.png', 'css_f2.png', 'Edit CSS', false, false );
+ JToolBarHelper::save( 'save' );
+ JToolBarHelper::apply();
+ JToolBarHelper::cancel( 'cancel', 'Close' );
+ JToolBarHelper::help( 'screen.templates' );
+ }
+
+ function _CHOOSE_CSS(&$client){
+ JToolBarHelper::title( JText::_( 'Template CSS Editor' ), 'thememanager' );
+ JToolBarHelper::custom( 'edit_css', 'edit.png', 'edit_f2.png', 'Edit', true );
+ JToolBarHelper::cancel('edit');
+ JToolBarHelper::help( 'screen.templates' );
+ }
+
+ function _EDIT_CSS(&$client){
+ JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' );
+ JToolBarHelper::save( 'save_css' );
+ JToolBarHelper::apply( 'apply_css');
+ JToolBarHelper::cancel('choose_css');
+ JToolBarHelper::help( 'screen.templates' );
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php
index b6ce0ba3..17246ac7 100644
--- a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php
+++ b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php
@@ -1,48 +1,48 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ authorize( 'com_trash', 'manage' )) {
- $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
-}
-
-require_once( JApplicationHelper::getPath( 'admin_html' ) );
-
-$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
-$mid = JRequest::getVar( 'mid', array(0), 'post', 'array' );
-
-JArrayHelper::toInteger($cid, array(0));
-JArrayHelper::toInteger($mid, array(0));
-
-switch ($task)
-{
- case 'deleteconfirm':
- viewdeleteTrash( $cid, $mid, $option );
- break;
-
- case 'delete':
- deleteTrash( $cid, $option );
- break;
-
- case 'restoreconfirm':
- viewrestoreTrash( $cid, $mid, $option );
- break;
-
- case 'restore':
- restoreTrash( $cid, $option );
- break;
-
- case 'viewMenu':
- viewTrashMenu( $option );
- break;
-
- case 'viewContent':
- viewTrashContent( $option );
- break;
-
- default:
- $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
- if ( $return == 'viewMenu' ) {
- viewTrashMenu( $option );
- } else {
- viewTrashContent( $option );
- }
- break;
-}
-
-
-/**
-* Compiles a list of trash items
-*/
-function viewTrashContent( $option )
-{
- global $mainframe;
-
- $db =& JFactory::getDBO();
- $filter_order = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order", 'filter_order', 'sectname', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order_Dir", 'filter_order_Dir', '', 'word' );
- $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
-
- $where[] = 'c.state = -2';
-
- if ($search) {
- $where[] = 'LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
- }
-
- $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
- $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', s.name, cc.name, c.title';
-
- // get the total number of content
- $query = 'SELECT count(c.id)'
- . ' FROM #__content AS c'
- . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid'
- . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"'
- . ' LEFT JOIN #__groups AS g ON g.id = c.access'
- . ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
- . $where
- ;
- $db->setQuery( $query );
- $total = $db->loadResult();
-
- jimport('joomla.html.pagination');
- $pageNav = new JPagination( $total, $limitstart, $limit );
-
- // Query articles
- $query = 'SELECT c.title, c.id, c.sectionid, c.catid, g.name AS groupname, cc.title AS catname, s.title AS sectname'
- . ' FROM #__content AS c'
- . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid'
- . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"'
- . ' LEFT JOIN #__groups AS g ON g.id = c.access'
- . ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
- . $where
- . $orderby
- ;
- $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
- $contents = $db->loadObjectList();
-
- for ( $i = 0; $i < count($contents); $i++ ) {
- if ( ( $contents[$i]->sectionid == 0 ) && ( $contents[$i]->catid == 0 ) ) {
- $contents[$i]->sectname = JText::_('UNCATEGORIZED');
- }
- }
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- HTML_trash::showListContent( $option, $contents, $pageNav, $lists );
-}
-
-/**
-* Compiles a list of trash items
-*/
-function viewTrashMenu( $option )
-{
- global $mainframe;
-
- $db =& JFactory::getDBO();
- $filter_order = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order", 'filter_order', 'm.menutype', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order_Dir", 'filter_order_Dir', '', 'word' );
- $limit = $mainframe->getUserStateFromRequest( "limit", 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( "$option.viewMenu.limitstart", 'limitstart', 0, 'int' );
- $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $where[] = 'm.published = -2';
-
- if ($search) {
- $where[] = 'LOWER(m.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
- }
-
- $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
- $orderby = ' ORDER BY '. $filter_order . ' ' . $filter_order_Dir .', m.menutype, m.ordering, m.ordering, m.name';
-
- $query = 'SELECT count(*)'
- . ' FROM #__menu AS m'
- . ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
- . $where
- ;
- $db->setQuery( $query );
- $total = $db->loadResult();
-
- jimport('joomla.html.pagination');
- $pageNav = new JPagination( $total, $limitstart, $limit );
-
- // Query menu items
- $query = 'SELECT m.name, m.id, m.menutype, m.type, com.name AS com_name'
- . ' FROM #__menu AS m'
- . ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
- . ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "components"'
- . $where
- . $orderby
- ;
- $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
- $menus = $db->loadObjectList();
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- HTML_trash::showListMenu( $option, $menus, $pageNav, $lists );
-}
-
-
-/**
-* Compiles a list of the items you have selected to permanently delte
-*/
-function viewdeleteTrash( $cid, $mid, $option )
-{
- global $mainframe;
-
- $db =& JFactory::getDBO();
- $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
-
- JArrayHelper::toInteger($cid, array(0));
- JArrayHelper::toInteger($mid, array(0));
-
- // seperate contentids
- $cids = implode( ',', $cid );
- $mids = implode( ',', $mid );
-
- if ( $cids ) {
- // Articles query
- $query = 'SELECT a.title AS name'
- . ' FROM #__content AS a'
- . ' WHERE ( a.id IN ( '.$cids.' ) )'
- . ' ORDER BY a.title'
- ;
- $db->setQuery( $query );
- $items = $db->loadObjectList();
- $id = $cid;
- $type = "content";
- } else if ( $mids ) {
- // Articles query
- $query = 'SELECT a.name'
- . ' FROM #__menu AS a'
- . ' WHERE ( a.id IN ( '.$mids.' ) )'
- . ' ORDER BY a.name'
- ;
- $db->setQuery( $query );
- $items = $db->loadObjectList();
- $id = $mid;
- $type = "menu";
- }
-
- HTML_trash::showDelete( $option, $id, $items, $type, $return );
-}
-
-
-/**
-* Permanently deletes the selected list of trash items
-*/
-function deleteTrash( $cid, $option )
-{
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
- $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
- $type = JRequest::getCmd( 'type', '', 'post' );
-
- $total = count( $cid );
-
- if ( $type == 'content' )
- {
- $obj =& JTable::getInstance('content');
-
- require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php');
- $fp = new TableFrontPage( $db );
- foreach ( $cid as $id ) {
- $id = intval( $id );
- $obj->delete( $id );
- $fp->delete( $id );
- }
- } else if ( $type == "menu" ) {
- $obj =& JTable::getInstance('menu');
- foreach ( $cid as $id ) {
- $id = intval( $id );
- $obj->delete( $id );
- }
- }
-
- $msg = JText::sprintf( 'Item(s) successfully Deleted', $total );
- $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg );
-}
-
-
-/**
-* Compiles a list of the items you have selected to permanently delte
-*/
-function viewrestoreTrash( $cid, $mid, $option ) {
- global $mainframe;
-
- $db =& JFactory::getDBO();
- $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
-
- JArrayHelper::toInteger($cid, array(0));
- JArrayHelper::toInteger($mid, array(0));
-
- // seperate contentids
- $cids = implode( ',', $cid );
- $mids = implode( ',', $mid );
-
- if ( $cids ) {
- // Articles query
- $query = 'SELECT a.title AS name'
- . ' FROM #__content AS a'
- . ' WHERE ( a.id IN ( '.$cids.' ) )'
- . ' ORDER BY a.title'
- ;
- $db->setQuery( $query );
- $items = $db->loadObjectList();
- $id = $cid;
- $type = "content";
- } else if ( $mids ) {
- // Articles query
- $query = 'SELECT a.name'
- . ' FROM #__menu AS a'
- . ' WHERE ( a.id IN ( '.$mids.' ) )'
- . ' ORDER BY a.name'
- ;
- $db->setQuery( $query );
- $items = $db->loadObjectList();
- $id = $mid;
- $type = "menu";
- }
-
- HTML_trash::showRestore( $option, $id, $items, $type, $return );
-}
-
-
-/**
-* Restores items selected to normal - restores to an unpublished state
-*/
-function restoreTrash( $cid, $option )
-{
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db = & JFactory::getDBO();
- $type = JRequest::getCmd( 'type', '', 'post' );
-
- $total = count( $cid );
-
- // restores to an unpublished state
- $state = 0;
- $ordering = 9999;
-
- if ( $type == 'content' ) {
- $return = 'viewContent';
-
- //seperate contentids
- JArrayHelper::toInteger($cid, array(0));
- $cids = implode( ',', $cid );
-
- // query to restore article
- $query = 'UPDATE #__content'
- . ' SET state = '.(int) $state.', ordering = '.(int) $ordering
- . ' WHERE id IN ( '.$cids.' )'
- ;
- $db->setQuery( $query );
- if ( !$db->query() ) {
- JError::raiseError(500, $db->getErrorMsg() );
- }
- } else if ( $type == 'menu' ) {
- $return = 'viewMenu';
-
- jimport('joomla.application.component.model');
- JModel::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models');
- $model =& JModel::getInstance('List', 'MenusModel');
- $total = $model->fromTrash($cid);
-
- if (!$total) {
- JError::raiseError(500, $db->getErrorMsg() );
- }
- }
-
- $msg = JText::sprintf( 'Item(s) successfully Restored', $total );
- $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg );
-}
-
-function ReadMenuXML( $type, $component=-1 )
-{
- // xml file for module
- $xmlfile = JPATH_ADMINISTRATOR .'/components/com_menus/'. $type .'/'. $type .'.xml';
-
- $data = JApplicationHelper::parseXMLInstallFile($xmlfile);
-
- if ( $data['type'] == 'component' || $data['type'] == 'menu' )
- {
- if ( ( $component <> -1 ) && ( $data['name'] == 'Component') ) {
- $data['name'] .= ' - '. $component;
- }
-
- $row[0] = $data['name'];
- }
-
- return $row;
+authorize( 'com_trash', 'manage' )) {
+ $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
+}
+
+require_once( JApplicationHelper::getPath( 'admin_html' ) );
+
+$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+$mid = JRequest::getVar( 'mid', array(0), 'post', 'array' );
+
+JArrayHelper::toInteger($cid, array(0));
+JArrayHelper::toInteger($mid, array(0));
+
+switch ($task)
+{
+ case 'deleteconfirm':
+ viewdeleteTrash( $cid, $mid, $option );
+ break;
+
+ case 'delete':
+ deleteTrash( $cid, $option );
+ break;
+
+ case 'restoreconfirm':
+ viewrestoreTrash( $cid, $mid, $option );
+ break;
+
+ case 'restore':
+ restoreTrash( $cid, $option );
+ break;
+
+ case 'viewMenu':
+ viewTrashMenu( $option );
+ break;
+
+ case 'viewContent':
+ viewTrashContent( $option );
+ break;
+
+ default:
+ $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
+ if ( $return == 'viewMenu' ) {
+ viewTrashMenu( $option );
+ } else {
+ viewTrashContent( $option );
+ }
+ break;
+}
+
+
+/**
+* Compiles a list of trash items
+*/
+function viewTrashContent( $option )
+{
+ global $mainframe;
+
+ $db =& JFactory::getDBO();
+ $filter_order = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order", 'filter_order', 'sectname', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order_Dir", 'filter_order_Dir', '', 'word' );
+ $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
+
+ $where[] = 'c.state = -2';
+
+ if ($search) {
+ $where[] = 'LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ }
+
+ $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
+ $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', s.name, cc.name, c.title';
+
+ // get the total number of content
+ $query = 'SELECT count(c.id)'
+ . ' FROM #__content AS c'
+ . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid'
+ . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"'
+ . ' LEFT JOIN #__groups AS g ON g.id = c.access'
+ . ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
+ . $where
+ ;
+ $db->setQuery( $query );
+ $total = $db->loadResult();
+
+ jimport('joomla.html.pagination');
+ $pageNav = new JPagination( $total, $limitstart, $limit );
+
+ // Query articles
+ $query = 'SELECT c.title, c.id, c.sectionid, c.catid, g.name AS groupname, cc.title AS catname, s.title AS sectname'
+ . ' FROM #__content AS c'
+ . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid'
+ . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"'
+ . ' LEFT JOIN #__groups AS g ON g.id = c.access'
+ . ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
+ . $where
+ . $orderby
+ ;
+ $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
+ $contents = $db->loadObjectList();
+
+ for ( $i = 0; $i < count($contents); $i++ ) {
+ if ( ( $contents[$i]->sectionid == 0 ) && ( $contents[$i]->catid == 0 ) ) {
+ $contents[$i]->sectname = JText::_('UNCATEGORIZED');
+ }
+ }
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ HTML_trash::showListContent( $option, $contents, $pageNav, $lists );
+}
+
+/**
+* Compiles a list of trash items
+*/
+function viewTrashMenu( $option )
+{
+ global $mainframe;
+
+ $db =& JFactory::getDBO();
+ $filter_order = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order", 'filter_order', 'm.menutype', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order_Dir", 'filter_order_Dir', '', 'word' );
+ $limit = $mainframe->getUserStateFromRequest( "limit", 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( "$option.viewMenu.limitstart", 'limitstart', 0, 'int' );
+ $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $where[] = 'm.published = -2';
+
+ if ($search) {
+ $where[] = 'LOWER(m.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ }
+
+ $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
+ $orderby = ' ORDER BY '. $filter_order . ' ' . $filter_order_Dir .', m.menutype, m.ordering, m.ordering, m.name';
+
+ $query = 'SELECT count(*)'
+ . ' FROM #__menu AS m'
+ . ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
+ . $where
+ ;
+ $db->setQuery( $query );
+ $total = $db->loadResult();
+
+ jimport('joomla.html.pagination');
+ $pageNav = new JPagination( $total, $limitstart, $limit );
+
+ // Query menu items
+ $query = 'SELECT m.name, m.id, m.menutype, m.type, com.name AS com_name'
+ . ' FROM #__menu AS m'
+ . ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
+ . ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "components"'
+ . $where
+ . $orderby
+ ;
+ $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
+ $menus = $db->loadObjectList();
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ HTML_trash::showListMenu( $option, $menus, $pageNav, $lists );
+}
+
+
+/**
+* Compiles a list of the items you have selected to permanently delte
+*/
+function viewdeleteTrash( $cid, $mid, $option )
+{
+ global $mainframe;
+
+ $db =& JFactory::getDBO();
+ $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
+
+ JArrayHelper::toInteger($cid, array(0));
+ JArrayHelper::toInteger($mid, array(0));
+
+ // seperate contentids
+ $cids = implode( ',', $cid );
+ $mids = implode( ',', $mid );
+
+ if ( $cids ) {
+ // Articles query
+ $query = 'SELECT a.title AS name'
+ . ' FROM #__content AS a'
+ . ' WHERE ( a.id IN ( '.$cids.' ) )'
+ . ' ORDER BY a.title'
+ ;
+ $db->setQuery( $query );
+ $items = $db->loadObjectList();
+ $id = $cid;
+ $type = "content";
+ } else if ( $mids ) {
+ // Articles query
+ $query = 'SELECT a.name'
+ . ' FROM #__menu AS a'
+ . ' WHERE ( a.id IN ( '.$mids.' ) )'
+ . ' ORDER BY a.name'
+ ;
+ $db->setQuery( $query );
+ $items = $db->loadObjectList();
+ $id = $mid;
+ $type = "menu";
+ }
+
+ HTML_trash::showDelete( $option, $id, $items, $type, $return );
+}
+
+
+/**
+* Permanently deletes the selected list of trash items
+*/
+function deleteTrash( $cid, $option )
+{
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
+ $type = JRequest::getCmd( 'type', '', 'post' );
+
+ $total = count( $cid );
+
+ if ( $type == 'content' )
+ {
+ $obj =& JTable::getInstance('content');
+
+ require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php');
+ $fp = new TableFrontPage( $db );
+ foreach ( $cid as $id ) {
+ $id = intval( $id );
+ $obj->delete( $id );
+ $fp->delete( $id );
+ }
+ } else if ( $type == "menu" ) {
+ $obj =& JTable::getInstance('menu');
+ foreach ( $cid as $id ) {
+ $id = intval( $id );
+ $obj->delete( $id );
+ }
+ }
+
+ $msg = JText::sprintf( 'Item(s) successfully Deleted', $total );
+ $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg );
+}
+
+
+/**
+* Compiles a list of the items you have selected to permanently delte
+*/
+function viewrestoreTrash( $cid, $mid, $option ) {
+ global $mainframe;
+
+ $db =& JFactory::getDBO();
+ $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
+
+ JArrayHelper::toInteger($cid, array(0));
+ JArrayHelper::toInteger($mid, array(0));
+
+ // seperate contentids
+ $cids = implode( ',', $cid );
+ $mids = implode( ',', $mid );
+
+ if ( $cids ) {
+ // Articles query
+ $query = 'SELECT a.title AS name'
+ . ' FROM #__content AS a'
+ . ' WHERE ( a.id IN ( '.$cids.' ) )'
+ . ' ORDER BY a.title'
+ ;
+ $db->setQuery( $query );
+ $items = $db->loadObjectList();
+ $id = $cid;
+ $type = "content";
+ } else if ( $mids ) {
+ // Articles query
+ $query = 'SELECT a.name'
+ . ' FROM #__menu AS a'
+ . ' WHERE ( a.id IN ( '.$mids.' ) )'
+ . ' ORDER BY a.name'
+ ;
+ $db->setQuery( $query );
+ $items = $db->loadObjectList();
+ $id = $mid;
+ $type = "menu";
+ }
+
+ HTML_trash::showRestore( $option, $id, $items, $type, $return );
+}
+
+
+/**
+* Restores items selected to normal - restores to an unpublished state
+*/
+function restoreTrash( $cid, $option )
+{
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db = & JFactory::getDBO();
+ $type = JRequest::getCmd( 'type', '', 'post' );
+
+ $total = count( $cid );
+
+ // restores to an unpublished state
+ $state = 0;
+ $ordering = 9999;
+
+ if ( $type == 'content' ) {
+ $return = 'viewContent';
+
+ //seperate contentids
+ JArrayHelper::toInteger($cid, array(0));
+ $cids = implode( ',', $cid );
+
+ // query to restore article
+ $query = 'UPDATE #__content'
+ . ' SET state = '.(int) $state.', ordering = '.(int) $ordering
+ . ' WHERE id IN ( '.$cids.' )'
+ ;
+ $db->setQuery( $query );
+ if ( !$db->query() ) {
+ JError::raiseError(500, $db->getErrorMsg() );
+ }
+ } else if ( $type == 'menu' ) {
+ $return = 'viewMenu';
+
+ jimport('joomla.application.component.model');
+ JModel::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models');
+ $model =& JModel::getInstance('List', 'MenusModel');
+ $total = $model->fromTrash($cid);
+
+ if (!$total) {
+ JError::raiseError(500, $db->getErrorMsg() );
+ }
+ }
+
+ $msg = JText::sprintf( 'Item(s) successfully Restored', $total );
+ $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg );
+}
+
+function ReadMenuXML( $type, $component=-1 )
+{
+ // xml file for module
+ $xmlfile = JPATH_ADMINISTRATOR .'/components/com_menus/'. $type .'/'. $type .'.xml';
+
+ $data = JApplicationHelper::parseXMLInstallFile($xmlfile);
+
+ if ( $data['type'] == 'component' || $data['type'] == 'menu' )
+ {
+ if ( ( $component <> -1 ) && ( $data['name'] == 'Component') ) {
+ $data['name'] .= ' - '. $component;
+ }
+
+ $row[0] = $data['name'];
+ }
+
+ return $row;
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php
index 68b7c327..f80c897e 100644
--- a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php
+++ b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php
@@ -1,48 +1,48 @@
-['. JText::_( 'Menu Items' ) .']';
- } else {
- $text = ': ['. JText::_( 'Articles' ) .']';
- }
-
- JToolBarHelper::title( JText::_( 'Trash Manager' ) . $text, 'trash.png' );
- JToolBarHelper::custom('restoreconfirm','restore.png','restore_f2.png', 'Restore', true);
- JToolBarHelper::custom('deleteconfirm','delete.png','delete_f2.png', 'Delete', true);
- JToolBarHelper::help( 'screen.trashmanager' );
- }
-
- function _RESTORE() {
- JToolBarHelper::title( JText::_( 'Restore Items' ), 'restoredb.png' );
- JToolBarHelper::cancel();
- }
-
- function _DELETE() {
- JToolBarHelper::title( JText::_( 'Delete Items' ), 'delete_f2.png' );
- JToolBarHelper::cancel();
- }
+['. JText::_( 'Menu Items' ) .']';
+ } else {
+ $text = ': ['. JText::_( 'Articles' ) .']';
+ }
+
+ JToolBarHelper::title( JText::_( 'Trash Manager' ) . $text, 'trash.png' );
+ JToolBarHelper::custom('restoreconfirm','restore.png','restore_f2.png', 'Restore', true);
+ JToolBarHelper::custom('deleteconfirm','delete.png','delete_f2.png', 'Delete', true);
+ JToolBarHelper::help( 'screen.trashmanager' );
+ }
+
+ function _RESTORE() {
+ JToolBarHelper::title( JText::_( 'Restore Items' ), 'restoredb.png' );
+ JToolBarHelper::cancel();
+ }
+
+ function _DELETE() {
+ JToolBarHelper::title( JText::_( 'Delete Items' ), 'delete_f2.png' );
+ JToolBarHelper::cancel();
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php
index 9e06f1c5..9975c788 100644
--- a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php
+++ b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php
@@ -1,33 +1,33 @@
-
-
- Trash
- Joomla! Project
- Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.0.0
- PARAMTRASH
-
+
+
+ Trash
+ Joomla! Project
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.0.0
+ PARAMTRASH
+
diff --git a/oss/joomla/trunk/administrator/components/com_users/controller.php b/oss/joomla/trunk/administrator/components/com_users/controller.php
index 8836312b..369afc55 100644
--- a/oss/joomla/trunk/administrator/components/com_users/controller.php
+++ b/oss/joomla/trunk/administrator/components/com_users/controller.php
@@ -1,464 +1,465 @@
-registerTask( 'add' , 'display' );
- $this->registerTask( 'edit' , 'display' );
- $this->registerTask( 'apply', 'save' );
- $this->registerTask( 'flogout', 'logout');
- $this->registerTask( 'unblock', 'block' );
- }
-
- /**
- * Displays a view
- */
- function display( )
- {
- switch($this->getTask())
- {
- case 'add' :
- { JRequest::setVar( 'hidemainmenu', 1 );
- JRequest::setVar( 'layout', 'form' );
- JRequest::setVar( 'view', 'user' );
- JRequest::setVar( 'edit', false );
- } break;
- case 'edit' :
- {
- JRequest::setVar( 'hidemainmenu', 1 );
- JRequest::setVar( 'layout', 'form' );
- JRequest::setVar( 'view', 'user' );
- JRequest::setVar( 'edit', true );
- } break;
- }
-
- parent::display();
- }
-
- /**
- * Saves the record
- */
- function save()
- {
- global $mainframe;
-
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $option = JRequest::getCmd( 'option');
-
- // Initialize some variables
- $db = & JFactory::getDBO();
- $me = & JFactory::getUser();
- $acl =& JFactory::getACL();
- $MailFrom = $mainframe->getCfg('mailfrom');
- $FromName = $mainframe->getCfg('fromname');
- $SiteName = $mainframe->getCfg('sitename');
-
- // Create a new JUser object
- $user = new JUser(JRequest::getVar( 'id', 0, 'post', 'int'));
- $original_gid = $user->get('gid');
-
- $post = JRequest::get('post');
- $post['username'] = JRequest::getVar('username', '', 'post', 'username');
- $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
- $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
-
- if (!$user->bind($post))
- {
- $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
- $mainframe->enqueueMessage($user->getError(), 'error');
- //$mainframe->redirect( 'index.php?option=com_users', $user->getError() );
- //return false;
- return $this->execute('edit');
- }
-
- $objectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' );
- $groups = $acl->get_object_groups( $objectID, 'ARO' );
- $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
-
-
- if ( $user->get('id') == $me->get( 'id' ) && $user->get('block') == 1 )
- {
- $msg = JText::_( 'You cannot block Yourself!' );
- $mainframe->enqueueMessage($msg, 'message');
- return $this->execute('edit');
- }
- else if ( ( $this_group == 'super administrator' ) && $user->get('block') == 1 ) {
- $msg = JText::_( 'You cannot block a Super Administrator' );
- $mainframe->enqueueMessage($msg, 'message');
- return $this->execute('edit');
- }
- else if ( ( $this_group == 'administrator' ) && ( $me->get( 'gid' ) == 24 ) && $user->get('block') == 1 )
- {
- $msg = JText::_( 'WARNBLOCK' );
- $mainframe->enqueueMessage($msg, 'message');
- return $this->execute('edit');
- }
- else if ( ( $this_group == 'super administrator' ) && ( $me->get( 'gid' ) != 25 ) )
- {
- $msg = JText::_( 'You cannot edit a super administrator account' );
- $mainframe->enqueueMessage($msg, 'message');
- return $this->execute('edit');
- }
- // Are we dealing with a new user which we need to create?
- $isNew = ($user->get('id') < 1);
- if (!$isNew)
- {
- // if group has been changed and where original group was a Super Admin
- if ( $user->get('gid') != $original_gid && $original_gid == 25 )
- {
- // count number of active super admins
- $query = 'SELECT COUNT( id )'
- . ' FROM #__users'
- . ' WHERE gid = 25'
- . ' AND block = 0'
- ;
- $db->setQuery( $query );
- $count = $db->loadResult();
-
- if ( $count <= 1 )
- {
- // disallow change if only one Super Admin exists
- $this->setRedirect( 'index.php?option=com_users', JText::_('WARN_ONLY_SUPER') );
- return false;
- }
- }
- }
-
- /*
- * Lets save the JUser object
- */
- if (!$user->save())
- {
-
- $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
- $mainframe->enqueueMessage($user->getError(), 'error');
- return $this->execute('edit');
- }
-
- /*
- * Time for the email magic so get ready to sprinkle the magic dust...
- */
- if ($isNew)
- {
- $adminEmail = $me->get('email');
- $adminName = $me->get('name');
-
- $subject = JText::_('NEW_USER_MESSAGE_SUBJECT');
- $message = sprintf ( JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear );
-
- if ($MailFrom != '' && $FromName != '')
- {
- $adminName = $FromName;
- $adminEmail = $MailFrom;
- }
- JUtility::sendMail( $adminEmail, $adminName, $user->get('email'), $subject, $message );
- }
-
- // If updating self, load the new user object into the session
- if ($user->get('id') == $me->get('id'))
- {
- // Get an ACL object
- $acl = &JFactory::getACL();
-
- // Get the user group from the ACL
- $grp = $acl->getAroGroup($user->get('id'));
-
- // Mark the user as logged in
- $user->set('guest', 0);
- $user->set('aid', 1);
-
- // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
- if ($acl->is_group_child_of($grp->name, 'Registered') ||
- $acl->is_group_child_of($grp->name, 'Public Backend')) {
- $user->set('aid', 2);
- }
-
- // Set the usertype based on the ACL group name
- $user->set('usertype', $grp->name);
-
- $session = &JFactory::getSession();
- $session->set('user', $user);
- }
-
- switch ( $this->getTask() )
- {
- case 'apply':
- $msg = JText::sprintf( 'Successfully Saved changes to User', $user->get('name') );
- $this->setRedirect( 'index.php?option=com_users&view=user&task=edit&cid[]='. $user->get('id'), $msg );
- break;
-
- case 'save':
- default:
- $msg = JText::sprintf( 'Successfully Saved User', $user->get('name') );
- $this->setRedirect( 'index.php?option=com_users', $msg );
- break;
- }
- }
-
- /**
- * Removes the record(s) from the database
- */
- function remove()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
- $currentUser =& JFactory::getUser();
- $acl =& JFactory::getACL();
- $cid = JRequest::getVar( 'cid', array(), '', 'array' );
-
- JArrayHelper::toInteger( $cid );
-
- if (count( $cid ) < 1) {
- JError::raiseError(500, JText::_( 'Select a User to delete', true ) );
- }
-
- foreach ($cid as $id)
- {
- // check for a super admin ... can't delete them
- $objectID = $acl->get_object_id( 'users', $id, 'ARO' );
- $groups = $acl->get_object_groups( $objectID, 'ARO' );
- $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
-
- $success = false;
- if ( $this_group == 'super administrator' )
- {
- $msg = JText::_( 'You cannot delete a Super Administrator' );
- }
- else if ( $id == $currentUser->get( 'id' ) )
- {
- $msg = JText::_( 'You cannot delete Yourself!' );
- }
- else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) )
- {
- $msg = JText::_( 'WARNDELETE' );
- }
- else
- {
- $user =& JUser::getInstance((int)$id);
- $count = 2;
-
- if ( $user->get( 'gid' ) == 25 )
- {
- // count number of active super admins
- $query = 'SELECT COUNT( id )'
- . ' FROM #__users'
- . ' WHERE gid = 25'
- . ' AND block = 0'
- ;
- $db->setQuery( $query );
- $count = $db->loadResult();
- }
-
- if ( $count <= 1 && $user->get( 'gid' ) == 25 )
- {
- // cannot delete Super Admin where it is the only one that exists
- $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site";
- }
- else
- {
- // delete user
- $user->delete();
- $msg = '';
-
- JRequest::setVar( 'task', 'remove' );
- JRequest::setVar( 'cid', $id );
-
- // delete user acounts active sessions
- $this->logout();
- }
- }
- }
-
- $this->setRedirect( 'index.php?option=com_users', $msg);
- }
-
- /**
- * Cancels an edit operation
- */
- function cancel( )
- {
- $this->setRedirect( 'index.php?option=com_users' );
- }
-
- /**
- * Disables the user account
- */
- function block( )
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $db =& JFactory::getDBO();
- $acl =& JFactory::getACL();
- $currentUser =& JFactory::getUser();
-
- $cid = JRequest::getVar( 'cid', array(), '', 'array' );
- $block = $this->getTask() == 'block' ? 1 : 0;
-
- JArrayHelper::toInteger( $cid );
-
- if (count( $cid ) < 1) {
- JError::raiseError(500, JText::_( 'Select a User to '.$this->getTask(), true ) );
- }
- foreach ($cid as $id)
- {
- // check for a super admin ... can't delete them
- $objectID = $acl->get_object_id( 'users', $id, 'ARO' );
- $groups = $acl->get_object_groups( $objectID, 'ARO' );
- $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
-
- $success = false;
- if ( $this_group == 'super administrator' )
- {
- $msg = JText::_( 'You cannot block a Super Administrator' );
- }
- else if ( $id == $currentUser->get( 'id' ) )
- {
- $msg = JText::_( 'You cannot block Yourself!' );
- }
- else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) )
- {
- $msg = JText::_( 'WARNBLOCK' );
- }
- else
- {
- $user =& JUser::getInstance((int)$id);
- $count = 2;
-
- if ( $user->get( 'gid' ) == 25 )
- {
- // count number of active super admins
- $query = 'SELECT COUNT( id )'
- . ' FROM #__users'
- . ' WHERE gid = 25'
- . ' AND block = 0'
- ;
- $db->setQuery( $query );
- $count = $db->loadResult();
- }
-
- if ( $count <= 1 && $user->get( 'gid' ) == 25 )
- {
- // cannot delete Super Admin where it is the only one that exists
- $msg = "You cannot block this Super Administrator as it is the only active Super Administrator for your site";
- }
- else
- {
- $user =& JUser::getInstance((int)$id);
- $user->block = $block;
- $user->save();
-
- if($block)
- {
- JRequest::setVar( 'task', 'block' );
- JRequest::setVar( 'cid', array($id) );
-
- // delete user acounts active sessions
- $this->logout();
- }
- }
- }
- }
-
- $this->setRedirect( 'index.php?option=com_users', $msg);
- }
-
- /**
- * Force log out a user
- */
- function logout( )
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- global $mainframe;
-
- $db =& JFactory::getDBO();
- $task = $this->getTask();
- $cids = JRequest::getVar( 'cid', array(), '', 'array' );
- $client = JRequest::getVar( 'client', 0, '', 'int' );
- $id = JRequest::getVar( 'id', 0, '', 'int' );
-
- JArrayHelper::toInteger($cids);
-
- if ( count( $cids ) < 1 ) {
- $this->setRedirect( 'index.php?option=com_users', JText::_( 'User Deleted' ) );
- return false;
- }
-
- foreach($cids as $cid)
- {
- $options = array();
-
- if ($task == 'logout' || $task == 'block') {
- $options['clientid'][] = 0; //site
- $options['clientid'][] = 1; //administrator
- } else if ($task == 'flogout') {
- $options['clientid'][] = $client;
- }
-
- $mainframe->logout((int)$cid, $options);
- }
-
-
- $msg = JText::_( 'User Session Ended' );
- switch ( $task )
- {
- case 'flogout':
- $this->setRedirect( 'index.php', $msg );
- break;
-
- case 'remove':
- case 'block':
- return;
- break;
-
- default:
- $this->setRedirect( 'index.php?option=com_users', $msg );
- break;
- }
- }
-
- function contact()
- {
- $contact_id = JRequest::getVar( 'contact_id', '', 'post', 'int' );
- $this->setRedirect( 'index.php?option=com_contact&task=edit&cid[]='. $contact_id );
- }
-}
+registerTask( 'add' , 'display' );
+ $this->registerTask( 'edit' , 'display' );
+ $this->registerTask( 'apply', 'save' );
+ $this->registerTask( 'flogout', 'logout');
+ $this->registerTask( 'unblock', 'block' );
+ }
+
+ /**
+ * Displays a view
+ */
+ function display( )
+ {
+ switch($this->getTask())
+ {
+ case 'add' :
+ { JRequest::setVar( 'hidemainmenu', 1 );
+ JRequest::setVar( 'layout', 'form' );
+ JRequest::setVar( 'view', 'user' );
+ JRequest::setVar( 'edit', false );
+ } break;
+ case 'edit' :
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+ JRequest::setVar( 'layout', 'form' );
+ JRequest::setVar( 'view', 'user' );
+ JRequest::setVar( 'edit', true );
+ } break;
+ }
+
+ parent::display();
+ }
+
+ /**
+ * Saves the record
+ */
+ function save()
+ {
+ global $mainframe;
+
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $option = JRequest::getCmd( 'option');
+
+ // Initialize some variables
+ $db = & JFactory::getDBO();
+ $me = & JFactory::getUser();
+ $acl =& JFactory::getACL();
+ $MailFrom = $mainframe->getCfg('mailfrom');
+ $FromName = $mainframe->getCfg('fromname');
+ $SiteName = $mainframe->getCfg('sitename');
+
+ // Create a new JUser object
+ $user = new JUser(JRequest::getVar( 'id', 0, 'post', 'int'));
+ $original_gid = $user->get('gid');
+
+ $post = JRequest::get('post');
+ $post['username'] = JRequest::getVar('username', '', 'post', 'username');
+ $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
+ $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
+
+ if (!$user->bind($post))
+ {
+ $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
+ $mainframe->enqueueMessage($user->getError(), 'error');
+ //$mainframe->redirect( 'index.php?option=com_users', $user->getError() );
+ //return false;
+ return $this->execute('edit');
+ }
+
+ $objectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' );
+ $groups = $acl->get_object_groups( $objectID, 'ARO' );
+ $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
+
+
+ if ( $user->get('id') == $me->get( 'id' ) && $user->get('block') == 1 )
+ {
+ $msg = JText::_( 'You cannot block Yourself!' );
+ $mainframe->enqueueMessage($msg, 'message');
+ return $this->execute('edit');
+ }
+ else if ( ( $this_group == 'super administrator' ) && $user->get('block') == 1 ) {
+ $msg = JText::_( 'You cannot block a Super Administrator' );
+ $mainframe->enqueueMessage($msg, 'message');
+ return $this->execute('edit');
+ }
+ else if ( ( $this_group == 'administrator' ) && ( $me->get( 'gid' ) == 24 ) && $user->get('block') == 1 )
+ {
+ $msg = JText::_( 'WARNBLOCK' );
+ $mainframe->enqueueMessage($msg, 'message');
+ return $this->execute('edit');
+ }
+ else if ( ( $this_group == 'super administrator' ) && ( $me->get( 'gid' ) != 25 ) )
+ {
+ $msg = JText::_( 'You cannot edit a super administrator account' );
+ $mainframe->enqueueMessage($msg, 'message');
+ return $this->execute('edit');
+ }
+ // Are we dealing with a new user which we need to create?
+ $isNew = ($user->get('id') < 1);
+ if (!$isNew)
+ {
+ // if group has been changed and where original group was a Super Admin
+ if ( $user->get('gid') != $original_gid && $original_gid == 25 )
+ {
+ // count number of active super admins
+ $query = 'SELECT COUNT( id )'
+ . ' FROM #__users'
+ . ' WHERE gid = 25'
+ . ' AND block = 0'
+ ;
+ $db->setQuery( $query );
+ $count = $db->loadResult();
+
+ if ( $count <= 1 )
+ {
+ // disallow change if only one Super Admin exists
+ $this->setRedirect( 'index.php?option=com_users', JText::_('WARN_ONLY_SUPER') );
+ return false;
+ }
+ }
+ }
+
+ /*
+ * Lets save the JUser object
+ */
+ if (!$user->save())
+ {
+
+ $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
+ $mainframe->enqueueMessage($user->getError(), 'error');
+ return $this->execute('edit');
+ }
+
+ /*
+ * Time for the email magic so get ready to sprinkle the magic dust...
+ */
+ if ($isNew)
+ {
+ $adminEmail = $me->get('email');
+ $adminName = $me->get('name');
+
+ $subject = JText::_('NEW_USER_MESSAGE_SUBJECT');
+ $message = sprintf ( JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear );
+
+ if ($MailFrom != '' && $FromName != '')
+ {
+ $adminName = $FromName;
+ $adminEmail = $MailFrom;
+ }
+ JUtility::sendMail( $adminEmail, $adminName, $user->get('email'), $subject, $message );
+ }
+
+ // If updating self, load the new user object into the session
+ if ($user->get('id') == $me->get('id'))
+ {
+ // Get an ACL object
+ $acl = &JFactory::getACL();
+
+ // Get the user group from the ACL
+ $grp = $acl->getAroGroup($user->get('id'));
+
+ // Mark the user as logged in
+ $user->set('guest', 0);
+ $user->set('aid', 1);
+
+ // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
+ if ($acl->is_group_child_of($grp->name, 'Registered') ||
+ $acl->is_group_child_of($grp->name, 'Public Backend')) {
+ $user->set('aid', 2);
+ }
+
+ // Set the usertype based on the ACL group name
+ $user->set('usertype', $grp->name);
+
+ $session = &JFactory::getSession();
+ $session->set('user', $user);
+ }
+
+ switch ( $this->getTask() )
+ {
+ case 'apply':
+ $msg = JText::sprintf( 'Successfully Saved changes to User', $user->get('name') );
+ $this->setRedirect( 'index.php?option=com_users&view=user&task=edit&cid[]='. $user->get('id'), $msg );
+ break;
+
+ case 'save':
+ default:
+ $msg = JText::sprintf( 'Successfully Saved User', $user->get('name') );
+ $this->setRedirect( 'index.php?option=com_users', $msg );
+ break;
+ }
+ }
+
+ /**
+ * Removes the record(s) from the database
+ */
+ function remove()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $currentUser =& JFactory::getUser();
+ $acl =& JFactory::getACL();
+ $cid = JRequest::getVar( 'cid', array(), '', 'array' );
+
+ JArrayHelper::toInteger( $cid );
+
+ if (count( $cid ) < 1) {
+ JError::raiseError(500, JText::_( 'Select a User to delete', true ) );
+ }
+
+ foreach ($cid as $id)
+ {
+ // check for a super admin ... can't delete them
+ $objectID = $acl->get_object_id( 'users', $id, 'ARO' );
+ $groups = $acl->get_object_groups( $objectID, 'ARO' );
+ $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
+
+ $success = false;
+ if ( $this_group == 'super administrator' )
+ {
+ $msg = JText::_( 'You cannot delete a Super Administrator' );
+ }
+ else if ( $id == $currentUser->get( 'id' ) )
+ {
+ $msg = JText::_( 'You cannot delete Yourself!' );
+ }
+ else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) )
+ {
+ $msg = JText::_( 'WARNDELETE' );
+ }
+ else
+ {
+ $user =& JUser::getInstance((int)$id);
+ $count = 2;
+
+ if ( $user->get( 'gid' ) == 25 )
+ {
+ // count number of active super admins
+ $query = 'SELECT COUNT( id )'
+ . ' FROM #__users'
+ . ' WHERE gid = 25'
+ . ' AND block = 0'
+ ;
+ $db->setQuery( $query );
+ $count = $db->loadResult();
+ }
+
+ if ( $count <= 1 && $user->get( 'gid' ) == 25 )
+ {
+ // cannot delete Super Admin where it is the only one that exists
+ $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site";
+ }
+ else
+ {
+ // delete user
+ $user->delete();
+ $msg = '';
+
+ JRequest::setVar( 'task', 'remove' );
+ JRequest::setVar( 'cid', $id );
+
+ // delete user acounts active sessions
+ $this->logout();
+ }
+ }
+ }
+
+ $this->setRedirect( 'index.php?option=com_users', $msg);
+ }
+
+ /**
+ * Cancels an edit operation
+ */
+ function cancel( )
+ {
+ $this->setRedirect( 'index.php?option=com_users' );
+ }
+
+ /**
+ * Disables the user account
+ */
+ function block( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $acl =& JFactory::getACL();
+ $currentUser =& JFactory::getUser();
+
+ $cid = JRequest::getVar( 'cid', array(), '', 'array' );
+ $block = $this->getTask() == 'block' ? 1 : 0;
+
+ JArrayHelper::toInteger( $cid );
+
+ if (count( $cid ) < 1) {
+ JError::raiseError(500, JText::_( 'Select a User to '.$this->getTask(), true ) );
+ }
+ foreach ($cid as $id)
+ {
+ // check for a super admin ... can't delete them
+ $objectID = $acl->get_object_id( 'users', $id, 'ARO' );
+ $groups = $acl->get_object_groups( $objectID, 'ARO' );
+ $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
+
+ $msg = '';
+ $success = false;
+ if ( $this_group == 'super administrator' )
+ {
+ $msg = JText::_( 'You cannot block a Super Administrator' );
+ }
+ else if ( $id == $currentUser->get( 'id' ) )
+ {
+ $msg = JText::_( 'You cannot block Yourself!' );
+ }
+ else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) )
+ {
+ $msg = JText::_( 'WARNBLOCK' );
+ }
+ else
+ {
+ $user =& JUser::getInstance((int)$id);
+ $count = 2;
+
+ if ( $user->get( 'gid' ) == 25 )
+ {
+ // count number of active super admins
+ $query = 'SELECT COUNT( id )'
+ . ' FROM #__users'
+ . ' WHERE gid = 25'
+ . ' AND block = 0'
+ ;
+ $db->setQuery( $query );
+ $count = $db->loadResult();
+ }
+
+ if ( $count <= 1 && $user->get( 'gid' ) == 25 )
+ {
+ // cannot delete Super Admin where it is the only one that exists
+ $msg = "You cannot block this Super Administrator as it is the only active Super Administrator for your site";
+ }
+ else
+ {
+ $user =& JUser::getInstance((int)$id);
+ $user->block = $block;
+ $user->save();
+
+ if($block)
+ {
+ JRequest::setVar( 'task', 'block' );
+ JRequest::setVar( 'cid', array($id) );
+
+ // delete user acounts active sessions
+ $this->logout();
+ }
+ }
+ }
+ }
+
+ $this->setRedirect( 'index.php?option=com_users', $msg);
+ }
+
+ /**
+ * Force log out a user
+ */
+ function logout( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ global $mainframe;
+
+ $db =& JFactory::getDBO();
+ $task = $this->getTask();
+ $cids = JRequest::getVar( 'cid', array(), '', 'array' );
+ $client = JRequest::getVar( 'client', 0, '', 'int' );
+ $id = JRequest::getVar( 'id', 0, '', 'int' );
+
+ JArrayHelper::toInteger($cids);
+
+ if ( count( $cids ) < 1 ) {
+ $this->setRedirect( 'index.php?option=com_users', JText::_( 'User Deleted' ) );
+ return false;
+ }
+
+ foreach($cids as $cid)
+ {
+ $options = array();
+
+ if ($task == 'logout' || $task == 'block') {
+ $options['clientid'][] = 0; //site
+ $options['clientid'][] = 1; //administrator
+ } else if ($task == 'flogout') {
+ $options['clientid'][] = $client;
+ }
+
+ $mainframe->logout((int)$cid, $options);
+ }
+
+
+ $msg = JText::_( 'User Session Ended' );
+ switch ( $task )
+ {
+ case 'flogout':
+ $this->setRedirect( 'index.php', $msg );
+ break;
+
+ case 'remove':
+ case 'block':
+ return;
+ break;
+
+ default:
+ $this->setRedirect( 'index.php?option=com_users', $msg );
+ break;
+ }
+ }
+
+ function contact()
+ {
+ $contact_id = JRequest::getVar( 'contact_id', '', 'post', 'int' );
+ $this->setRedirect( 'index.php?option=com_contact&task=edit&cid[]='. $contact_id );
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_users/users.class.php b/oss/joomla/trunk/administrator/components/com_users/users.class.php
index 1caa821f..ec8f6b60 100644
--- a/oss/joomla/trunk/administrator/components/com_users/users.class.php
+++ b/oss/joomla/trunk/administrator/components/com_users/users.class.php
@@ -1,30 +1,30 @@
-authorize( 'com_users', 'manage' )) {
- $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
-}
-
-// Require the base controller
-require_once (JPATH_COMPONENT.DS.'controller.php');
-
-// Create the controller
-$controller = new UsersController( );
-
-// Perform the Request task
-$controller->execute( JRequest::getCmd('task'));
+authorize( 'com_users', 'manage' )) {
+ $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
+}
+
+// Require the base controller
+require_once (JPATH_COMPONENT.DS.'controller.php');
+
+// Create the controller
+$controller = new UsersController( );
+
+// Perform the Request task
+$controller->execute( JRequest::getCmd('task'));
$controller->redirect();
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_users/users.xml b/oss/joomla/trunk/administrator/components/com_users/users.xml
index 310edb4c..c59ff38a 100644
--- a/oss/joomla/trunk/administrator/components/com_users/users.xml
+++ b/oss/joomla/trunk/administrator/components/com_users/users.xml
@@ -1,12 +1,12 @@
-
-
- User Manager
- Joomla! Project
- April 2006
- (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.5.0
- User Manager
-
+
+
+ User Manager
+ Joomla! Project
+ April 2006
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5.0
+ User Manager
+
diff --git a/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php b/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php
index bddb38ba..c800ccd3 100644
--- a/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php
+++ b/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php
@@ -1,141 +1,141 @@
-bind($post);
- }
-
- if ( $user->get('id'))
- {
- $query = 'SELECT *'
- . ' FROM #__contact_details'
- . ' WHERE user_id = '.(int) $cid[0]
- ;
- $db->setQuery( $query );
- $contact = $db->loadObjectList();
- }
- else
- {
- $contact = NULL;
- // Get the default group id for a new user
- $config = &JComponentHelper::getParams( 'com_users' );
- $newGrp = $config->get( 'new_usertype' );
- $user->set( 'gid', $acl->get_group_id( $newGrp, null, 'ARO' ) );
- }
-
- $userObjectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' );
- $userGroups = $acl->get_object_groups( $userObjectID, 'ARO' );
- $userGroupName = strtolower( $acl->get_group_name( $userGroups[0], 'ARO' ) );
-
- $myObjectID = $acl->get_object_id( 'users', $myuser->get('id'), 'ARO' );
- $myGroups = $acl->get_object_groups( $myObjectID, 'ARO' );
- $myGroupName = strtolower( $acl->get_group_name( $myGroups[0], 'ARO' ) );;
-
- // ensure user can't add/edit group higher than themselves
- /* NOTE : This check doesn't work commented out for the time being
- if ( is_array( $myGroups ) && count( $myGroups ) > 0 )
- {
- $excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' );
- }
- else
- {
- $excludeGroups = array();
- }
-
- if ( in_array( $userGroups[0], $excludeGroups ) )
- {
- echo 'not auth';
- $mainframe->redirect( 'index.php?option=com_users', JText::_('NOT_AUTH') );
- }
- */
-
- /*
- if ( $userGroupName == 'super administrator' )
- {
- // super administrators can't change
- $lists['gid'] = ''. JText::_( 'Super Administrator' ) .'';
- }
- else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) {
- */
-
- if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' )
- {
- // administrators can't change each other
- $lists['gid'] = ''. JText::_( 'Administrator' ) .'';
- }
- else
- {
- $gtree = $acl->get_group_children_tree( null, 'USERS', false );
-
- // remove users 'above' me
- //$i = 0;
- //while ($i < count( $gtree )) {
- // if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) {
- // array_splice( $gtree, $i, 1 );
- // } else {
- // $i++;
- // }
- //}
-
- $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid') );
- }
-
- // build the html select list
- $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block') );
-
- // build the html select list
- $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') );
-
- $this->assignRef('me', $me);
- $this->assignRef('lists', $lists);
- $this->assignRef('user', $user);
- $this->assignRef('contact', $contact);
-
- parent::display($tpl);
- }
-}
+bind($post);
+ }
+
+ if ( $user->get('id'))
+ {
+ $query = 'SELECT *'
+ . ' FROM #__contact_details'
+ . ' WHERE user_id = '.(int) $cid[0]
+ ;
+ $db->setQuery( $query );
+ $contact = $db->loadObjectList();
+ }
+ else
+ {
+ $contact = NULL;
+ // Get the default group id for a new user
+ $config = &JComponentHelper::getParams( 'com_users' );
+ $newGrp = $config->get( 'new_usertype' );
+ $user->set( 'gid', $acl->get_group_id( $newGrp, null, 'ARO' ) );
+ }
+
+ $userObjectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' );
+ $userGroups = $acl->get_object_groups( $userObjectID, 'ARO' );
+ $userGroupName = strtolower( $acl->get_group_name( $userGroups[0], 'ARO' ) );
+
+ $myObjectID = $acl->get_object_id( 'users', $myuser->get('id'), 'ARO' );
+ $myGroups = $acl->get_object_groups( $myObjectID, 'ARO' );
+ $myGroupName = strtolower( $acl->get_group_name( $myGroups[0], 'ARO' ) );;
+
+ // ensure user can't add/edit group higher than themselves
+ /* NOTE : This check doesn't work commented out for the time being
+ if ( is_array( $myGroups ) && count( $myGroups ) > 0 )
+ {
+ $excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' );
+ }
+ else
+ {
+ $excludeGroups = array();
+ }
+
+ if ( in_array( $userGroups[0], $excludeGroups ) )
+ {
+ echo 'not auth';
+ $mainframe->redirect( 'index.php?option=com_users', JText::_('NOT_AUTH') );
+ }
+ */
+
+ /*
+ if ( $userGroupName == 'super administrator' )
+ {
+ // super administrators can't change
+ $lists['gid'] = ''. JText::_( 'Super Administrator' ) .'';
+ }
+ else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) {
+ */
+
+ if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' )
+ {
+ // administrators can't change each other
+ $lists['gid'] = ''. JText::_( 'Administrator' ) .'';
+ }
+ else
+ {
+ $gtree = $acl->get_group_children_tree( null, 'USERS', false );
+
+ // remove users 'above' me
+ //$i = 0;
+ //while ($i < count( $gtree )) {
+ // if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) {
+ // array_splice( $gtree, $i, 1 );
+ // } else {
+ // $i++;
+ // }
+ //}
+
+ $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid') );
+ }
+
+ // build the html select list
+ $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block') );
+
+ // build the html select list
+ $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') );
+
+ $this->assignRef('me', $me);
+ $this->assignRef('lists', $lists);
+ $this->assignRef('user', $user);
+ $this->assignRef('contact', $contact);
+
+ parent::display($tpl);
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php
index 5a67726a..a78f3b6d 100644
--- a/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php
+++ b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php
@@ -1,138 +1,138 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php b/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php
index 182b1cab..badc2d6b 100644
--- a/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php
+++ b/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php
@@ -1,165 +1,168 @@
-getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.name', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' );
- $filter_type = $mainframe->getUserStateFromRequest( "$option.filter_type", 'filter_type', 0, 'string' );
- $filter_logged = $mainframe->getUserStateFromRequest( "$option.filter_logged", 'filter_logged', 0, 'int' );
- $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
-
- $where = array();
- if (isset( $search ) && $search!= '')
- {
- $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
- $where[] = 'a.username LIKE '.$searchEscaped.' OR a.email LIKE '.$searchEscaped.' OR a.name LIKE '.$searchEscaped;
- }
- if ( $filter_type )
- {
- if ( $filter_type == 'Public Frontend' )
- {
- $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' ';
- }
- else if ( $filter_type == 'Public Backend' )
- {
- $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' ';
- }
- else
- {
- $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) ';
- }
- }
- if ( $filter_logged == 1 )
- {
- $where[] = 's.userid = a.id';
- }
- else if ($filter_logged == 2)
- {
- $where[] = 's.userid IS NULL';
- }
-
- // exclude any child group id's for this user
- $pgids = $acl->get_group_children( $currentUser->get('gid'), 'ARO', 'RECURSE' );
-
- if (is_array( $pgids ) && count( $pgids ) > 0)
- {
- JArrayHelper::toInteger($pgids);
- $where[] = 'a.gid NOT IN (' . implode( ',', $pgids ) . ')';
- }
- $filter = '';
- if ($filter_logged == 1 || $filter_logged == 2)
- {
- $filter = ' INNER JOIN #__session AS s ON s.userid = a.id';
- }
-
- $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir;
- $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' );
-
- $query = 'SELECT COUNT(a.id)'
- . ' FROM #__users AS a'
- . $filter
- . $where
- ;
- $db->setQuery( $query );
- $total = $db->loadResult();
-
- jimport('joomla.html.pagination');
- $pagination = new JPagination( $total, $limitstart, $limit );
-
- $query = 'SELECT a.*, g.name AS groupname'
- . ' FROM #__users AS a'
- . ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id'
- . ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id'
- . ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id'
- . $filter
- . $where
- . ' GROUP BY a.id'
- . $orderby
- ;
- $db->setQuery( $query, $pagination->limitstart, $pagination->limit );
- $rows = $db->loadObjectList();
-
- $n = count( $rows );
- $template = 'SELECT COUNT(s.userid)'
- . ' FROM #__session AS s'
- . ' WHERE s.userid = %d'
- ;
- for ($i = 0; $i < $n; $i++)
- {
- $row = &$rows[$i];
- $query = sprintf( $template, intval( $row->id ) );
- $db->setQuery( $query );
- $row->loggedin = $db->loadResult();
- }
-
- // get list of Groups for dropdown filter
- $query = 'SELECT name AS value, name AS text'
- . ' FROM #__core_acl_aro_groups'
- . ' WHERE name != "ROOT"'
- . ' AND name != "USERS"'
- ;
- $db->setQuery( $query );
- $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Group' ) .' -' );
- foreach( $db->loadObjectList() as $obj )
- {
- $types[] = JHTML::_('select.option', $obj->value, JText::_( $obj->text ) );
- }
- $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" );
-
- // get list of Log Status for dropdown filter
- $logged[] = JHTML::_('select.option', 0, '- '. JText::_( 'Select Log Status' ) .' -');
- $logged[] = JHTML::_('select.option', 1, JText::_( 'Logged In' ) );
- $lists['logged'] = JHTML::_('select.genericlist', $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged" );
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- $this->assignRef('user', JFactory::getUser());
- $this->assignRef('lists', $lists);
- $this->assignRef('items', $rows);
- $this->assignRef('pagination', $pagination);
-
- parent::display($tpl);
- }
+getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.name', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' );
+ $filter_type = $mainframe->getUserStateFromRequest( "$option.filter_type", 'filter_type', 0, 'string' );
+ $filter_logged = $mainframe->getUserStateFromRequest( "$option.filter_logged", 'filter_logged', 0, 'int' );
+ $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
+
+ $where = array();
+ if (isset( $search ) && $search!= '')
+ {
+ $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ $where[] = 'a.username LIKE '.$searchEscaped.' OR a.email LIKE '.$searchEscaped.' OR a.name LIKE '.$searchEscaped;
+ }
+ if ( $filter_type )
+ {
+ if ( $filter_type == 'Public Frontend' )
+ {
+ $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' ';
+ }
+ else if ( $filter_type == 'Public Backend' )
+ {
+ $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' ';
+ }
+ else
+ {
+ $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) ';
+ }
+ }
+ if ( $filter_logged == 1 )
+ {
+ $where[] = 's.userid = a.id';
+ }
+ else if ($filter_logged == 2)
+ {
+ $where[] = 's.userid IS NULL';
+ }
+
+ // exclude any child group id's for this user
+ $pgids = $acl->get_group_children( $currentUser->get('gid'), 'ARO', 'RECURSE' );
+
+ if (is_array( $pgids ) && count( $pgids ) > 0)
+ {
+ JArrayHelper::toInteger($pgids);
+ $where[] = 'a.gid NOT IN (' . implode( ',', $pgids ) . ')';
+ }
+ $filter = '';
+ if ($filter_logged == 1 || $filter_logged == 2)
+ {
+ $filter = ' INNER JOIN #__session AS s ON s.userid = a.id';
+ }
+
+ $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir;
+ $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' );
+
+ $query = 'SELECT COUNT(a.id)'
+ . ' FROM #__users AS a'
+ . $filter
+ . $where
+ ;
+ $db->setQuery( $query );
+ $total = $db->loadResult();
+
+ jimport('joomla.html.pagination');
+ $pagination = new JPagination( $total, $limitstart, $limit );
+
+ $query = 'SELECT a.*, g.name AS groupname'
+ . ' FROM #__users AS a'
+ . ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id'
+ . ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id'
+ . ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id'
+ . $filter
+ . $where
+ . ' GROUP BY a.id'
+ . $orderby
+ ;
+ $db->setQuery( $query, $pagination->limitstart, $pagination->limit );
+ $rows = $db->loadObjectList();
+
+ $n = count( $rows );
+ $template = 'SELECT COUNT(s.userid)'
+ . ' FROM #__session AS s'
+ . ' WHERE s.userid = %d'
+ ;
+ for ($i = 0; $i < $n; $i++)
+ {
+ $row = &$rows[$i];
+ $query = sprintf( $template, intval( $row->id ) );
+ $db->setQuery( $query );
+ $row->loggedin = $db->loadResult();
+ }
+
+ // get list of Groups for dropdown filter
+ $query = 'SELECT name AS value, name AS text'
+ . ' FROM #__core_acl_aro_groups'
+ . ' WHERE name != "ROOT"'
+ . ' AND name != "USERS"'
+ ;
+ $db->setQuery( $query );
+ $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Group' ) .' -' );
+ foreach( $db->loadObjectList() as $obj )
+ {
+ $types[] = JHTML::_('select.option', $obj->value, JText::_( $obj->text ) );
+ }
+ $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" );
+
+ // get list of Log Status for dropdown filter
+ $logged[] = JHTML::_('select.option', 0, '- '. JText::_( 'Select Log Status' ) .' -');
+ $logged[] = JHTML::_('select.option', 1, JText::_( 'Logged In' ) );
+ $lists['logged'] = JHTML::_('select.genericlist', $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged" );
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ $this->assignRef('user', JFactory::getUser());
+ $this->assignRef('lists', $lists);
+ $this->assignRef('items', $rows);
+ $this->assignRef('pagination', $pagination);
+
+ parent::display($tpl);
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/controller.php b/oss/joomla/trunk/administrator/components/com_weblinks/controller.php
index 5b22426c..9d2a524a 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/controller.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/controller.php
@@ -1,205 +1,205 @@
-registerTask( 'add', 'display' );
- $this->registerTask( 'edit', 'display' );
- }
-
- function display( )
- {
- switch($this->getTask())
- {
- case 'add' :
- {
- JRequest::setVar( 'hidemainmenu', 1 );
- JRequest::setVar( 'layout', 'form' );
- JRequest::setVar( 'view' , 'weblink');
- JRequest::setVar( 'edit', false );
-
- // Checkout the weblink
- $model = $this->getModel('weblink');
- $model->checkout();
- } break;
- case 'edit' :
- {
- JRequest::setVar( 'hidemainmenu', 1 );
- JRequest::setVar( 'layout', 'form' );
- JRequest::setVar( 'view' , 'weblink');
- JRequest::setVar( 'edit', true );
-
- // Checkout the weblink
- $model = $this->getModel('weblink');
- $model->checkout();
- } break;
- }
-
- parent::display();
- }
-
- function save()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $post = JRequest::get('post');
- $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
- $post['id'] = (int) $cid[0];
-
- $model = $this->getModel('weblink');
-
- if ($model->store($post)) {
- $msg = JText::_( 'Weblink Saved' );
- } else {
- $msg = JText::_( 'Error Saving Weblink' );
- }
-
- // Check the table in so it can be edited.... we are done with it anyway
- $model->checkin();
- $link = 'index.php?option=com_weblinks';
- $this->setRedirect($link, $msg);
- }
-
- function remove()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (count( $cid ) < 1) {
- JError::raiseError(500, JText::_( 'Select an item to delete' ) );
- }
-
- $model = $this->getModel('weblink');
- if(!$model->delete($cid)) {
- echo "\n";
- }
-
- $this->setRedirect( 'index.php?option=com_weblinks' );
- }
-
-
- function publish()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (count( $cid ) < 1) {
- JError::raiseError(500, JText::_( 'Select an item to publish' ) );
- }
-
- $model = $this->getModel('weblink');
- if(!$model->publish($cid, 1)) {
- echo "\n";
- }
-
- $this->setRedirect( 'index.php?option=com_weblinks' );
- }
-
-
- function unpublish()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
-
- if (count( $cid ) < 1) {
- JError::raiseError(500, JText::_( 'Select an item to unpublish' ) );
- }
-
- $model = $this->getModel('weblink');
- if(!$model->publish($cid, 0)) {
- echo "\n";
- }
-
- $this->setRedirect( 'index.php?option=com_weblinks' );
- }
-
- function cancel()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- // Checkin the weblink
- $model = $this->getModel('weblink');
- $model->checkin();
-
- $this->setRedirect( 'index.php?option=com_weblinks' );
- }
-
-
- function orderup()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $model = $this->getModel('weblink');
- $model->move(-1);
-
- $this->setRedirect( 'index.php?option=com_weblinks');
- }
-
- function orderdown()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $model = $this->getModel('weblink');
- $model->move(1);
-
- $this->setRedirect( 'index.php?option=com_weblinks');
- }
-
- function saveorder()
- {
- // Check for request forgeries
- JRequest::checkToken() or jexit( 'Invalid Token' );
-
- $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
- $order = JRequest::getVar( 'order', array(), 'post', 'array' );
- JArrayHelper::toInteger($cid);
- JArrayHelper::toInteger($order);
-
- $model = $this->getModel('weblink');
- $model->saveorder($cid, $order);
-
- $msg = JText::_( 'New ordering saved' );
- $this->setRedirect( 'index.php?option=com_weblinks', $msg );
- }
+registerTask( 'add', 'display' );
+ $this->registerTask( 'edit', 'display' );
+ }
+
+ function display( )
+ {
+ switch($this->getTask())
+ {
+ case 'add' :
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+ JRequest::setVar( 'layout', 'form' );
+ JRequest::setVar( 'view' , 'weblink');
+ JRequest::setVar( 'edit', false );
+
+ // Checkout the weblink
+ $model = $this->getModel('weblink');
+ $model->checkout();
+ } break;
+ case 'edit' :
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+ JRequest::setVar( 'layout', 'form' );
+ JRequest::setVar( 'view' , 'weblink');
+ JRequest::setVar( 'edit', true );
+
+ // Checkout the weblink
+ $model = $this->getModel('weblink');
+ $model->checkout();
+ } break;
+ }
+
+ parent::display();
+ }
+
+ function save()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $post = JRequest::get('post');
+ $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+ $post['id'] = (int) $cid[0];
+
+ $model = $this->getModel('weblink');
+
+ if ($model->store($post)) {
+ $msg = JText::_( 'Weblink Saved' );
+ } else {
+ $msg = JText::_( 'Error Saving Weblink' );
+ }
+
+ // Check the table in so it can be edited.... we are done with it anyway
+ $model->checkin();
+ $link = 'index.php?option=com_weblinks';
+ $this->setRedirect($link, $msg);
+ }
+
+ function remove()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (count( $cid ) < 1) {
+ JError::raiseError(500, JText::_( 'Select an item to delete' ) );
+ }
+
+ $model = $this->getModel('weblink');
+ if(!$model->delete($cid)) {
+ echo "\n";
+ }
+
+ $this->setRedirect( 'index.php?option=com_weblinks' );
+ }
+
+
+ function publish()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (count( $cid ) < 1) {
+ JError::raiseError(500, JText::_( 'Select an item to publish' ) );
+ }
+
+ $model = $this->getModel('weblink');
+ if(!$model->publish($cid, 1)) {
+ echo "\n";
+ }
+
+ $this->setRedirect( 'index.php?option=com_weblinks' );
+ }
+
+
+ function unpublish()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+
+ if (count( $cid ) < 1) {
+ JError::raiseError(500, JText::_( 'Select an item to unpublish' ) );
+ }
+
+ $model = $this->getModel('weblink');
+ if(!$model->publish($cid, 0)) {
+ echo "\n";
+ }
+
+ $this->setRedirect( 'index.php?option=com_weblinks' );
+ }
+
+ function cancel()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ // Checkin the weblink
+ $model = $this->getModel('weblink');
+ $model->checkin();
+
+ $this->setRedirect( 'index.php?option=com_weblinks' );
+ }
+
+
+ function orderup()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $model = $this->getModel('weblink');
+ $model->move(-1);
+
+ $this->setRedirect( 'index.php?option=com_weblinks');
+ }
+
+ function orderdown()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $model = $this->getModel('weblink');
+ $model->move(1);
+
+ $this->setRedirect( 'index.php?option=com_weblinks');
+ }
+
+ function saveorder()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
+ $order = JRequest::getVar( 'order', array(), 'post', 'array' );
+ JArrayHelper::toInteger($cid);
+ JArrayHelper::toInteger($order);
+
+ $model = $this->getModel('weblink');
+ $model->saveorder($cid, $order);
+
+ $msg = JText::_( 'New ordering saved' );
+ $this->setRedirect( 'index.php?option=com_weblinks', $msg );
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php
index f155f709..32d3b520 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php
@@ -1,389 +1,389 @@
-setId((int)$array[0]);
- }
-
- /**
- * Method to set the weblink identifier
- *
- * @access public
- * @param int Weblink identifier
- */
- function setId($id)
- {
- // Set weblink id and wipe data
- $this->_id = $id;
- $this->_data = null;
- }
-
- /**
- * Method to get a weblink
- *
- * @since 1.5
- */
- function &getData()
- {
- // Load the weblink data
- if ($this->_loadData())
- {
- // Initialize some variables
- $user = &JFactory::getUser();
-
- // Check to see if the category is published
- if (!$this->_data->cat_pub) {
- JError::raiseError( 404, JText::_("Resource Not Found") );
- return;
- }
-
- // Check whether category access level allows access
- if ($this->_data->cat_access > $user->get('aid', 0)) {
- JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
- return;
- }
- }
- else $this->_initData();
-
- return $this->_data;
- }
-
- /**
- * Tests if weblink is checked out
- *
- * @access public
- * @param int A user id
- * @return boolean True if checked out
- * @since 1.5
- */
- function isCheckedOut( $uid=0 )
- {
- if ($this->_loadData())
- {
- if ($uid) {
- return ($this->_data->checked_out && $this->_data->checked_out != $uid);
- } else {
- return $this->_data->checked_out;
- }
- }
- }
-
- /**
- * Method to checkin/unlock the weblink
- *
- * @access public
- * @return boolean True on success
- * @since 1.5
- */
- function checkin()
- {
- if ($this->_id)
- {
- $weblink = & $this->getTable();
- if(! $weblink->checkin($this->_id)) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
- }
- return false;
- }
-
- /**
- * Method to checkout/lock the weblink
- *
- * @access public
- * @param int $uid User ID of the user checking the article out
- * @return boolean True on success
- * @since 1.5
- */
- function checkout($uid = null)
- {
- if ($this->_id)
- {
- // Make sure we have a user id to checkout the article with
- if (is_null($uid)) {
- $user =& JFactory::getUser();
- $uid = $user->get('id');
- }
- // Lets get to it and checkout the thing...
- $weblink = & $this->getTable();
- if(!$weblink->checkout($uid, $this->_id)) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- return true;
- }
- return false;
- }
-
- /**
- * Method to store the weblink
- *
- * @access public
- * @return boolean True on success
- * @since 1.5
- */
- function store($data)
- {
- $row =& $this->getTable();
-
- // Bind the form fields to the web link table
- if (!$row->bind($data)) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- // Create the timestamp for the date
- $row->date = gmdate('Y-m-d H:i:s');
-
- // if new item, order last in appropriate group
- if (!$row->id) {
- $where = 'catid = ' . (int) $row->catid ;
- $row->ordering = $row->getNextOrder( $where );
- }
-
- // Make sure the web link table is valid
- if (!$row->check()) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- // Store the web link table to the database
- if (!$row->store()) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- return true;
- }
-
- /**
- * Method to remove a weblink
- *
- * @access public
- * @return boolean True on success
- * @since 1.5
- */
- function delete($cid = array())
- {
- $result = false;
-
- if (count( $cid ))
- {
- JArrayHelper::toInteger($cid);
- $cids = implode( ',', $cid );
- $query = 'DELETE FROM #__weblinks'
- . ' WHERE id IN ( '.$cids.' )';
- $this->_db->setQuery( $query );
- if(!$this->_db->query()) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Method to (un)publish a weblink
- *
- * @access public
- * @return boolean True on success
- * @since 1.5
- */
- function publish($cid = array(), $publish = 1)
- {
- $user =& JFactory::getUser();
-
- if (count( $cid ))
- {
- JArrayHelper::toInteger($cid);
- $cids = implode( ',', $cid );
-
- $query = 'UPDATE #__weblinks'
- . ' SET published = '.(int) $publish
- . ' WHERE id IN ( '.$cids.' )'
- . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'
- ;
- $this->_db->setQuery( $query );
- if (!$this->_db->query()) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Method to move a weblink
- *
- * @access public
- * @return boolean True on success
- * @since 1.5
- */
- function move($direction)
- {
- $row =& $this->getTable();
- if (!$row->load($this->_id)) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- if (!$row->move( $direction, ' catid = '.(int) $row->catid.' AND published >= 0 ' )) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
-
- return true;
- }
-
- /**
- * Method to move a weblink
- *
- * @access public
- * @return boolean True on success
- * @since 1.5
- */
- function saveorder($cid = array(), $order)
- {
- $row =& $this->getTable();
- $groupings = array();
-
- // update ordering values
- for( $i=0; $i < count($cid); $i++ )
- {
- $row->load( (int) $cid[$i] );
- // track categories
- $groupings[] = $row->catid;
-
- if ($row->ordering != $order[$i])
- {
- $row->ordering = $order[$i];
- if (!$row->store()) {
- $this->setError($this->_db->getErrorMsg());
- return false;
- }
- }
- }
-
- // execute updateOrder for each parent group
- $groupings = array_unique( $groupings );
- foreach ($groupings as $group){
- $row->reorder('catid = '.(int) $group);
- }
-
- return true;
- }
-
- /**
- * Method to load content weblink data
- *
- * @access private
- * @return boolean True on success
- * @since 1.5
- */
- function _loadData()
- {
- // Lets load the content if it doesn't already exist
- if (empty($this->_data))
- {
- $query = 'SELECT w.*, cc.title AS category,'.
- ' cc.published AS cat_pub, cc.access AS cat_access'.
- ' FROM #__weblinks AS w' .
- ' LEFT JOIN #__categories AS cc ON cc.id = w.catid' .
- ' WHERE w.id = '.(int) $this->_id;
- $this->_db->setQuery($query);
- $this->_data = $this->_db->loadObject();
- return (boolean) $this->_data;
- }
- return true;
- }
-
- /**
- * Method to initialise the weblink data
- *
- * @access private
- * @return boolean True on success
- * @since 1.5
- */
- function _initData()
- {
- // Lets load the content if it doesn't already exist
- if (empty($this->_data))
- {
- $weblink = new stdClass();
- $weblink->id = 0;
- $weblink->catid = 0;
- $weblink->sid = 0;
- $weblink->title = null;
- $weblink->alias = null;
- $weblink->url = null;
- $weblink->description = null;
- $weblink->date = null;
- $weblink->hits = 0;
- $weblink->published = 0;
- $weblink->checked_out = 0;
- $weblink->checked_out_time = 0;
- $weblink->ordering = 0;
- $weblink->archived = 0;
- $weblink->approved = 0;
- $weblink->params = null;
- $weblink->category = null;
- $this->_data = $weblink;
- return (boolean) $this->_data;
- }
- return true;
- }
+setId((int)$array[0]);
+ }
+
+ /**
+ * Method to set the weblink identifier
+ *
+ * @access public
+ * @param int Weblink identifier
+ */
+ function setId($id)
+ {
+ // Set weblink id and wipe data
+ $this->_id = $id;
+ $this->_data = null;
+ }
+
+ /**
+ * Method to get a weblink
+ *
+ * @since 1.5
+ */
+ function &getData()
+ {
+ // Load the weblink data
+ if ($this->_loadData())
+ {
+ // Initialize some variables
+ $user = &JFactory::getUser();
+
+ // Check to see if the category is published
+ if (!$this->_data->cat_pub) {
+ JError::raiseError( 404, JText::_("Resource Not Found") );
+ return;
+ }
+
+ // Check whether category access level allows access
+ if ($this->_data->cat_access > $user->get('aid', 0)) {
+ JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
+ return;
+ }
+ }
+ else $this->_initData();
+
+ return $this->_data;
+ }
+
+ /**
+ * Tests if weblink is checked out
+ *
+ * @access public
+ * @param int A user id
+ * @return boolean True if checked out
+ * @since 1.5
+ */
+ function isCheckedOut( $uid=0 )
+ {
+ if ($this->_loadData())
+ {
+ if ($uid) {
+ return ($this->_data->checked_out && $this->_data->checked_out != $uid);
+ } else {
+ return $this->_data->checked_out;
+ }
+ }
+ }
+
+ /**
+ * Method to checkin/unlock the weblink
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function checkin()
+ {
+ if ($this->_id)
+ {
+ $weblink = & $this->getTable();
+ if(! $weblink->checkin($this->_id)) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Method to checkout/lock the weblink
+ *
+ * @access public
+ * @param int $uid User ID of the user checking the article out
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function checkout($uid = null)
+ {
+ if ($this->_id)
+ {
+ // Make sure we have a user id to checkout the article with
+ if (is_null($uid)) {
+ $user =& JFactory::getUser();
+ $uid = $user->get('id');
+ }
+ // Lets get to it and checkout the thing...
+ $weblink = & $this->getTable();
+ if(!$weblink->checkout($uid, $this->_id)) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Method to store the weblink
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function store($data)
+ {
+ $row =& $this->getTable();
+
+ // Bind the form fields to the web link table
+ if (!$row->bind($data)) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ // Create the timestamp for the date
+ $row->date = gmdate('Y-m-d H:i:s');
+
+ // if new item, order last in appropriate group
+ if (!$row->id) {
+ $where = 'catid = ' . (int) $row->catid ;
+ $row->ordering = $row->getNextOrder( $where );
+ }
+
+ // Make sure the web link table is valid
+ if (!$row->check()) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ // Store the web link table to the database
+ if (!$row->store()) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to remove a weblink
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function delete($cid = array())
+ {
+ $result = false;
+
+ if (count( $cid ))
+ {
+ JArrayHelper::toInteger($cid);
+ $cids = implode( ',', $cid );
+ $query = 'DELETE FROM #__weblinks'
+ . ' WHERE id IN ( '.$cids.' )';
+ $this->_db->setQuery( $query );
+ if(!$this->_db->query()) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to (un)publish a weblink
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function publish($cid = array(), $publish = 1)
+ {
+ $user =& JFactory::getUser();
+
+ if (count( $cid ))
+ {
+ JArrayHelper::toInteger($cid);
+ $cids = implode( ',', $cid );
+
+ $query = 'UPDATE #__weblinks'
+ . ' SET published = '.(int) $publish
+ . ' WHERE id IN ( '.$cids.' )'
+ . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'
+ ;
+ $this->_db->setQuery( $query );
+ if (!$this->_db->query()) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to move a weblink
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function move($direction)
+ {
+ $row =& $this->getTable();
+ if (!$row->load($this->_id)) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ if (!$row->move( $direction, ' catid = '.(int) $row->catid.' AND published >= 0 ' )) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to move a weblink
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function saveorder($cid = array(), $order)
+ {
+ $row =& $this->getTable();
+ $groupings = array();
+
+ // update ordering values
+ for( $i=0; $i < count($cid); $i++ )
+ {
+ $row->load( (int) $cid[$i] );
+ // track categories
+ $groupings[] = $row->catid;
+
+ if ($row->ordering != $order[$i])
+ {
+ $row->ordering = $order[$i];
+ if (!$row->store()) {
+ $this->setError($this->_db->getErrorMsg());
+ return false;
+ }
+ }
+ }
+
+ // execute updateOrder for each parent group
+ $groupings = array_unique( $groupings );
+ foreach ($groupings as $group){
+ $row->reorder('catid = '.(int) $group);
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to load content weblink data
+ *
+ * @access private
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function _loadData()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_data))
+ {
+ $query = 'SELECT w.*, cc.title AS category,'.
+ ' cc.published AS cat_pub, cc.access AS cat_access'.
+ ' FROM #__weblinks AS w' .
+ ' LEFT JOIN #__categories AS cc ON cc.id = w.catid' .
+ ' WHERE w.id = '.(int) $this->_id;
+ $this->_db->setQuery($query);
+ $this->_data = $this->_db->loadObject();
+ return (boolean) $this->_data;
+ }
+ return true;
+ }
+
+ /**
+ * Method to initialise the weblink data
+ *
+ * @access private
+ * @return boolean True on success
+ * @since 1.5
+ */
+ function _initData()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_data))
+ {
+ $weblink = new stdClass();
+ $weblink->id = 0;
+ $weblink->catid = 0;
+ $weblink->sid = 0;
+ $weblink->title = null;
+ $weblink->alias = null;
+ $weblink->url = null;
+ $weblink->description = null;
+ $weblink->date = null;
+ $weblink->hits = 0;
+ $weblink->published = 0;
+ $weblink->checked_out = 0;
+ $weblink->checked_out_time = 0;
+ $weblink->ordering = 0;
+ $weblink->archived = 0;
+ $weblink->approved = 0;
+ $weblink->params = null;
+ $weblink->category = null;
+ $this->_data = $weblink;
+ return (boolean) $this->_data;
+ }
+ return true;
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php
index 8cd5ec0b..0e2cb1f7 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php
@@ -1,190 +1,193 @@
-getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
-
- // In case limit has been changed, adjust limitstart accordingly
- $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
-
- $this->setState('limit', $limit);
- $this->setState('limitstart', $limitstart);
- }
-
- /**
- * Method to get weblinks item data
- *
- * @access public
- * @return array
- */
- function getData()
- {
- // Lets load the content if it doesn't already exist
- if (empty($this->_data))
- {
- $query = $this->_buildQuery();
- $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
- }
-
- return $this->_data;
- }
-
- /**
- * Method to get the total number of weblink items
- *
- * @access public
- * @return integer
- */
- function getTotal()
- {
- // Lets load the content if it doesn't already exist
- if (empty($this->_total))
- {
- $query = $this->_buildQuery();
- $this->_total = $this->_getListCount($query);
- }
-
- return $this->_total;
- }
-
- /**
- * Method to get a pagination object for the weblinks
- *
- * @access public
- * @return integer
- */
- function getPagination()
- {
- // Lets load the content if it doesn't already exist
- if (empty($this->_pagination))
- {
- jimport('joomla.html.pagination');
- $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
- }
-
- return $this->_pagination;
- }
-
- function _buildQuery()
- {
- // Get the WHERE and ORDER BY clauses for the query
- $where = $this->_buildContentWhere();
- $orderby = $this->_buildContentOrderBy();
-
- $query = ' SELECT a.*, cc.title AS category, u.name AS editor '
- . ' FROM #__weblinks AS a '
- . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid '
- . ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
- . $where
- . $orderby
- ;
-
- return $query;
- }
-
- function _buildContentOrderBy()
- {
- global $mainframe, $option;
-
- $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
-
- if ($filter_order == 'a.ordering'){
- $orderby = ' ORDER BY category, a.ordering '.$filter_order_Dir;
- } else {
- $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.' , category, a.ordering ';
- }
-
- return $orderby;
- }
-
- function _buildContentWhere()
- {
- global $mainframe, $option;
- $db =& JFactory::getDBO();
- $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
- $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' );
- $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
- $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- $where = array();
-
- if ($filter_catid > 0) {
- $where[] = 'a.catid = '.(int) $filter_catid;
- }
- if ($search) {
- $where[] = 'LOWER(a.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
- }
- if ( $filter_state ) {
- if ( $filter_state == 'P' ) {
- $where[] = 'a.published = 1';
- } else if ($filter_state == 'U' ) {
- $where[] = 'a.published = 0';
- }
- }
-
- $where = ( count( $where ) ? ' WHERE '. implode( ' AND ', $where ) : '' );
-
- return $where;
- }
-}
+getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
+ $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
+
+ // In case limit has been changed, adjust limitstart accordingly
+ $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
+
+ $this->setState('limit', $limit);
+ $this->setState('limitstart', $limitstart);
+ }
+
+ /**
+ * Method to get weblinks item data
+ *
+ * @access public
+ * @return array
+ */
+ function getData()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_data))
+ {
+ $query = $this->_buildQuery();
+ $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * Method to get the total number of weblink items
+ *
+ * @access public
+ * @return integer
+ */
+ function getTotal()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_total))
+ {
+ $query = $this->_buildQuery();
+ $this->_total = $this->_getListCount($query);
+ }
+
+ return $this->_total;
+ }
+
+ /**
+ * Method to get a pagination object for the weblinks
+ *
+ * @access public
+ * @return integer
+ */
+ function getPagination()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_pagination))
+ {
+ jimport('joomla.html.pagination');
+ $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
+ }
+
+ return $this->_pagination;
+ }
+
+ function _buildQuery()
+ {
+ // Get the WHERE and ORDER BY clauses for the query
+ $where = $this->_buildContentWhere();
+ $orderby = $this->_buildContentOrderBy();
+
+ $query = ' SELECT a.*, cc.title AS category, u.name AS editor '
+ . ' FROM #__weblinks AS a '
+ . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid '
+ . ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
+ . $where
+ . $orderby
+ ;
+
+ return $query;
+ }
+
+ function _buildContentOrderBy()
+ {
+ global $mainframe, $option;
+
+ $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
+
+ if ($filter_order == 'a.ordering'){
+ $orderby = ' ORDER BY category, a.ordering '.$filter_order_Dir;
+ } else {
+ $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.' , category, a.ordering ';
+ }
+
+ return $orderby;
+ }
+
+ function _buildContentWhere()
+ {
+ global $mainframe, $option;
+ $db =& JFactory::getDBO();
+ $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
+ $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' );
+ $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
+ $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ $where = array();
+
+ if ($filter_catid > 0) {
+ $where[] = 'a.catid = '.(int) $filter_catid;
+ }
+ if ($search) {
+ $where[] = 'LOWER(a.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ }
+ if ( $filter_state ) {
+ if ( $filter_state == 'P' ) {
+ $where[] = 'a.published = 1';
+ } else if ($filter_state == 'U' ) {
+ $where[] = 'a.published = 0';
+ }
+ }
+
+ $where = ( count( $where ) ? ' WHERE '. implode( ' AND ', $where ) : '' );
+
+ return $where;
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php b/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php
index b09b1836..602e8094 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php
@@ -1,190 +1,190 @@
-loadArray($array['params']);
- $array['params'] = $registry->toString();
- }
-
- return parent::bind($array, $ignore);
- }
-
- /**
- * Overloaded check method to ensure data integrity
- *
- * @access public
- * @return boolean True on success
- * @since 1.0
- */
- function check()
- {
- if (JFilterInput::checkAttribute(array ('href', $this->url))) {
- $this->setError( JText::_('Please provide a valid URL'));
- return false;
- }
-
- //Remove all HTML tags from the title and description
- $filter = new JFilterInput(array(), array(), 0, 0);
- $this->description = $filter->clean($this->description);
- $this->title = $filter->clean($this->title);
-
- /** check for valid name */
- if (trim($this->title) == '') {
- $this->setError(JText::_('Your Weblink must contain a title.'));
- return false;
- }
-
- if (!(eregi('http://', $this->url) || (eregi('https://', $this->url)) || (eregi('ftp://', $this->url)))) {
- $this->url = 'http://'.$this->url;
- }
-
- /** check for existing name */
- $query = 'SELECT id FROM #__weblinks WHERE title = '.$this->_db->Quote($this->title).' AND catid = '.(int) $this->catid;
- $this->_db->setQuery($query);
-
- $xid = intval($this->_db->loadResult());
- if ($xid && $xid != intval($this->id)) {
- $this->setError(JText::sprintf('WARNNAMETRYAGAIN', JText::_('Web Link')));
- return false;
- }
-
- if(empty($this->alias)) {
- $this->alias = $this->title;
- }
- $this->alias = JFilterOutput::stringURLSafe($this->alias);
- if(trim(str_replace('-','',$this->alias)) == '') {
- $datenow =& JFactory::getDate();
- $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
- }
-
- return true;
- }
-}
+loadArray($array['params']);
+ $array['params'] = $registry->toString();
+ }
+
+ return parent::bind($array, $ignore);
+ }
+
+ /**
+ * Overloaded check method to ensure data integrity
+ *
+ * @access public
+ * @return boolean True on success
+ * @since 1.0
+ */
+ function check()
+ {
+ if (JFilterInput::checkAttribute(array ('href', $this->url))) {
+ $this->setError( JText::_('Please provide a valid URL'));
+ return false;
+ }
+
+ //Remove all HTML tags from the title and description
+ $filter = new JFilterInput(array(), array(), 0, 0);
+ $this->description = $filter->clean($this->description);
+ $this->title = $filter->clean($this->title);
+
+ /** check for valid name */
+ if (trim($this->title) == '') {
+ $this->setError(JText::_('Your Weblink must contain a title.'));
+ return false;
+ }
+
+ if (!(preg_match('#http://#i', $this->url) || (preg_match('#https://#i', $this->url)) || (preg_match('#ftp://#i', $this->url)))) {
+ $this->url = 'http://'.$this->url;
+ }
+
+ /** check for existing name */
+ $query = 'SELECT id FROM #__weblinks WHERE title = '.$this->_db->Quote($this->title).' AND catid = '.(int) $this->catid;
+ $this->_db->setQuery($query);
+
+ $xid = intval($this->_db->loadResult());
+ if ($xid && $xid != intval($this->id)) {
+ $this->setError(JText::sprintf('WARNNAMETRYAGAIN', JText::_('Web Link')));
+ return false;
+ }
+
+ if(empty($this->alias)) {
+ $this->alias = $this->title;
+ }
+ $this->alias = JFilterOutput::stringURLSafe($this->alias);
+ if(trim(str_replace('-','',$this->alias)) == '') {
+ $datenow =& JFactory::getDate();
+ $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
+ }
+
+ return true;
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php
index b069a3aa..05efa339 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php
@@ -1,111 +1,111 @@
-getLayout() == 'form') {
- $this->_displayForm($tpl);
- return;
- }
-
- //get the weblink
- $weblink =& $this->get('data');
-
- if ($weblink->url) {
- // redirects to url if matching id found
- $mainframe->redirect($weblink->url);
- }
-
- parent::display($tpl);
- }
-
- function _displayForm($tpl)
- {
- global $mainframe, $option;
-
- $db =& JFactory::getDBO();
- $uri =& JFactory::getURI();
- $user =& JFactory::getUser();
- $model =& $this->getModel();
-
-
- $lists = array();
-
- //get the weblink
- $weblink =& $this->get('data');
- $isNew = ($weblink->id < 1);
-
- // fail if checked out not by 'me'
- if ($model->isCheckedOut( $user->get('id') )) {
- $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The weblink' ), $weblink->title );
- $mainframe->redirect( 'index.php?option='. $option, $msg );
- }
-
- // Edit or Create?
- if (!$isNew)
- {
- $model->checkout( $user->get('id') );
- }
- else
- {
- // initialise new record
- $weblink->published = 1;
- $weblink->approved = 1;
- $weblink->order = 0;
- $weblink->catid = JRequest::getVar( 'catid', 0, 'post', 'int' );
- }
-
- // build the html select list for ordering
- $query = 'SELECT ordering AS value, title AS text'
- . ' FROM #__weblinks'
- . ' WHERE catid = ' . (int) $weblink->catid
- . ' ORDER BY ordering';
-
- $lists['ordering'] = JHTML::_('list.specificordering', $weblink, $weblink->id, $query );
-
- // build list of categories
- $lists['catid'] = JHTML::_('list.category', 'catid', $option, intval( $weblink->catid ) );
- // build the html select list
- $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $weblink->published );
-
- //clean weblink data
- JFilterOutput::objectHTMLSafe( $weblink, ENT_QUOTES, 'description' );
-
- $file = JPATH_COMPONENT.DS.'models'.DS.'weblink.xml';
- $params = new JParameter( $weblink->params, $file );
-
- $this->assignRef('lists', $lists);
- $this->assignRef('weblink', $weblink);
- $this->assignRef('params', $params);
-
- parent::display($tpl);
- }
-}
+getLayout() == 'form') {
+ $this->_displayForm($tpl);
+ return;
+ }
+
+ //get the weblink
+ $weblink =& $this->get('data');
+
+ if ($weblink->url) {
+ // redirects to url if matching id found
+ $mainframe->redirect($weblink->url);
+ }
+
+ parent::display($tpl);
+ }
+
+ function _displayForm($tpl)
+ {
+ global $mainframe, $option;
+
+ $db =& JFactory::getDBO();
+ $uri =& JFactory::getURI();
+ $user =& JFactory::getUser();
+ $model =& $this->getModel();
+
+
+ $lists = array();
+
+ //get the weblink
+ $weblink =& $this->get('data');
+ $isNew = ($weblink->id < 1);
+
+ // fail if checked out not by 'me'
+ if ($model->isCheckedOut( $user->get('id') )) {
+ $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The weblink' ), $weblink->title );
+ $mainframe->redirect( 'index.php?option='. $option, $msg );
+ }
+
+ // Edit or Create?
+ if (!$isNew)
+ {
+ $model->checkout( $user->get('id') );
+ }
+ else
+ {
+ // initialise new record
+ $weblink->published = 1;
+ $weblink->approved = 1;
+ $weblink->order = 0;
+ $weblink->catid = JRequest::getVar( 'catid', 0, 'post', 'int' );
+ }
+
+ // build the html select list for ordering
+ $query = 'SELECT ordering AS value, title AS text'
+ . ' FROM #__weblinks'
+ . ' WHERE catid = ' . (int) $weblink->catid
+ . ' ORDER BY ordering';
+
+ $lists['ordering'] = JHTML::_('list.specificordering', $weblink, $weblink->id, $query );
+
+ // build list of categories
+ $lists['catid'] = JHTML::_('list.category', 'catid', $option, intval( $weblink->catid ) );
+ // build the html select list
+ $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $weblink->published );
+
+ //clean weblink data
+ JFilterOutput::objectHTMLSafe( $weblink, ENT_QUOTES, 'description' );
+
+ $file = JPATH_COMPONENT.DS.'models'.DS.'weblink.xml';
+ $params = new JParameter( $weblink->params, $file );
+
+ $this->assignRef('lists', $lists);
+ $this->assignRef('weblink', $weblink);
+ $this->assignRef('params', $params);
+
+ parent::display($tpl);
+ }
+}
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php
index 767a5f95..75332c1e 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php
@@ -1,141 +1,141 @@
-
-
-
-
-lists['order'] == 'a.ordering');
-?>
-
+
+
+
+
+lists['order'] == 'a.ordering');
+?>
+
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php
index b1fceb85..c3190f58 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php
@@ -1,70 +1,73 @@
-getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
- $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' );
- $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
- $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
- $search = JString::strtolower( $search );
-
- // Get data from the model
- $items = & $this->get( 'Data');
- $total = & $this->get( 'Total');
- $pagination = & $this->get( 'Pagination' );
-
- // build list of categories
- $javascript = 'onchange="document.adminForm.submit();"';
- $lists['catid'] = JHTML::_('list.category', 'filter_catid', $option, intval( $filter_catid ), $javascript );
-
- // state filter
- $lists['state'] = JHTML::_('grid.state', $filter_state );
-
- // table ordering
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
-
- // search filter
- $lists['search']= $search;
-
- $this->assignRef('user', JFactory::getUser());
- $this->assignRef('lists', $lists);
- $this->assignRef('items', $items);
- $this->assignRef('pagination', $pagination);
-
- parent::display($tpl);
- }
+getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
+ $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' );
+ $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
+ $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
+ if (strpos($search, '"') !== false) {
+ $search = str_replace(array('=', '<'), '', $search);
+ }
+ $search = JString::strtolower($search);
+
+ // Get data from the model
+ $items = & $this->get( 'Data');
+ $total = & $this->get( 'Total');
+ $pagination = & $this->get( 'Pagination' );
+
+ // build list of categories
+ $javascript = 'onchange="document.adminForm.submit();"';
+ $lists['catid'] = JHTML::_('list.category', 'filter_catid', $option, intval( $filter_catid ), $javascript );
+
+ // state filter
+ $lists['state'] = JHTML::_('grid.state', $filter_state );
+
+ // table ordering
+ $lists['order_Dir'] = $filter_order_Dir;
+ $lists['order'] = $filter_order;
+
+ // search filter
+ $lists['search']= $search;
+
+ $this->assignRef('user', JFactory::getUser());
+ $this->assignRef('lists', $lists);
+ $this->assignRef('items', $items);
+ $this->assignRef('pagination', $pagination);
+
+ parent::display($tpl);
+ }
}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php
index a8ee25cf..66ac844e 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php
@@ -1,33 +1,33 @@
-authorize( 'com_weblinks', 'manage' )) {
- $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
-}
-
-// Require the base controller
-require_once (JPATH_COMPONENT.DS.'controller.php');
-
-$controller = new WeblinksController( );
-
-// Perform the Request task
-$controller->execute( JRequest::getCmd('task'));
+authorize( 'com_weblinks', 'manage' )) {
+ $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
+}
+
+// Require the base controller
+require_once (JPATH_COMPONENT.DS.'controller.php');
+
+$controller = new WeblinksController( );
+
+// Perform the Request task
+$controller->execute( JRequest::getCmd('task'));
$controller->redirect();
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml
index 049c0365..5c9d1502 100644
--- a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml
+++ b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml
@@ -1,12 +1,12 @@
-
-
- Weblinks
- Joomla! Project
- April 2006
- (C) 2005 - 2008 Open Source Matters. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- admin@joomla.org
- www.joomla.org
- 1.5.0
- This component shows a listing of Weblinks
-
+
+
+ Weblinks
+ Joomla! Project
+ April 2006
+ Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5.0
+ This component shows a listing of Weblinks
+
diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html
index 7f1ed505..90f52ddd 100644
--- a/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html
+++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html
@@ -1,14 +1,14 @@
-
-
-
-Credits
-
-
-
-
-
-
Credits
-
The local copy of this help file is no longer maintained. Please use the online version.
-
+
+
+
+Credits
+
+
+
+
+
+
Credits
+
The local copy of this help file is no longer maintained. Please use the online version.
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html
index cc8a7466..e88c532f 100644
--- a/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html
+++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html
@@ -1,14 +1,14 @@
-
-
-
-Glossary
-
-
-
-
-
-
Glossary
-
The local copy of this help file is no longer maintained. Please use the online version.
-
+
+
+
+Glossary
+
+
+
+
+
+
Glossary
+
The local copy of this help file is no longer maintained. Please use the online version.
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html
index 0cfe4fdd..f9b2fa89 100644
--- a/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html
+++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html
@@ -1,14 +1,14 @@
-
-
-
-Support
-
-
-
-
-
-
Support
-
The local copy of this help file is no longer maintained. Please use the online version.
-
+
+
+
+Support
+
+
+
+
+
+
Support
+
The local copy of this help file is no longer maintained. Please use the online version.
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html
index fd281238..df49b3c2 100644
--- a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html
+++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html
@@ -4,7 +4,7 @@
What's New in Version 1.0
-
+
diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html
index 7d928250..64ca590f 100644
--- a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html
+++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html
@@ -1,54 +1,54 @@
-
-
-
-What's New in Version 1.5
-
-
-
-
-
-
-
What's New in Version 1.5
-
-
The following outlines the highlights of the second major release of Joomla!
-
-
As with previous releases, Joomla! provides a unified and easy-to-use framework for delivering content for websites of all kinds. To support the changing nature of the Internet and emerging web technologies, Joomla! required substantial restructuring of its core functionality and we also used this effort to simplify many challenges within the current user interface. Joomla! 1.5 has many new features.
-
-
The goals for the Joomla! 1.5 release are to:
-
-
Substantially improve usability, manageability, and scalability far beyond the original Mambo foundations.
-
Expand accessibility to support internationalisation, double-byte characters and Right-to-Left support for Arabic and Hebrew languages.
-
Extend the integration of external applications through Web Services and remote authentication such as the Lightweight Directory Access Protocol (LDAP).
-
Enhance the content delivery, template and presentation capabilities to support accessibility standards and content delivery to any destination.
-
Achieve a more sustainable and flexible framework for component and extension developers.
-
Deliver backwards compatibility with previous releases of components, templates, modules and other extensions.
-
-
-
What are "extensions"?
-
Components, languages, modules, plugins and templates are now collectively known as Extensions.
-
-
Where did the installer go?
-
The improved installer can be found under the extensions option. With versions prior to 1.5 you needed to select a specific extension type when you wanted to install it. With Joomla! 1.5 you just select the extension you want to upload, and click on install. The installer will do all the hard work for you.
-
-
What happened to the locale setting?
-
This is now defined in the language .xml file in the language metadata settings. If you are having locale problems (dates don't appear in your language, for example) you might want to check/edit the entries in the locale tag. Note that multiple locale strings can be set and the host will usually accept the first one recognised.
-
-
Only one edit window! How do I create "Read more..."?
-
This is now implemented by inserting a tag (button is in the editor area) a dotted line appears in the edited text showing the split location for the "Read more...". A new bot takes care of the rest.
-
It is worth mentioning that this does not have a negative effect on migrated data from older sites. The new implementation is fully backwards compatible.
-
-
Where did the Mambots go?
-
Mambots have been renamed as "Plugins". Mambots were introduced in Mambo and offered possibilities to add plugin logic to your site mainly for the purpose of manipulating content. In Joomla!, Plugins will now have much broader capabilities than Mambots. Plugins are able to extend functionality at the framework layer as well.
-
-
Where is the static content?
-
In Joomla! versions prior to 1.5 there was a distinct difference between static and normal content. Both content types are still around, but are not handled as separate items. If you want to create static content, just select "uncategorised" as section and category and the content is handled as static content.
-
-
What about developers?
-
This is the release that developers' have been waiting for. A massive effort has been made to refactor and reorganise the core of Joomla! into a true extendable framework. The new features in the framework are too many to list here but additional documentation can be found on the Joomla! Developer Network site.
-
-
Compatibility
-
We have made every effort to make this version backwards compatible with Joomla 1.0. In order to install 1.0 extensions you will probably need to activate the legacy code plugin. This can be found in the Plugin Manager (it's called "System - Legacy") and you just need to enable it.
-
-
-
+
+
+
+What's New in Version 1.5
+
+
+
+
+
+
+
What's New in Version 1.5
+
+
The following outlines the highlights of the second major release of Joomla!
+
+
As with previous releases, Joomla! provides a unified and easy-to-use framework for delivering content for websites of all kinds. To support the changing nature of the Internet and emerging web technologies, Joomla! required substantial restructuring of its core functionality and we also used this effort to simplify many challenges within the current user interface. Joomla! 1.5 has many new features.
+
+
The goals for the Joomla! 1.5 release are to:
+
+
Substantially improve usability, manageability, and scalability far beyond the original Mambo foundations.
+
Expand accessibility to support internationalisation, double-byte characters and Right-to-Left support for Arabic and Hebrew languages.
+
Extend the integration of external applications through Web Services and remote authentication such as the Lightweight Directory Access Protocol (LDAP).
+
Enhance the content delivery, template and presentation capabilities to support accessibility standards and content delivery to any destination.
+
Achieve a more sustainable and flexible framework for component and extension developers.
+
Deliver backwards compatibility with previous releases of components, templates, modules and other extensions.
+
+
+
What are "extensions"?
+
Components, languages, modules, plugins and templates are now collectively known as Extensions.
+
+
Where did the installer go?
+
The improved installer can be found under the extensions option. With versions prior to 1.5 you needed to select a specific extension type when you wanted to install it. With Joomla! 1.5 you just select the extension you want to upload, and click on install. The installer will do all the hard work for you.
+
+
What happened to the locale setting?
+
This is now defined in the language .xml file in the language metadata settings. If you are having locale problems (dates don't appear in your language, for example) you might want to check/edit the entries in the locale tag. Note that multiple locale strings can be set and the host will usually accept the first one recognised.
+
+
Only one edit window! How do I create "Read more..."?
+
This is now implemented by inserting a tag (button is in the editor area) a dotted line appears in the edited text showing the split location for the "Read more...". A new bot takes care of the rest.
+
It is worth mentioning that this does not have a negative effect on migrated data from older sites. The new implementation is fully backwards compatible.
+
+
Where did the Mambots go?
+
Mambots have been renamed as "Plugins". Mambots were introduced in Mambo and offered possibilities to add plugin logic to your site mainly for the purpose of manipulating content. In Joomla!, Plugins will now have much broader capabilities than Mambots. Plugins are able to extend functionality at the framework layer as well.
+
+
Where is the static content?
+
In Joomla! versions prior to 1.5 there was a distinct difference between static and normal content. Both content types are still around, but are not handled as separate items. If you want to create static content, just select "uncategorised" as section and category and the content is handled as static content.
+
+
What about developers?
+
This is the release that developers' have been waiting for. A massive effort has been made to refactor and reorganise the core of Joomla! into a true extendable framework. The new features in the framework are too many to list here but additional documentation can be found on the Joomla! Developer Network site.
+
+
Compatibility
+
We have made every effort to make this version backwards compatible with Joomla 1.0. In order to install 1.0 extensions you will probably need to activate the legacy code plugin. This can be found in the Plugin Manager (it's called "System - Legacy") and you just need to enable it.