diff --git a/oss/joomla/trunk/administrator/components/com_plugins/controller.php b/oss/joomla/trunk/administrator/components/com_plugins/controller.php
new file mode 100644
index 00000000..1c028268
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/controller.php
@@ -0,0 +1,282 @@
+registerTask( 'apply', 'save');
+ $this->registerTask( 'unpublish', 'publish');
+ $this->registerTask( 'edit' , 'display' );
+ $this->registerTask( 'add' , 'display' );
+ $this->registerTask( 'orderup' , 'order' );
+ $this->registerTask( 'orderdown' , 'order' );
+
+ $this->registerTask( 'accesspublic' , 'access' );
+ $this->registerTask( 'accessregistered' , 'access' );
+ $this->registerTask( 'accessspecial' , 'access' );
+
+ }
+
+ function display( )
+ {
+ switch($this->getTask())
+ {
+ case 'add' :
+ case 'edit' :
+ {
+ JRequest::setVar( 'hidemainmenu', 1 );
+ JRequest::setVar( 'layout', 'form' );
+ JRequest::setVar( 'view', 'plugin' );
+ } break;
+ }
+
+ parent::display();
+ }
+
+ function save()
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $row =& JTable::getInstance('plugin');
+ $task = $this->getTask();
+
+ $client = JRequest::getWord( 'filter_client', 'site' );
+
+ if (!$row->bind(JRequest::get('post'))) {
+ JError::raiseError(500, $row->getError() );
+ }
+ if (!$row->check()) {
+ JError::raiseError(500, $row->getError() );
+ }
+ if (!$row->store()) {
+ JError::raiseError(500, $row->getError() );
+ }
+ $row->checkin();
+
+ if ($client == 'admin') {
+ $where = "client_id=1";
+ } else {
+ $where = "client_id=0";
+ }
+
+ $row->reorder( 'folder = '.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND ( '.$where.' )' );
+
+ switch ( $task )
+ {
+ case 'apply':
+ $msg = JText::sprintf( 'Successfully Saved changes to Plugin', $row->name );
+ $this->setRedirect( 'index.php?option=com_plugins&view=plugin&client='. $client .'&task=edit&cid[]='. $row->id, $msg );
+ break;
+
+ case 'save':
+ default:
+ $msg = JText::sprintf( 'Successfully Saved Plugin', $row->name );
+ $this->setRedirect( 'index.php?option=com_plugins&client='. $client, $msg );
+ break;
+ }
+ }
+
+ function publish( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+ $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+ $publish = ( $this->getTask() == 'publish' ? 1 : 0 );
+ $client = JRequest::getWord( 'filter_client', 'site' );
+
+ if (count( $cid ) < 1) {
+ $action = $publish ? JText::_( 'publish' ) : JText::_( 'unpublish' );
+ JError::raiseError(500, JText::_( 'Select a plugin to '.$action ) );
+ }
+
+ $cids = implode( ',', $cid );
+
+ $query = 'UPDATE #__plugins SET published = '.(int) $publish
+ . ' WHERE id IN ( '.$cids.' )'
+ . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ))'
+ ;
+ $db->setQuery( $query );
+ if (!$db->query()) {
+ JError::raiseError(500, $db->getErrorMsg() );
+ }
+
+ if (count( $cid ) == 1) {
+ $row =& JTable::getInstance('plugin');
+ $row->checkin( $cid[0] );
+ }
+
+ $this->setRedirect( 'index.php?option=com_plugins&client='. $client );
+ }
+
+ function cancel( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $client = JRequest::getWord( 'filter_client', 'site' );
+
+ $db =& JFactory::getDBO();
+ $row =& JTable::getInstance('plugin');
+ $row->bind(JRequest::get('post'));
+ $row->checkin();
+
+ $this->setRedirect( JRoute::_( 'index.php?option=com_plugins&client='. $client, false ) );
+ }
+
+ function order( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $db =& JFactory::getDBO();
+
+ $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+
+ $uid = $cid[0];
+ $inc = ( $this->getTask() == 'orderup' ? -1 : 1 );
+ $client = JRequest::getWord( 'filter_client', 'site' );
+
+
+ // Currently Unsupported
+ if ($client == 'admin') {
+ $where = "client_id = 1";
+ } else {
+ $where = "client_id = 0";
+ }
+ $row =& JTable::getInstance('plugin');
+ $row->load( $uid );
+ $row->move( $inc, 'folder='.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND ('.$where.')' );
+
+ $this->setRedirect( 'index.php?option=com_plugins' );
+ }
+
+ function access( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+
+ $uid = $cid[0];
+ $access = $this->getTask();
+
+ $db =& JFactory::getDBO();
+ switch ( $access )
+ {
+ case 'accesspublic':
+ $access = 0;
+ break;
+
+ case 'accessregistered':
+ $access = 1;
+ break;
+
+ case 'accessspecial':
+ $access = 2;
+ break;
+ }
+
+ $row =& JTable::getInstance('plugin');
+ $row->load( $uid );
+ $row->access = $access;
+
+ if ( !$row->check() ) {
+ return $row->getError();
+ }
+ if ( !$row->store() ) {
+ return $row->getError();
+ }
+
+ $this->setRedirect( 'index.php?option=com_plugins' );
+ }
+
+ function saveorder( )
+ {
+ // Check for request forgeries
+ JRequest::checkToken() or jexit( 'Invalid Token' );
+
+ $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+
+ $db =& JFactory::getDBO();
+ $total = count( $cid );
+ $order = JRequest::getVar( 'order', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($order, array(0));
+
+ $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
+ JArrayHelper::toInteger($cid, array(0));
+
+ $row =& JTable::getInstance('plugin');
+ $conditions = array();
+
+ // update ordering values
+ for ( $i=0; $i < $total; $i++ )
+ {
+ $row->load( (int) $cid[$i] );
+ if ($row->ordering != $order[$i])
+ {
+ $row->ordering = $order[$i];
+ if (!$row->store()) {
+ JError::raiseError(500, $db->getErrorMsg() );
+ }
+ // remember to updateOrder this group
+ $condition = 'folder = '.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND client_id = ' . (int) $row->client_id;
+ $found = false;
+ foreach ( $conditions as $cond )
+ {
+ if ($cond[1]==$condition) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) $conditions[] = array($row->id, $condition);
+ }
+ }
+
+ // execute updateOrder for each group
+ foreach ( $conditions as $cond ) {
+ $row->load( $cond[0] );
+ $row->reorder( $cond[1] );
+ }
+
+ $msg = JText::_( 'New ordering saved' );
+ $this->setRedirect( 'index.php?option=com_plugins', $msg );
+ }
+}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/controllers/index.html b/oss/joomla/trunk/administrator/components/com_plugins/controllers/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/controllers/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/index.html b/oss/joomla/trunk/administrator/components/com_plugins/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/plugins.php b/oss/joomla/trunk/administrator/components/com_plugins/plugins.php
new file mode 100644
index 00000000..a45bc5de
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/plugins.php
@@ -0,0 +1,32 @@
+authorize( 'com_plugins', 'manage' )) {
+ $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
+}
+
+require_once( JPATH_COMPONENT.DS.'controller.php' );
+
+// Create the controller
+$controller = new PluginsController( );
+
+$controller->execute( JRequest::getCmd( 'task' ) );
+$controller->redirect();
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml b/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml
new file mode 100644
index 00000000..df827382
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml
@@ -0,0 +1,12 @@
+
+
+ Plugin 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
+ Plugin Manager
+
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/index.html b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/tmpl/form.php
new file mode 100644
index 00000000..11d2b595
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/tmpl/form.php
@@ -0,0 +1,161 @@
+
+
+
+
+[' .JText::_('Edit'). ']', 'plugin.png' );
+ JToolBarHelper::save();
+ JToolBarHelper::apply();
+ JToolBarHelper::cancel( 'cancel', 'Close' );
+ JToolBarHelper::help( 'screen.plugins.edit' );
+?>
+
+plugin, ENT_QUOTES, '' );
+?>
+
+plugin->nameA = '';
+ if ( $this->plugin->id ) {
+ $row->nameA = '[ '. $this->plugin->name .' ]';
+ }
+?>
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/tmpl/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/tmpl/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php
new file mode 100644
index 00000000..d9fe9f4d
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php
@@ -0,0 +1,117 @@
+load( $cid[0] );
+
+ // fail if checked out not by 'me'
+
+ if ($row->isCheckedOut( $user->get('id') ))
+ {
+ $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The plugin' ), $row->title );
+ $this->setRedirect( 'index.php?option='. $option .'&client='. $client, $msg, 'error' );
+ return false;
+ }
+
+ if ($client == 'admin') {
+ $where = "client_id='1'";
+ } else {
+ $where = "client_id='0'";
+ }
+
+ // get list of groups
+ if ($row->access == 99 || $row->client_id == 1) {
+ $lists['access'] = 'Administrator';
+ } else {
+ // build the html select list for the group access
+ $lists['access'] = JHTML::_('list.accesslevel', $row );
+ }
+
+ if ($cid[0])
+ {
+ $row->checkout( $user->get('id') );
+
+ if ( $row->ordering > -10000 && $row->ordering < 10000 )
+ {
+ // build the html select list for ordering
+ $query = 'SELECT ordering AS value, name AS text'
+ . ' FROM #__plugins'
+ . ' WHERE folder = '.$db->Quote($row->folder)
+ . ' AND published > 0'
+ . ' AND '. $where
+ . ' AND ordering > -10000'
+ . ' AND ordering < 10000'
+ . ' ORDER BY ordering'
+ ;
+ $order = JHTML::_('list.genericordering', $query );
+ $lists['ordering'] = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
+ } else {
+ $lists['ordering'] = ''. JText::_( 'This plugin cannot be reordered' );
+ }
+
+ $lang =& JFactory::getLanguage();
+ $lang->load( 'plg_' . trim( $row->folder ) . '_' . trim( $row->element ), JPATH_ADMINISTRATOR );
+
+ $data = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . DS . 'plugins'. DS .$row->folder . DS . $row->element .'.xml');
+
+ $row->description = $data['description'];
+
+ } else {
+ $row->folder = '';
+ $row->ordering = 999;
+ $row->published = 1;
+ $row->description = '';
+ }
+
+ $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published );
+
+ // get params definitions
+ $params = new JParameter( $row->params, JApplicationHelper::getPath( 'plg_xml', $row->folder.DS.$row->element ), 'plugin' );
+
+ $this->assignRef('lists', $lists);
+ $this->assignRef('plugin', $row);
+ $this->assignRef('params', $params);
+
+ parent::display($tpl);
+ }
+}
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/index.html b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php
new file mode 100644
index 00000000..9b8184be
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php
@@ -0,0 +1,141 @@
+
+
+
+
+lists['order'] == 'p.folder' || $this->lists['order'] == 'p.ordering');
+ $rows =& $this->items;
+
+?>
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php
new file mode 100644
index 00000000..548f952a
--- /dev/null
+++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php
@@ -0,0 +1,139 @@
+getUserStateFromRequest( "$option.$client.filter_order", 'filter_order', 'p.folder', 'cmd' );
+ $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.$client.filter_order_Dir", 'filter_order_Dir', '', 'word' );
+ $filter_state = $mainframe->getUserStateFromRequest( "$option.$client.filter_state", 'filter_state', '', 'word' );
+ $filter_type = $mainframe->getUserStateFromRequest( "$option.$client.filter_type", 'filter_type', 1, 'cmd' );
+ $search = $mainframe->getUserStateFromRequest( "$option.$client.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 = '';
+ if ($client == 'admin') {
+ $where[] = 'p.client_id = 1';
+ $client_id = 1;
+ } else {
+ $where[] = 'p.client_id = 0';
+ $client_id = 0;
+ }
+
+ // used by filter
+ if ( $filter_type != 1 ) {
+ $where[] = 'p.folder = '.$db->Quote($filter_type);
+ }
+ if ( $search ) {
+ $where[] = 'LOWER( p.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
+ }
+ if ( $filter_state ) {
+ if ( $filter_state == 'P' ) {
+ $where[] = 'p.published = 1';
+ } else if ($filter_state == 'U' ) {
+ $where[] = 'p.published = 0';
+ }
+ }
+
+ $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
+ if ($filter_order == 'p.ordering') {
+ $orderby = ' ORDER BY p.folder, p.ordering '. $filter_order_Dir;
+ } else {
+ $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', p.ordering ASC';
+ }
+
+
+ // get the total number of records
+ $query = 'SELECT COUNT(*)'
+ . ' FROM #__plugins AS p'
+ . $where
+ ;
+ $db->setQuery( $query );
+ $total = $db->loadResult();
+
+ jimport('joomla.html.pagination');
+ $pagination = new JPagination( $total, $limitstart, $limit );
+
+ $query = 'SELECT p.*, u.name AS editor, g.name AS groupname'
+ . ' FROM #__plugins AS p'
+ . ' LEFT JOIN #__users AS u ON u.id = p.checked_out'
+ . ' LEFT JOIN #__groups AS g ON g.id = p.access'
+ . $where
+ . ' GROUP BY p.id'
+ . $orderby
+ ;
+ $db->setQuery( $query, $pagination->limitstart, $pagination->limit );
+ $rows = $db->loadObjectList();
+ if ($db->getErrorNum()) {
+ echo $db->stderr();
+ return false;
+ }
+
+
+ // get list of Positions for dropdown filter
+ $query = 'SELECT folder AS value, folder AS text'
+ . ' FROM #__plugins'
+ . ' WHERE client_id = '.(int) $client_id
+ . ' GROUP BY folder'
+ . ' ORDER BY folder'
+ ;
+ $types[] = JHTML::_('select.option', 1, '- '. JText::_( 'Select Type' ) .' -' );
+ $db->setQuery( $query );
+ $types = array_merge( $types, $db->loadObjectList() );
+ $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type );
+
+ // 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->assign('client', $client);
+
+ $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