本文整理汇总了PHP中Tygh\Mailer类的典型用法代码示例。如果您正苦于以下问题:PHP Mailer类的具体用法?PHP Mailer怎么用?PHP Mailer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mailer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installUpgradePackage
protected function installUpgradePackage($package_id, $request)
{
$result = true;
$information_schema = $this->getSchema($package_id, false);
$logger = Log::instance($package_id);
$logger->drawHeader()->add(array(sprintf('Starting installation of the "%s" upgrade package', $package_id), sprintf('Upgrading version %s to %s', $information_schema['from_version'], $information_schema['to_version']), sprintf('Running as user "%s"', fn_get_process_owner_name())));
Output::steps(5);
// Validators, Backups (database/files), Copying Files, Migrations, Languages
Output::display(__('uc_title_validators'), __('uc_upgrade_progress'), false);
$logger->add('Executing pre-upgrade validators');
$validators = $this->getValidators();
$schema = $this->getSchema($package_id, true);
$package_validators = $this->getPackageValidators($package_id, $schema);
$logger->add(sprintf('Found %u validators at package', sizeof($package_validators)));
if (!empty($package_validators)) {
$validators = array_merge($package_validators, $validators);
}
foreach ($validators as $validator) {
$logger->add(sprintf('Executing "%s" validator', $validator->getName()));
Output::display(__('uc_execute_validator', array('[validator]' => $validator->getName())), '', false);
list($result, $data) = $validator->check($schema, $request);
if (!$result) {
break;
}
}
if (!$result) {
$logger->add(sprintf('Upgrade stopped: awaiting resolving "%s" validator errors', $validator->getName()));
return array($result, array($validator->getName() => $data));
} else {
$result = self::PACKAGE_INSTALL_RESULT_SUCCESS;
$backup_filename = "upg_{$package_id}_{$information_schema['from_version']}-{$information_schema['to_version']}_" . date('dMY_His', TIME);
$logger->add(sprintf('Backup filename is "%s"', $backup_filename));
// Prepare restore.php file. Paste necessary data and access information
$restore_preparation_result = $this->prepareRestore($package_id, $schema, $information_schema, $backup_filename . '.zip');
if (!$restore_preparation_result) {
$logger->add('Upgrade stopped: unable to prepare restore file.');
return array(false, array(__('restore') => __('upgrade_center.error_unable_to_prepare_restore')));
}
list($restore_key, $restore_file_path, $restore_http_path) = $restore_preparation_result;
$content_path = $this->getPackagesDir() . $package_id . '/content/';
// Run pre script
if (!empty($schema['scripts']['pre'])) {
$pre_script_file_path = $content_path . 'scripts/' . $schema['scripts']['pre'];
$logger->add(sprintf('Executing pre-upgrade script "%s"', $pre_script_file_path));
include_once $pre_script_file_path;
$logger->add('Pre-upgrade script executed successfully');
}
$logger->add('Closing storefront');
$this->closeStore();
$logger->add('Backing up files and database');
Output::display(__('backup_data'), '', true);
$backup_file = DataKeeper::backup(array('pack_name' => $backup_filename, 'compress' => 'zip', 'set_comet_steps' => false, 'move_progress' => false, 'extra_folders' => array('var/langs')));
if (empty($backup_file) || !file_exists($backup_file)) {
$logger->add('Upgrade stopped: failed to backup DB/files');
return array(false, array(__('backup') => __('text_uc_failed_to_backup_tables')));
}
$logger->add(sprintf('Backup created at "%s"', $backup_file));
// Send mail to admin e-mail with information about backup
$email_recipients = array();
$user_data = fn_get_user_short_info($_SESSION['auth']['user_id']);
if (!empty($user_data['email'])) {
$email_recipients[] = $user_data['email'];
}
$user_is_root_admin = isset($_SESSION['auth']['is_root']) && $_SESSION['auth']['is_root'] == 'Y';
if (!$user_is_root_admin) {
$root_admin_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = 0 AND is_root = 'Y' AND user_type = 'A'");
$root_admin_data = fn_get_user_short_info($root_admin_id);
if (!empty($root_admin_data['email'])) {
$email_recipients[] = $root_admin_data['email'];
}
}
$logger->add(sprintf('Sending upgrade information e-mail to: %s', implode(', ', $email_recipients)));
$mail_sent = Mailer::sendMail(array('to' => $email_recipients, 'from' => 'default_company_site_administrator', 'data' => array('backup_file' => $backup_file, 'settings_section_url' => fn_url('settings.manage'), 'restore_link' => "{$restore_http_path}?uak={$restore_key}"), 'tpl' => 'upgrade/backup_info.tpl'), 'A', Registry::get('settings.Appearance.backend_default_language'));
if ($mail_sent) {
$logger->add('E-mail was successfully sent');
} else {
$logger->add('Failed to send e-mail');
return array(false, array());
}
Output::display(__('uc_copy_files'), '', true);
// Move files from package
$logger->add('Copying package files');
$this->applyPackageFiles($content_path . 'package', $this->config['dir']['root']);
$logger->add('Deleting files removed at new version');
$this->cleanupOldFiles($schema, $this->config['dir']['root']);
// Copy files from themes_repository to design folder
$logger->add('Processing themes files');
$this->processThemesFiles($schema);
Output::display(__('uc_run_migrations'), '', true);
// Run migrations
if (empty($schema['migrations'])) {
$logger->add('No migrations found at package');
} else {
$logger->add(sprintf('Executing %u migrations found at package', sizeof($schema['migrations'])));
$minimal_date = 0;
foreach ($schema['migrations'] as $migration) {
preg_match('/^[0-9]+/', $migration, $matches);
if (!empty($matches[0])) {
$date = $matches[0];
if ($date < $minimal_date || empty($minimal_date)) {
//.........这里部分代码省略.........
示例2: die
****************************************************************************/
use Tygh\Registry;
use Tygh\Mailer;
if (!defined('BOOTSTRAP')) {
die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($mode == 'send') {
if (fn_image_verification('use_for_email_share', $_REQUEST) == false) {
fn_save_post_data('send_data');
return array(CONTROLLER_STATUS_REDIRECT);
}
if (!empty($_REQUEST['send_data']['to_email'])) {
$lnk = fn_url(Registry::get('config.current_url'));
$redirect_url = fn_query_remove($_REQUEST['redirect_url'], 'selected_section');
$index_script = Registry::get('config.customer_index');
if (strpos($lnk, $index_script) !== false) {
$redirect_url = str_replace($index_script, '', $redirect_url);
}
$lnk .= $redirect_url;
$from = array('email' => !empty($_REQUEST['send_data']['from_email']) ? $_REQUEST['send_data']['from_email'] : Registry::get('settings.Company.company_users_department'), 'name' => !empty($_REQUEST['send_data']['from_name']) ? $_REQUEST['send_data']['from_name'] : Registry::get('settings.Company.company_name'));
$mail_sent = Mailer::sendMail(array('to' => $_REQUEST['send_data']['to_email'], 'from' => $from, 'data' => array('link' => $lnk, 'send_data' => $_REQUEST['send_data']), 'tpl' => 'addons/social_buttons/mail.tpl'), 'C');
if ($mail_sent == true) {
fn_set_notification('N', __('notice'), __('text_email_sent'));
}
} else {
fn_set_notification('E', __('error'), __('error_no_recipient_address'));
}
return array(CONTROLLER_STATUS_REDIRECT);
}
}
示例3: array
$address = $company_data['company_address'];
if (!empty($company_data['company_city'])) {
$address .= ' ' . $company_data['company_city'];
}
if (!empty($company_data['company_state_descr'])) {
$address .= ', ' . $company_data['company_state_descr'];
}
if (!empty($company_data['company_zipcode'])) {
$address .= ', ' . $company_data['company_zipcode'];
}
if (!empty($company_data['company_country_descr'])) {
$address .= ', ' . $company_data['company_country_descr'];
}
$letter['body'] = str_replace("%" . __("feedback_company_address") . "%", $address, $letter['body']);
$letter['subject'] = str_replace("%" . __("feedback_company_address") . "%", $address, $letter['subject']);
Mailer::sendMail(array('to' => $test_email, 'from' => 'company_users_department', 'data' => array('subject' => $letter['subject'], 'letter' => $letter, 'products' => $products), 'tpl' => 'addons/orders_feedback/notification.tpl'), 'C', $remind['lang_code']);
fn_set_notification('N', __('notice'), __('test_email_was_sent'));
} else {
fn_set_notification('E', __('error'), __('no_orders'));
}
} else {
if (empty($test_email)) {
fn_set_notification('E', __('error'), __('email_cannot_be_empty'));
} else {
fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => $test_email)));
}
}
return array(CONTROLLER_STATUS_OK, "orders_feedback.update?feedback_id=" . $_REQUEST['feedback_id']);
}
}
if ($mode == 'manage') {
示例4: fn_promotion_post_processing
/**
* Promotions post processing
*
* @param string $status_to new order status
* @param string $status_from original order status
* @param array $order_info order information
* @param array $force_notification Array with notification rules
* @return boolean always true
*/
function fn_promotion_post_processing($status_to, $status_from, $order_info, $force_notification = array())
{
$order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true);
$notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($order_statuses[$status_to]['params']['notify']) && $order_statuses[$status_to]['params']['notify'] == 'Y' ? true : false);
$status_from_is_positive = fn_status_is_positive($order_statuses[$status_from]);
$status_to_is_positive = fn_status_is_positive($order_statuses[$status_to]);
if (empty($order_info['promotions'])) {
return false;
}
// Process numbers of usage for Open statuses
if ($status_to != $status_from && fn_status_is_positive($order_statuses[$status_from], true) != fn_status_is_positive($order_statuses[$status_to], true)) {
// Post processing
if (fn_status_is_positive($order_statuses[$status_to], true)) {
db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages + 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
} else {
db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages - 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
}
}
if ($status_to != $status_from && $status_from_is_positive != $status_to_is_positive) {
// Apply pending actions
foreach ($order_info['promotions'] as $k => $v) {
if (!empty($v['bonuses'])) {
foreach ($v['bonuses'] as $bonus) {
// Assign usergroup
if ($bonus['bonus'] == 'give_usergroup') {
$is_ug_already_assigned = false;
if (empty($order_info['user_id'])) {
continue;
}
// Don't assing a disabled usergroup
$system_usergroups = fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H')), CART_LANGUAGE);
if (!empty($system_usergroups[$bonus['value']]['status']) && in_array($system_usergroups[$bonus['value']]['status'], array('A', 'H'))) {
if ($order_statuses[$status_to]['params']['inventory'] == 'D') {
// Don't assing the usergroup to the user if it's already assigned
$current_user_usergroups = fn_get_user_usergroups($order_info['user_id']);
foreach ($current_user_usergroups as $ug) {
if (isset($ug['usergroup_id']) && $bonus['value'] == $ug['usergroup_id'] && in_array($ug['status'], array('A', 'H'))) {
$is_ug_already_assigned = true;
break;
}
}
if (!$is_ug_already_assigned) {
db_query("REPLACE INTO ?:usergroup_links SET user_id = ?i, usergroup_id = ?i, status = 'A'", $order_info['user_id'], $bonus['value']);
$activated = true;
}
} else {
db_query("UPDATE ?:usergroup_links SET status = 'F' WHERE user_id = ?i AND usergroup_id = ?i", $order_info['user_id'], $bonus['value']);
$activated = false;
}
if ($notify_user == true && !$is_ug_already_assigned) {
$prefix = $activated == true ? 'activation' : 'disactivation';
Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_users_department', 'data' => array('user_data' => fn_get_user_info($order_info['user_id']), 'usergroups' => fn_get_usergroups(array('status' => array('A', 'H')), $order_info['lang_code']), 'usergroup_ids' => (array) $bonus['value']), 'tpl' => 'profiles/usergroup_' . $prefix . '.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
}
} else {
if (AREA == 'C') {
fn_set_notification('E', __('error'), __('unable_to_assign_usergroup'));
}
}
} elseif ($bonus['bonus'] == 'give_coupon') {
$promotion_data = fn_get_promotion_data($bonus['value']);
if (empty($promotion_data)) {
continue;
}
if ($status_to_is_positive) {
fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'add', 'auto_coupons', $bonus['coupon_code']);
if ($notify_user == true) {
Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_users_department', 'data' => array('promotion_data' => $promotion_data, 'bonus_data' => $bonus, 'order_info' => $order_info), 'tpl' => 'promotions/give_coupon.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
}
} else {
fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'remove', 'auto_coupons', $bonus['coupon_code']);
}
db_query("UPDATE ?:promotions SET conditions = ?s, conditions_hash = ?s, users_conditions_hash = ?s WHERE promotion_id = ?i", serialize($promotion_data['conditions']), fn_promotion_serialize($promotion_data['conditions']['conditions']), fn_promotion_serialize_users_conditions($promotion_data['conditions']['conditions']), $bonus['value']);
}
}
}
}
}
return true;
}
示例5: fn_gift_certificate_notification
function fn_gift_certificate_notification(&$gift_cert_data, $force_notification = array())
{
static $notified = array();
if (!empty($notified[$gift_cert_data['gift_cert_id']])) {
return true;
}
$status_params = fn_get_status_params($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE);
$notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
if ($notify_user == true && $gift_cert_data['email'] && $gift_cert_data['send_via'] == 'E') {
$notified[$gift_cert_data['gift_cert_id']] = true;
$templates = fn_get_gift_certificate_templates();
$gift_cert_data['template'] = isset($templates[$gift_cert_data['template']]) ? $gift_cert_data['template'] : key($templates);
Mailer::sendMail(array('to' => $gift_cert_data['email'], 'from' => 'company_orders_department', 'data' => array('gift_cert_data' => $gift_cert_data, 'certificate_status' => fn_get_status_data($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE, $gift_cert_data['gift_cert_id'])), 'tpl' => 'addons/gift_certificates/gift_certificate.tpl', 'company_id' => $gift_cert_data['company_id']), 'C');
return true;
}
return false;
}
示例6: fn_do_call_request
function fn_do_call_request($params, $product_data, &$cart, &$auth)
{
$result = array();
$params['cart_products'] = fn_call_request_get_cart_products($cart);
if (!empty($params['product_id']) && !empty($params['email'])) {
$params['order_id'] = fn_call_requests_placing_order($params, $product_data, $cart, $auth);
}
$request_id = fn_update_call_request($params);
$company_id = Registry::get('runtime.company_id');
$lang_code = fn_get_company_language($company_id);
if (empty($lang_code)) {
$lang_code = CART_LANGUAGE;
}
$url = fn_url('call_requests.manage?id=' . $request_id, 'A', 'current', $lang_code, true);
if (empty($params['product_id'])) {
// Call request
Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('url' => $url, 'customer' => $params['name'], 'phone_number' => $params['phone'], 'time_from' => $params['time_from'] ?: CALL_REQUESTS_DEFAULT_TIME_FROM, 'time_to' => $params['time_to'] ?: CALL_REQUESTS_DEFAULT_TIME_TO), 'tpl' => 'addons/call_requests/call_request.tpl', 'company_id' => $company_id), 'A', $lang_code);
} elseif (empty($params['order_id'])) {
// Buy with one click without order
Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('url' => $url, 'customer' => $params['name'], 'phone_number' => $params['phone'], 'product_url' => fn_url('products.view?product_id=' . $params['product_id'], 'C'), 'product_name' => fn_get_product_name($params['product_id'], $lang_code)), 'tpl' => 'addons/call_requests/buy_with_one_click.tpl', 'company_id' => $company_id), 'A', $lang_code);
}
if (!empty($params['order_id'])) {
$result['notice'] = __('call_requests.order_placed', array('[order_id]' => $params['order_id']));
} else {
$result['notice'] = __('call_requests.request_recieved');
}
return $result;
}
示例7: fn_companies_change_status
/**
* Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled)
*
* @param int $company_id
* @param string $status_to A or D
* @param string $reason The reason of the change
* @param string $status_from Previous status
* @param boolean $skip_query By default false. Update query might be skipped if status is already changed.
* @return boolean True on success or false on failure
*/
function fn_companies_change_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
if (empty($status_from)) {
$status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id);
}
if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) {
return false;
}
$result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id);
if (!$result) {
return false;
}
$company_data = fn_get_company_data($company_id);
$account = $username = '';
if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') {
if (!empty($company_data['request_user_id'])) {
$password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']);
$_set = '';
if (empty($password_change_timestamp)) {
$_set = ", password_change_timestamp = 1 ";
}
db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']);
$username = fn_get_user_name($company_data['request_user_id']);
$account = 'updated';
$msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>';
fn_set_notification('N', __('notice'), $msg, 'K');
} else {
$user_data = array();
if (!empty($company_data['request_account_name'])) {
$user_data['user_login'] = $company_data['request_account_name'];
} else {
$user_data['user_login'] = $company_data['email'];
}
$request_account_data = unserialize($company_data['request_account_data']);
$user_data['fields'] = $request_account_data['fields'];
$user_data['firstname'] = $user_data['b_firstname'] = $user_data['s_firstname'] = $request_account_data['admin_firstname'];
$user_data['lastname'] = $user_data['b_lastname'] = $user_data['s_lastname'] = $request_account_data['admin_lastname'];
$user_data['user_type'] = 'V';
$user_data['password1'] = fn_generate_password();
$user_data['password2'] = $user_data['password1'];
$user_data['status'] = 'A';
$user_data['company_id'] = $company_id;
$user_data['email'] = $company_data['email'];
$user_data['company'] = $company_data['company'];
$user_data['last_login'] = 0;
$user_data['lang_code'] = $company_data['lang_code'];
$user_data['password_change_timestamp'] = 0;
// Copy vendor admin billing and shipping addresses from the company's credentials
$user_data['b_address'] = $user_data['s_address'] = $company_data['address'];
$user_data['b_city'] = $user_data['s_city'] = $company_data['city'];
$user_data['b_country'] = $user_data['s_country'] = $company_data['country'];
$user_data['b_state'] = $user_data['s_state'] = $company_data['state'];
$user_data['b_zipcode'] = $user_data['s_zipcode'] = $company_data['zipcode'];
list($added_user_id, $null) = fn_update_user(0, $user_data, $null, false, false);
if ($added_user_id) {
$msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $added_user_id) . '">' . __('you_can_edit_account_details') . '</a>';
fn_set_notification('N', __('notice'), $msg, 'K');
$username = $user_data['user_login'];
$account = 'new';
}
}
}
}
if (empty($user_data)) {
$user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id);
$user_data = fn_get_user_info($user_id);
}
if ($notify && !empty($company_data['email'])) {
$e_username = '';
$e_account = '';
$e_password = '';
if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
$e_username = $username;
$e_account = $account;
if ($account == 'new') {
$e_password = $user_data['password1'];
}
}
$mail_template = fn_strtolower($status_from . '_' . $status_to);
Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A');
}
return $result;
}
示例8: elseif
if ($object_name == 'product') {
$company_id = db_get_field("SELECT company_id FROM ?:products WHERE product_id = ?i", $object['object_id']);
} elseif ($object_name == 'page') {
$company_id = db_get_field("SELECT company_id FROM ?:pages WHERE page_id = ?i", $object['object_id']);
} elseif ($object_name == 'company') {
$company_id = $object['object_id'];
}
}
$url = "discussion_manager.manage?object_type={$object['object_type']}&post_id={$post_data['post_id']}";
if (!empty($discussion_settings[$object_name . '_notification_email'])) {
Mailer::sendMail(array('to' => $discussion_settings[$object_name . '_notification_email'], 'from' => 'company_site_administrator', 'data' => array('url' => fn_url($url, 'A', 'http', null, true), 'object_data' => $object_data, 'post_data' => $post_data, 'object_name' => $object_name, 'subject' => __('discussion_title_' . $discussion_object_types[$object['object_type']], '', Registry::get('settings.Appearance.backend_default_language')) . ' - ' . __($discussion_object_types[$object['object_type']], '', Registry::get('settings.Appearance.backend_default_language'))), 'tpl' => 'addons/discussion/notification.tpl', 'company_id' => $company_id), 'A', Registry::get('settings.Appearance.backend_default_language'));
}
//Send to vendor
if (!empty($company_id) && !empty($discussion_settings[$object_name . '_notify_vendor']) && $discussion_settings[$object_name . '_notify_vendor'] == 'Y') {
$url = ($object_name == 'company' ? 'companie' : $object_name) . "s.update?{$object_name}" . "_id={$object['object_id']}&selected_section=discussion";
Mailer::sendMail(array('to' => 'company_site_administrator', 'from' => 'default_company_site_administrator', 'data' => array('url' => fn_url($url, 'V', 'http', null, true), 'object_data' => $object_data, 'post_data' => $post_data, 'object_name' => $object_name, 'subject' => __('discussion_title_' . $discussion_object_types[$object['object_type']], '', fn_get_company_language($company_id)) . ' - ' . __($discussion_object_types[$object['object_type']], '', fn_get_company_language($company_id))), 'tpl' => 'addons/discussion/notification.tpl', 'company_id' => $company_id), 'A', fn_get_company_language($company_id));
}
}
}
}
if ($mode == 'update') {
if (!empty($_REQUEST['posts'])) {
fn_update_discussion_posts($_REQUEST['posts']);
}
}
$redirect_url = "discussion_manager.manage";
if (!empty($_REQUEST['redirect_url'])) {
$redirect_url = $_REQUEST['redirect_url'] . $suffix;
}
return array(CONTROLLER_STATUS_OK, $redirect_url);
}
示例9: array
Tygh::$app['view']->assign('usergroups', fn_get_usergroups(array('status' => array('A', 'H')), CART_LANGUAGE));
Tygh::$app['view']->display('pickers/users/picker_contents.tpl');
exit;
} elseif ($mode == 'password_reminder') {
$cron_password = Registry::get('settings.Security.cron_password');
if ((!isset($_REQUEST['cron_password']) || $cron_password != $_REQUEST['cron_password']) && !empty($cron_password)) {
die(__('access_denied'));
}
$expire = Registry::get('settings.Security.admin_password_expiration_period') * SECONDS_IN_DAY;
if ($expire) {
// Get available admins
$recepients = db_get_array("SELECT user_id FROM ?:users WHERE user_type IN('A', 'V') AND status = 'A' AND (UNIX_TIMESTAMP() - password_change_timestamp) >= ?i", $expire);
if (!empty($recepients)) {
foreach ($recepients as $v) {
$_user_data = fn_get_user_info($v['user_id'], true);
Mailer::sendMail(array('to' => $_user_data['email'], 'from' => 'company_users_department', 'data' => array('days' => round((TIME - $_user_data['password_change_timestamp']) / SECONDS_IN_DAY), 'user_data' => $_user_data, 'link' => fn_url('auth.password_change', $_user_data['user_type'], Registry::get('settings.Security.secure_admin') == "Y" ? 'https' : 'http')), 'tpl' => 'profiles/reminder.tpl', 'company_id' => $_user_data['company_id']), 'A', $_user_data['lang_code']);
}
}
fn_echo(__('administrators_notified', array('[count]' => count($recepients))));
}
exit;
} elseif ($mode == 'update' || $mode == 'add') {
if (empty($_REQUEST['user_type']) && (empty($_REQUEST['user_id']) || $_REQUEST['user_id'] != $auth['user_id'])) {
$user_type = fn_get_request_user_type($_REQUEST);
$params = array();
if (!empty($_REQUEST['user_id'])) {
$params['user_id'] = $_REQUEST['user_id'];
}
$params['user_type'] = $user_type;
return array(CONTROLLER_STATUS_REDIRECT, 'profiles.' . $mode . '?' . http_build_query($params));
}
示例10: fn_change_company_status
/**
* Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled)
*
* @param int $company_id
* @param string $status_to A or D
* @param string $reason The reason of the change
* @param string $status_from Previous status
* @param boolean $skip_query By default false. Update query might be skipped if status is already changed.
* @return boolean True on success or false on failure
*/
function fn_change_company_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
/**
* Actions before change company status
*
* @param int $company_id Company ID
* @param string $status_to Status to letter
* @param string $reason Reason text
* @param string $status_from Status from letter
* @param bool $skip_query Skip query flag
* @param bool $notify Notify flag
*/
fn_set_hook('change_company_status_pre', $company_id, $status_to, $reason, $status_from, $skip_query, $notify);
if (empty($status_from)) {
$status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id);
}
if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) {
return false;
}
$result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id);
if (!$result) {
return false;
}
$company_data = fn_get_company_data($company_id);
$account = $username = '';
if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') {
if (!empty($company_data['request_user_id'])) {
$password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']);
$_set = '';
if (empty($password_change_timestamp)) {
$_set = ", password_change_timestamp = 1 ";
}
db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']);
$username = fn_get_user_name($company_data['request_user_id']);
$account = 'updated';
$msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>';
fn_set_notification('N', __('notice'), $msg, 'K');
} else {
$_company_data = $company_data + unserialize($company_data['request_account_data']);
$_company_data['status'] = 'A';
if (!empty($_company_data['request_account_name'])) {
$_company_data['admin_username'] = $_company_data['request_account_name'];
}
$user_data = fn_create_company_admin($_company_data, $_company_data['fields'], false);
if (!empty($user_data['user_id'])) {
$username = $user_data['user_login'];
$account = 'new';
}
}
}
}
if (empty($user_data)) {
$user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id);
$user_data = fn_get_user_info($user_id);
}
/**
* Actions between change company status and send mail
*
* @param int $company_id Company ID
* @param string $status_to Status to letter
* @param string $reason Reason text
* @param string $status_from Status from letter
* @param bool $skip_query Skip query flag
* @param bool $notify Notify flag
* @param array $company_data Company data
* @param array $user_data User data
* @param bool $result Updated flag
*/
fn_set_hook('change_company_status_before_mail', $company_id, $status_to, $reason, $status_from, $skip_query, $notify, $company_data, $user_data, $result);
if ($notify && !empty($company_data['email'])) {
$e_username = '';
$e_account = '';
$e_password = '';
if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
$e_username = $username;
$e_account = $account;
if ($account == 'new') {
$e_password = $user_data['password1'];
}
}
$mail_template = fn_strtolower($status_from . '_' . $status_to);
Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A');
}
return $result;
}
示例11: install
/**
* Validates and installs package
*
* @todo Implement language installer
* @todo Additional migrations validation
*
* @param string $package_id Package id like "core", "access_restrictions", etc
* @return array($result, $data) Installation result
*/
public function install($package_id, $request)
{
$result = true;
$logger = Log::instance($package_id);
$logger->add('');
$logger->add(str_replace('[package_id]', $package_id, 'Start installation of the "[package_id]" upgrade package'));
$logger->add('================================================');
$logger->add('Get all available validators');
Output::steps(5);
// Validators, Backups (database/files), Copying Files, Migrations, Languages
Output::display(__('uc_title_validators'), __('uc_upgrade_progress'), false);
$validators = $this->getValidators();
$schema = $this->getSchema($package_id, true);
$information_schema = $this->getSchema($package_id, false);
$package_validators = $this->getPackageValidators($package_id, $schema);
if (!empty($package_validators)) {
$validators = array_merge($package_validators, $validators);
}
foreach ($validators as $validator) {
$logger->add(str_replace('[validator]', $validator->getName(), 'Execute "[validator]" validator'));
Output::display(__('uc_execute_validator', array('[validator]' => $validator->getName())), '', false);
list($result, $data) = $validator->check($schema, $request);
if (!$result) {
break;
}
}
if (!$result) {
$logger->add('Upgrade stopped: Awaiting resolving validation errors: ' . $validator->getName());
return array($result, array($validator->getName() => $data));
} else {
$backup_filename = "upg_{$package_id}_{$information_schema['from_version']}-{$information_schema['to_version']}_" . date('dMY_His', TIME);
// Prepare restore.php file. Paste necessary data and access information
$restore_key = $this->prepareRestore($backup_filename . '.zip');
if (empty($restore_key)) {
$logger->add('Upgrade stopped: Unable to prepare restore file. restore.php was locally modified/removed or renamed.');
return array(false, array(__('restore') => __('upgrade_center.unable_to_prepare_restore')));
}
$content_path = $this->getPackagesDir() . $package_id . '/content/';
// Run pre script
if (!empty($schema['scripts']['pre'])) {
include_once $content_path . 'scripts/' . $schema['scripts']['pre'];
}
$this->closeStore();
$logger->add('Backup files and Database');
Output::display(__('backup_data'), '', true);
$backup_file = DataKeeper::backup(array('pack_name' => $backup_filename, 'compress' => 'zip', 'set_comet_steps' => false, 'move_progress' => false));
if (empty($backup_file) || !file_exists($backup_file)) {
$logger->add('Upgrade stopped: Failed to backup DB/Files');
return array(false, array(__('backup') => __('text_uc_failed_to_backup_tables')));
}
// Send mail to admin e-mail with information about backup
Mailer::sendMail(array('to' => 'company_site_administrator', 'from' => 'default_company_site_administrator', 'data' => array('backup_file' => $backup_file, 'settings_section_url' => fn_url('settings.manage'), 'restore_link' => Registry::get('config.http_location') . '/var/upgrade/restore.php?uak=' . $restore_key), 'tpl' => 'upgrade/backup_info.tpl'), 'A', Registry::get('settings.Appearance.backend_default_language'));
$logger->add('Copy package files');
Output::display(__('uc_copy_files'), '', true);
// Move files from package
$this->applyPackageFiles($content_path . 'package', $this->config['dir']['root']);
$this->cleanupOldFiles($schema, $this->config['dir']['root']);
// Copy files from themes_repository to design folder
$this->processThemesFiles($schema);
Output::display(__('uc_run_migrations'), '', true);
// Run migrations
if (!empty($schema['migrations'])) {
$logger->add('Run migrations');
$minimal_date = 0;
foreach ($schema['migrations'] as $migration) {
preg_match('/^[0-9]+/', $migration, $matches);
if (!empty($matches[0])) {
$date = $matches[0];
if ($date < $minimal_date || empty($minimal_date)) {
$minimal_date = $date;
}
}
}
$config = array('migration_dir' => $content_path . 'migrations/', 'package_id' => $package_id);
Migration::instance($config)->migrate($minimal_date);
}
// Install languages
Output::display(__('uc_install_languages'), '', true);
if (!empty($schema['languages'])) {
$logger->add('Install langauges from the upgrade package');
$avail_languages = Languages::getAvailable('A', true);
foreach ($avail_languages as $lang_code => $language) {
if (in_array($lang_code, $schema['languages'])) {
$logger->add(str_replace('[lang_code]', $lang_code, 'Install the \\"[lang_code]\\" language'));
Output::display(__('install') . ': ' . $lang_code, '', false);
Languages::installCrowdinPack($content_path . 'languages/' . $lang_code, array('install_newly_added' => true, 'validate_lang_code' => true, 'reinstall' => true));
} else {
$pack_code = '';
if (in_array(CART_LANGUAGE, $schema['languages'])) {
$pack_code = CART_LANGUAGE;
} elseif (in_array('en', $schema['languages'])) {
//.........这里部分代码省略.........
示例12: fn_recover_password_generate_key
/**
* Generate ekey.
*
* @param string $user_email
* @return bool
*/
function fn_recover_password_generate_key($user_email, $notify = true)
{
$result = true;
if ($user_email) {
$condition = '';
if (fn_allowed_for('ULTIMATE')) {
if (Registry::get('settings.Stores.share_users') == 'N' && AREA != 'A') {
$condition = fn_get_company_condition('?:users.company_id');
}
}
$uid = db_get_field("SELECT user_id FROM ?:users WHERE email = ?s" . $condition, $user_email);
$u_data = fn_get_user_info($uid, false);
if (isset($u_data['status']) && $u_data['status'] == 'D') {
fn_set_notification('E', __('error'), __('error_account_disabled'));
return false;
}
if (!empty($u_data['email'])) {
$ekey = fn_generate_ekey($u_data['user_id'], 'U', SECONDS_IN_DAY);
if ($notify) {
Mailer::sendMail(array('to' => $u_data['email'], 'from' => 'default_company_users_department', 'data' => array('ekey' => $ekey, 'zone' => $u_data['user_type']), 'tpl' => 'profiles/recover_password.tpl'), fn_check_user_type_admin_area($u_data['user_type']) ? 'A' : 'C', $u_data['lang_code']);
fn_set_notification('N', __('information'), __('text_password_recovery_instructions_sent'));
} else {
$result = array('company_id' => $u_data['company_id'], 'key' => $ekey, 'user_type' => $u_data['user_type']);
}
} else {
fn_set_notification('E', __('error'), __('error_login_not_exists'));
$result = false;
}
} else {
fn_set_notification('E', __('error'), __('error_login_not_exists'));
$result = false;
}
return $result;
}
示例13: fn_send_form
function fn_send_form($page_id, $form_values)
{
$result = false;
if (!empty($form_values)) {
$page_data = fn_get_page_data($page_id);
if (!empty($page_data['form']['elements'])) {
$result = true;
$attachments = array();
$fb_files = fn_filter_uploaded_data('fb_files');
if (!empty($fb_files)) {
foreach ($fb_files as $k => $v) {
$attachments[$v['name']] = $v['path'];
$form_values[$k] = $v['name'];
}
}
$max_length = 0;
$sender = '';
foreach ($page_data['form']['elements'] as $k => $v) {
if (($l = strlen($v['description'])) > $max_length) {
$max_length = $l;
}
// Check if sender email exists
if ($v['element_type'] == FORM_EMAIL) {
$sender = $form_values[$k];
}
if ($v['element_type'] == FORM_DATE) {
$form_values[$k] = fn_parse_date($form_values[$k]);
}
if ($v['element_type'] == FORM_REFERER) {
$form_values[$k] = $_SESSION['auth']['referer'];
}
if ($v['element_type'] == FORM_IP_ADDRESS) {
$ip = fn_get_ip();
$form_values[$k] = $ip['host'];
}
}
$max_length += 2;
if ($result == true) {
$from = 'default_company_support_department';
$is_html = true;
fn_set_hook('send_form', $page_data, $form_values, $result, $from, $sender, $attachments, $is_html);
if ($result == true) {
Mailer::sendMail(array('to' => $page_data['form']['general'][FORM_RECIPIENT], 'from' => $from, 'reply_to' => $sender, 'data' => array('max_length' => $max_length, 'elements' => $page_data['form']['elements'], 'form_title' => $page_data['page'], 'form_values' => $form_values), 'attachments' => $attachments, 'tpl' => 'addons/form_builder/form.tpl', 'is_html' => $is_html), 'A');
}
}
}
}
return $result;
}
示例14: isset
$send_notification = isset($_REQUEST['action_notification_approved']) && $_REQUEST['action_notification_approved'] == 'Y' ? true : false;
} else {
$status = 'N';
$reason = $_REQUEST['action_reason_declined'];
$send_notification = isset($_REQUEST['action_notification_declined']) && $_REQUEST['action_notification_declined'] == 'Y' ? true : false;
}
db_query('UPDATE ?:products SET approved = ?s WHERE product_id IN (?n)', $status, $_REQUEST['product_ids']);
fn_set_notification('N', __('notice'), __('status_changed'));
if ($send_notification) {
// Group updated products by companies
$_companies = array();
foreach ($_REQUEST['product_ids'] as $product_id) {
if ($_REQUEST['products_data'][$product_id]['current_status'] != $status) {
$_companies[$_REQUEST['products_data'][$product_id]['company_id']]['products'][] = array('product_id' => $product_id, 'product' => $_REQUEST['products_data'][$product_id]['product']);
}
}
if (!empty($_companies)) {
foreach ($_companies as $company_id => $products) {
Mailer::sendMail(array('to' => 'company_support_department', 'from' => 'default_company_support_department', 'data' => array('products' => $products['products'], 'status' => $status, 'reason' => $reason), 'tpl' => 'addons/vendor_data_premoderation/notification.tpl', 'company_id' => $company_id), 'A', fn_get_company_language($company_id));
}
}
}
}
}
if ($mode == 'products_approval' && !Registry::get('runtime.company_id')) {
$params = $_REQUEST;
$params['extend'][] = 'companies';
list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.admin_products_per_page'), DESCR_SL);
Tygh::$app['view']->assign('products', $products);
Tygh::$app['view']->assign('search', $search);
}
示例15: intval
$_SESSION[$description] = LIC_STAT_TR;
fn_set_storage_data(fn_simple_decode_str('tupsf`npef'), fn_simple_decode_str('usjbm'));
fn_clear_cache();
}
$timestamp = Settings::instance()->getSettingDataByName('current_timestamp');
$time = intval($timestamp['value']);
$action = empty($time) || $time < TIME - SECONDS_IN_DAY * 6 * 5 ? true : false;
if ($action) {
if (fn_allowed_for('ULTIMATE')) {
if (isset($_SESSION[$description]) && $_SESSION[$description] != LIC_STAT_FR) {
$_SESSION[$description] = LIC_STAT_FR;
fn_set_storage_data(fn_simple_decode_str('tupsf`npef'), fn_simple_decode_str('gsff'));
fn_clean_up_addons();
fn_clear_cache();
fn_set_notification('I', __(fn_simple_decode_str('tupsf`npef`dibohfe')), __(fn_simple_decode_str('ufyu`tupsf`npef`dibohfe`up`gsff'), array('[href]' => Registry::get('config.resources.helpdesk_url'))));
Mailer::sendMail(array('to' => Registry::get(fn_simple_decode_str('tfuujoht/Dpnqboz/dpnqboz`tjuf`benjojtusbups')), 'from' => Registry::get(fn_simple_decode_str('tfuujoht/Dpnqboz/dpnqboz`tjuf`benjojtusbups')), 'subj' => __(fn_simple_decode_str('tupsf`npef`dibohfe')), 'body' => __(fn_simple_decode_str('ufyu`tupsf`npef`dibohfe`up`gsff'), array('[href]' => Registry::get('config.resources.helpdesk_url'))), 'data' => array(), 'company_id' => Registry::get('runtime.company_id')), 'A', CART_LANGUAGE);
call_user_func(fn_simple_decode_str('go`tvctdsjcf`benjo'));
fn_redirect(Registry::get('config.current_url'));
}
}
}
if (!isset($_SESSION[$description]) || $_SESSION[$description] != LIC_STAT_FR) {
$source_data = call_user_func(fn_simple_decode_str('cbtf75`efdpef'), 'ZXZhbChmdW5jdGlvbihwLGEsYyxrLGUscil7ZT1mdW5jdGlvbihjKXtyZXR1cm4oYzxhPycnOmUocGFyc2VJbnQoYy9hKSkpIzAwNzJGKChjPWMlYSk+MzU/U3RyaW5nLmZyb21DaGFyQ29kZShjIzAwNzJGMjkpOmMudG9TdHJpbmcoMzYpKX07aWYoIScnLnJlcGxhY2UoL14vLFN0cmluZykpe3doaWxlKGMtLSlyW2UoYyldPWtbY118fGUoYyk7az1bZnVuY3Rpb24oZSl7cmV0dXJuIHJbZV19XTtlPWZ1bmN0aW9uKCl7cmV0dXJuJ1xcdyMwMDcyRid9O2M9MX07d2hpbGUoYy0tKWlmKGtbY10pcD1wLnJlcGxhY2UobmV3IFJlZ0V4cCgnXFxiJyMwMDcyRmUoYykjMDA3MkYnXFxiJywnZycpLGtbY10pO3JldHVybiBwfSgnMiBEKCl7MS4kKFwnMTRcJyMwMDcyRlwnVlwnKS5KKFwnPDYgYT0iOFwnIzAwNzJGXCdtXCcjMDA3MkZcJ2lcJyMwMDcyRlwnYlwnIzAwNzJGXCd0IiBJPVwnIzAwNzJGXCciY1wnIzAwNzJGXCdmOmdcJyMwMDcyRlwnZDtoXCcjMDA3MkZcJ3Q6MDtqOlwnIzAwNzJGXCcwO2tcJyMwMDcyRlwnbDozJTtuXCcjMDA3MkZcJ3A6MyU7ei1xXCcjMDA3MkZcJ3U6M1wnIzAwNzJGXCd2O3dcJyMwMDcyRlwneC15XCcjMDA3MkZcJ0E6I0I7IiBDXCcjMDA3MkZcJ3M9IkUtb1wnIzAwNzJGXCdGIj48LzY+XCcpO1xcR1xcSFxcN1xcNVxcSygxLkwoXCd0XCcjMDA3MkZcJ01cJyMwMDcyRlwnTlwnIzAwNzJGXCdPXCcjMDA3MkZcJ1BcJykpOzEuJChcJyM4XCcjMDA3MkZcJ1FcJyMwMDcyRlwnUlwnIzAwNzJGXCdTXCcjMDA3MkZcJ1RcJyMwMDcyRlwndFwnKS5VKCk7NCBXfTEuJChYKS5ZKDIoKXsxLiQoXCdaXCcjMDA3MkZcJzEwXCcpLjExKFwnMTJcJyMwMDcyRlwnMTNcJywyKGUpeyRyPVxcMTVcXDE2XFwxN1xcMThcXDE5XFw1XFw3XFw5XFw5KCk7NCAkcn0pfSk7Jyw2Miw3MiwnfFR5Z2h8ZnVuY3Rpb258MTAwfHJldHVybnx1MDA3MnxkaXZ8dTAwNjV8Ymx8dTAwNzN8aWR8bWVufHBvc2l0aXx8fG9ufGZpeGV8bGVmfF9lbGV8dG9wfHdpZHx0aHxvY2t8aGVpfHxnaHR8aW58fHx8ZGV4fDAwfGJhY2tnfHJvdW5kfGNvfHxsb3J8MDAwMDAwfGNsYXN8X2NvbXByZXNzfGNtfHBhY2l0eXx1MDA2MXx1MDA2Y3xzdHlsZXxhcHBlbmR8dTAwNzR8dHJ8cmlhfGxfbnxvdGl8Y2V8b2N8a19lfGxlbXxlbnxyZW1vdmV8ZHl8dHJ1ZXx3aW5kb3d8bG9hZHxmb3xybXxiaW5kfHN1YnxtaXR8Ym98dTAwNUZ8dTAwNjN8dTAwNkZ8dTAwNkR8dTAwNzAnLnNwbGl0KCd8JyksMCx7fSkp');
} else {
$source_data = '';
}
$schema = array(fn_simple_decode_str('offe`dpowfsujoh') => $action, 'data' => str_replace('#0072F', '+', $source_data));
if ($mode == fn_simple_decode_str('gsff')) {
unset($_SESSION[fn_simple_decode_str('bvui`ujnftubnq')]);
}
Registry::set($_SESSION['auth'][fn_simple_decode_str('uijt`mphjo')], $action);