SHOW:
|
|
- or go back to the newest paste.
1 | public static function _installFiles($files = NULL) | |
2 | { | |
3 | if(!isset($files)) { | |
4 | /*$libs = array( | |
5 | dirname(__FILE__).'/lib/PixPlaceCsvManager.php' => _PS_CLASS_DIR_.'PixPlaceCsvManager.php', | |
6 | dirname(__FILE__).'/lib/PixPlaceLog.php' => _PS_CLASS_DIR_.'PixPlaceLog.php', | |
7 | dirname(__FILE__).'/lib/PixPlaceObj.php' => _PS_CLASS_DIR_.'PixPlaceObj.php', | |
8 | dirname(__FILE__).'/lib/PixPlaceOrder.php' => _PS_CLASS_DIR_.'PixPlaceOrder.php', | |
9 | dirname(__FILE__).'/lib/PixPlaceOrderDetail.php' => _PS_CLASS_DIR_.'PixPlaceOrderDetail.php', | |
10 | dirname(__FILE__).'/lib/PixPlaceProduct.php' => _PS_CLASS_DIR_.'PixPlaceProduct.php', | |
11 | dirname(__FILE__).'/lib/PixPlaceReport.php' => _PS_CLASS_DIR_.'PixPlaceReport.php', | |
12 | dirname(__FILE__).'/lib/PixPlaceReportStatus.php' => _PS_CLASS_DIR_.'PixPlaceReportStatus.php', | |
13 | dirname(__FILE__).'/lib/PixPlacePayment.php' => _PS_CLASS_DIR_.'PixPlacePayment.php', | |
14 | ); | |
15 | $files = $libs;*/ | |
16 | return true; | |
17 | } | |
18 | ||
19 | foreach($files as $from=>&$to) { | |
20 | if(file_exists($to)) | |
21 | self::_addlog("INSTALL FILES: file '{$to}' allready exists, it will be overwrited.", 'install'); | |
22 | ||
23 | $dir = dirname($to); | |
24 | if(!file_exists($dir)){ | |
25 | self::_addlog("INSTALL FILES: directory '$dir' doesn't exists, it will be created.", 'install'); | |
26 | ||
27 | if(!mkdir($dir,0755,true)){ | |
28 | self::_addlog("INSTALL FILES: Unable to create directory '$dir', unable to install file '".basename($to)."'.", 'install'); | |
29 | return false; | |
30 | } | |
31 | ||
32 | self::_addlog("INSTALL FILES: directory '$dir' created.", 'install'); | |
33 | } | |
34 | ||
35 | if(!copy($from,$to)){ | |
36 | self::_addlog("INSTALL FILES: Unable to install file from:'{$from}' to:'{$to}'", 'install'); | |
37 | self::_addlog("INSTALL FILES: Give 777 permissions to '{$dir}' prestashop folder", 'install'); | |
38 | if (version_compare(PHP_VERSION, '5.2.0', '>=')) { | |
39 | $errors = error_get_last(); | |
40 | self::_addlog("COPY ERROR: {$errors['type']} - {$errors['message']}", 'install'); | |
41 | } | |
42 | return false; | |
43 | } | |
44 | else{ | |
45 | chmod($to, 0777); | |
46 | self::_addlog("INSTALL FILES: Installed '$to'", 'install'); | |
47 | } | |
48 | } | |
49 | ||
50 | self::_addlog('INSTALL FILES: Successfully installed', 'install'); | |
51 | return true; | |
52 | } | |
53 | ||
54 | public static function _uninstallFiles($files = NULL) | |
55 | { | |
56 | if(!isset($files)) { | |
57 | /*$libs = array( | |
58 | dirname(__FILE__).'/lib/PixPlaceCsvManager.php' => _PS_CLASS_DIR_.'PixPlaceCsvManager.php', | |
59 | dirname(__FILE__).'/lib/PixPlaceLog.php' => _PS_CLASS_DIR_.'PixPlaceLog.php', | |
60 | dirname(__FILE__).'/lib/PixPlaceObj.php' => _PS_CLASS_DIR_.'PixPlaceObj.php', | |
61 | dirname(__FILE__).'/lib/PixPlaceOrder.php' => _PS_CLASS_DIR_.'PixPlaceOrder.php', | |
62 | dirname(__FILE__).'/lib/PixPlaceOrderDetail.php' => _PS_CLASS_DIR_.'PixPlaceOrderDetail.php', | |
63 | dirname(__FILE__).'/lib/PixPlaceProduct.php' => _PS_CLASS_DIR_.'PixPlaceProduct.php', | |
64 | dirname(__FILE__).'/lib/PixPlaceReport.php' => _PS_CLASS_DIR_.'PixPlaceReport.php', | |
65 | dirname(__FILE__).'/lib/PixPlaceReportStatus.php' => _PS_CLASS_DIR_.'PixPlaceReportStatus.php', | |
66 | dirname(__FILE__).'/lib/PixPlacePayment.php' => _PS_CLASS_DIR_.'PixPlacePayment.php', | |
67 | ); | |
68 | $files = $libs;*/ | |
69 | return true; | |
70 | } | |
71 | ||
72 | foreach($files as &$file) { | |
73 | if(!file_exists($file)){ | |
74 | self::_addlog("UNINSTALL FILES: file '$file' does not exist.",'uninstall'); | |
75 | } | |
76 | elseif(!unlink($file)){ | |
77 | self::_addlog("UNINSTALL FILES: unable to delete file '$file'.",'uninstall'); | |
78 | return false; | |
79 | } | |
80 | else{ | |
81 | self::_addlog("UNINSTALL FILES: '$file' deleted",'uninstall'); | |
82 | } | |
83 | } | |
84 | ||
85 | self::_addlog('UNINSTALL FILES: Successfully uninstalled','uninstall'); | |
86 | return true; | |
87 | } | |
88 | ||
89 | public static function _installEmails() | |
90 | { | |
91 | $files = array(); | |
92 | ||
93 | foreach (Language::getLanguages(false) AS $language) | |
94 | { | |
95 | if(strtolower($language['iso_code']) == 'it') { | |
96 | $files = array( | |
97 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.html', | |
98 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.txt', | |
99 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.html', | |
100 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.txt', | |
101 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.html', | |
102 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.txt', | |
103 | ); | |
104 | ||
105 | self::_installFiles($files); | |
106 | } | |
107 | else { | |
108 | $files = array( | |
109 | dirname(__FILE__).'/mails/en/pixplace_shipped.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.html', | |
110 | dirname(__FILE__).'/mails/en/pixplace_shipped.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.txt', | |
111 | dirname(__FILE__).'/mails/en/pixplace_invoice.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.html', | |
112 | dirname(__FILE__).'/mails/en/pixplace_invoice.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.txt', | |
113 | dirname(__FILE__).'/mails/en/pixplace_refunded.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.html', | |
114 | dirname(__FILE__).'/mails/en/pixplace_refunded.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.txt', | |
115 | ); | |
116 | ||
117 | self::_installFiles($files); | |
118 | } | |
119 | } | |
120 | ||
121 | return true; | |
122 | } | |
123 | ||
124 | public static function _uninstallEmails() | |
125 | { | |
126 | foreach (Language::getLanguages() AS $language) | |
127 | { | |
128 | $files = array( | |
129 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.html' => _MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.html', | |
130 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.txt' => _MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.txt', | |
131 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.html' => _MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.html', | |
132 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.txt' => _MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.txt', | |
133 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.html' => _MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.html', | |
134 | dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.txt' => _MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.txt', | |
135 | ); | |
136 | ||
137 | self::_uninstallFiles($files); | |
138 | } | |
139 | return true; | |
140 | } |