Example #1
0
 function installCB_Plugin()
 {
     $html = '';
     $message = '';
     $autoSubmit = '';
     $errorMsg = '';
     $db =& JFactory::getDBO();
     $this->frontendPath = JPATH_ROOT . DS . 'components' . DS . 'com_community_acl' . DS;
     $this->backendPath = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community_acl' . DS;
     $html = '<div id="timer" style="display:none"></div>';
     $html .= '<div id="installSuccesMsg"><div id="timer"></div><div style="width:100%; float:left;">' . JText::_('Extracting Files...') . '</div><br/>';
     $default_link = rtrim(JURI::root(), '/') . '/administrator/index.php?option=com_community_acl&task=install&step=5';
     $installCB_link = rtrim(JURI::root(), '/') . '/administrator/index.php?option=com_community_acl&task=install&step=4&installCB=yes';
     $installCB = JRequest::getVar('installCB');
     if ($installCB != 'yes') {
         $autoSubmit .= caclInstaller::getAutoSubmitFunction();
         $html .= $autoSubmit;
         $html .= "</div>\n\t\t\t<table><tr><td><h3>Would you like to install Community Builder Plugin?</h3></td></tr>\n\t\t\t<tr><td><input type=\"button\" id=\"btnYes\" name=\"btnYes\" value=\"Yes\" onclick=\"window.location='" . $installCB_link . "'\" /></td>\n\t\t\t<td><input type=\"button\" id=\"btnNo\" name=\"btnNo\" value=\"No\" onclick=\"window.location='" . $default_link . "'\" /></td></tr>\n\t\t\t</table>";
     }
     if ($installCB == 'yes') {
         //Install CB Plugin
         $cb_plugin_zip = $this->frontendPath . 'plug_cacl_userreg.zip';
         #unzip Joomla File
         $destination = JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler/plugin/user/';
         $plg_destination = $destination;
         if (caclInstaller::extractArchive($cb_plugin_zip, $plg_destination)) {
             $autoSubmit .= caclInstaller::getAutoSubmitFunction();
             $message .= $autoSubmit . $html;
             //Inject the Insert query into DB
             $query = "SELECT element FROM #__comprofiler_plugin WHERE `element` = 'userreg'";
             $db->setQuery($query);
             $element = $db->loadResult();
             if ($element) {
                 //it exists
                 #- Delete the record
                 $query = "DELETE FROM #__comprofiler_plugin WHERE `element` = 'userreg'";
                 $db->setQuery($query);
                 $db->query();
             }
             #- Insert record into DB
             $query = "INSERT INTO `#__comprofiler_plugin` \n\t\t\t\t\t\t\t(`id`, `name`, `element`, `type`, `folder`, `backend_menu`, `access`, `ordering`, `published`, `iscore`, \n\t\t\t\t\t\t\t\t`client_id`, `checked_out`, `checked_out_time`, `params`) \n\t\t\t\t\t\t\t\t\tVALUES ('', 'Community ACL Registration Plugin', 'userreg', \n\t\t\t\t\t\t\t\t\t\t'user', 'plug_cacl_userreg', '', 0, 99, 1, 0, 0, 0, '0000-00-00 00:00:00', '')";
             $db->setQuery($query);
             $db->query();
         } else {
             $errorMsg .= "<p style='color:red'>Unable to extract plug_cacl_userreg.zip</p>";
             $message .= $html . $errorMsg;
         }
         #Patch the Plugin Authentication File
         $plugin_name = $this->frontendPath . 'plug_redirect_acl.zip';
         $destination = JPATH_ROOT . DS . 'plugins/authentication/';
         if (caclInstaller::extractArchive($plugin_name, $destination)) {
             $autoSubmit .= caclInstaller::getAutoSubmitFunction();
             $message = $autoSubmit . $html;
             //Inject the Insert query into DB
             $query = "SELECT element FROM #__plugin WHERE `element` = 'community_acl' AND `folder` = 'authentication'";
             $db->setQuery($query);
             $element = $db->loadResult();
             if ($element) {
                 //it exists
                 #- Delete the record
                 $query = "DELETE FROM #__plugin WHERE `element` = 'community_acl' AND `folder` = 'authentication'";
                 $db->setQuery($query);
                 $db->query();
             }
             #- Insert record into DB
             $query = "INSERT INTO `#__plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES\n\t\t\t\t\t\t\t('', 'User - Community ACL', 'community_acl', 'authentication', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '')";
             $db->setQuery($query);
             $db->query();
         } else {
             $errorMsg .= "<p style='color:red'>Unable to extract plug_redirect_acl.zip</p>";
             $message .= $html . $errorMsg;
         }
         $link = rtrim(JURI::root(), '/') . '/administrator/index.php?option=com_community_acl&task=install&step=5';
         $inputbox = "</div></div><div ><table width=\"100%\" border=\"0\"><tr><td><input type=\"button\" class=\"button-next\" onclick=\"window.location = '" . $link . "'\" value=\"Next\"/>\n\t\t\t\t\t\t</td></tr></table></div>";
         $message .= $inputbox;
     }
     return $html . $message;
 }