Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function _installFiles($files = NULL)
- {
- if(!isset($files)) {
- /*$libs = array(
- dirname(__FILE__).'/lib/PixPlaceCsvManager.php' => _PS_CLASS_DIR_.'PixPlaceCsvManager.php',
- dirname(__FILE__).'/lib/PixPlaceLog.php' => _PS_CLASS_DIR_.'PixPlaceLog.php',
- dirname(__FILE__).'/lib/PixPlaceObj.php' => _PS_CLASS_DIR_.'PixPlaceObj.php',
- dirname(__FILE__).'/lib/PixPlaceOrder.php' => _PS_CLASS_DIR_.'PixPlaceOrder.php',
- dirname(__FILE__).'/lib/PixPlaceOrderDetail.php' => _PS_CLASS_DIR_.'PixPlaceOrderDetail.php',
- dirname(__FILE__).'/lib/PixPlaceProduct.php' => _PS_CLASS_DIR_.'PixPlaceProduct.php',
- dirname(__FILE__).'/lib/PixPlaceReport.php' => _PS_CLASS_DIR_.'PixPlaceReport.php',
- dirname(__FILE__).'/lib/PixPlaceReportStatus.php' => _PS_CLASS_DIR_.'PixPlaceReportStatus.php',
- dirname(__FILE__).'/lib/PixPlacePayment.php' => _PS_CLASS_DIR_.'PixPlacePayment.php',
- );
- $files = $libs;*/
- return true;
- }
- foreach($files as $from=>&$to) {
- if(file_exists($to))
- self::_addlog("INSTALL FILES: file '{$to}' allready exists, it will be overwrited.", 'install');
- $dir = dirname($to);
- if(!file_exists($dir)){
- self::_addlog("INSTALL FILES: directory '$dir' doesn't exists, it will be created.", 'install');
- if(!mkdir($dir,0755,true)){
- self::_addlog("INSTALL FILES: Unable to create directory '$dir', unable to install file '".basename($to)."'.", 'install');
- return false;
- }
- self::_addlog("INSTALL FILES: directory '$dir' created.", 'install');
- }
- if(!copy($from,$to)){
- self::_addlog("INSTALL FILES: Unable to install file from:'{$from}' to:'{$to}'", 'install');
- self::_addlog("INSTALL FILES: Give 777 permissions to '{$dir}' prestashop folder", 'install');
- if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
- $errors = error_get_last();
- self::_addlog("COPY ERROR: {$errors['type']} - {$errors['message']}", 'install');
- }
- return false;
- }
- else{
- chmod($to, 0777);
- self::_addlog("INSTALL FILES: Installed '$to'", 'install');
- }
- }
- self::_addlog('INSTALL FILES: Successfully installed', 'install');
- return true;
- }
- public static function _uninstallFiles($files = NULL)
- {
- if(!isset($files)) {
- /*$libs = array(
- dirname(__FILE__).'/lib/PixPlaceCsvManager.php' => _PS_CLASS_DIR_.'PixPlaceCsvManager.php',
- dirname(__FILE__).'/lib/PixPlaceLog.php' => _PS_CLASS_DIR_.'PixPlaceLog.php',
- dirname(__FILE__).'/lib/PixPlaceObj.php' => _PS_CLASS_DIR_.'PixPlaceObj.php',
- dirname(__FILE__).'/lib/PixPlaceOrder.php' => _PS_CLASS_DIR_.'PixPlaceOrder.php',
- dirname(__FILE__).'/lib/PixPlaceOrderDetail.php' => _PS_CLASS_DIR_.'PixPlaceOrderDetail.php',
- dirname(__FILE__).'/lib/PixPlaceProduct.php' => _PS_CLASS_DIR_.'PixPlaceProduct.php',
- dirname(__FILE__).'/lib/PixPlaceReport.php' => _PS_CLASS_DIR_.'PixPlaceReport.php',
- dirname(__FILE__).'/lib/PixPlaceReportStatus.php' => _PS_CLASS_DIR_.'PixPlaceReportStatus.php',
- dirname(__FILE__).'/lib/PixPlacePayment.php' => _PS_CLASS_DIR_.'PixPlacePayment.php',
- );
- $files = $libs;*/
- return true;
- }
- foreach($files as &$file) {
- if(!file_exists($file)){
- self::_addlog("UNINSTALL FILES: file '$file' does not exist.",'uninstall');
- }
- elseif(!unlink($file)){
- self::_addlog("UNINSTALL FILES: unable to delete file '$file'.",'uninstall');
- return false;
- }
- else{
- self::_addlog("UNINSTALL FILES: '$file' deleted",'uninstall');
- }
- }
- self::_addlog('UNINSTALL FILES: Successfully uninstalled','uninstall');
- return true;
- }
- public static function _installEmails()
- {
- $files = array();
- foreach (Language::getLanguages(false) AS $language)
- {
- if(strtolower($language['iso_code']) == 'it') {
- $files = array(
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.html',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.txt',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.html',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.txt',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.html',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.txt',
- );
- self::_installFiles($files);
- }
- else {
- $files = array(
- dirname(__FILE__).'/mails/en/pixplace_shipped.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.html',
- dirname(__FILE__).'/mails/en/pixplace_shipped.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.txt',
- dirname(__FILE__).'/mails/en/pixplace_invoice.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.html',
- dirname(__FILE__).'/mails/en/pixplace_invoice.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.txt',
- dirname(__FILE__).'/mails/en/pixplace_refunded.html' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.html',
- dirname(__FILE__).'/mails/en/pixplace_refunded.txt' => _PS_MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.txt',
- );
- self::_installFiles($files);
- }
- }
- return true;
- }
- public static function _uninstallEmails()
- {
- foreach (Language::getLanguages() AS $language)
- {
- $files = array(
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.html' => _MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.html',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_shipped.txt' => _MAIL_DIR_.$language['iso_code'].'/pixplace_shipped.txt',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.html' => _MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.html',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_invoice.txt' => _MAIL_DIR_.$language['iso_code'].'/pixplace_invoice.txt',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.html' => _MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.html',
- dirname(__FILE__).'/mails/'.$language['iso_code'].'/pixplace_refunded.txt' => _MAIL_DIR_.$language['iso_code'].'/pixplace_refunded.txt',
- );
- self::_uninstallFiles($files);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement