Warning, file /webapps/ocs-webserver/application/modules/default/views/helpers/BuildMemberUrl.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class Default_View_Helper_BuildMemberUrl extends Zend_View_Helper_Abstract 0024 { 0025 0026 /** 0027 * @param int|string $member_ident 0028 * @param string $action 0029 * @param array $params 0030 * 0031 * @return string 0032 * @throws Zend_Exception 0033 */ 0034 public function buildMemberUrl($member_ident, $action = '', $params = null) 0035 { 0036 /** @var Zend_Controller_Request_Http $request */ 0037 $request = Zend_Controller_Front::getInstance()->getRequest(); 0038 $http_scheme = $request->getScheme(); 0039 0040 $baseurl = ''; 0041 0042 $http_host = $request->getHttpHost(); 0043 $http_scheme = isset($scheme) ? $scheme : $request->getScheme(); 0044 $host = $http_scheme . '://' . $http_host; 0045 0046 $storeId = null; 0047 if (false === isset($params['store_id'])) { 0048 if ($request->getParam('domain_store_id')) { 0049 $storeId = '/s/' . $request->getParam('domain_store_id'); 0050 } 0051 } else { 0052 $storeId = "/s/{$params['store_id']}"; 0053 unset($params['store_id']); 0054 } 0055 0056 //20190214 ronald: removed to stay in context, if set in store config 0057 $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null; 0058 0059 if(null != $storeConfig && $storeConfig->stay_in_context == false) { 0060 $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl_member; 0061 } else { 0062 //20191125 but if the url is a real domain, then we do not need the /s/STORE_NAME 0063 if($storeConfig->is_show_real_domain_as_url == true) { 0064 $baseurl = "{$host}"; 0065 } else { 0066 //otherwiese send to baseurl_member 0067 //$baseurl = "{$host}{$storeId}"; 0068 $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl_member; 0069 } 0070 } 0071 0072 0073 $url_param = ''; 0074 if (is_array($params)) { 0075 array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); 0076 $url_param = implode('/', $params); 0077 } 0078 0079 if ($action != '') { 0080 $action = $action . '/'; 0081 } 0082 0083 $member_ident = strtolower($member_ident); 0084 $member_ident = urlencode($member_ident); 0085 0086 $memberLink = "u"; 0087 if(is_int($member_ident)) { 0088 $memberLink = "member"; 0089 } 0090 0091 return "{$baseurl}/{$memberLink}/{$member_ident}/{$action}{$url_param}"; 0092 } 0093 0094 0095 /** 0096 * @param int $member_id 0097 * @param string $action 0098 * @param array $params 0099 * @param bool $withHost 0100 * @param string $scheme 0101 * 0102 * @return string 0103 */ 0104 /* 0105 public function buildMemberUrl($member_id, $action = '', $params = null, $withHost = false, $scheme = null) 0106 { 0107 $request = Zend_Controller_Front::getInstance()->getRequest(); 0108 0109 $host = ''; 0110 if ($withHost) { 0111 $http_scheme = isset($scheme) ? $scheme : $request->getScheme(); 0112 $host = $http_scheme . '://' . $request->getHttpHost(); 0113 } 0114 0115 $storeId = null; 0116 if (false === isset($params['store_id'])) { 0117 if ($request->getParam('domain_store_id')) { 0118 $storeId = 's/' . $request->getParam('domain_store_id') . '/'; 0119 } 0120 } else { 0121 $storeId = "s/{$params['store_id']}/"; 0122 unset($params['store_id']); 0123 } 0124 0125 $url_param = ''; 0126 if (is_array($params)) { 0127 array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); 0128 $url_param = implode('/', $params); 0129 } 0130 0131 if ($action != '') { 0132 $action = $action . '/'; 0133 } 0134 0135 return "{$host}/{$storeId}member/{$member_id}/{$action}{$url_param}"; 0136 } 0137 */ 0138 0139 public function buildExternalUrl($member_id, $action = null, $params = null) 0140 { 0141 $url_param = ''; 0142 if (is_array($params)) { 0143 array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); 0144 $url_param = implode('/', $params); 0145 } 0146 0147 if (isset($action)) { 0148 $action .= '/'; 0149 } 0150 0151 $member_host = Zend_Registry::get('config')->settings->member->page->server; 0152 0153 return "//{$member_host}/me/{$member_id}/{$action}{$url_param}"; 0154 } 0155 0156 }