コード例 #1
0
 public function getCountryName()
 {
     $country = '';
     if ($this->Country) {
         $country = CountryCodes::countryCode2name($this->Country);
     }
     return $country;
 }
コード例 #2
0
ファイル: format.php プロジェクト: abhinay100/feng_app
function get_member_custom_property_value_for_listing($cp, $member_id, $cp_vals = null)
{
    if (is_null($cp_vals)) {
        $cp_vals = MemberCustomPropertyValues::getMemberCustomPropertyValues($member_id, $cp->getId());
    }
    $val_to_show = "";
    foreach ($cp_vals as $cp_val) {
        if (in_array($cp->getType(), array('contact', 'user')) && $cp_val instanceof MemberCustomPropertyValue) {
            $cp_contact = Contacts::findById($cp_val->getValue());
            if ($cp_contact instanceof Contact) {
                $cp_val->setValue($cp_contact->getObjectName());
            } else {
                $cp_val->setValue("");
            }
        }
        if ($cp->getType() == 'date' && $cp_val instanceof MemberCustomPropertyValue) {
            $format = user_config_option('date_format');
            Hook::fire("custom_property_date_format", null, $format);
            $tmp_date = DateTimeValueLib::dateFromFormatAndString(DATE_MYSQL, $cp_val->getValue());
            if (str_starts_with($cp_val->getValue(), EMPTY_DATE)) {
                $formatted = "";
            } else {
                if (str_ends_with($cp_val->getValue(), "00:00:00")) {
                    $formatted = $tmp_date->format(user_config_option('date_format'));
                } else {
                    $formatted = $tmp_date->format($format);
                }
            }
            $cp_val->setValue($formatted);
        }
        if ($cp->getType() == 'address' && $cp_val instanceof MemberCustomPropertyValue) {
            $values = str_replace("\\|", "%%_PIPE_%%", $cp_val->getValue());
            $exploded = explode("|", $values);
            foreach ($exploded as &$v) {
                $v = str_replace("%%_PIPE_%%", "|", $v);
                $v = str_replace("'", "\\'", $v);
            }
            if (count($exploded) > 0) {
                $address_type = array_var($exploded, 0, '');
                $street = array_var($exploded, 1, '');
                $city = array_var($exploded, 2, '');
                $state = array_var($exploded, 3, '');
                $country = array_var($exploded, 4, '');
                $zip_code = array_var($exploded, 5, '');
                $country_name = CountryCodes::getCountryNameByCode($country);
                $tmp = array();
                if ($street != '') {
                    $tmp[] = $street;
                }
                if ($city != '') {
                    $tmp[] = $city;
                }
                if ($state != '') {
                    $tmp[] = $state;
                }
                if ($zip_code != '') {
                    $tmp[] = $zip_code;
                }
                if ($country_name != '') {
                    $tmp[] = $country_name;
                }
                $cp_val->setValue(implode(' - ', $tmp));
            }
        }
        $val_to_show .= ($val_to_show == "" ? "" : ", ") . ($cp_val instanceof MemberCustomPropertyValue ? $cp_val->getValue() : "");
    }
    $val_to_show = html_to_text($val_to_show);
    return $val_to_show;
}
コード例 #3
0
	function buildCompanyData($position, $checked, $fields) {
		$contact_data = array();
		if (isset($checked['first_name']) && $checked['first_name']) $contact_data['first_name'] = array_var($fields, $position['first_name']);
		if (isset($checked['email']) && $checked['email']) $contact_data['email'] = array_var($fields, $position['email']);
		if (isset($checked['homepage']) && $checked['homepage']) $contact_data['homepage'] = array_var($fields, $position['homepage']);
		if (isset($checked['address']) && $checked['address']) $contact_data['address'] = array_var($fields, $position['address']);
		if (isset($checked['address2']) && $checked['address2']) $contact_data['address2'] = array_var($fields, $position['address2']);
		if (isset($checked['city']) && $checked['city']) $contact_data['city'] = array_var($fields, $position['city']);
		if (isset($checked['state']) && $checked['state']) $contact_data['state'] = array_var($fields, $position['state']);
		if (isset($checked['zipcode']) && $checked['zipcode']) $contact_data['zipcode'] = array_var($fields, $position['zipcode']);
		if (isset($checked['country']) && $checked['country']) $contact_data['country'] = CountryCodes::getCountryCodeByName(array_var($fields, $position['country']));
		if (isset($checked['phone_number']) && $checked['phone_number']) $contact_data['phone_number'] = array_var($fields, $position['phone_number']);
		if (isset($checked['fax_number']) && $checked['fax_number']) $contact_data['fax_number'] = array_var($fields, $position['fax_number']);
		if (isset($checked['notes']) && $checked['notes']) $contact_data['notes'] = array_var($fields, $position['notes']);
		$contact_data['timezone'] = logged_user()->getTimezone();
		
		return $contact_data;
	}
