@param string $phone_number
@param string $first_name
@param string $last_name
@param string $user_id
@param string $vcard

@return Contact
772921
public static function create($phone_number, $first_name, $last_name, $user_id, $vcard = null)
    {
        return new self($phone_number, $first_name, $last_name, $user_id, $vcard);
    }
991910
public static function vCard($name, $address = '', $locality = '', $state = '', $zip = '', $email = '')
    {
        $items   = array();
        $items[] = \CHtml::tag('li', array('class' => 'fn'), $name);
        $items[] = \CHtml::tag('li', array('class' => 'street-address'), $address);
        $items[] = \CHtml::tag('li', array('class' => 'locality'), $locality);
        $sub     = array();
        $sub[]   = \CHtml::tag('span', array('class' => 'state'), $state);
        $sub[]   = \CHtml::tag('span', array('class' => 'zip'), $zip);
        $items[] = \CHtml::tag('li', array(), implode(", ", $sub));
        $items[] = \CHtml::tag('li', array('class' => 'email'), $email);

        return \CHtml::tag('ul', array('class' => 'vcard'), implode("\n", $items));
    }
208054
def getContact(self, user=None, channel=None):
        
        try:
            return self.contacts[(channel, user)]
        except KeyError:
            new_contact = self.contactClass(self, user=user, channel=channel)
            self.contacts[(channel, user)] = new_contact
            new_contact.setServiceParent(self)
            return new_contact
1056350
public static function getBill($bill_id, $provider_id)
	{
		$bill = Bill::whereBillId($bill_id)
			->whereMerchantId($provider_id)
			->first();

		return $bill;
	}
1051800
public function validForCreation($first_name, $last_name, $email, $password)
	{
		return $this->validateUser($first_name, $last_name, $email, $password);
	}
272126
private function functionCall(Node $function_reference, $dynamic = FALSE) {
    if ($dynamic) {
      $node = new CallbackCallNode();
      $node->addChild($function_reference, 'callback');
    }
    else {
      if ($function_reference instanceof NameNode && $function_reference->childCount() === 1 && $function_reference == 'define') {
        $node = new DefineNode();
      }
      else {
        $node = new FunctionCallNode();
      }
      $node->addChild($function_reference, 'name');
    }
    $this->functionCallParameterList($node);
    return $this->objectDereference($this->arrayDeference($node));
  }
311628
def send_contact(self, phone_number, first_name, **options):
        
        return self.bot.api_call(
            "sendContact",
            chat_id=self.id,
            phone_number=phone_number,
            first_name=first_name,
            **options
        )
565943
function vCard() {

  if( !(this instanceof vCard) )
    return new vCard()

  /** @type {String} Version number */
  this.version = vCard.versions[ vCard.versions.length - 1 ]
  /** @type {Object} Card data */
  this.data = {}

}
1096046
public static function create_contact_request(int $userid, int $requesteduserid) : \stdClass {
        global $DB, $PAGE;

        $request = new \stdClass();
        $request->userid = $userid;
        $request->requesteduserid = $requesteduserid;
        $request->timecreated = time();

        $request->id = $DB->insert_record('message_contact_requests', $request);

        // Send a notification.
        $userfrom = \core_user::get_user($userid);
        $userfromfullname = fullname($userfrom);
        $userto = \core_user::get_user($requesteduserid);
        $url = new \moodle_url('/message/pendingcontactrequests.php');

        $subject = get_string('messagecontactrequestsnotificationsubject', 'core_message', $userfromfullname);
        $fullmessage = get_string('messagecontactrequestsnotification', 'core_message', $userfromfullname);

        $message = new \core\message\message();
        $message->courseid = SITEID;
        $message->component = 'moodle';
        $message->name = 'messagecontactrequests';
        $message->notification = 1;
        $message->userfrom = $userfrom;
        $message->userto = $userto;
        $message->subject = $subject;
        $message->fullmessage = text_to_html($fullmessage);
        $message->fullmessageformat = FORMAT_HTML;
        $message->fullmessagehtml = $fullmessage;
        $message->smallmessage = '';
        $message->contexturl = $url->out(false);
        $userpicture = new \user_picture($userfrom);
        $userpicture->includetoken = $userto->id; // Generate an out-of-session token for the user receiving the message.
        $message->customdata = [
            'notificationiconurl' => $userpicture->get_url($PAGE)->out(false),
            'actionbuttons' => [
                'accept' => get_string_manager()->get_string('accept', 'moodle', null, $userto->lang),
                'reject' => get_string_manager()->get_string('reject', 'moodle', null, $userto->lang),
            ],
        ];

        message_send($message);

        return $request;
    }
