From 30a5516171816d525ac2cfa8f3a7a0e40b7b1c53 Mon Sep 17 00:00:00 2001 From: samapraku Date: Mon, 20 Jul 2020 12:33:03 +0200 Subject: [PATCH 1/4] Upgrade to twig 2.9 --- src/bb-di.php | 20 +- src/bb-library/Box/AppAdmin.php | 4 +- src/bb-library/Box/AppClient.php | 11 +- src/bb-library/Box/TwigExtensions.php | 81 +- src/bb-library/Box/TwigLoader.php | 6 +- .../html_email/mod_client_confirm.phtml | 4 +- .../mod_client_password_reset_approve.phtml | 4 +- .../mod_client_password_reset_request.phtml | 4 +- .../Client/html_email/mod_client_signup.phtml | 4 +- .../html_admin/mod_currency_manage.phtml | 2 +- .../html_admin/mod_currency_settings.phtml | 2 +- src/bb-modules/Email/Api/Admin.php | 4 +- src/bb-modules/Email/Service.php | 41 +- .../Email/html_admin/mod_email_template.phtml | 4 +- .../Email/html_client/mod_email_email.phtml | 2 +- .../Email/html_client/mod_email_index.phtml | 2 +- .../Email/html_email/mod_email_test.phtml | 4 +- .../Embed/html_admin/mod_embed_index.phtml | 2 +- .../html_email/mod_example_email.phtml | 4 +- .../Forum/html_email/mod_forum_new_post.phtml | 4 +- src/bb-modules/Invoice/Service.php | 2 +- src/bb-modules/Invoice/ServiceInvoiceItem.php | 5 + src/bb-modules/Invoice/ServiceTransaction.php | 2 + .../html_email/mod_invoice_created.phtml | 4 +- .../html_email/mod_invoice_due_after.phtml | 4 +- .../Invoice/html_email/mod_invoice_paid.phtml | 4 +- .../mod_invoice_payment_reminder.phtml | 4 +- src/bb-modules/Massmailer/Api/Admin.php | 4 +- src/bb-modules/Massmailer/Service.php | 17 +- .../html_admin/mod_massmailer_message.phtml | 2 +- .../News/html_admin/mod_news_post.phtml | 1 + .../Order/html_client/mod_order_index.phtml | 2 +- .../Order/html_client/mod_order_manage.phtml | 2 +- .../Order/html_client/mod_order_product.phtml | 2 +- .../html_client/mod_orderbutton_addons.phtml | 6 +- ...od_serviceboxbillinglicense_settings.phtml | 2 +- .../mod_servicecentovacast_activated.phtml | 4 +- .../mod_servicecentovacast_canceled.phtml | 4 +- .../mod_servicecentovacast_renewed.phtml | 4 +- .../mod_servicecentovacast_suspended.phtml | 4 +- .../mod_servicecentovacast_unsuspended.phtml | 4 +- .../mod_servicecustom_activated.phtml | 4 +- .../mod_servicecustom_canceled.phtml | 4 +- .../mod_servicecustom_renewed.phtml | 4 +- .../mod_servicecustom_suspended.phtml | 4 +- .../mod_servicecustom_unsuspended.phtml | 4 +- .../mod_servicedomain_activated.phtml | 4 +- .../mod_servicedomain_renewed.phtml | 4 +- .../mod_servicedomain_suspended.phtml | 4 +- .../mod_servicedomain_unsuspended.phtml | 4 +- .../mod_servicedownloadable_activated.phtml | 4 +- .../mod_servicehosting_manage.phtml | 3 + .../mod_servicehosting_activated.phtml | 4 +- .../mod_servicehosting_canceled.phtml | 4 +- .../mod_servicehosting_renewed.phtml | 4 +- .../mod_servicehosting_suspended.phtml | 4 +- .../mod_servicehosting_unsuspended.phtml | 4 +- .../mod_servicelicense_activated.phtml | 4 +- .../mod_servicelicense_canceled.phtml | 4 +- .../mod_servicelicense_renewed.phtml | 4 +- .../mod_servicelicense_suspended.phtml | 4 +- .../mod_servicelicense_unsuspended.phtml | 4 +- .../mod_servicemembership_activated.phtml | 4 +- .../mod_servicemembership_canceled.phtml | 4 +- .../mod_servicemembership_renewed.phtml | 4 +- .../mod_servicemembership_suspended.phtml | 4 +- .../mod_servicemembership_unsuspended.phtml | 4 +- .../mod_servicesolusvm_import_clients.phtml | 2 +- .../mod_servicesolusvm_import_servers.phtml | 2 +- .../mod_servicesolusvm_settings.phtml | 2 +- .../mod_servicesolusvm_activated.phtml | 4 +- .../mod_servicesolusvm_canceled.phtml | 4 +- .../mod_servicesolusvm_renewed.phtml | 4 +- .../mod_servicesolusvm_suspended.phtml | 4 +- .../mod_servicesolusvm_unsuspended.phtml | 4 +- .../mod_serviceyouhosting_activated.phtml | 4 +- .../mod_serviceyouhosting_canceled.phtml | 4 +- .../mod_serviceyouhosting_renewed.phtml | 4 +- .../mod_serviceyouhosting_suspended.phtml | 4 +- .../mod_serviceyouhosting_unsuspended.phtml | 4 +- .../Staff/html_admin/mod_staff_settings.phtml | 1 + .../html_email/mod_staff_client_order.phtml | 4 +- .../html_email/mod_staff_client_signup.phtml | 4 +- .../html_email/mod_staff_pticket_close.phtml | 4 +- .../html_email/mod_staff_pticket_open.phtml | 4 +- .../html_email/mod_staff_pticket_reply.phtml | 4 +- .../html_email/mod_staff_ticket_close.phtml | 4 +- .../html_email/mod_staff_ticket_open.phtml | 4 +- .../html_email/mod_staff_ticket_reply.phtml | 4 +- .../mod_support_helpdesk_ticket_open.phtml | 4 +- .../html_email/mod_support_pticket_open.phtml | 4 +- .../mod_support_pticket_staff_close.phtml | 4 +- .../mod_support_pticket_staff_open.phtml | 4 +- .../mod_support_pticket_staff_reply.phtml | 4 +- .../html_email/mod_support_ticket_open.phtml | 4 +- .../mod_support_ticket_staff_close.phtml | 4 +- .../mod_support_ticket_staff_open.phtml | 4 +- .../mod_support_ticket_staff_reply.phtml | 4 +- src/bb-modules/System/Service.php | 17 +- .../admin_default/html/mod_client_index.phtml | 1 + .../html/mod_client_manage.phtml | 1 + .../html/mod_index_dashboard.phtml | 1 + .../html/mod_invoice_invoice.phtml | 2 +- .../html/mod_invoice_subscription.phtml | 1 + .../admin_default/html/mod_invoice_tax.phtml | 1 + .../html/mod_invoice_taxupdate.phtml | 1 + .../html/mod_invoice_transaction.phtml | 1 + .../html/mod_product_category.phtml | 1 + .../html/mod_product_index.phtml | 1 + .../html/mod_product_manage.phtml | 1 + .../html/mod_product_promos.phtml | 1 + .../html/mod_servicedomain_index.phtml | 1 + .../html/mod_servicehosting_config.phtml | 1 + .../html/mod_servicehosting_index.phtml | 1 + .../html/mod_servicehosting_manage.phtml | 1 + .../html/mod_servicelicense_config.phtml | 1 + .../admin_default/html/mod_staff_manage.phtml | 1 + .../boxbilling/html/mod_email_email.phtml | 2 +- .../boxbilling/html/mod_order_index.phtml | 2 +- .../boxbilling/html/mod_order_manage.phtml | 2 +- .../boxbilling/html/partial_addons.phtml | 8 +- src/composer.json | 14 +- src/composer.lock | 1420 +++++++++++++---- src/install/index.php | 10 +- 124 files changed, 1391 insertions(+), 613 deletions(-) diff --git a/src/bb-di.php b/src/bb-di.php index 7f921430b..690b7f3d0 100644 --- a/src/bb-di.php +++ b/src/bb-di.php @@ -139,18 +139,20 @@ $di['twig'] = function () use ($di) { $config = $di['config']; $options = $config['twig']; - $loader = new Twig_Loader_String(); - $twig = new Twig_Environment($loader, $options); + $loader = new Twig\Loader\ArrayLoader(); + $twig = new Twig\Environment($loader, $options); $box_extensions = new Box_TwigExtensions(); $box_extensions->setDi($di); - $twig->addExtension(new Twig_Extension_Optimizer()); - $twig->addExtension(new Twig_Extensions_Extension_I18n()); - $twig->addExtension(new Twig_Extensions_Extension_Debug()); + //$twig->addExtension(new Twig\Extension\OptimizerExtension()); + $twig->addExtension(new \Twig\Extension\StringLoaderExtension()); + $twig->addExtension(new Twig\Extension\DebugExtension()); + $twig->addExtension(new Twig\Extensions\I18nExtension()); $twig->addExtension($box_extensions); - $twig->getExtension('core')->setDateFormat($config['locale_date_format']); - $twig->getExtension('core')->setTimezone($config['timezone']); + $twig->getExtension(Twig\Extension\CoreExtension::class)->setDateFormat($config['locale_date_format']); + $twig->getExtension(Twig\Extension\CoreExtension::class)->setTimezone($config['timezone']); + // add globals if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { @@ -165,6 +167,8 @@ $di['twig'] = function () use ($di) { $di['is_client_logged'] = function() use($di) { if(!$di['auth']->isClientLoggedIn()) { + $url = $di['url']->link('login'); + header("Location: $url"); throw new Exception('Client is not logged in'); } return true; @@ -338,6 +342,6 @@ $di['translate'] = $di->protect(function($textDomain = '') use ($di) { return $tr; }); $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use ($di) { - return isset ($array[$key]) ? $array[$key] : $default; + return array_key_exists($key, $array) ? $array[$key] : $default; }); return $di; diff --git a/src/bb-library/Box/AppAdmin.php b/src/bb-library/Box/AppAdmin.php index 38994ef90..92bb8f6fa 100644 --- a/src/bb-library/Box/AppAdmin.php +++ b/src/bb-library/Box/AppAdmin.php @@ -22,7 +22,7 @@ class Box_AppAdmin extends Box_App public function render($fileName, $variableArray = array()) { - $template = $this->getTwig()->loadTemplate($fileName.'.phtml'); + $template = $this->getTwig()->load($fileName.'.phtml'); return $template->render($variableArray); } @@ -56,4 +56,4 @@ class Box_AppAdmin extends Box_App return $twig; } -} +} \ No newline at end of file diff --git a/src/bb-library/Box/AppClient.php b/src/bb-library/Box/AppClient.php index 1af78965c..44b3e9eb7 100644 --- a/src/bb-library/Box/AppClient.php +++ b/src/bb-library/Box/AppClient.php @@ -57,7 +57,12 @@ class Box_AppClient extends Box_App } catch(Exception $e) { if(BB_DEBUG) error_log($e); } - throw new \Box_Exception('Page :url not found', array(':url'=>$page), 404); + // throw new \Box_Exception('Page :url not found', array(':url'=>$page), 404); + $e = new \Box_Exception('Page :url not found', array(':url'=>$this->url), 404); + + error_log($e->getMessage()); + header("HTTP/1.0 404 Not Found"); + return $this->render('404', array('exception'=>$e)); } /** @@ -66,8 +71,8 @@ class Box_AppClient extends Box_App public function render($fileName, $variableArray = array(), $ext = 'phtml') { try { - $template = $this->getTwig()->loadTemplate($fileName.'.'.$ext); - } catch (\Twig_Error_Loader $e) { + $template = $this->getTwig()->load($fileName.'.'.$ext); + } catch (Twig\Error\LoaderError $e) { error_log($e->getMessage()); throw new \Box_Exception('Page not found', null, 404); } diff --git a/src/bb-library/Box/TwigExtensions.php b/src/bb-library/Box/TwigExtensions.php index 806bdef40..c7c32230c 100644 --- a/src/bb-library/Box/TwigExtensions.php +++ b/src/bb-library/Box/TwigExtensions.php @@ -11,7 +11,7 @@ */ -class Box_TwigExtensions extends Twig_Extension implements \Box\InjectionAwareInterface +class Box_TwigExtensions extends Twig\Extension\AbstractExtension implements \Box\InjectionAwareInterface { protected $di; @@ -39,34 +39,34 @@ class Box_TwigExtensions extends Twig_Extension implements \Box\InjectionAwareIn public function getFilters() { return array( - 'alink' => new Twig_Filter_Function(array($this, 'twig_bb_admin_link_filter'), array('is_safe' => array('html'))), - 'link' => new Twig_Filter_Function(array($this, 'twig_bb_client_link_filter'), array('is_safe' => array('html'))), - 'gravatar' => new Twig_Filter_Function('twig_gravatar_filter'), - 'markdown' => new Twig_Filter_Function('twig_markdown_filter', array('needs_environment' => true, 'is_safe' => array('html'))), - 'truncate' => new Twig_Filter_Function('twig_truncate_filter', array('needs_environment' => true)), - 'timeago' => new Twig_Filter_Function('twig_timeago_filter'), - 'daysleft' => new Twig_Filter_Function('twig_daysleft_filter'), - 'size' => new Twig_Filter_Function('twig_size_filter'), - 'ipcountryname' => new Twig_Filter_Function(array($this, 'twig_ipcountryname_filter')), - 'number' => new Twig_Filter_Function('twig_number_filter'), - 'period_title' => new Twig_Filter_Function('twig_period_title', array('needs_environment' => true, 'is_safe' => array('html'))), - 'autolink' => new Twig_Filter_Function('twig_autolink_filter'), - 'bbmd' => new Twig_Filter_Function('twig_bbmd_filter', array('needs_environment' => true, 'is_safe' => array('html'))), + 'alink' => new Twig\TwigFilter('alink', array($this, 'twig_bb_admin_link_filter'), array('is_safe' => array('html'))), + 'link' => new Twig\TwigFilter('link', array($this, 'twig_bb_client_link_filter'), array('is_safe' => array('html'))), + 'gravatar' => new Twig\TwigFilter('gravatar','twig_gravatar_filter'), + 'markdown' => new Twig\TwigFilter('markdown','twig_markdown_filter', array('needs_environment' => true, 'is_safe' => array('html'))), + 'truncate' => new Twig\TwigFilter('truncate','twig_truncate_filter', array('needs_environment' => true)), + 'timeago' => new Twig\TwigFilter('timeago','twig_timeago_filter'), + 'daysleft' => new Twig\TwigFilter('daysleft','twig_daysleft_filter'), + 'size' => new Twig\TwigFilter('size', 'twig_size_filter'), + 'ipcountryname' => new Twig\TwigFilter('ipcountryname', array($this, 'twig_ipcountryname_filter')), + 'number' => new Twig\TwigFilter('number', 'twig_number_filter'), + 'period_title' => new Twig\TwigFilter('period_title', 'twig_period_title', array('needs_environment' => true, 'is_safe' => array('html'))), + 'autolink' => new Twig\TwigFilter('autolink', 'twig_autolink_filter'), + 'bbmd' => new Twig\TwigFilter('bbmd', 'twig_bbmd_filter', array('needs_environment' => true, 'is_safe' => array('html'))), - 'bb_date' => new Twig_Filter_Function(array($this, 'twig_bb_date')), - 'bb_datetime' => new Twig_Filter_Function(array($this, 'twig_bb_datetime')), + 'bb_date' => new Twig\TwigFilter('bb_date', array($this, 'twig_bb_date')), + 'bb_datetime' => new Twig\TwigFilter('bb_datetime', array($this, 'twig_bb_datetime')), - 'img_tag' => new Twig_Filter_Function('twig_img_tag', array('needs_environment' => false, 'is_safe' => array('html'))), - 'script_tag' => new Twig_Filter_Function('twig_script_tag', array('needs_environment' => false, 'is_safe' => array('html'))), - 'stylesheet_tag' => new Twig_Filter_Function('twig_stylesheet_tag', array('needs_environment' => false, 'is_safe' => array('html'))), + 'img_tag' => new Twig\TwigFilter('img_tag', 'twig_img_tag', array('needs_environment' => false, 'is_safe' => array('html'))), + 'script_tag' => new Twig\TwigFilter('script_tag', 'twig_script_tag', array('needs_environment' => false, 'is_safe' => array('html'))), + 'stylesheet_tag' => new Twig\TwigFilter('stylesheet_tag', 'twig_stylesheet_tag', array('needs_environment' => false, 'is_safe' => array('html'))), - 'mod_asset_url' => new Twig_Filter_Function('twig_mod_asset_url'), - 'asset_url' => new Twig_Filter_Function('twig_asset_url', array('needs_environment' => true, 'is_safe' => array('html'))), + 'mod_asset_url' => new Twig\TwigFilter('mod_asset_url', 'twig_mod_asset_url'), + 'asset_url' => new Twig\TwigFilter('asset_url', 'twig_asset_url', array('needs_environment' => true, 'is_safe' => array('html'))), - 'money' => new Twig_Filter_Function('twig_money', array('needs_environment' => true, 'is_safe' => array('html'))), - 'money_without_currency' => new Twig_Filter_Function('twig_money_without_currency', array('needs_environment' => true, 'is_safe' => array('html'))), - 'money_convert' => new Twig_Filter_Function('twig_money_convert', array('needs_environment' => true, 'is_safe' => array('html'))), - 'money_convert_without_currency' => new Twig_Filter_Function('money_convert_without_currency', array('needs_environment' => true, 'is_safe' => array('html'))), + 'money' => new Twig\TwigFilter('money', 'twig_money', array('needs_environment' => true, 'is_safe' => array('html'))), + 'money_without_currency' => new Twig\TwigFilter('money_without_currency','twig_money_without_currency', array('needs_environment' => true, 'is_safe' => array('html'))), + 'money_convert' => new Twig\TwigFilter('money_convert', 'twig_money_convert', array('needs_environment' => true, 'is_safe' => array('html'))), + 'money_convert_without_currency' => new Twig\TwigFilter('money_convert_without_currency', array('needs_environment' => true, 'is_safe' => array('html'))), ); } @@ -107,6 +107,9 @@ class Box_TwigExtensions extends Twig_Extension implements \Box\InjectionAwareIn function twig_bb_client_link_filter($link, $params = null) { + if($this->di['url'] === null) { + return null; + } return $this->di['url']->link($link, $params); } @@ -117,14 +120,14 @@ class Box_TwigExtensions extends Twig_Extension implements \Box\InjectionAwareIn } -function twig_period_title(Twig_Environment $env, $period) +function twig_period_title(Twig\Environment $env, $period) { $globals = $env->getGlobals(); $api_guest = $globals['guest']; return $api_guest->system_period_title(array('code'=>$period)); } -function twig_money_convert(Twig_Environment $env, $price, $currency = null) +function twig_money_convert(Twig\Environment $env, $price, $currency = null) { $globals = $env->getGlobals(); $api_guest = $globals['guest']; @@ -135,7 +138,7 @@ function twig_money_convert(Twig_Environment $env, $price, $currency = null) return $api_guest->currency_format(array("price" => $price, 'code'=>$currency, 'convert'=>true)); } -function money_convert_without_currency(Twig_Environment $env, $price, $currency = null, $without_currency = false) +function money_convert_without_currency(Twig\Environment $env, $price, $currency = null, $without_currency = false) { $globals = $env->getGlobals(); $api_guest = $globals['guest']; @@ -146,14 +149,14 @@ function money_convert_without_currency(Twig_Environment $env, $price, $currency return $api_guest->currency_format(array("price" => $price, 'code'=>$currency, 'convert'=>true, 'without_currency'=>true)); } -function twig_money(Twig_Environment $env, $price, $currency = null) +function twig_money(Twig\Environment $env, $price, $currency = null) { $globals = $env->getGlobals(); $api_guest = $globals['guest']; return $api_guest->currency_format(array("price" => $price, 'code'=>$currency, 'convert'=>false)); } -function twig_money_without_currency(Twig_Environment $env, $price, $currency = null) +function twig_money_without_currency(Twig\Environment $env, $price, $currency = null) { $globals = $env->getGlobals(); $api_guest = $globals['guest']; @@ -165,7 +168,7 @@ function twig_mod_asset_url($asset, $mod) return BB_URL . 'bb-modules/'.ucfirst($mod).'/assets/'.$asset; } -function twig_asset_url(Twig_Environment $env, $asset) +function twig_asset_url(Twig\Environment $env, $asset) { $globals = $env->getGlobals(); return BB_URL . 'bb-themes/'.$globals['current_theme'].'/assets/'.$asset; @@ -201,14 +204,18 @@ function twig_gravatar_filter($email, $size = null) function twig_autolink_filter($text) { $pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#'; - $callback = create_function('$matches', ' + + $callback = function($matches) + { $url = array_shift($matches); $url_parts = parse_url($url); if(!isset($url_parts["scheme"])) { - $url = "http://".$url; + $url = 'http://' . $url; } - return sprintf(\'%s\', $url, $url); - '); + + return sprintf('%s', $url, $url); + }; + return preg_replace_callback($pattern, $callback, $text); } @@ -251,7 +258,9 @@ function twig_size_filter($value) function twig_markdown_filter(Twig_Environment $env, $value) { $markdownParser = new \Michelf\MarkdownExtra; - return $markdownParser->transform(htmlspecialchars($value, ENT_NOQUOTES)); + // Michelf Markdown version 1.7.0 and up + $markdownParser->hard_wrap = true; + return $markdownParser->transform($value); //htmlspecialchars($value, ENT_NOQUOTES) } function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') diff --git a/src/bb-library/Box/TwigLoader.php b/src/bb-library/Box/TwigLoader.php index 932958df2..4a0a5bb8d 100644 --- a/src/bb-library/Box/TwigLoader.php +++ b/src/bb-library/Box/TwigLoader.php @@ -11,7 +11,7 @@ */ -class Box_TwigLoader extends Twig_Loader_Filesystem +class Box_TwigLoader extends Twig\Loader\FilesystemLoader { protected $options = array(); @@ -40,7 +40,7 @@ class Box_TwigLoader extends Twig_Loader_Filesystem } - protected function findTemplate($name) + protected function findTemplate($name, $throw = true) { // normalize name $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); @@ -63,6 +63,6 @@ class Box_TwigLoader extends Twig_Loader_Filesystem } } - throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $paths))); + throw new \Twig\Error\LoaderError(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $paths))); } } \ No newline at end of file diff --git a/src/bb-modules/Client/html_email/mod_client_confirm.phtml b/src/bb-modules/Client/html_email/mod_client_confirm.phtml index b159f98c8..4b3aacd44 100644 --- a/src/bb-modules/Client/html_email/mod_client_confirm.phtml +++ b/src/bb-modules/Client/html_email/mod_client_confirm.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] Please confirm your email address {% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, Please verify your email by clicking on the link below: @@ -12,5 +12,5 @@ Edit your profile at {{'client/me'|link}} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} \ No newline at end of file diff --git a/src/bb-modules/Client/html_email/mod_client_password_reset_approve.phtml b/src/bb-modules/Client/html_email/mod_client_password_reset_approve.phtml index 8c6f7ed2a..666c42a16 100644 --- a/src/bb-modules/Client/html_email/mod_client_password_reset_approve.phtml +++ b/src/bb-modules/Client/html_email/mod_client_password_reset_approve.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] Password Changed{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -18,5 +18,5 @@ Edit your profile at {{ 'client/me'|link }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Client/html_email/mod_client_password_reset_request.phtml b/src/bb-modules/Client/html_email/mod_client_password_reset_request.phtml index 366ef4d73..df2688b9a 100644 --- a/src/bb-modules/Client/html_email/mod_client_password_reset_request.phtml +++ b/src/bb-modules/Client/html_email/mod_client_password_reset_request.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] Confirm Password Reset{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -19,5 +19,5 @@ Edit your profile at {{'client/me'|link}} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Client/html_email/mod_client_signup.phtml b/src/bb-modules/Client/html_email/mod_client_signup.phtml index 704aa5c8e..dc88928b1 100644 --- a/src/bb-modules/Client/html_email/mod_client_signup.phtml +++ b/src/bb-modules/Client/html_email/mod_client_signup.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] Welcome {{ c.first_name }}{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, Thank you for signing up with us. Your new account has been setup and you can now login to our client area using the details below. @@ -22,5 +22,5 @@ Edit your profile at {{'client/me'|link}} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} \ No newline at end of file diff --git a/src/bb-modules/Currency/html_admin/mod_currency_manage.phtml b/src/bb-modules/Currency/html_admin/mod_currency_manage.phtml index e8a0f8400..fc39c50e1 100644 --- a/src/bb-modules/Currency/html_admin/mod_currency_manage.phtml +++ b/src/bb-modules/Currency/html_admin/mod_currency_manage.phtml @@ -39,7 +39,7 @@
- +
diff --git a/src/bb-modules/Currency/html_admin/mod_currency_settings.phtml b/src/bb-modules/Currency/html_admin/mod_currency_settings.phtml index 1d9465fbc..cfe0ac04a 100644 --- a/src/bb-modules/Currency/html_admin/mod_currency_settings.phtml +++ b/src/bb-modules/Currency/html_admin/mod_currency_settings.phtml @@ -106,7 +106,7 @@
- +
diff --git a/src/bb-modules/Email/Api/Admin.php b/src/bb-modules/Email/Api/Admin.php index 7fc268ea3..b27ec455d 100644 --- a/src/bb-modules/Email/Api/Admin.php +++ b/src/bb-modules/Email/Api/Admin.php @@ -315,8 +315,8 @@ class Admin extends \Api_Abstract $t = $this->template_get($data); $vars = $t['vars']; $vars['_tpl'] = $this->di['array_get']($data, '_tpl', $t['content']); - - return $this->di['twig']->render($vars['_tpl'], $vars); + $systemService = $this->di['mod_service']('System'); + return $systemService->renderString($vars['_tpl'], true, $vars); } /** diff --git a/src/bb-modules/Email/Service.php b/src/bb-modules/Email/Service.php index 082447f7a..d65067a04 100644 --- a/src/bb-modules/Email/Service.php +++ b/src/bb-modules/Email/Service.php @@ -38,11 +38,12 @@ class Service implements \Box\InjectionAwareInterface if($search) { $search = "%$search%"; - $where[] = '(m.sender LIKE :sender OR m.recipients LIKE :recipient OR m.subject LIKE :subject OR m.content_text LIKE :context_text)'; + $where[] = '(sender LIKE :sender OR recipients LIKE :recipient OR subject LIKE :subject OR content_text LIKE :content_text OR content_html LIKE :content_html)'; $bindings[':sender'] = $search; $bindings[':recipient'] = $search; $bindings[':subject'] = $search; $bindings[':content_text'] = $search; + $bindings[':content_html'] = $search; } if(NULL !== $client_id) { @@ -272,7 +273,7 @@ class Service implements \Box\InjectionAwareInterface private function _getVarsString() { - $str = '{% filter markdown %}' . PHP_EOL . PHP_EOL; + $str = '{% apply markdown %}' . PHP_EOL . PHP_EOL; $str .= 'This email template was automatically generated by BoxBilling extension. ' . PHP_EOL; $str .= 'Template is ready to be modified. ' . PHP_EOL; $str .= 'Email template is just like BoxBilling theme file. ' . PHP_EOL; @@ -280,14 +281,15 @@ class Service implements \Box\InjectionAwareInterface $str .= 'Example API usage in email template:' . PHP_EOL . PHP_EOL; $str .= '{{ guest.system_version }}' . PHP_EOL . PHP_EOL; $str .= "{{ now|date('Y-m-d') }}" . PHP_EOL . PHP_EOL; - $str .= '{% endfilter %}'; + $str .= '{% endapply %}'; return $str; } private function _parse(\Model_EmailTemplate $t, $vars) { - $pc = $this->di['twig']->render($t->content, $vars); - $ps = $this->di['twig']->render($t->subject, $vars); + $systemService = $this->di['mod_service']('System'); + $pc = $systemService->renderString($t->content, false, $vars); + $ps = $systemService->renderString($t->subject, false, $vars); return array($ps, $pc); } @@ -302,8 +304,6 @@ class Service implements \Box\InjectionAwareInterface $mail->setSubject($email->subject); $mail->addTo($email->recipients); - $this->_logEmailToDb($email); //Logging to DB - $settings = $this->di['mod_config']('email'); $transport = $this->di['array_get']($settings, 'mailer', 'sendmail'); @@ -323,30 +323,8 @@ class Service implements \Box\InjectionAwareInterface return true; } - private function _logEmailToDb(\Model_ActivityClientEmail $email) - { - $query = "INSERT INTO activity_client_email - SET client_id = :client_id, - sender = :sender, - recipients = :recipients, - subject = :subject, - content_html = :content_html, - content_text = :content_text - "; - $bindings = array( - ':client_id' => $email->client_id, - ':sender' => $email->sender, - ':recipients' => $email->recipients, - ':subject' => $email->subject, - ':content_html' => $email->content_html, - ':content_text' => $email->content_text - ); - $di = $this->getDi(); - $db = $di['db']; - $db->exec($query, $bindings); - } public function templateGetSearchQuery($data) { @@ -411,13 +389,14 @@ class Service implements \Box\InjectionAwareInterface $model->category = $category; } + $systemService = $this->di['mod_service']('System'); $vars = $this->getVars($model); if (isset($subject)) { // check subject syntax before saving // should throw exception if render fails $vars['_tpl'] = $subject; - $this->di['twig']->render($subject, $vars); + $systemService->renderString($subject, false, $vars); $model->subject = $subject; } @@ -425,7 +404,7 @@ class Service implements \Box\InjectionAwareInterface // check content syntax before saving // should throw exception if render fails $vars['_tpl'] = $content; - $this->di['twig']->render($content, $vars); + $systemService->renderString($content, false, $vars); $model->content = $content; } diff --git a/src/bb-modules/Email/html_admin/mod_email_template.phtml b/src/bb-modules/Email/html_admin/mod_email_template.phtml index 9614be2ed..2d2af8271 100644 --- a/src/bb-modules/Email/html_admin/mod_email_template.phtml +++ b/src/bb-modules/Email/html_admin/mod_email_template.phtml @@ -162,7 +162,7 @@
- +{% endapply %}{% endautoescape %}
diff --git a/src/bb-modules/Email/html_client/mod_email_email.phtml b/src/bb-modules/Email/html_client/mod_email_email.phtml index 904147d5b..7264a7e14 100644 --- a/src/bb-modules/Email/html_client/mod_email_email.phtml +++ b/src/bb-modules/Email/html_client/mod_email_email.phtml @@ -41,7 +41,7 @@ {% endblock %} {% block js %} -{% autoescape true js %} +{% autoescape "js" %} +{% endblock %} {% endif %} \ No newline at end of file diff --git a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_activated.phtml b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_activated.phtml index 20a36c2af..7676fbb09 100644 --- a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_activated.phtml +++ b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_activated.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Activated{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -71,5 +71,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_canceled.phtml b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_canceled.phtml index 7c62f69c3..f343438c1 100644 --- a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_canceled.phtml +++ b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_canceled.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Canceled{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -16,5 +16,5 @@ Submit support ticket: {{ 'support'|link({'ticket' : 1}) }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_renewed.phtml b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_renewed.phtml index ae9636860..8df02a25a 100644 --- a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_renewed.phtml +++ b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_renewed.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Renewed{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -17,5 +17,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_suspended.phtml b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_suspended.phtml index c8247f5e5..a45181b3d 100644 --- a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_suspended.phtml +++ b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_suspended.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Suspended{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -16,5 +16,5 @@ Submit support ticket: {{ 'support'|link({'ticket' : 1}) }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_unsuspended.phtml b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_unsuspended.phtml index 6e19799fe..6600331c2 100644 --- a/src/bb-modules/Servicehosting/html_email/mod_servicehosting_unsuspended.phtml +++ b/src/bb-modules/Servicehosting/html_email/mod_servicehosting_unsuspended.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Reactivated{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -11,5 +11,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_activated.phtml b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_activated.phtml index 30e5672f2..28ec36e0a 100644 --- a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_activated.phtml +++ b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_activated.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Activated{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -13,5 +13,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_canceled.phtml b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_canceled.phtml index bfd781ccb..3e463f971 100644 --- a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_canceled.phtml +++ b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_canceled.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Canceled{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -16,5 +16,5 @@ Submit support ticket: {{ 'support'|link({'ticket' : 1}) }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_renewed.phtml b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_renewed.phtml index ae9636860..8df02a25a 100644 --- a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_renewed.phtml +++ b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_renewed.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Renewed{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -17,5 +17,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_suspended.phtml b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_suspended.phtml index 70cd4917f..4de54ba58 100644 --- a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_suspended.phtml +++ b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_suspended.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Suspended{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -16,5 +16,5 @@ Submit support ticket: {{ 'support'|link({'ticket' : 1}) }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_unsuspended.phtml b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_unsuspended.phtml index 68f6c047d..e97f22fee 100644 --- a/src/bb-modules/Servicelicense/html_email/mod_servicelicense_unsuspended.phtml +++ b/src/bb-modules/Servicelicense/html_email/mod_servicelicense_unsuspended.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Reactivated{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -11,5 +11,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_activated.phtml b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_activated.phtml index 4ea460bbf..1bf60ec0b 100644 --- a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_activated.phtml +++ b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_activated.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Activated{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -11,5 +11,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_canceled.phtml b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_canceled.phtml index 4b4959bc4..5b4b889a2 100644 --- a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_canceled.phtml +++ b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_canceled.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Canceled{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -16,5 +16,5 @@ Submit support ticket: {{ 'support'|link({'ticket' : 1}) }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_renewed.phtml b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_renewed.phtml index ae9636860..8df02a25a 100644 --- a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_renewed.phtml +++ b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_renewed.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Renewed{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -17,5 +17,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_suspended.phtml b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_suspended.phtml index 1fabd72a5..66bc014ca 100644 --- a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_suspended.phtml +++ b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_suspended.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Suspended{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -16,5 +16,5 @@ Submit support ticket: {{ 'support'|link({'ticket' : 1}) }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_unsuspended.phtml b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_unsuspended.phtml index 68f6c047d..e97f22fee 100644 --- a/src/bb-modules/Servicemembership/html_email/mod_servicemembership_unsuspended.phtml +++ b/src/bb-modules/Servicemembership/html_email/mod_servicemembership_unsuspended.phtml @@ -1,6 +1,6 @@ {% block subject %}[{{ guest.system_company.name }}] {{ order.title }} Reactivated{% endblock %} {% block content %} -{% filter markdown %} +{% apply markdown %} Hello {{ c.first_name }} {{ c.last_name }}, @@ -11,5 +11,5 @@ Manage order: {{ 'order/service/manage'|link }}/{{ order.id }} {{ guest.system_company.signature }} -{% endfilter %} +{% endapply %} {% endblock %} diff --git a/src/bb-modules/Servicesolusvm/html_admin/mod_servicesolusvm_import_clients.phtml b/src/bb-modules/Servicesolusvm/html_admin/mod_servicesolusvm_import_clients.phtml index 3dec0eccd..6e0a800e8 100644 --- a/src/bb-modules/Servicesolusvm/html_admin/mod_servicesolusvm_import_clients.phtml +++ b/src/bb-modules/Servicesolusvm/html_admin/mod_servicesolusvm_import_clients.phtml @@ -57,7 +57,7 @@ {% endblock %} {% block js %} -{% autoescape true js %} +{% autoescape "js" %}