コード例 #4
0
 /**
  * Builds minfraud query from user input
  *
  * Required:
  * - city
  * - country
  * - i: Client IPA
  * - license_key
  * - postal
  * - region
  *
  * Optional that we are sending:
  * - bin: First 6 digits of the card
  * - domain: send the domain of the email address
  * - emailMD5: send an MD5 of the email address
  * - txnID: The internal transaction id of the contribution.
  *
  * @param array $data
  * @return array containing hash for minfraud query
  */
 protected function build_query(array $data)
 {
     // mapping of data keys -> minfraud array keys
     $map = array("city" => "city", "region" => "state", "postal" => "zip", "country" => "country", "domain" => "email", "emailMD5" => "email", "bin" => "card_num", "txnID" => "contribution_tracking_id");
     $this->minfraudQuery = array();
     // minfraud license key
     $this->minfraudQuery["license_key"] = $this->minfraudLicenseKey;
     // user's IP address
     $this->minfraudQuery["i"] = $this->gateway_adapter->getData_Unstaged_Escaped('user_ip');
     // We only have access to these fields when the user's request is still
     // present, but not when in batch mode.
     if (!$this->gateway_adapter->isBatchProcessor()) {
         // user's user agent
         $this->minfraudQuery['user_agent'] = WmfFramework::getRequestHeader('user-agent');
         // user's language
         $this->minfraudQuery['accept_language'] = WmfFramework::getRequestHeader('accept-language');
     }
     // fetch the array of country codes
     $country_codes = CountryCodes::getCountryCodes();
     // loop through the map and add pertinent values from $data to the hash
     foreach ($map as $key => $value) {
         // do some data processing to clean up values for minfraud
         switch ($key) {
             case "domain":
                 // get just the domain from the email address
                 $newdata[$value] = substr(strstr($data[$value], '@'), 1);
                 break;
             case "bin":
                 // get just the first 6 digits from CC#... if we have one.
                 $bin = '';
                 if (isset($data[$value])) {
                     $bin = substr($data[$value], 0, 6);
                 }
                 $newdata[$value] = $bin;
                 break;
             case "country":
                 $newdata[$value] = $country_codes[$data[$value]];
                 break;
             case "emailMD5":
                 $newdata[$value] = $this->get_ccfd()->filter_field($key, $data[$value]);
                 break;
             default:
                 $newdata[$value] = $data[$value];
         }
         $this->minfraudQuery[$key] = $newdata[$value];
     }
     return $this->minfraudQuery;
 }
コード例 #5
0
 function Countries()
 {
     return CountryCodes::asObject();
 }
コード例 #6
0
ファイル: form.php プロジェクト: rorteg/fengoffice
/**
 * Show select country box
 *
 * @access public
 * @param string $name Control name
 * @param string $value Country code of selected country
 * @param array $attributes Array of additional select box attributes
 * @return string
 */
function select_country_widget($name, $value, $attributes = null)
{
    $country_codes = array_keys(CountryCodes::getAll());
    $countries = array();
    foreach ($country_codes as $code) {
        if (Localization::instance()->lang_exists("country {$code}")) {
            $countries[$code] = lang("country {$code}");
        } else {
            $countries[$code] = CountryCodes::getCountryNameByCode($code);
        }
    }
    // foreach
    asort($countries);
    $country_options = array(option_tag(lang('none'), ''));
    foreach ($countries as $country_code => $country_name) {
        $option_attributes = $country_code == $value ? array('selected' => true) : null;
        $country_options[] = option_tag($country_name, $country_code, $option_attributes);
    }
    // foreach
    return select_box($name, $country_options, $attributes);
}
コード例 #7
0
ファイル: form.php プロジェクト: bahmany/PythonPurePaperless
/**
 * Show select country box
 *
 * @access public
 * @param string $name Control name
 * @param string $value Country code of selected country
 * @param array $attributes Array of additional select box attributes
 * @return string
 */