97301
public static function cleanup($vcard)
    {
        // convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility
        $vcard = preg_replace_callback(
            '/item(\d+)\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./s',
            array('self', 'x_abrelatednames_callback'),
            $vcard);

        // Cleanup
        $vcard = preg_replace(array(
                // convert special types (like Skype) to normal type='skype' classes with this simple regex ;)
                '/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./si',
                '/^item\d*\.X-AB.*$/mi',  // remove cruft like item1.X-AB*
                '/^item\d*\./mi',         // remove item1.ADR instead of ADR
                '/\n+/',                 // remove empty lines
                '/^(N:[^;\R]*)$/m',      // if N doesn't have any semicolons, add some
            ),
            array(
                '\2;type=\5\3:\4',
                '',
                '',
                "\n",
                '\1;;;;',
            ), $vcard);

        // convert X-WAB-GENDER to X-GENDER
        if (preg_match('/X-WAB-GENDER:(\d)/', $vcard, $matches)) {
            $value = $matches[1] == '2' ? 'male' : 'female';
            $vcard = preg_replace('/X-WAB-GENDER:\d/', 'X-GENDER:' . $value, $vcard);
        }

        return $vcard;
    }
945127
def to_array(self):
        
        array = super(Contact, self).to_array()
        array['phone_number'] = u(self.phone_number)  # py2: type unicode, py3: type str

        array['first_name'] = u(self.first_name)  # py2: type unicode, py3: type str

        if self.last_name is not None:
            array['last_name'] = u(self.last_name)  # py2: type unicode, py3: type str

        if self.user_id is not None:
            array['user_id'] = int(self.user_id)  # type int
        if self.vcard is not None:
            array['vcard'] = u(self.vcard)  # py2: type unicode, py3: type str

        return array
710206
public function createSubscription($phoneNumber_, $shortCode_, $keyword_)
  {
  	
  	if ( strlen($phoneNumber_) == 0 || strlen($shortCode_) == 0 || strlen($keyword_) == 0 ) {
      throw new AfricasTalkingGatewayException('Please supply phoneNumber, shortCode and keyword');
    }
    
    $params = array(
		    'username'    => $this->_username,
		    'phoneNumber' => $phoneNumber_,
		    'shortCode'   => $shortCode_,
		    'keyword'     => $keyword_
		    );
    
    $this->_requestUrl  = self::SUBSCRIPTION_URL."/create";
    $this->_requestBody = http_build_query($params, '', '&');
    
    $this->executePOST();
    
     if ( $this->_responseInfo['http_code'] != self::HTTP_CODE_CREATED )
     	throw new AfricasTalkingGatewayException($this->_responseBody);
     
    		return json_decode($this->_responseBody);
  }
1001501
@Programmatic
    public PhoneOrFaxNumber findByPhoneOrFaxNumber(
            final Object owner,
            final String phoneNumber) {

        final Optional<PhoneOrFaxNumber> phoneNumberIfFound = findByPhoneOrFaxNumber(owner, phoneNumber, CommunicationChannelType.PHONE_NUMBER);
        if(phoneNumberIfFound.isPresent()) {
            return phoneNumberIfFound.get();
        }

        final Optional<PhoneOrFaxNumber> faxNumberIfFound = findByPhoneOrFaxNumber(owner, phoneNumber, CommunicationChannelType.FAX_NUMBER);
        return faxNumberIfFound.orNull();
    }
