PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_acymailing/install.acymailing.php

https://github.com/srgg6701/auction-ruseasons
PHP | 586 lines | 473 code | 106 blank | 7 comment | 50 complexity | 89ecc312b09f0a711f6815e1151ff537 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, LGPL-2.1, BSD-3-Clause, JSON
  1. <?php
  2. /**
  3. * @package AcyMailing for Joomla!
  4. * @version 4.1.0
  5. * @author acyba.com
  6. * @copyright (C) 2009-2013 ACYBA S.A.R.L. All rights reserved.
  7. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
  8. */
  9. defined('_JEXEC') or die('Restricted access');
  10. ?><?php
  11. function installAcyMailing(){
  12. include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');
  13. acymailing_increasePerf();
  14. $installClass = new acymailingInstall();
  15. $installClass->updateJoomailing();
  16. $installClass->addPref();
  17. $installClass->updatePref();
  18. $installClass->updateSQL();
  19. $installClass->displayInfo();
  20. }
  21. function uninstallAcyMailing(){
  22. $uninstallClass = new acymailingUninstall();
  23. $uninstallClass->unpublishModules();
  24. $uninstallClass->message();
  25. }
  26. if(!function_exists('com_install')){
  27. function com_install(){
  28. return installAcyMailing();
  29. }
  30. }
  31. if(!function_exists('com_uninstall')){
  32. function com_uninstall(){
  33. return uninstallAcyMailing();
  34. }
  35. }
  36. class com_acymailingInstallerScript {
  37. function install($parent) { installAcyMailing(); }
  38. function update($parent) { installAcyMailing(); }
  39. function uninstall($parent) { uninstallAcyMailing(); }
  40. function preflight($type, $parent) { return true; }
  41. function postflight($type, $parent) { return true; }
  42. }
  43. class acymailingInstall{
  44. var $level = 'starter';
  45. var $version = '4.1.0';
  46. var $update = false;
  47. var $fromLevel = '';
  48. var $fromVersion = '';
  49. var $db;
  50. function acymailingInstall(){
  51. $this->db = JFactory::getDBO();
  52. }
  53. function displayInfo(){
  54. echo '<h1>Please wait... </h1><h2>AcyMailing will now automatically install the Plugins and the Module</h2>';
  55. $url = 'index.php?option=com_acymailing&ctrl=update&task=install';
  56. echo '<a href="'.$url.'">Please click here if you are not automatically redirected within 3 seconds</a>';
  57. echo "<script language=\"javascript\" type=\"text/javascript\">document.location.href='$url';</script>\n";
  58. }
  59. function updatePref(){
  60. $this->db->setQuery("SELECT `namekey`, `value` FROM `#__acymailing_config` WHERE `namekey` IN ('version','level') LIMIT 2");
  61. $results = $this->db->loadObjectList('namekey');
  62. if($results['version']->value == $this->version AND $results['level']->value == $this->level) return true;
  63. $this->update = true;
  64. $this->fromLevel = $results['level']->value;
  65. $this->fromVersion = $results['version']->value;
  66. $query = "REPLACE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('level',".$this->db->Quote($this->level)."),('version',".$this->db->Quote($this->version)."),('installcomplete','0')";
  67. $this->db->setQuery($query);
  68. $this->db->query();
  69. }
  70. function updateSQL(){
  71. if(!$this->update) return true;
  72. jimport('joomla.filesystem.folder');
  73. jimport('joomla.filesystem.file');
  74. if(version_compare($this->fromVersion,'1.1.4','<')){
  75. $replace1 = "REPLACE(`params`, 'showhtml=1\nshowname=1', 'customfields=name,email,html' )";
  76. $replace2 = "REPLACE( $replace1 , 'showhtml=0\nshowname=1', 'customfields=name,email' )";
  77. $replace3 = "REPLACE( $replace2 , 'showhtml=1\nshowname=0', 'customfields=email,html' )";
  78. $replace4 = "REPLACE( $replace3 , 'showhtml=0\nshowname=0', 'customfields=email' )";
  79. $this->db->setQuery("UPDATE #__modules SET `params`= $replace4 WHERE `module` = 'mod_acymailing' ");
  80. $this->db->query();
  81. }
  82. if(version_compare($this->fromVersion,'1.2.1','<')){
  83. $this->db->setQuery("UPDATE `#__acymailing_config` SET `value` = 'data' WHERE `value` = '0' AND `namekey` = 'allow_modif' LIMIT 1");
  84. $this->db->query();
  85. $this->db->setQuery("UPDATE `#__acymailing_config` SET `value` = 'all' WHERE `value` = '1' AND `namekey` = 'allow_modif' LIMIT 1");
  86. $this->db->query();
  87. }
  88. if(version_compare($this->fromVersion,'1.2.2','<')){
  89. $this->db->setQuery("ALTER TABLE `#__acymailing_mail` ADD `sentby` INT UNSIGNED NULL DEFAULT NULL");
  90. $this->db->query();
  91. $this->db->setQuery("ALTER TABLE `#__acymailing_template` ADD `subject` VARCHAR( 250 ) NULL DEFAULT NULL");
  92. $this->db->query();
  93. $this->db->setQuery("DELETE FROM `#__plugins` WHERE `folder` = 'acymailing' AND `element` = 'autocontent'");
  94. $this->db->query();
  95. }
  96. if(version_compare($this->fromVersion,'1.2.3','<')){
  97. $this->db->setQuery("UPDATE `#__plugins` SET `folder` = 'system', `element`= 'regacymailing', `name` = 'AcyMailing : (auto)Subscribe during Joomla registration', `params`= REPLACE(`params`, 'lists=', 'autosub=' ) WHERE `folder` = 'user' AND `element` = 'acymailing'");
  98. $this->db->query();
  99. $this->db->setQuery("DELETE FROM `#__plugins` WHERE `folder` = 'acymailing' AND `element` = 'autocontent'");
  100. $this->db->query();
  101. $this->db->setQuery("ALTER TABLE `#__acymailing_template` ADD `stylesheet` TEXT NULL");
  102. $this->db->query();
  103. if(is_dir(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.ACYMAILING_COMPONENT.DS.'plugins'.DS.'plg_user_acymailing')){
  104. JFolder::delete(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.ACYMAILING_COMPONENT.DS.'plugins'.DS.'plg_user_acymailing');
  105. }
  106. if(is_dir(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.ACYMAILING_COMPONENT.DS.'plugins'.DS.'plg_acymailing_autocontent')){
  107. JFolder::delete(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.ACYMAILING_COMPONENT.DS.'plugins'.DS.'plg_acymailing_autocontent');
  108. }
  109. }
  110. if(version_compare($this->fromVersion,'1.3.1','<')){
  111. $this->db->setQuery("ALTER TABLE `#__acymailing_config` CHANGE `value` `value` TEXT NULL ");
  112. $this->db->query();
  113. $this->db->setQuery("ALTER TABLE `#__acymailing_fields` ADD `listing` TINYINT NULL DEFAULT NULL ");
  114. $this->db->query();
  115. $this->db->setQuery("UPDATE `#__acymailing_fields` SET `listing` = 1 WHERE `namekey` IN ('name','email','html') ");
  116. $this->db->query();
  117. $this->db->setQuery("ALTER TABLE `#__acymailing_template` ADD `fromname` VARCHAR( 250 ) NULL , ADD `fromemail` VARCHAR( 250 ) NULL , ADD `replyname` VARCHAR( 250 ) NULL , ADD `replyemail` VARCHAR( 250 ) NULL ");
  118. $this->db->query();
  119. }
  120. if(version_compare($this->fromVersion,'1.5.2','<')){
  121. $this->db->setQuery("SELECT `params` FROM #__plugins WHERE `element` = 'regacymailing' LIMIT 1");
  122. $existingEntry = $this->db->loadResult();
  123. $listids = 'None';
  124. if(preg_match('#autosub=(.*)#i',$existingEntry,$autosubResult)){
  125. $listids = $autosubResult[1];
  126. }
  127. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('autosub',".$this->db->Quote($listids).")");
  128. $this->db->query();
  129. }
  130. if(version_compare($this->fromVersion,'1.5.3','<')){
  131. $this->db->setQuery('UPDATE #__acymailing_config SET `value` = REPLACE(`value`,\'<sup style="font-size: 4px;">TM</sup>\',\'™\')');
  132. $this->db->query();
  133. }
  134. if(version_compare($this->fromVersion,'1.6.2','<')){
  135. $this->db->setQuery("UPDATE #__acymailing_config SET `value` = 'media/com_acymailing/upload' WHERE `namekey` = 'uploadfolder' AND `value` = 'components/com_acymailing/upload' ");
  136. $this->db->query();
  137. $this->db->setQuery("UPDATE #__acymailing_config SET `value` = 'media/com_acymailing/logs/report".rand(0,999999999).".log' WHERE `namekey` = 'cron_savepath' ");
  138. $this->db->query();
  139. if(!ACYMAILING_J16){
  140. $this->db->setQuery("UPDATE #__plugins SET `params` = REPLACE(`params`,'components/com_acymailing/images','media/com_acymailing/images') ");
  141. }else{
  142. $this->db->setQuery("UPDATE #__extensions SET `params` = REPLACE(`params`,'components\/com_acymailing\/images','media\/com_acymailing\/images') ");
  143. }
  144. $this->db->query();
  145. $updateClass = acymailing_get('helper.update');
  146. $removeFiles = array();
  147. $removeFiles[] = ACYMAILING_FRONT.'css'.DS.'component_default.css';
  148. $removeFiles[] = ACYMAILING_FRONT.'css'.DS.'frontendedition.css';
  149. $removeFiles[] = ACYMAILING_FRONT.'css'.DS.'module_default.css';
  150. foreach($removeFiles as $oneFile){
  151. if(is_file($oneFile)) JFile::delete($oneFile);
  152. }
  153. $fromFolders = array();
  154. $toFolders = array();
  155. $fromFolders[] = ACYMAILING_FRONT.'css';
  156. $toFolders[] = ACYMAILING_MEDIA.'css';
  157. $fromFolders[] = ACYMAILING_FRONT.'templates'.DS.'plugins';
  158. $toFolders[] = ACYMAILING_MEDIA.'plugins';
  159. $fromFolders[] = ACYMAILING_FRONT.'upload';
  160. $toFolders[] = ACYMAILING_MEDIA.'upload';
  161. foreach($fromFolders as $i => $oneFolder){
  162. if(!is_dir($oneFolder)) continue;
  163. if(is_dir($toFolders[$i])){
  164. $updateClass->copyFolder($oneFolder,$toFolders[$i]);
  165. }
  166. }
  167. $deleteFolders = array();
  168. $deleteFolders[] = ACYMAILING_FRONT.'css';
  169. $deleteFolders[] = ACYMAILING_FRONT.'images';
  170. $deleteFolders[] = ACYMAILING_FRONT.'js';
  171. $deleteFolders[] = ACYMAILING_BACK.'logs';
  172. foreach($deleteFolders as $oneFolder){
  173. if(!is_dir($oneFolder)) continue;
  174. JFolder::delete($oneFolder);
  175. }
  176. }
  177. if(version_compare($this->fromVersion,'1.7.1','<')){
  178. $this->db->setQuery("CREATE TABLE IF NOT EXISTS `#__acymailing_history` (`subid` INT UNSIGNED NOT NULL ,`date` INT UNSIGNED NOT NULL ,`ip` VARCHAR( 50 ) NULL ,
  179. `action` VARCHAR( 50 ) NOT NULL , `data` TEXT NULL , `source` TEXT NULL , INDEX ( `subid` , `date` ) ) ENGINE=MyISAM ;");
  180. $this->db->query();
  181. }
  182. if(version_compare($this->fromVersion,'1.7.3','<')){
  183. $this->db->setQuery("ALTER TABLE `#__acymailing_mail` ADD `metakey` TEXT NULL , ADD `metadesc` TEXT NULL ");
  184. $this->db->query();
  185. }
  186. if(version_compare($this->fromVersion,'1.8.4','<')){
  187. $this->db->setQuery("UPDATE `#__acymailing_config` as a, `#__acymailing_config` as b SET a.`value` = b.`value` WHERE a.`namekey`= 'queue_nbmail_auto' AND b.`namekey`= 'queue_nbmail' ");
  188. $this->db->query();
  189. $this->db->setQuery("UPDATE `#__acymailing_mail` SET `body` = CONCAT(`body`,'<p>{survey}</p>') WHERE type = 'notification' AND `alias` IN ('notification_refuse','notification_unsub','notification_unsuball')");
  190. $this->db->query();
  191. }
  192. if(version_compare($this->fromVersion,'1.8.5','<')){
  193. $metaFile = ACYMAILING_FRONT.'metadata.xml';
  194. if(file_exists($metaFile)) JFile::delete($metaFile);
  195. $this->db->setQuery('ALTER TABLE #__acymailing_url DROP INDEX url');
  196. $this->db->query();
  197. $this->db->setQuery('ALTER TABLE `#__acymailing_url` CHANGE `url` `url` TEXT NOT NULL');
  198. $this->db->query();
  199. $this->db->setQuery('ALTER TABLE `#__acymailing_url` ADD INDEX `url` ( `url` ( 250 ) ) ');
  200. $this->db->query();
  201. $this->db->setQuery("UPDATE `#__acymailing_mail` SET `body` = CONCAT(`body`,'<p>Subscription : {user:subscription}</p>') WHERE type = 'notification' AND `alias` = 'notification_created'");
  202. $this->db->query();
  203. }
  204. if(version_compare($this->fromVersion,'1.9.1','<')){
  205. $this->db->setQuery('ALTER TABLE `#__acymailing_history` ADD `mailid` MEDIUMINT UNSIGNED NULL' );
  206. $this->db->query();
  207. $this->db->setQuery('CREATE TABLE IF NOT EXISTS `#__acymailing_rules` (
  208. `ruleid` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  209. `name` VARCHAR( 250 ) NOT NULL ,
  210. `ordering` SMALLINT UNSIGNED NULL ,
  211. `regex` VARCHAR( 250 ) NOT NULL ,
  212. `executed_on` TEXT NOT NULL ,
  213. `action_message` TEXT NOT NULL ,
  214. `action_user` TEXT NOT NULL ,
  215. `published` TINYINT UNSIGNED NOT NULL
  216. )');
  217. $this->db->query();
  218. $this->db->setQuery("UPDATE `#__acymailing_mail` SET `body` = CONCAT(`body`,'<p>Subscription : {user:subscription}</p>') WHERE type = 'notification' AND `alias` IN ( 'notification_unsuball','notification_refuse','notification_unsub')");
  219. $this->db->query();
  220. $this->db->setQuery("REPLACE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('auto_bounce','0')");
  221. $this->db->query();
  222. }
  223. if(version_compare($this->fromVersion,'3.0.1','<')){
  224. $this->db->setQuery('ALTER TABLE `#__acymailing_mail` ADD `filter` TEXT NULL' );
  225. $this->db->query();
  226. $this->db->setQuery("ALTER TABLE `#__acymailing_subscriber` CHANGE `userid` `userid` INT UNSIGNED NOT NULL DEFAULT '0'" );
  227. $this->db->query();
  228. }
  229. if(version_compare($this->fromVersion,'3.5.1','<')){
  230. if(file_exists(ACYMAILING_FRONT.'sef_ext.php')) JFile::delete(ACYMAILING_FRONT.'sef_ext.php');
  231. $this->db->setQuery("ALTER TABLE `#__acymailing_queue` ADD `paramqueue` VARCHAR( 250 ) NULL " );
  232. $this->db->query();
  233. if(!ACYMAILING_J16){
  234. $this->db->setQuery("DELETE FROM `#__plugins` WHERE folder = 'acymailing' AND element LIKE 'tagvm%'");
  235. }else{
  236. $this->db->setQuery("DELETE FROM `#__extensions` WHERE folder = 'acymailing' AND element LIKE 'tagvm%'");
  237. }
  238. $this->db->query();
  239. }
  240. if(version_compare($this->fromVersion,'3.6.1','<')){
  241. $this->db->setQuery("ALTER TABLE `#__acymailing_rules` CHANGE `regex` `regex` TEXT NOT NULL" );
  242. $this->db->query();
  243. $this->db->setQuery("ALTER TABLE `#__acymailing_stats` ADD `bouncedetails` TEXT NULL" );
  244. $this->db->query();
  245. }
  246. if(version_compare($this->fromVersion,'3.7.1','<')){
  247. $this->db->setQuery("ALTER TABLE `#__acymailing_userstats` ADD `ip` VARCHAR( 100 ) NULL" );
  248. $this->db->query();
  249. $this->db->setQuery("ALTER TABLE `#__acymailing_urlclick` ADD `ip` VARCHAR( 100 ) NULL" );
  250. $this->db->query();
  251. }
  252. if(version_compare($this->fromVersion,'3.8.1','<')){
  253. $this->db->setQuery("UPDATE #__acymailing_mail SET subject = CONCAT(subject,' ','{mainreport}') WHERE type = 'notification' AND alias = 'report' AND subject NOT LIKE '%mainreport%' LIMIT 1");
  254. $this->db->query();
  255. }
  256. if(version_compare($this->fromVersion,'3.8.2','<')){
  257. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ('optimize_listsub',0),('optimize_stats',0),('optimize_list',0),('optimize_mail',0),('optimize_userstats',0),('optimize_urlclick',0),('optimize_history',0),('optimize_template',0),('optimize_queue',0),('optimize_subscriber',0) ");
  258. $this->db->query();
  259. }
  260. if(version_compare($this->fromVersion,'3.9.1','<')){
  261. $file = ACYMAILING_FRONT.'views'.DS.'newsletter'.DS.'metadata.xml';
  262. if(file_exists($file)) JFile::delete($file);
  263. $file = ACYMAILING_BACK.'admin.acymailing.php';
  264. if(file_exists($file)) JFile::delete($file);
  265. }
  266. if(version_compare($this->fromVersion,'4.0.0','<')){
  267. $this->db->setQuery("SELECT params,id FROM #__modules WHERE module = 'mod_acymailing'");
  268. $allModules = $this->db->loadObjectList();
  269. foreach($allModules as $oneMod){
  270. $newParams = preg_replace('#fieldsize=.*#i','fieldsize=80%',$oneMod->params);
  271. $newParams = preg_replace('#"fieldsize":"[^"]*"#i','"fieldsize":"80%"',$newParams);
  272. $this->db->setQuery("UPDATE #__modules SET params = ".$this->db->Quote($newParams)." WHERE id = ".intval($oneMod->id));
  273. $this->db->query();
  274. }
  275. $this->db->setQuery("SELECT options,fieldid FROM #__acymailing_fields WHERE type IN ('phone','text','date','file') AND options LIKE '%size%'");
  276. $allFields = $this->db->loadObjectList();
  277. foreach($allFields as $oneField){
  278. $options = unserialize($oneField->options);
  279. $options['size'] = intval($options['size']*5);
  280. $this->db->setQuery("UPDATE #__acymailing_fields SET options = ".$this->db->Quote(serialize($options))." WHERE fieldid = ".intval($oneField->fieldid));
  281. $this->db->query();
  282. }
  283. }
  284. if(version_compare($this->fromVersion,'4.0.1','<')){
  285. if(is_dir(ACYMAILING_BACK.'inc'.DS.'openflash')){
  286. JFolder::delete(ACYMAILING_BACK.'inc'.DS.'openflash');
  287. }
  288. if(is_dir(ACYMAILING_FRONT.'inc'.DS.'openflash')){
  289. JFolder::delete(ACYMAILING_FRONT.'inc'.DS.'openflash');
  290. }
  291. }
  292. }
  293. function updateJoomailing(){
  294. $this->db->setQuery("SHOW TABLES LIKE '".$this->db->getPrefix()."joomailing_config'");
  295. $result = $this->db->loadResult();
  296. if(empty($result)) return true;
  297. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) SELECT `namekey`, REPLACE(`value`,'com_joomailing','com_acymailing') FROM `#__joomailing_config`");
  298. $this->db->query();
  299. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_list` (`name`, `description`, `ordering`, `listid`, `published`, `userid`, `alias`, `color`, `visible`, `welmailid`, `unsubmailid`, `type`) SELECT `name`, `description`, `ordering`, `listid`, `published`, `userid`, `alias`, `color`, `visible`, `welmailid`, `unsubmailid`, `type` FROM `#__joomailing_list`");
  300. $this->db->query();
  301. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_listcampaign` (`campaignid`, `listid`) SELECT `campaignid`, `listid` FROM `#__joomailing_listcampaign`");
  302. $this->db->query();
  303. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_listmail` (`listid`, `mailid`) SELECT `listid`, `mailid` FROM `#__joomailing_listmail`");
  304. $this->db->query();
  305. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_listsub` (`listid`, `subid`, `subdate`, `unsubdate`, `status`) SELECT `listid`, `subid`, `subdate`, `unsubdate`, `status` FROM `#__joomailing_listsub`");
  306. $this->db->query();
  307. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_mail` (`mailid`, `subject`, `body`, `altbody`, `published`, `senddate`, `created`, `fromname`, `fromemail`, `replyname`, `replyemail`, `type`, `visible`, `userid`, `alias`, `attach`, `html`, `tempid`, `key`, `frequency`, `params`) SELECT `mailid`, `subject`, REPLACE(`body`,'joomailing','acymailing'), REPLACE(`altbody`,'joomailing','acymailing'), `published`, `senddate`, `created`, `fromname`, `fromemail`, `replyname`, `replyemail`, `type`, `visible`, `userid`, `alias`, REPLACE(`attach`,'com_joomailing','com_acymailing'), `html`, `tempid`, `key`, `frequency`, REPLACE(`params`,'com_joomailing','com_acymailing') FROM `#__joomailing_mail`");
  308. $this->db->query();
  309. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_queue` (`senddate`, `subid`, `mailid`, `priority`, `try`) SELECT `senddate`, `subid`, `mailid`, `priority`, `try` FROM `#__joomailing_queue`");
  310. $this->db->query();
  311. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_stats` (`mailid`, `senthtml`, `senttext`, `senddate`, `openunique`, `opentotal`, `bounceunique`, `fail`, `clicktotal`, `clickunique`, `unsub`, `forward`) SELECT `mailid`, `senthtml`, `senttext`, `senddate`, `openunique`, `opentotal`, `bounceunique`, `fail`, `clicktotal`, `clickunique`, `unsub`, `forward` FROM `#__joomailing_stats`");
  312. $this->db->query();
  313. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_subscriber` (`subid`, `email`, `userid`, `name`, `created`, `confirmed`, `enabled`, `accept`, `ip`, `html`, `key`) SELECT `subid`, `email`, `userid`, `name`, `created`, `confirmed`, `enabled`, `accept`, `ip`, `html`, `key` FROM `#__joomailing_subscriber`");
  314. $this->db->query();
  315. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_template` (`tempid`, `name`, `description`, `body`, `altbody`, `created`, `published`, `premium`, `ordering`, `namekey`, `styles`) SELECT `tempid`, `name`, REPLACE(`description`,'joomailing','acymailing'), REPLACE(`body`,'joomailing','acymailing'), REPLACE(`altbody`,'joomailing','acymailing'), `created`, `published`, `premium`, `ordering`, `namekey`, REPLACE(`styles`,'joomailing','acymailing') FROM `#__joomailing_template`");
  316. $this->db->query();
  317. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_url` (`urlid`, `name`, `url`) SELECT `urlid`, REPLACE(`name`,'com_joomailing','com_acymailing'), REPLACE(`url`,'com_joomailing','com_acymailing') FROM `#__joomailing_url`");
  318. $this->db->query();
  319. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_urlclick` (`urlid`, `mailid`, `click`, `subid`, `date`) SELECT `urlid`, `mailid`, `click`, `subid`, `date` FROM `#__joomailing_urlclick`");
  320. $this->db->query();
  321. $this->db->setQuery("INSERT IGNORE INTO `#__acymailing_userstats` (`mailid`, `subid`, `html`, `sent`, `senddate`, `open`, `opendate`, `bounce`, `fail`) SELECT `mailid`, `subid`, `html`, `sent`, `senddate`, `open`, `opendate`, `bounce`, `fail` FROM `#__joomailing_userstats`");
  322. $this->db->query();
  323. $this->db->setQuery("DROP TABLE IF EXISTS `#__joomailing_config`, `#__joomailing_list`, `#__joomailing_listcampaign`, `#__joomailing_listmail`, `#__joomailing_listsub`, `#__joomailing_mail`, `#__joomailing_queue` , `#__joomailing_stats`, `#__joomailing_subscriber`, `#__joomailing_template` , `#__joomailing_url`, `#__joomailing_urlclick`, `#__joomailing_userstats`");
  324. $this->db->query();
  325. $this->db->setQuery("UPDATE `#__modules` SET `title` = REPLACE(`title`,'JooMailing','AcyMailing'), `module` = REPLACE(`module`,'joomailing','acymailing'), `params` = REPLACE(`params`,'joomailing','acymailing')");
  326. $this->db->query();
  327. $this->db->setQuery("UPDATE `#__plugins` SET `name` = REPLACE(REPLACE(REPLACE(`name`,'jooMailing','AcyMailing'),'joomailing','acymailing'),'JooMailing','AcyMailing'), `element` = REPLACE(`element`,'joomailing','acymailing'), `folder` = REPLACE(`folder`,'joomailing','acymailing'), `params` = REPLACE(`params`,'joomailing','acymailing')");
  328. $this->db->query();
  329. $this->db->setQuery("DELETE FROM `#__components` WHERE `option` LIKE '%joomailing%' OR `admin_menu_link` LIKE '%joomailing%'");
  330. $this->db->query();
  331. $this->db->setQuery("UPDATE `#__menu` SET `menutype` = REPLACE(`menutype`,'joomailing','acymailing'), `name` = REPLACE(`name`,'joomailing','acymailing'), `alias` = REPLACE(`alias`,'joomailing','acymailing'), `link` = REPLACE(`link`,'joomailing','acymailing')");
  332. $this->db->query();
  333. $newFile = '<?php
  334. $app = JFactory::getApplication();
  335. $url = \'index.php?option=com_acymailing\';
  336. foreach($_GET as $name => $value){
  337. if($name == \'option\') continue;
  338. $url .= \'&\'.$name.\'=\'.$value;
  339. }
  340. $app->redirect($url);
  341. ';
  342. @file_put_contents(rtrim(JPATH_SITE,DS).DS.'components'.DS.'com_joomailing'.DS.'joomailing.php',$newFile);
  343. @file_put_contents(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_joomailing'.DS.'admin.joomailing.php',$newFile);
  344. }
  345. function addPref(){
  346. $conf = JFactory::getConfig();
  347. $this->level = ucfirst($this->level);
  348. $allPref = array();
  349. $allPref['level'] = $this->level;
  350. $allPref['version'] = $this->version;
  351. if(ACYMAILING_J30){
  352. $allPref['from_name'] = $conf->get('fromname');
  353. $allPref['from_email'] = $conf->get('mailfrom');
  354. $allPref['mailer_method'] = $conf->get('mailer');
  355. $allPref['sendmail_path'] = $conf->get('sendmail');
  356. $smtpinfos = explode(':',$conf->get('smtphost'));
  357. $allPref['smtp_secured'] = $conf->get('smtpsecure');
  358. $allPref['smtp_auth'] = $conf->get('smtpauth');
  359. $allPref['smtp_username'] = $conf->get('smtpuser');
  360. $allPref['smtp_password'] = $conf->get('smtppass');
  361. }else{
  362. $allPref['from_name'] = $conf->getValue('config.fromname');
  363. $allPref['from_email'] = $conf->getValue('config.mailfrom');
  364. $allPref['mailer_method'] = $conf->getValue('config.mailer');
  365. $allPref['sendmail_path'] = $conf->getValue('config.sendmail');
  366. $smtpinfos = explode(':',$conf->getValue('config.smtphost'));
  367. $allPref['smtp_secured'] = $conf->getValue('config.smtpsecure');
  368. $allPref['smtp_auth'] = $conf->getValue('config.smtpauth');
  369. $allPref['smtp_username'] = $conf->getValue('config.smtpuser');
  370. $allPref['smtp_password'] = $conf->getValue('config.smtppass');
  371. }
  372. $allPref['reply_name'] = $allPref['from_name'];
  373. $allPref['reply_email'] = $allPref['from_email'];
  374. $allPref['cron_sendto'] = $allPref['from_email'];
  375. $allPref['bounce_email'] = '';
  376. $allPref['add_names'] = '1';
  377. $allPref['encoding_format'] = '8bit';
  378. $allPref['charset'] = 'UTF-8';
  379. $allPref['word_wrapping'] = '150';
  380. $allPref['hostname'] = '';
  381. $allPref['embed_images'] = '0';
  382. $allPref['embed_files'] = '1';
  383. $allPref['editor'] = '0';
  384. $allPref['multiple_part'] = '1';
  385. $allPref['smtp_host'] = $smtpinfos[0];
  386. $allPref['smtp_port'] = '';
  387. if(isset($smtpinfos[1])) $allPref['smtp_port'] = $smtpinfos[1];
  388. if(!in_array($allPref['smtp_secured'],array('tls','ssl'))) $allPref['smtp_secured'] = '';
  389. $allPref['queue_nbmail'] = '40';
  390. $allPref['queue_nbmail_auto'] = '70';
  391. $allPref['queue_type'] = 'auto';
  392. $allPref['queue_try'] = '3';
  393. $allPref['queue_pause'] = '120';
  394. $allPref['allow_visitor'] = '1';
  395. $allPref['require_confirmation'] = '0';
  396. $allPref['priority_newsletter'] = '3';
  397. $allPref['allowedfiles'] = 'zip,doc,docx,pdf,xls,txt,gzip,rar,jpg,gif,xlsx,pps,csv,bmp,ico,odg,odp,ods,odt,png,ppt,swf,xcf,mp3,wma';
  398. $allPref['uploadfolder'] = 'media/com_acymailing/upload';
  399. $allPref['confirm_redirect'] = '';
  400. $allPref['subscription_message'] = '1';
  401. $allPref['notification_unsuball'] = '';
  402. $allPref['cron_next'] = '1251990901';
  403. $allPref['confirmation_message'] = '1';
  404. $allPref['welcome_message'] = '1';
  405. $allPref['unsub_message'] = '1';
  406. $allPref['cron_last'] = '0';
  407. $allPref['cron_fromip'] = '';
  408. $allPref['cron_report'] = '';
  409. $allPref['cron_frequency'] = '900';
  410. $allPref['cron_sendreport'] = '2';
  411. $allPref['cron_fullreport'] = '1';
  412. $allPref['cron_savereport'] = '2';
  413. $allPref['cron_savepath'] = 'media/com_acymailing/logs/report'.rand(0,999999999).'.log';
  414. $allPref['notification_created'] = '';
  415. $allPref['notification_accept'] = '';
  416. $allPref['notification_refuse'] = '';
  417. $allPref['forward'] = '0';
  418. $descriptions = array('Joomla!™ Newsletter Extension','Joomla!™ Mailing Extension','Joomla!™ Newsletter System','Joomla!™ E-mail Marketing','Joomla!™ Marketing Campaign');
  419. $allPref['description_starter'] = $descriptions[rand(0,4)];
  420. $allPref['description_essential'] = $descriptions[rand(0,4)];
  421. $allPref['description_business'] = $descriptions[rand(0,4)];
  422. $allPref['description_enterprise'] = $descriptions[rand(0,4)];
  423. $allPref['priority_followup'] = '2';
  424. $allPref['unsub_redirect'] = '';
  425. $allPref['show_footer'] = '1';
  426. $allPref['use_sef'] = '0';
  427. $allPref['itemid'] = '0';
  428. $allPref['css_module'] = 'default';
  429. $allPref['css_frontend'] = 'default';
  430. $allPref['css_backend'] = 'default';
  431. $allPref['menu_position'] = 'under';
  432. $allPref['unsub_reasons'] = serialize(array('UNSUB_SURVEY_FREQUENT','UNSUB_SURVEY_RELEVANT'));
  433. $app = JFactory::getApplication();
  434. $currentTemplate = $app->getTemplate();
  435. if(ACYMAILING_J30 || in_array($currentTemplate,array('rt_missioncontrol','aplite'))){
  436. $allPref['menu_position'] = 'above';
  437. }
  438. $allPref['installcomplete'] = '0';
  439. $allPref['Starter'] = '0';
  440. $allPref['Essential'] = '1';
  441. $allPref['Business'] = '2';
  442. $allPref['Enterprise'] = '3';
  443. $query = "INSERT IGNORE INTO `#__acymailing_config` (`namekey`,`value`) VALUES ";
  444. foreach($allPref as $namekey => $value){
  445. $query .= '('.$this->db->Quote($namekey).','.$this->db->Quote($value).'),';
  446. }
  447. $query = rtrim($query,',');
  448. $this->db->setQuery($query);
  449. $this->db->query();
  450. }
  451. }
  452. class acymailingUninstall{
  453. var $db;
  454. function acymailingUninstall(){
  455. $this->db = JFactory::getDBO();
  456. }
  457. function message(){
  458. ?>
  459. You uninstalled the AcyMailing component.<br/>
  460. AcyMailing also unpublished the modules attached to the component.<br/><br/>
  461. If you want to completely uninstall AcyMailing, please select all the AcyMailing modules and plugins and uninstall them from the Joomla Extensions Manager.<br/>
  462. Then execute this query via phpMyAdmin to remove all AcyMailing data:<br/><br/>
  463. DROP TABLE <?php
  464. $this->db->setQuery("SHOW TABLES LIKE '".$this->db->getPrefix()."acymailing%' ");
  465. if(version_compare(JVERSION,'3.0.0','>=')){
  466. echo implode(' , ',$this->db->loadColumn());
  467. }else{
  468. echo implode(' , ',$this->db->loadResultArray());
  469. }
  470. ?>;<br/><br/>
  471. If you DO NOT execute the query, you will be able to install AcyMailing again without loosing data.<br/>
  472. Please note that you don't have to uninstall AcyMailing to install a new version, simply install the new one without uninstalling your current version.
  473. <?php
  474. }
  475. function unpublishModules(){
  476. $this->db->setQuery("UPDATE `#__modules` SET `published` = 0 WHERE `module` LIKE '%acymailing%'");
  477. $this->db->query();
  478. }
  479. }