function select_country_widget($name, $value, $attributes = null)
{
    $country_codes = array_keys(CountryCodes::getAll());
    $countries = array();
    foreach ($country_codes as $code) {
        $countries[$code] = lang("country {$code}");
    }
    // foreach
    asort($countries);
    $country_options = array(option_tag(lang('none'), ''));
    foreach ($countries as $country_code => $country_name) {
        $option_attributes = $country_code == $value ? array('selected' => true) : null;
        $country_options[] = option_tag($country_name, $country_code, $option_attributes);
    }
    // foreach
    return select_box($name, $country_options, $attributes);
}
コード例 #8
0
 private function read_vcard_file($filename, $only_first_record = false)
 {
     $handle = fopen($filename, 'rb');
     if (!$handle) {
         flash_error(lang('file not exists'));
         ajx_current("empty");
         return;
     }
     // parse VCard blocks
     $in_block = true;
     $results = array();
     while (($line = fgets($handle)) !== false) {
         if (preg_match('/^BEGIN:VCARD/', $line)) {
             // START OF CONTACT
             $in_block = true;
             $block_data = array();
         } else {
             if (preg_match('/^END:VCARD/', $line)) {
                 // END OF CONTACT
                 $in_block = false;
                 if (isset($photo_data)) {
                     if (isset($photo_data)) {
                         $filename = ROOT . "/tmp/" . rand() . ".{$photo_type}";
                         $f_handle = fopen($filename, "wb");
                         fwrite($f_handle, base64_decode($photo_data));
                         fclose($f_handle);
                         $block_data['photo_tmp_filename'] = $filename;
                     }
                 }
                 unset($photo_data);
                 unset($photo_enc);
                 unset($photo_type);
                 $results[] = $block_data;
                 if ($only_first_record && count($results) > 0) {
                     return $results;
                 }
             } else {
                 if (preg_match('/^N(:|;charset=[-a-zA-Z0-9.]+:)([^;]*);([^;]*)/i', $line, $matches)) {
                     // NAME
                     $block_data["firstname"] = trim($matches[count($matches) - 1]);
                     $block_data["lastname"] = trim($matches[count($matches) - 2]);
                 } else {
                     if (preg_match('/^ORG(:|;charset=[-a-zA-Z0-9.]+:)([^;]*)/i', $line, $matches)) {
                         // ORGANIZATION
                         $block_data["company_name"] = str_replace(array("\r\n", "\n", "\r", "\t", '\\r\\n', '\\n', '\\r', '\\t'), " ", trim($matches[2]));
                     } else {
                         if (preg_match('/^NOTE(:|;charset=[-a-zA-Z0-9.]+:)([^;]*)/i', $line, $matches)) {
                             // NOTES
                             $block_data["notes"] = trim($matches[count($matches) - 1]);
                         } else {
                             if (preg_match('/EMAIL;type=(PREF,)?INTERNET(,PREF)?(;type=(HOME|WORK))?(;type=PREF)?:([-a-zA-Z0-9_.]+@[-a-zA-Z0-9.]+)/i', $line, $matches)) {
                                 // EMAIL
                                 $email = trim($matches[count($matches) - 1]);
                                 if (!isset($block_data["email"])) {
                                     $block_data["email"] = $email;
                                 } else {
                                     if (!isset($block_data["email2"])) {
                                         $block_data["email2"] = $email;
                                     } else {
                                         if (!isset($block_data["email3"])) {
                                             $block_data["email3"] = $email;
                                         }
                                     }
                                 }
                             } else {
                                 if (preg_match('/URL(;type=(HOME|WORK))?.*?:(.+)/i', $line, $matches)) {
                                     // WEB URL
                                     $url = trim($matches[3]);
                                     $url = str_replace(array("\r\n", "\n", "\r", "\t", '\\r\\n', '\\n', '\\r', '\\t'), " ", $url);
                                     if ($matches[2] == "HOME") {
                                         $block_data['h_web_page'] = $url;
                                     } else {
                                         if ($matches[2] == "WORK") {
                                             $block_data['w_web_page'] = $url;
                                         } else {
                                             $block_data['o_web_page'] = $url;
                                         }
                                     }
                                 } else {
                                     if (preg_match('/TEL(;type=(HOME|WORK|CELL|FAX)[,A-Z]*)?.*:(.+)/i', $line, $matches)) {
                                         // PHONE
                                         $phone = trim($matches[3]);
                                         $phone = str_replace(array("\r\n", "\n", "\r", "\t", '\\r\\n', '\\n', '\\r', '\\t'), " ", $phone);
                                         if ($matches[2] == "HOME") {
                                             $block_data["h_phone_number"] = $phone;
                                         } else {
                                             if ($matches[2] == "CELL") {
                                                 $block_data["h_mobile_number"] = $phone;
                                             } else {
                                                 if ($matches[2] == "WORK") {
                                                     $block_data["w_phone_number"] = $phone;
                                                 } else {
                                                     if ($matches[2] == "FAX") {
                                                         $block_data["w_fax_number"] = $phone;
                                                     } else {
                                                         $block_data["o_phone_number"] = $phone;
                                                     }
                                                 }
                                             }
                                         }
                                     } else {
                                         if (preg_match('/ADR;type=(HOME|WORK|[A-Z0-9]*)[,A-Z]*(:|;charset=[-a-zA-Z0-9.]+:|;type=pref:);;([^;]*);([^;]*);([^;]*);([^;]*);([^;]*)/i', $line, $matches)) {
                                             // ADDRESS
                                             // $matches is
                                             // [1] <-- street
                                             // [2] <-- city
                                             // [3] <-- state
                                             // [4] <-- zip
                                             // [5] <-- country
                                             $addr = array_slice($matches, count($matches) - 5);
                                             foreach ($addr as $k => $v) {
                                                 $addr[$k] = str_replace(array("\r\n", "\n", "\r", "\t", '\\r\\n', '\\n', '\\r', '\\t'), " ", trim($v));
                                             }
                                             if ($matches[1] == "HOME") {
                                                 $block_data["h_address"] = $addr[0];
                                                 $block_data["h_city"] = $addr[1];
                                                 $block_data["h_state"] = $addr[2];
                                                 $block_data["h_zipcode"] = $addr[3];
                                                 $block_data["h_country"] = CountryCodes::getCountryCodeByName($addr[4]);
                                             } else {
                                                 if ($matches[1] == "WORK") {
                                                     $block_data["w_address"] = $addr[0];
                                                     $block_data["w_city"] = $addr[1];
                                                     $block_data["w_state"] = $addr[2];
                                                     $block_data["w_zipcode"] = $addr[3];
                                                     $block_data["w_country"] = CountryCodes::getCountryCodeByName($addr[4]);
                                                 } else {
                                                     $block_data["o_address"] = $addr[0];
                                                     $block_data["o_city"] = $addr[1];
                                                     $block_data["o_state"] = $addr[2];
                                                     $block_data["o_zipcode"] = $addr[3];
                                                     $block_data["o_country"] = CountryCodes::getCountryCodeByName($addr[4]);
                                                 }
                                             }
                                         } else {
                                             if (preg_match('/^BDAY[;value=date]*:([0-9]+)-([0-9]+)-([0-9]+)/i', $line, $matches)) {
                                                 // BIRTHDAY
                                                 // $matches[1]  <-- year     $matches[2]  <-- month    $matches[3]  <-- day
                                                 $block_data["o_birthday"] = $matches[1] . '-' . $matches[2] . '-' . $matches[3] . "00:00:00";
                                             } else {
                                                 if (preg_match('/TITLE(:|;charset=[-a-zA-Z0-9.]+:)(.*)/i', $line, $matches)) {
                                                     // JOB TITLE
                                                     $block_data["job_title"] = str_replace(array("\r\n", "\n", "\r", "\t", '\\r\\n', '\\n', '\\r', '\\t'), " ", trim($matches[2]));
                                                 } else {
                                                     if (preg_match('/PHOTO(;ENCODING=(b|BASE64)?(;TYPE=([-a-zA-Z.]+))|;VALUE=uri):(.*)/i', $line, $matches)) {
                                                         foreach ($matches as $k => $v) {
                                                             if (str_starts_with(strtoupper($v), ";ENCODING")) {
                                                                 $enc_idx = $k + 1;
                                                             }
                                                             if (str_starts_with(strtoupper($v), ";TYPE")) {
                                                                 $type_idx = $k + 1;
                                                             }
                                                             if (str_starts_with(strtoupper($v), ";VALUE=uri")) {
                                                                 $uri_idx = $k + 1;
                                                             }
                                                         }
                                                         if (isset($enc_idx) && isset($type_idx)) {
                                                             $photo_enc = $matches[$enc_idx];
                                                             $photo_type = $matches[$type_idx];
                                                             $photo_data = str_replace(array("\r\n", "\n", "\r", "\t"), "", trim($matches[count($matches) - 1]));
                                                         } else {
                                                             if (isset($uri_idx)) {
                                                                 $uri = trim($matches[count($matches) - 1]);
                                                                 $photo_type = substr($uri, strrpos($uri, "."));
                                                                 $data = file_get_contents(urldecode($uri));
                                                                 $filename = ROOT . "/tmp/" . rand() . ".{$photo_type}";
                                                                 $f_handle = fopen($filename, "wb");
                                                                 fwrite($f_handle, $data);
                                                                 fclose($f_handle);
                                                                 $block_data['photo_tmp_filename'] = $filename;
                                                             }
                                                         }
                                                     } else {
                                                         if (isset($photo_data) && isset($enc_idx) && isset($type_idx)) {
                                                             $photo_data .= str_replace(array("\r\n", "\n", "\r", "\t"), "", trim($line));
                                                         }
                                                         // unknown / ignored VCard field
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         unset($matches);
     }
     fclose($handle);
     return $results;
 }