Example #1
0
 /**
  * Installing plugin by press install button
  * @run redirect
  **/
 function installPlugin()
 {
     global $option, $mainframe;
     $db =& JFactory::getDBO();
     /* Delete Plugin */
     $query = "DELETE FROM #__plugins WHERE element = 'jyaml' and folder = 'system' LIMIT 1";
     $db->setQuery($query);
     if (!($result = $db->query())) {
         echo $db->stderr();
     }
     $files = array();
     $files2 = array();
     $files = JFolder::files(JPATH_SITE . DS . 'plugins' . DS . 'system', '^jyaml', true, true);
     $files2 = JFolder::files(JPATH_ADMINISTRATOR . DS . 'language', 'plg_system_jyaml.ini$', true, true);
     $files = array_merge($files, $files2);
     foreach ($files as $file) {
         JFile::delete($file);
     }
     $lang =& JFactory::getLanguage();
     $lang->load('com_installer', JPATH_BASE);
     /* Install Plugin */
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_installer' . DS . 'models' . DS . 'install.php';
     $m = new InstallerModelInstall();
     $r = $m->install();
     /* and enable the plugin */
     if ($r) {
         JYAML::enablePlugin();
     } else {
         $mainframe->redirect(JURI::base() . 'index.php?option=' . $option);
     }
 }