[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * VigLink extension for the phpBB Forum Software package. 5 * 6 * @copyright (c) 2014 phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 */ 10 11 namespace phpbb\viglink\acp; 12 13 use phpbb\request\type_cast_helper; 14 15 /** 16 * VigLink ACP module 17 */ 18 class viglink_module 19 { 20 /** @var string $page_title The page title */ 21 public $page_title; 22 23 /** @var string $tpl_name The page template name */ 24 public $tpl_name; 25 26 /** @var string $u_action Custom form action */ 27 public $u_action; 28 29 public function main($id, $mode) 30 { 31 global $phpbb_container; 32 33 /** @var \phpbb\config\config $config Config object */ 34 $config = $phpbb_container->get('config'); 35 36 /** @var \phpbb\language\language $language Language object */ 37 $language = $phpbb_container->get('language'); 38 39 /** @var \phpbb\request\request $request Request object */ 40 $request = $phpbb_container->get('request'); 41 42 /** @var \phpbb\template\template $template Template object */ 43 $template = $phpbb_container->get('template'); 44 45 $language->add_lang('viglink_module_acp', 'phpbb/viglink'); 46 47 $this->tpl_name = 'acp_viglink'; 48 $this->page_title = $language->lang('ACP_VIGLINK_SETTINGS'); 49 50 $submit = $request->is_set_post('submit'); 51 52 if ($mode !== 'settings') 53 { 54 return; 55 } 56 57 $form_key = 'acp_viglink'; 58 add_form_key($form_key); 59 60 $error = array(); 61 62 // Get stored config/default values 63 $cfg_array = array( 64 'viglink_enabled' => isset($config['viglink_enabled']) ? $config['viglink_enabled'] : 0, 65 ); 66 67 // Error if the form is invalid 68 if ($submit && !check_form_key($form_key)) 69 { 70 $error[] = $language->lang('FORM_INVALID'); 71 } 72 73 // Do not process form if invalid 74 if (count($error)) 75 { 76 $submit = false; 77 } 78 79 if ($submit) 80 { 81 // Get the VigLink form field values 82 $cfg_array['viglink_enabled'] = $request->variable('viglink_enabled', 0); 83 84 // If no errors, set the config values 85 if (!count($error)) 86 { 87 foreach ($cfg_array as $cfg => $value) 88 { 89 $config->set($cfg, $value); 90 } 91 92 trigger_error($language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); 93 } 94 } 95 96 if (!isset($config['questionnaire_unique_id'])) 97 { 98 $config->set('questionnaire_unique_id', unique_id()); 99 } 100 101 // Set a general error message if VigLink has been disabled by phpBB 102 if (!$config['allow_viglink_phpbb']) 103 { 104 $error[] = $language->lang('ACP_VIGLINK_DISABLED_PHPBB'); 105 } 106 107 // Try to get convert account key from .com 108 $sub_id = md5($config['viglink_api_siteid'] . $config['questionnaire_unique_id']); 109 $convert_account_link = $config->offsetGet('viglink_convert_account_url'); 110 111 if (empty($convert_account_link) || strpos($config['viglink_convert_account_url'], 'subId=' . $sub_id) === false) 112 { 113 $convert_account_link = @file_get_contents('https://www.phpbb.com/viglink/convert?domain=' . urlencode($config['server_name']) . '&siteid=' . $config['viglink_api_siteid'] . '&uuid=' . $config['questionnaire_unique_id'] . '&key=' . $config['phpbb_viglink_api_key']); 114 if (!empty($convert_account_link) && strpos($convert_account_link, 'https://www.viglink.com/users/convertAccount') === 0) 115 { 116 $type_caster = new type_cast_helper(); 117 $type_caster->set_var($convert_account_link, $convert_account_link, 'string', false, false); 118 $config->set('viglink_convert_account_url', $convert_account_link); 119 } 120 else 121 { 122 $error[] = $language->lang('ACP_VIGLINK_NO_CONVERT_LINK'); 123 $convert_account_link = ''; 124 } 125 } 126 127 $template->assign_vars(array( 128 'S_ERROR' => (bool) count($error), 129 'ERROR_MSG' => implode('<br />', $error), 130 131 'VIGLINK_ENABLED' => $cfg_array['viglink_enabled'], 132 133 'U_VIGLINK_CONVERT' => $convert_account_link, 134 'U_ACTION' => $this->u_action, 135 )); 136 } 137 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |