예제 #1
0
 /**
  * Remove (uninstall) an extension
  *
  * @param	array	An array of identifiers
  * @return	boolean	True on success
  * @since	1.5
  */
 function remove($eid = array())
 {
     // Initialise variables.
     $user = JFactory::getUser();
     if ($user->authorise('core.delete', 'com_jckman')) {
         // Initialise variables.
         $failed = array();
         $db = JFactory::getDBO();
         $app = JFactory::getApplication();
         $lang = JFactory::getLanguage();
         /*
          * Ensure eid is an array of extension ids in the form id => client_id
          * TODO: If it isn't an array do we want to set an error and fail?
          */
         if (!is_array($eid)) {
             $eid = array($eid);
         }
         // Get an installer object for the extension type
         require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'installer.php';
         $view = $app->input->get('view', false);
         $installer =& JCKInstaller::getInstance();
         // Uninstall the chosen extensions
         foreach ($eid as $id) {
             $id = trim($id);
             if ($view) {
                 $result = $installer->uninstall($view, $id);
                 // Build an array of extensions that failed to uninstall
                 if ($result === false) {
                     $failed[] = $id;
                 }
             } else {
                 $failed[] = $id;
             }
         }
         $lang->load('com_installer');
         $langstring = 'COM_INSTALLER_TYPE_TYPE_' . strtoupper($row->type);
         $rowtype = JText::_($langstring);
         if (strpos($rowtype, $langstring) !== false) {
             $rowtype = $row->type;
         }
         if (count($failed)) {
             // There was an error in uninstalling the package
             $msg = JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype);
             $result = false;
         } else {
             // Package uninstalled sucessfully
             $msg = JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $rowtype);
             $result = true;
         }
         $app->enqueueMessage($msg);
         $this->setState('action', 'remove');
         $this->setState('name', $installer->get('name'));
         $app->setUserState('com_jckman.message', $installer->message);
         $app->setUserState('com_jckman.extension_message', $installer->get('extension_message'));
         return $result;
     } else {
         $result = false;
         JCKHelper::error(JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
     }
 }
예제 #2
0
 function install()
 {
     $mainframe =& JFactory::getApplication();
     $this->setState('action', 'install');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $this->setState('message', 'No Install Type Found');
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', 'Unable to find install package');
         return false;
     }
     // Get a database connector
     //$db = & JFactory::getDBO();
     // Get an installer instance
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'installer.php';
     $installer =& JCKInstaller::getInstance();
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
         $result = true;
     }
     // Set some model state values
     $mainframe->enqueueMessage($msg);
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $this->setState('message', $installer->message);
     $this->setState('extension.message', $installer->get('extension.message'));
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config =& JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
예제 #3
0
 /**
  * Remove (uninstall) an extension
  *
  * @static
  * @param	array	An array of identifiers
  * @return	boolean	True on success
  * @since 1.0
  */
 function remove($eid = array())
 {
     $mainframe =& JFactory::getApplication();
     // Initialize variables
     $failed = array();
     /*
      * Ensure eid is an array of extension ids in the form id => client_id
      * TODO: If it isn't an array do we want to set an error and fail?
      */
     if (!is_array($eid)) {
         $eid = array($eid => 0);
     }
     // Get a database connector
     $db = JFactory::getDBO();
     // Get an installer object for the extension type
     //jimport('joomla.installer.installer');
     //$installer = & JInstaller::getInstance();
     require_once JPATH_COMPONENT . DS . 'installer.php';
     $installer = JCKInstaller::getInstance();
     // Uninstall the chosen extensions
     foreach ($eid as $id => $clientId) {
         $id = trim($id);
         $result = $installer->uninstall($this->_type, $id, $clientId);
         // Build an array of extensions that failed to uninstall
         if ($result === false) {
             $failed[] = $id;
         }
     }
     if (count($failed)) {
         // There was an error in uninstalling the package
         $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error'));
         $result = false;
     } else {
         // Package uninstalled sucessfully
         $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success'));
         $result = true;
     }
     $mainframe->enqueueMessage($msg);
     $this->setState('action', 'remove');
     $this->setState('name', $installer->get('name'));
     $this->setState('message', $installer->message);
     $this->setState('extension.message', $installer->get('extension.message'));
     return $result;
 }