//user_sms } if (defined('AJAX_REQUEST')) { exit; } elseif (!empty($_REQUEST['return_url'])) { return array(CONTROLLER_STATUS_OK, $_REQUEST['return_url']); } else { return array(CONTROLLER_STATUS_OK, 'profiles.update?user_id=' . $_REQUEST['user_id']); } } return array(CONTROLLER_STATUS_OK, 'profiles.manage?user_type=C'); } if ($mode == 'manage') { // [Page sections] Registry::set('navigation.tabs', array('fields' => array('title' => __('addons.rus_unisender.map_fields'), 'js' => true))); // [/Page sections] if (fn_allowed_for('MULTIVENDOR') || Registry::get('runtime.company_id') || Registry::get('runtime.simple_ultimate')) { $fields = fn_unisender_get_fields(); $unisender_fields = fn_unisender_get_unisender_fields(); $profile_fields = fn_get_profile_fields('ALL', array(), CART_LANGUAGE); // FIXME: code for compatibility foreach ($fields as &$field) { if (empty($field['unisender_field_id'])) { $field['unisender_field_id'] = fn_unisender_compatibility($unisender_fields, $field); } } Tygh::$app['view']->assign('unisender_fields', $unisender_fields); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('fields', $fields); } }
function fn_uniseder_get_fields($user_data, $user_field, $list_name = '', $lang_code = DESCR_SL) { static $profile_fields = array(); if (empty($profile_fields)) { $profile_fields = db_get_hash_array("SELECT field_id, field_name, field_type FROM ?:profile_fields", "field_id"); } $unisender_fields = fn_unisender_get_unisender_fields(); $data = array(); $data['email'] = $user_data['email']; if (!empty($list_name)) { $data['email_list_ids'] = $list_name; } $data['email_status'] = 'active'; $data['phone'] = !empty($user_data['phone']) ? $user_data['phone'] : ''; if (!empty($list_name)) { $data['phone_list_ids'] = $list_name; } $data['phone_status'] = 'active'; $fields = array('value', 'field_id', "CONVERT(GROUP_CONCAT(`value_id` SEPARATOR ',') USING utf8) as variants"); $join = db_quote("LEFT JOIN ?:profile_field_values USING(field_id)"); $user_profile_data = array(); if (!empty($user_data['user_id'])) { $user_profile_data = db_get_hash_array("SELECT ?p FROM ?:profile_fields_data ?p WHERE object_type = 'U' AND object_id = ?i GROUP BY field_id", "field_id", implode(',', $fields), $join, $user_data['user_id']); } foreach ($user_profile_data as $field_id => $field_data) { if (!empty($field_data['variants'])) { $user_profile_data[$field_id]['variant'] = db_get_field("SELECT description FROM ?:profile_field_descriptions WHERE object_id = ?i AND object_type = 'V' AND lang_code = ?s", $field_data['value'], $lang_code); } } foreach ($user_field as $unisender_field_id => $profile_field_id) { $unisender_field = $unisender_fields[$unisender_field_id]['name']; if (!empty($profile_fields[$profile_field_id]['field_name'])) { $field_name = $profile_fields[$profile_field_id]['field_name']; $data[$unisender_field] = !empty($user_data[$field_name]) ? $user_data[$field_name] : ''; } elseif (isset($user_profile_data[$profile_field_id])) { $data[$unisender_field] = !empty($user_profile_data[$profile_field_id]['variant']) ? $user_profile_data[$profile_field_id]['variant'] : $user_profile_data[$profile_field_id]['value']; } else { $data[$unisender_field] = ""; } if ($profile_fields[$profile_field_id]['field_type'] == 'C') { if ($data[$unisender_field] == 'Y') { $data[$unisender_field] = true; } else { $data[$unisender_field] = false; } } } return $data; }