591726
function one_user_info($first = FALSE, $username = NULL, $fields = NULL, $group_cn_cache_only = FALSE, $groups_filtering = '', $in_groups_filtering = array())
	{
        $this->_warning_message = '';
		$sr = FALSE;
		if ($first) {
			if ($username==NULL){ return (false); }
			if (!$this->_bind_paged){ return (false); }
            if  ('' == $this->_users_dn) {
                $this->_users_dn = $this->_base_dn;
            }

            if (1 == $this->_ldap_server_type) { // Active Directory
                $filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(".$this->_cn_identifier."=".$username.")".$groups_filtering.")";
                if ($fields==NULL){ $fields=array($this->_cn_identifier,"mail",$this->_group_attribute,"department","description","displayname","telephonenumber","primarygroupid","distinguishedname"); }
            } elseif (3 == $this->_ldap_server_type) { // legacy Active Directory
                $filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(".$this->_cn_identifier."=".$username."))";
                if ($fields==NULL){ $fields=array($this->_cn_identifier,"mail",$this->_group_attribute,"department","description","displayname","telephonenumber","primarygroupid","distinguishedname"); }
            } else { // Generic LDAP (2) or others
                $filter = "(&(objectClass=posixAccount)(".$this->_cn_identifier."=".$username."))";
                if ($fields==NULL){ $fields=array($this->_cn_identifier,"mail",$this->_group_attribute,"department","gecos","description","displayname","telephonenumber","gidnumber","distinguishedname"); }
            }
			$this->_oui_paged_sr = @ldap_search($this->_conn_paged,$this->_users_dn,$filter,$fields);
            if (4 == ldap_errno($this->_conn_paged)) {
                $cr = @ldap_count_entries($this->_conn_paged,$this->_oui_paged_sr);
                $this->_warning_message = "LDAP server cannot return more than $cr records.";
            }
            // echo "DEBUG: Error: ".ldap_errno($this->_conn_paged);
            // $cr = ldap_count_entries($this->_conn_paged,$sr);
            // echo $cr;
            // echo "DEBUG: Error: ".ldap_errno($this->_conn_paged);
		}
		if ($one_entry = $this->ldap_get_one_entry_raw("ONE_USER", $first, $this->_oui_paged_sr, $this->_conn_paged)) {
            // AD does not return the primary group in the ldap query, we may need to fudge it
            // SysCo/al added a test to check if $entries[0]["primarygroupid"][0] exists
            $add_primary_group = FALSE;
            if ($this->_real_primarygroup) {
                if (isset($one_entry["primarygroupid"][0])) {
                    $pri_grp_rid = $one_entry["primarygroupid"][0];
                    if (isset($this->_cache_group_dn[$pri_grp_rid])) {
                        $dn_group = $this->_cache_group_dn[$pri_grp_rid];
                        $one_entry[$this->_group_attribute][] = $dn_group;
                        $add_primary_group = TRUE;
                    } else {
                        $r = ldap_read($this->_conn, $this->_base_dn, "(objectclass=*)", array("objectSid")) or exit();
                        $data = ldap_get_entries($this->_conn, $r);
                        if (isset($data[0]["objectsid"][0])) {
                            $domain_sid = $data[0]["objectsid"][0];
                            $domain_sid_s = sid2str($domain_sid);
                            $r = ldap_search($this->_conn, $this->_base_dn, "objectSid=".$domain_sid_s."-".$pri_grp_rid, array("distinguishedname")) or exit();
                            $data = ldap_get_entries($this->_conn, $r);
                            if (isset($data[0]["distinguishedname"][0])) {
                                $dn_group = $data[0]["distinguishedname"][0];
                                $one_entry[$this->_group_attribute][] = $dn_group;
                                $add_primary_group = TRUE;
                                if (count($this->_cache_group_dn) < 1000) { // Don't overload the memory cache
                                    $this->_cache_group_dn[$pri_grp_rid] = $dn_group;
                                }
                            }
                        }
                    }
                }
            } else {
                $one_entry[$this->_group_attribute][]="CN=Domain Users,CN=Users,".$this->_base_dn;
                $add_primary_group = TRUE;
            }

            if ($add_primary_group) {
                @$one_entry[$this->_group_attribute]["count"]++;
            }
            
            if ((1 == $this->_ldap_server_type) && ( '' != $groups_filtering)) { // Active Directory (but not legacy)
                // Add the nested groups of the user
                $filter = "(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=".$one_entry[$this->_cn_identifier][0].")".$groups_filtering.")";
                $internal_fields = array("cn");
                $sr = ldap_search($this->_conn,$this->_base_dn,$filter, $internal_fields);
                $group_entries = $this->rCountRemover(ldap_get_entries($this->_conn, $sr));
                $group_array = array();
                foreach ($group_entries as $group_entry) {
                    $group_array[] = $group_entry['cn'][0];
                }
                foreach($group_array as $one_group) {
                    $add_it = TRUE;
                    foreach($this->nice_names($one_entry[$this->_group_attribute]) as $level_one_group) {
                        if (strpos($one_group, $level_one_group) !== FALSE) {
                            $add_it = FALSE;
                        }
                    }
                    if ($add_it) {
                        $one_entry[$this->_group_attribute][] = $one_group;
                        @$one_entry[$this->_group_attribute]["count"]++;
                    }
                }

                // Adding all implicit groups if needed
                foreach($in_groups_filtering as $one_group_filtering) {
                    $filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(".$this->_cn_identifier."=".$one_entry[$this->_cn_identifier][0].")".$one_group_filtering['distinguishedname'].")";
                    $internal_fields = array("cn");
                    $sr = ldap_search($this->_conn,$this->_base_dn,$filter, $internal_fields);
                    if (ldap_count_entries($this->_conn, $sr) > 0) {
                        $add_it = TRUE;
                        foreach($this->nice_names($one_entry[$this->_group_attribute]) as $level_one_group) {
                            if (strpos($one_group_filtering['name'], $level_one_group) !== FALSE) {
                                $add_it = FALSE;
                            }
                        }
                        if ($add_it) {
                            $one_entry[$this->_group_attribute][] = $one_group_filtering['name'];
                            @$one_entry[$this->_group_attribute]["count"]++;
                        }
                    }
                }
            }
		}
		return ($one_entry);
    }
