diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/controller.php b/oss/joomla/trunk/administrator/components/com_jce/groups/controller.php new file mode 100644 index 00000000..541cfaaf --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/controller.php @@ -0,0 +1,330 @@ +registerTask( 'apply', 'save'); + $this->registerTask( 'unpublish', 'publish'); + $this->registerTask( 'edit' , 'display' ); + $this->registerTask( 'add' , 'display' ); + $this->registerTask( 'remove' , 'remove' ); + $this->registerTask( 'addusers' , 'display' ); + $this->registerTask( 'removeusers' ,'display' ); + $this->registerTask( 'orderup' , 'order' ); + $this->registerTask( 'orderdown' , 'order' ); + $this->registerTask( 'legend' , 'display' ); + $this->registerTask( 'copy' , 'copy' ); + } + + function display( ) + { + switch($this->getTask()) + { + case 'add' : + case 'edit' : + { + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'group' ); + JRequest::setVar( 'hidemainmenu', 1 ); + } break; + case 'addusers' : + case 'removeusers' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'view', 'users' ); + } break; + case 'legend': + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'view', 'legend' ); + } break; + } + + parent::display(); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a Group to remove' ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'DELETE FROM #__jce_groups' + . ' WHERE id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + $this->setRedirect( 'index.php?option=com_jce&type=group' ); + } + + function copy() + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $n = count( $cid ); + if ($n == 0) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + $row =& JTable::getInstance('groups', 'JCETable'); + + foreach ($cid as $id){ + // load the row from the db table + $row->load( (int) $id ); + $row->name = JText::sprintf( 'Copy of %s', $row->name ); + $row->id = 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( 'ordering='.$db->Quote( $row->ordering ) ); + } + $msg = JText::sprintf( 'Items Copied', $n ); + $this->setRedirect( 'index.php?option=com_jce&type=group', $msg ); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + require_once( dirname( __FILE__ ) .DS. 'helper.php' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('groups', 'JCETable'); + $task = $this->getTask(); + + $pid = JRequest::getVar( 'pid', array(), 'post', 'array' ); + $components = JRequest::getVar( 'components', array(), 'post', 'array' ); + $types = JRequest::getVar( 'types', array(), 'post', 'array' ); + $users = JRequest::getVar( 'users', array(), 'post', 'array' ); + + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError() ); + } + + if( substr( $row->rows, -1, 1 ) == ';' ){ + $row->rows = substr( $row->rows, 0, -1 ); + } + + $row->types = implode( ',', $types ); + $row->components = implode( ',', $components ); + $row->users = implode( ',', $users ); + + $query = "SELECT id" + . " FROM #__jce_plugins" + . " WHERE published = 1" + . " AND type = 'plugin'" + . " AND id IN (". str_replace( ';', ',', $row->rows ) .")" + ; + $db->setQuery( $query ); + $ids = $db->loadResultArray(); + + if( !$ids ){ + $ids = array(); + } + + $row->plugins = implode( ',', array_merge( $pid, $ids ) ); + + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + + switch ( $task ) + { + case 'apply': + $msg = JText::sprintf( 'Successfully Saved changes to Group', $row->name ); + $this->setRedirect( 'index.php?option=com_jce&type=group&view=group&task=edit&cid[]='. $row->id, $msg ); + break; + + case 'save': + default: + $msg = JText::sprintf( 'Successfully Saved Group', $row->name ); + $this->setRedirect( 'index.php?option=com_jce&type=group', $msg ); + break; + } + } + + function publish( ){ + // Check for request forgeries + JRequest::checkToken() or die( '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 ); + + if (count( $cid ) < 1) { + $action = $publish ? JText::_( 'publish' ) : JText::_( 'unpublish' ); + JError::raiseError(500, JText::_( 'Select a Group to '.$action ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__jce_groups 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('groups', 'JCETable'); + $row->checkin( $cid[0] ); + } + + $this->setRedirect( 'index.php?option=com_jce&type=group' ); + } + + 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 ); + + $row =& JTable::getInstance('groups', 'JCETable'); + $row->load( $uid ); + //$row->move( $inc, ' AND ordering > -10000 AND ordering < 10000' ); + $row->move( $inc ); + + $this->setRedirect( 'index.php?option=com_jce&type=group' ); + } + + 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('groups', 'JCETable'); + $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 = ' AND ordering > -10000 AND ordering < 10000'; + $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_jce&type=group', $msg ); + } + + function cancel( ){ + $this->setRedirect( JRoute::_( 'index.php?option=com_jce', false ) ); + } + + function cancelEdit( ) + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('groups', 'JCETable'); + $row->bind(JRequest::get('post')); + $row->checkin(); + + $this->setRedirect( JRoute::_( 'index.php?option=com_jce&type=group', false ) ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/groups.php b/oss/joomla/trunk/administrator/components/com_jce/groups/groups.php new file mode 100644 index 00000000..57efa7da --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/groups.php @@ -0,0 +1,143 @@ +loadArray($array['params']); + $array['params'] = $registry->toString(); + } + + return parent::bind($array, $ignore); + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/helper.php b/oss/joomla/trunk/administrator/components/com_jce/groups/helper.php new file mode 100644 index 00000000..34e0ce39 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/helper.php @@ -0,0 +1,45 @@ +setQuery( $query ); + $groups = $db->loadObjectList(); + return $groups[0]; + } + function getUserGroupFromType( $type ){ + $db =& JFactory::getDBO(); + + if(!is_int($type)){ + $query = 'SELECT id' + . ' FROM #__core_acl_aro_groups' + . ' WHERE name = "'.$type.'"' + ; + $db->setQuery( $query ); + $id = $db->loadResult(); + } + + $query = 'SELECT *' + . ' FROM #__jce_groups' + . ' WHERE '.$type.' IN (types)' + ; + $db->setQuery( $query ); + $groups = $db->loadObjectList(); + return $groups[0]; + } + function getRowArray($rows){ + $out = array(); + $rows = explode(';', $rows); + $i = 1; + foreach($rows as $row){ + $out[$i] = $row; + $i++; + } + return $out; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/index.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/tmpl/form.php new file mode 100644 index 00000000..86684d5a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/tmpl/form.php @@ -0,0 +1,511 @@ +[' .JText::_('Edit'). ']', 'user.png' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + JToolBarHelper::cancel( 'cancelEdit', 'Close' ); + jceToolbarHelper::help( 'groups' ); + + // clean item data + JFilterOutput::objectHTMLSafe( $this->group, ENT_QUOTES, '' ); +?> + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/view.html.php new file mode 100644 index 00000000..f1b80429 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/group/view.html.php @@ -0,0 +1,192 @@ +load( $cid[0] ); + + // fail if checked out not by 'me' + + if( $row->isCheckedOut( $user->get('id') ) ){ + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The Group' ), $row->name ); + $this->setRedirect( 'index.php?option='. $option .'&type=group', $msg, 'error' ); + return false; + } + // Load editor + $editor =& JPluginHelper::getPlugin('editors', 'jce'); + + // Load Language + $lang =& JFactory::getLanguage(); + $lang->load( 'com_jce', JPATH_SITE ); + + // Get all plugins/commands + $query = 'SELECT *' + . ' FROM #__jce_plugins' + . ' WHERE published = 1' + ; + + $db->setQuery( $query ); + $plugins = $db->loadObjectList(); + + // load the row from the db table + if( $cid[0] ){ + $row->checkout( $user->get('id') ); + }else{ + $query = 'SELECT COUNT(id)' + . ' FROM #__jce_groups' + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + $row->name = ''; + $row->description = ''; + $row->types = ''; + $row->components = ''; + $row->types = ''; + $row->rows = ''; + $row->plugins = ''; + $row->published = 1; + $row->ordering = 0; + $row->params = ''; + + $row->params .= $editor->params; + + foreach( $plugins as $plugin ){ + if( $plugin->type == 'plugin' ){ + $row->params .= $plugin->params; + } + } + } + + // build the html select list for ordering + $query = 'SELECT ordering AS value, name AS text' + . ' FROM #__jce_groups' + . ' WHERE published = 1' + . ' 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 ) ); + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + + // Get components list + $query = "SELECT *" + . " FROM #__components" + . " WHERE link <> ''" + . " AND parent = 0" + . " AND enabled = 1" + . " ORDER BY name"; + $db->setQuery( $query ); + $components = $db->loadObjectList(); + + $options = array(); + $options[] = JHTML::_('select.option', '', JText::_( 'All Components' ) ); + foreach( $components as $component ){ + $options[] = JHTML::_('select.option', $component->option, JText::_( $component->name ) ); + } + $lists['components'] = JHTML::_('select.genericlist', $options, 'components[]', 'class="inputbox levels" size="10" multiple="multiple"', 'value', 'text', $row->components == '' ? '' : explode( ',', $row->components ) ); + + $query = 'SELECT types' + . ' FROM #__jce_groups' + // Exclude ROOT, USERS, Super Administrator, Public Frontend, Public Backend + . ' WHERE id NOT IN (17,28,29,30)' + ; + $db->setQuery( $query ); + $types = $db->loadResultArray(); + + // get list of Groups for dropdown filter + $query = 'SELECT id AS value, name AS text' + . ' FROM #__core_acl_aro_groups' + // Exclude ROOT, USERS, Super Administrator, Public Frontend, Public Backend + . ' WHERE id NOT IN (17,28,29,30)' + ; + $db->setQuery( $query ); + $types = $db->loadObjectList(); + + $i = '-'; + $options = array( JHTML::_('select.option', '0', JText::_( 'Guest' ) ) ); + foreach( $types as $type ){ + $options[] = JHTML::_('select.option', $type->value, $i . JText::_( $type->text ) ); + $i .= '-'; + } + $lists['types'] = JHTML::_('select.genericlist', $options, 'types[]', 'class="inputbox levels" size="8" multiple="multiple"', 'value', 'text', $row->types == '' ? '' : explode( ',', $row->types ) ); + + $options = array(); + if( $row->id && $row->users ){ + $query = 'SELECT id as value, username as text' + . ' FROM #__users' + . ' WHERE id IN ('.$row->users.')' + ; + + $db->setQuery( $query ); + $gusers = $db->loadObjectList(); + if( $gusers ){ + foreach( $gusers as $guser ){ + $options[] = JHTML::_('select.option', $guser->value, $guser->text ); + } + } + } + $lists['users'] = JHTML::_('select.genericlist', $options, 'users[]', 'class="inputbox users" size="10" multiple="multiple"', 'value', 'text', '' ); + + // get params definitions + $xml = JCE_LIBRARIES.DS.'xml'.DS.'config'.DS.'config.xml'; + if (!file_exists($xml)) { + $xml = JPATH_PLUGINS.DS.'editors'.DS.'jce.xml'; + } + + $params = new JParameter( $row->params, $xml ); + + $params->addElementPath( JPATH_COMPONENT . DS . 'elements' ); + + $rows = str_replace( ';', ',', $row->rows ); + + $this->assignRef('lists', $lists); + $this->assignRef('group', $row); + $this->assignRef('params', $params); + $this->assignRef('plugins', $plugins); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/tmpl/default.php new file mode 100644 index 00000000..9168fc97 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/tmpl/default.php @@ -0,0 +1,148 @@ + + + + + +items; + + JToolBarHelper::title( JText::_( 'JCE Group Manager' ), 'user.png' ); + + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::custom( 'copy', 'copy.png', 'copy_f2.png', JText::_('Copy'), true ); + if( count( $rows ) > 1 ){ + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::deleteList(); + } + JToolBarHelper::cancel( 'cancel', JText::_( 'Close' ) ); + jceToolbarHelper::help( 'groups' ); + + +?> + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/view.html.php new file mode 100644 index 00000000..c7de775f --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/groups/view.html.php @@ -0,0 +1,105 @@ +getUserStateFromRequest( "$option.$type.$task.$client.filter_order", 'filter_order', 'g.name', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_state", 'filter_state', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.search", 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( '$option.$type.$task.$client.limitstart', 'limitstart', 0, 'int' ); + + $limitstart = isset( $limitstart->group ) ? $limitstart->group : 0; + + $where = array(); + + if ( $search ) { + $where[] = 'LOWER( g.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'g.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'g.published = 0'; + } + } + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY g.ordering ASC'; + + // get the total number of records + $query = 'SELECT COUNT(g.id)' + . ' FROM #__jce_groups AS g' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT g.*, u.name AS editor' + . ' FROM #__jce_groups AS g' + . ' LEFT JOIN #__users AS u ON u.id = g.checked_out' + . $where + . ' GROUP BY g.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // 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_jce/groups/views/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/tmpl/default.php new file mode 100644 index 00000000..6413e88c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/tmpl/default.php @@ -0,0 +1,39 @@ + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/view.html.php new file mode 100644 index 00000000..a30cafcc --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/legend/view.html.php @@ -0,0 +1,48 @@ + 0' + . ' ORDER BY title' + ; + $db->setQuery( $query ); + $icons = $db->loadObjectList(); + + $this->assignRef('icons', $icons); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/tmpl/default.php new file mode 100644 index 00000000..8f19601b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/tmpl/default.php @@ -0,0 +1,142 @@ + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/view.html.php new file mode 100644 index 00000000..725f4c54 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/groups/views/users/view.html.php @@ -0,0 +1,130 @@ +getUserStateFromRequest( "$option.$type.$task.$client.filter_order", 'filter_order', 'a.name', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_type = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_type", 'filter_type', 0, 'string' ); + $search = $mainframe->getUserStateFromRequest( "$option.$type.$task.$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 = 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 ) + { + $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) '; + } + + // 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 ) . ')'; + } + // Exclude ROOT, USERS, Super Administrator, Public Frontend, Public Backend + $where[] = 'a.gid NOT IN (17,28,29,30)'; + // Only unblocked users + $where[] = 'a.block = 0'; + + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; + $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' ); + + $query = 'SELECT COUNT(a.id)' + . ' FROM #__users AS a' + . $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' + . $where + . ' GROUP BY a.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + + // get list of Groups for dropdown filter + $query = 'SELECT name AS value, name AS text' + . ' FROM #__core_acl_aro_groups' + // Exclude ROOT, USERS, Super Administrator, Public Frontend, Public Backend + . ' WHERE id NOT IN (17,28,29,30)' + ; + $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['group'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" ); + + // 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_jce/installer/adapters/extension.php b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/extension.php new file mode 100644 index 00000000..8f05a561 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/extension.php @@ -0,0 +1,326 @@ +parent = & $parent; + } + + /** + * Custom install method + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function install() + { + // Get a database connector object + $db = & $this->parent->getDBO(); + + // Get the extension manifest object + $manifest = & $this->parent->getManifest(); + $this->manifest = & $manifest->document; + + /** + * --------------------------------------------------------------------------------------------- + * Manifest Document Setup Section + * --------------------------------------------------------------------------------------------- + */ + + // Set the component name + $name = & $this->manifest->getElementByPath('name'); + $this->set('name', $name->data()); + + // Get the component description + $description = & $this->manifest->getElementByPath('description'); + if (is_a($description, 'JSimpleXMLElement')) { + $this->parent->set('message', $description->data()); + } + else { + $this->parent->set('message', ''); + } + + $element = & $this->manifest->getElementByPath('files'); + + $extension = $this->manifest->attributes('extension'); + $plugin = $this->manifest->attributes('plugin'); + $folder = $this->manifest->attributes('folder'); + + if (! empty($plugin)) { + $this->parent->setPath('extension_root', JPATH_PLUGINS.DS.'editors'.DS.'jce'.DS.'tiny_mce'.DS.'plugins'.DS.$plugin.DS.'extensions'.DS.$folder); + } + else { + $this->parent->abort('Extension Install: '.JText::_('No JCE Plugin file specified')); + return false; + } + + /** + * --------------------------------------------------------------------------------------------- + * Filesystem Processing Section + * --------------------------------------------------------------------------------------------- + */ + + // Set overwrite flag if not set by Manifest + $this->parent->setOverwrite(true); + + // If the extension directory does not exist, lets create it + $created = false; + if (!file_exists($this->parent->getPath('extension_root'))) { + if (!$created = JFolder::create($this->parent->getPath('extension_root'))) { + $this->parent->abort('Extension Install: '.JText::_('Failed to create directory').': "'.$this->parent->getPath('extension_root').'"'); + return false; + } + } + + /* + * If we created the extension directory and will want to remove it if we + * have to roll back the installation, lets add it to the installation + * step stack + */ + if ($created) { + $this->parent->pushStep( array ('type'=>'folder', 'path'=>$this->parent->getPath('extension_root'))); + } + + // Copy all necessary files + if ($this->parent->parseFiles($element, -1) === false) { + // Install failed, roll back changes + $this->parent->abort(); + return false; + } + + // Parse optional tags -- language files for plugins + $this->parent->parseLanguages($this->manifest->getElementByPath('languages'), 0); + + /** + * --------------------------------------------------------------------------------------------- + * Database Processing Section + * --------------------------------------------------------------------------------------------- + */ + + // Check to see if an extension by the same name is already installed + $query = 'SELECT id' + .' FROM #__jce_extensions' + .' WHERE extension = '.$db->Quote($extension) + ; + $db->setQuery($query); + + + $row = & JTable::getInstance('extension', 'JCETable'); + + if (!$db->Query()) { + // Install failed, roll back changes + $this->parent->abort('Extension Install: '.$db->stderr(true)); + return false; + } + $id = $db->loadResult(); + + // Was there an extension already installed with the same name? + if ($id) { + + if (!$this->parent->getOverwrite()) + { + // Install failed, roll back changes + $this->parent->abort('Extension Install: '.JText::_('Extension').' "'.$ename.'" '.JText::_('already exists!')); + return false; + } + else { + $row->load($id); + } + } + // Get the associated plugin + $query = 'SELECT id' + .' FROM #__jce_plugins' + .' WHERE name = '.$db->Quote($plugin); + $db->setQuery($query); + + if (!$db->Query()) { + // Install failed, roll back changes + $this->parent->abort('Plugin not installed: '.$db->stderr(true)); + return false; + } + $id = $db->loadResult(); + + $row->pid = $id; + $row->name = $this->get('name'); + $row->extension = $this->manifest->attributes('extension'); + $row->folder = $this->manifest->attributes('folder'); + $row->published = 1; + + if (!$row->store()) { + // Install failed, roll back changes + $this->parent->abort('Extension Install: '.$db->stderr(true)); + return false; + } + + // Since we have created an extension item, we add it to the installation step stack + // so that if we have to rollback the changes we can undo it. + $this->parent->pushStep( array ('type'=>'extension', 'id'=>$row->id)); + + /** + * --------------------------------------------------------------------------------------------- + * Finalization and Cleanup Section + * --------------------------------------------------------------------------------------------- + */ + + // Lastly, we will copy the manifest file to its appropriate place. + if (!$this->parent->copyManifest(-1)) { + // Install failed, rollback changes + $this->parent->abort('Extension Install: '.JText::_('Could not copy setup file')); + return false; + } + return true; + } + + /** + * Custom uninstall method + * + * @access public + * @param int $cid The id of the plugin to uninstall + * @param int $clientId The id of the client (unused) + * @return boolean True on success + * @since 1.5 + */ + function uninstall($id, $clientId) + { + // Initialize variables + $row = null; + $retval = true; + $db = & $this->parent->getDBO(); + + // First order of business will be to load the module object table from the database. + // This should give us the necessary information to proceed. + + $row = & JTable::getInstance('extension', 'JCETable'); + $row->load((int)$id); + + $query = 'SELECT name' + .' FROM #__jce_plugins' + .' WHERE id = '.$row->pid + ; + + $db->setQuery($query); + if (!$db->Query()) { + // Install failed, roll back changes + $this->parent->abort('Plugin not installed: '.$db->stderr(true)); + return false; + } + $file = $db->loadResult(); + + // Get the extension folder so we can properly build the plugin path + if (trim($row->extension) == '') { + JError::raiseWarning(100, 'Extension Uninstall: '.JText::_('Extension field empty, cannot remove files')); + return false; + } + + // Set the plugin root path + $this->parent->setPath('extension_root', JPATH_PLUGINS.DS.'editors'.DS.'jce'.DS.'tiny_mce'.DS.'plugins'.DS.$file.DS.'extensions'.DS.$row->folder); + + $manifestFile = $this->parent->getPath('extension_root').DS.$row->extension.'.xml'; + + if (file_exists($manifestFile)) + { + $xml = & JFactory::getXMLParser('Simple'); + + // If we cannot load the xml file return null + if (!$xml->loadFile($manifestFile)) { + JError::raiseWarning(100, 'Extension Uninstall: '.JText::_('Could not load manifest file')); + return false; + } + + /* + * Check for a valid XML root tag. + */ + $root = & $xml->document; + if ($root->name() != 'install') { + JError::raiseWarning(100, 'Extension Uninstall: '.JText::_('Invalid manifest file')); + return false; + } + + // Remove the extension files + $this->parent->removeFiles($root->getElementByPath('files'), -1); + + // Remove all media and languages as well + $this->parent->removeFiles($root->getElementByPath('languages'), 0); + + + JFile::delete($manifestFile); + } + else { + JError::raiseWarning(100, 'Extension Uninstall: Manifest File invalid or not found. Extension entry removed from database.'); + + $row->delete($row->id); + unset ($row); + return false; + } + + // Now we will no longer need the extension object, so lets delete it + $row->delete($row->id); + unset ($row); + + // If the folder is empty, let's delete it + $files = JFolder::files($this->parent->getPath('extension_root')); + if (!count($files)) { + JFolder::delete($this->parent->getPath('extension_root')); + } + + return $retval; + } + + /** + * Custom rollback method + * - Roll back the plugin item + * + * @access public + * @param array $arg Installation step to rollback + * @return boolean True on success + * @since 1.5 + * Minor changes to the db query + */ + function _rollback_plugin($arg) + { + // Get database connector object + $db = & $this->parent->getDBO(); + + // Remove the entry from the #__jce_extensions table + $query = 'DELETE' + .' FROM #__jce_extensions' + .' WHERE id='.(int)$arg['id']; + + $db->setQuery($query); + + return ($db->query() !== false); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/index.html b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/language.php b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/language.php new file mode 100644 index 00000000..a3baa851 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/language.php @@ -0,0 +1,211 @@ +parent = & $parent; + } + + /** + * Custom install method + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function install() + { + // Get database connector object + $manifest = & $this->parent->getManifest(); + $this->manifest = & $manifest->document; + + // Get the language name + // Set the extensions name + $name = & $this->manifest->getElementByPath('name'); + $name = JFilterInput::clean($name->data(), 'cmd'); + $this->set('name', $name); + + // Get the Language tag [ISO tag, eg. en-GB] + $tag = & $this->manifest->getElementByPath('tag'); + + // Check if we found the tag - if we didn't, we may be trying to install from an older language package + if (!$tag) + { + $this->parent->abort(JText::_('Language').' '.JText::_('Install').': '.JText::_('NO LANGUAGE TAG?')); + return false; + } + + $this->set('tag', $tag->data()); + $folder = $tag->data(); + + $sitePath = JPATH_SITE.DS."language".DS.$folder; + $adminPath = JPATH_ADMINISTRATOR.DS."language".DS.$folder; + $tinyPath = JPATH_PLUGINS.DS."editors".DS."jce".DS."tiny_mce"; + + // Set the installation target paths + $this->parent->setPath('extension_site', $sitePath); + $this->parent->setPath('extension_administrator', $adminPath); + + $this->adminElement = & $this->manifest->getElementByPath('administration'); + $this->siteElement = & $this->manifest->getElementByPath('site'); + $this->tinyElement = & $this->manifest->getElementByPath('tinymce'); + + // Set overwrite flag if not set by Manifest + if (!$this->parent->getOverwrite()) { + $this->parent->setOverwrite(true); + } + + // Copy site files + foreach ($this->siteElement->children() as $child) + { + if (is_a($child, 'JSimpleXMLElement') && $child->name() == 'files') { + if ($this->parent->parseFiles($child) === false) { + // Install failed, rollback any changes + $this->parent->abort(); + return false; + } + } + } + // Copy admin files + foreach ($this->adminElement->children() as $child) + { + if (is_a($child, 'JSimpleXMLElement') && $child->name() == 'files') { + if ($this->parent->parseFiles($child, 1) === false) { + // Install failed, rollback any changes + $this->parent->abort(); + return false; + } + } + } + // Copy tinymce files + $this->parent->setPath('extension_site', $tinyPath); + foreach ($this->tinyElement->children() as $child) + { + if (is_a($child, 'JSimpleXMLElement') && $child->name() == 'files') { + if ($this->parent->parseFiles($child) === false) { + // Install failed, rollback any changes + $this->parent->abort(); + return false; + } + } + } + + // Set path back to site for manifest + $this->parent->setPath('extension_site', $sitePath); + // Lastly, we will copy the manifest file to its appropriate place. + if (!$this->parent->copyManifest(0)) { + // Install failed, rollback changes + $this->parent->abort(JText::_('Component').' '.JText::_('Install').': '.JText::_('Could not copy setup file')); + return false; + } + + // Get the language description + $description = & $this->manifest->getElementByPath('description'); + if (is_a($description, 'JSimpleXMLElement')) { + $this->parent->set('message', $description->data()); + } else { + $this->parent->set('message', ''); + } + return true; + } + + /** + * Custom uninstall method + * + * @access public + * @param string $tag The tag of the language to uninstall + * @param int $clientId The id of the client (unused) + * @return mixed Return value for uninstall method in component uninstall file + * @since 1.5 + */ + function uninstall($tag, $clientId) + { + $path = trim($tag); + if (!JFolder::exists($path)) { + JError::raiseWarning(100, 'Language Uninstall: '.JText::_('Language path is empty, cannot uninstall files')); + return false; + } + $tag = basename($path); + + // Because JCE languages don't have their own folders we cannot use the standard method of finding an installation manifest + $manifestFile = JPATH_ROOT.DS.'language'.DS.$tag.DS.$tag.'.com_jce.xml'; + if (file_exists($manifestFile)) + { + $xml = & JFactory::getXMLParser('Simple'); + + // If we cannot load the xml file return null + if (!$xml->loadFile($manifestFile)) { + JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Could not load manifest file')); + return false; + } + + /* + * Check for a valid XML root tag. + */ + $root = & $xml->document; + if ($root->name() != 'install' && $root->attributes('type') != 'language') { + JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Invalid manifest file')); + return false; + } + + // Get the admin and site paths for the component + $sitePath = JPATH_SITE.DS."language".DS.$tag; + $adminPath = JPATH_ADMINISTRATOR.DS."language".DS.$tag; + $tinyPath = JPATH_PLUGINS.DS."editors".DS."jce".DS."tiny_mce"; + + // Set the installation target paths + $this->parent->setPath('extension_site', $sitePath); + $this->parent->setPath('extension_administrator', $adminPath); + + if (!$this->parent->removeFiles($root->getElementByPath('site/files'))) { + JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Unable to delete files')); + return false; + } + if (!$this->parent->removeFiles($root->getElementByPath('administration/files'), 1)) { + JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Unable to delete files')); + return false; + } + + $this->parent->setPath('extension_site', $tinyPath); + if (!$this->parent->removeFiles($root->getElementByPath('tinymce/files'))) { + JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Unable to delete files')); + return false; + } + JFile::delete($manifestFile); + } else { + JError::raiseWarning(100, 'Language Uninstall: Manifest File invalid or not found'); + return false; + } + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/plugin.php b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/plugin.php new file mode 100644 index 00000000..f5d60a61 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/installer/adapters/plugin.php @@ -0,0 +1,505 @@ +parent = & $parent; + } + + /** + * Custom install method + * + * @access public + * @return boolean True on success + * @since 1.5 + * Minor alteration - see below + */ + function install() + { + // Get a database connector object + $db = & $this->parent->getDBO(); + + // Get the extension manifest object + $manifest = & $this->parent->getManifest(); + $this->manifest = & $manifest->document; + + /** + * --------------------------------------------------------------------------------------------- + * Manifest Document Setup Section + * --------------------------------------------------------------------------------------------- + */ + + // Set the plugin name + $name = & $this->manifest->getElementByPath('name'); + $this->set('name', $name->data()); + + // Get the plugin description + $description = & $this->manifest->getElementByPath('description'); + if (is_a($description, 'JSimpleXMLElement')) { + $this->parent->set('message', $description->data()); + } + else { + $this->parent->set('message', ''); + } + + $element = & $this->manifest->getElementByPath('files'); + + // Plugin name is specified + $plugin = $this->manifest->attributes('plugin'); + + if (! empty($plugin)) { + $this->parent->setPath('extension_root', JPATH_PLUGINS.DS.'editors'.DS.'jce'.DS.'tiny_mce'.DS.'plugins'.DS.$plugin); + } + else { + $this->parent->abort('Extension Install: '.JText::_('No JCE Plugin file specified')); + return false; + } + + /** + * --------------------------------------------------------------------------------------------- + * Filesystem Processing Section + * --------------------------------------------------------------------------------------------- + */ + + // If the extension directory does not exist, lets create it + $created = false; + if (!file_exists($this->parent->getPath('extension_root'))) { + if (!$created = JFolder::create($this->parent->getPath('extension_root'))) { + $this->parent->abort('Plugin Install: '.JText::_('Failed to create directory').': "'.$this->parent->getPath('extension_root').'"'); + return false; + } + } + // Set overwrite flag if not set by Manifest + $this->parent->setOverwrite(true); + + /* + * If we created the extension directory and will want to remove it if we + * have to roll back the installation, lets add it to the installation + * step stack + */ + if ($created) { + $this->parent->pushStep( array ('type'=>'folder', 'path'=>$this->parent->getPath('extension_root'))); + } + + // Copy all necessary files + if ($this->parent->parseFiles($element, -1) === false) { + // Install failed, roll back changes + $this->parent->abort(); + return false; + } + + // Parse optional tags -- language files for plugins + $this->parent->parseLanguages($this->manifest->getElementByPath('languages'), 0); + + // If there is an install file, lets copy it. + $installScriptElement = & $this->manifest->getElementByPath('installfile'); + if (is_a($installScriptElement, 'JSimpleXMLElement')) { + // Make sure it hasn't already been copied (this would be an error in the xml install file) + if (!file_exists($this->parent->getPath('extension_root').DS.$installScriptElement->data())) + { + $path['src'] = $this->parent->getPath('source').DS.$installScriptElement->data(); + $path['dest'] = $this->parent->getPath('extension_root').DS.$installScriptElement->data(); + if (!$this->parent->copyFiles( array ($path))) { + // Install failed, rollback changes + $this->parent->abort(JText::_('Component').' '.JText::_('Install').': '.JText::_('Could not copy PHP install file.')); + return false; + } + } + $this->set('install.script', $installScriptElement->data()); + } + + // If there is an uninstall file, lets copy it. + $uninstallScriptElement = & $this->manifest->getElementByPath('uninstallfile'); + if (is_a($uninstallScriptElement, 'JSimpleXMLElement')) { + // Make sure it hasn't already been copied (this would be an error in the xml install file) + if (!file_exists($this->parent->getPath('extension_root').DS.$uninstallScriptElement->data())) + { + $path['src'] = $this->parent->getPath('source').DS.$uninstallScriptElement->data(); + $path['dest'] = $this->parent->getPath('extension_root').DS.$uninstallScriptElement->data(); + if (!$this->parent->copyFiles( array ($path))) { + // Install failed, rollback changes + $this->parent->abort(JText::_('Component').' '.JText::_('Install').': '.JText::_('Could not copy PHP uninstall file.')); + return false; + } + } + } + + /** + * --------------------------------------------------------------------------------------------- + * Database Processing Section + * --------------------------------------------------------------------------------------------- + */ + + // Check to see if a plugin by the same name is already installed + $query = 'SELECT id'. + ' FROM #__jce_plugins'. + ' WHERE name = '.$db->Quote($plugin); + $db->setQuery($query); + if (!$db->Query()) { + // Install failed, roll back changes + $this->parent->abort('Plugin Install: '.$db->stderr(true)); + return false; + } + $id = $db->loadResult(); + + $row = & JTable::getInstance('plugin', 'JCETable'); + + if ($id) { + + if (!$this->parent->getOverwrite()) { + // Install failed, roll back changes + $this->parent->abort('Plugin Install: '.JText::_('Plugin').' "'.$plugin.'" '.JText::_('already exists!')); + return false; + } else { + $row->load($id); + } + + } + $icon = $this->manifest->getElementByPath('icon'); + $layout = $this->manifest->getElementByPath('layout'); + + $row->title = $this->get('name'); + $row->name = $this->manifest->attributes('plugin'); + $row->type = 'plugin'; + $row->row = 4; + $row->ordering = 1; + $row->published = 1; + $row->editable = 1; + $row->icon = $icon->data(); + $row->layout = $layout->data(); + $row->iscore = 0; + + if (!$row->store()) { + // Install failed, roll back changes + $this->parent->abort('Plugin Install: '.$db->stderr(true)); + return false; + } + + // Process default extension installation (files are assumed to have been copied!) + $element = & $this->manifest->getElementByPath('extensions'); + if (is_a($element, 'JSimpleXMLElement') && count($element->children())) { + $extensions = & $element->children(); + foreach ($extensions as $extension) { + if ($extension->attributes('name')) { + $query = 'INSERT INTO `#__jce_extensions` '. + ' VALUES ("", '.(int)$row->id.', '.$db->Quote($extension->attributes('title')).', '.$db->Quote($extension->attributes('name')).', '.$db->Quote($extension->attributes('folder')).', 1 )'; + + $db->setQuery($query); + if (!$db->query()) { + // Install failed, raise error + JError::raiseWarning(100, 'Plugin Install: Unable to install default extension '.$extension->attributes('title')); + return false; + } + } + } + } + + // Since we have created a plugin item, we add it to the installation step stack + // so that if we have to rollback the changes we can undo it. + $this->parent->pushStep( array ('type'=>'plugin', 'id'=>$row->id)); + + /** + * --------------------------------------------------------------------------------------------- + * Install plugin into Default Group + * --------------------------------------------------------------------------------------------- + */ + // Add to Default Group + if ($row->type == 'plugin') { + JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jce'.DS.'groups'); + $group = & JTable::getInstance('groups', 'JCETable'); + + $query = 'SELECT id' + .' FROM #__jce_groups' + .' WHERE name = '.$db->Quote('Default') + ; + $db->setQuery($query); + $gid = $db->loadResult(); + + $group->load($gid); + // Add to plugins list + $plugins = explode(',', $group->plugins); + if(!in_array($row->id, explode(',', $group->plugins))){ + $group->plugins .= ','.$row->id; + } + // Add to last row if plugin has a layout icon + if ($row->layout) { + if (!in_array($row->id, preg_split('/[;,]+/', $group->rows))) { + $group->rows .= ','.$row->id; + } + } + if (!$group->store()) { + JError::raiseWarning(100, 'Plugin Install: Unable to add plugin to Default group'); + } + } + + /** + * --------------------------------------------------------------------------------------------- + * Finalization and Cleanup Section + * --------------------------------------------------------------------------------------------- + */ + + // Lastly, we will copy the manifest file to its appropriate place. + if (!$this->parent->copyManifest(-1)) { + // Install failed, rollback changes + $this->parent->abort('Plugin Install: '.JText::_('Could not copy setup file')); + return false; + } + + /* + * If we have an install script, lets include it, execute the custom + * install method, and append the return value from the custom install + * method to the installation message. + */ + if ($this->get('install.script')) { + if (is_file($this->parent->getPath('extension_root').DS.$this->get('install.script'))) { + ob_start(); + ob_implicit_flush(false); + require_once ($this->parent->getPath('extension_root').DS.$this->get('install.script')); + if (function_exists('jce_install')) { + if (jce_install() === false) { + $this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.JText::_('Custom install routine failure')); + return false; + } + }else if (function_exists('com_install')) { + if (com_install() === false) { + $this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.JText::_('Custom install routine failure')); + return false; + } + } + $msg = ob_get_contents(); + ob_end_clean(); + if ($msg != '') { + $this->parent->set('extension.message', $msg); + } + } + } + return true; + } + + /** + * Custom uninstall method + * + * @access public + * @param int $cid The id of the plugin to uninstall + * @param int $clientId The id of the client (unused) + * @return boolean True on success + * @since 1.5 + */ + function uninstall($id, $clientId) + { + // Initialize variables + $row = null; + $retval = true; + $db = & $this->parent->getDBO(); + + // First order of business will be to load the module object table from the database. + // This should give us the necessary information to proceed. + + // ^ Changes to plugin parameters. Use JCEPluginsTable class. + $row = & JTable::getInstance('plugin', 'JCETable'); + $row->load((int)$id); + + // Is the plugin we are trying to uninstall a core one? + // Because that is not a good idea... + if ($row->iscore) { + JError::raiseWarning(100, 'Plugin Uninstall: '.JText::sprintf('WARNCOREPLUGIN', $row->title)."| + |
|---|
| + |