NotificationTarget::getUserByField PHP Method

getUserByField() public method

Add user to the notified users list
public getUserByField ( $field, $search_in_object = false )
$field look for user looking for this field in the object which raises the event
$search_in_object search is done in the object ? if not in target object (false by default)
    function getUserByField($field, $search_in_object = false)
    {
        global $DB;
        $id = array();
        if (!$search_in_object) {
            $id[] = $this->obj->getField($field);
        } else {
            if (!empty($this->target_object)) {
                foreach ($this->target_object as $val) {
                    $id[] = $val->fields[$field];
                }
            }
        }
        if (!empty($id)) {
            //Look for the user by his id
            $query = $this->getDistinctUserSql() . "\n                  FROM `glpi_users`" . $this->getProfileJoinSql() . "\n                  WHERE `glpi_users`.`id` IN ('" . implode("','", $id) . "')";
            foreach ($DB->request($query) as $data) {
                //Add the user email and language in the notified users list
                $this->addToAddressesList($data);
            }
        }
    }