984108
public function getContactsByUser(
        User $user,
        $orderedBy = 'lastName',
        $order = 'ASC',
        $executeQuery = true
    )
    {
        return $this->contactRepo->findContactsByUser(
            $user,
            $orderedBy,
            $order, 
            $executeQuery
        );
    }
121204
public static function LasyClassVarConstAccessCallback ($name, $call_back) {
		if (!static::HasClassVar($name)) {
			static::$_ApplicationVariableTrait_Data[$name] = $call_back();
			static::$_ApplicationVariableTrait_ConstList[implode('=>', Arrays::AdjustArray($name))] = true;
		}
		return static::$_ApplicationVariableTrait_Data[$name];
	}
1237227
function save_vcard()
    {
        $this->add_texts('localization', true);

        $uid     = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
        $mbox    = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
        $mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);

        $rcmail  = rcmail::get_instance();
        $message = new rcube_message($uid, $mbox);

        if ($uid && $mime_id) {
            list($mime_id, $index) = explode(':', $mime_id);
            $part = $message->get_part_content($mime_id, null, true);
        }

        $error_msg = $this->gettext('vcardsavefailed');

        if ($part && ($vcards = rcube_vcard::import($part))
            && ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email
        ) {
            $CONTACTS = $this->get_address_book();
            $email    = $vcard->email[0];
            $contact  = $vcard->get_assoc();
            $valid    = true;

            // skip entries without an e-mail address or invalid
            if (empty($email) || !$CONTACTS->validate($contact, true)) {
                $valid = false;
            }
            else {
                // We're using UTF8 internally
                $email = rcube_utils::idn_to_utf8($email);

                // compare e-mail address
                $existing = $CONTACTS->search('email', $email, 1, false);
                // compare display name
                if (!$existing->count && $vcard->displayname) {
                    $existing = $CONTACTS->search('name', $vcard->displayname, 1, false);
                }

                if ($existing->count) {
                    $rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning');
                    $valid = false;
                }
            }

            if ($valid) {
                $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null));
                $contact = $plugin['record'];

                if (!$plugin['abort'] && $CONTACTS->insert($contact))
                    $rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation');
                else
                    $rcmail->output->command('display_message', $error_msg, 'error');
            }
        }
        else {
            $rcmail->output->command('display_message', $error_msg, 'error');
        }

        $rcmail->output->send();
    }