/** * Get subregion of current Item * * @param array params * @return string Subregion name */ function get_subregion($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('before' => '', 'after' => ''), $params); $this->load_Blog(); if ($this->subrg_ID == 0 || !$this->subregion_visible()) { // Subregion is not defined for current Item return; } load_class('regional/model/_subregion.class.php', 'Subregion'); $SubregionCache =& get_SubregionCache(); if ($Subregion = $SubregionCache->get_by_ID($this->subrg_ID)) { // Display subregion name $result = $params['before']; $result .= $Subregion->get_name(); $result .= $params['after']; return $result; } }
/** * Get regional data (Used to get regional IDs for user & item by regional names) * * @param string Country code * @param string Region name * @param string Subregion name * @param string City name * @return array Regional data */ function wp_get_regional_data($country_code, $region, $subregion, $city) { $data = array('country' => 0, 'region' => 0, 'subregion' => 0, 'city' => 0); if (!empty($country_code)) { // Get country ID from DB by code $CountryCache =& get_CountryCache(); if ($Country =& $CountryCache->get_by_name($country_code, false)) { $data['country'] = $Country->ID; if (!empty($region)) { // Get region ID from DB by name $RegionCache =& get_RegionCache(); if ($Region =& $RegionCache->get_by_name($region, false)) { if ($Region->ctry_ID == $data['country']) { $data['region'] = $Region->ID; if (!empty($subregion)) { // Get subregion ID from DB by name $SubregionCache =& get_SubregionCache(); if ($Subregion =& $SubregionCache->get_by_name($subregion, false)) { if ($Subregion->rgn_ID == $data['region']) { $data['subregion'] = $Subregion->ID; } } } if (!empty($city)) { // Get city ID from DB by name $CityCache =& get_CityCache(); if ($City =& $CityCache->get_by_name($city, false)) { if ($City->rgn_ID == $data['region']) { $data['city'] = $City->ID; } } } } } } } } return $data; }
* @var User */ global $current_User; // Check minimum permission: $current_User->check_perm('options', 'view', true); // Memorize this as the last "tab" used in the Global Settings: $UserSettings->set('pref_glob_settings_tab', $ctrl); $UserSettings->set('pref_glob_regional_tab', $ctrl); $UserSettings->dbupdate(); // Set options path: $AdminUI->set_path('options', 'regional', 'subregions'); // Get action parameter from request: param_action(); if (param('subrg_ID', 'integer', '', true)) { // Load subregion from cache: $SubregionCache =& get_SubregionCache(); if (($edited_Subregion =& $SubregionCache->get_by_ID($subrg_ID, false)) === false) { unset($edited_Subregion); forget_param('subrg_ID'); $Messages->add(sprintf(T_('Requested «%s» object does not exist any longer.'), T_('Region')), 'error'); $action = 'nil'; } } switch ($action) { case 'disable_subregion': case 'enable_subregion': // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('subregion'); // Disable a subregion only if it is enabled, and user has edit access. $current_User->check_perm('options', 'edit', true); // Make sure the subregion information was loaded. If not, just exit with error.