예제 #1
0
 # Prepare display
 if ($Contact['phone_home'] != '') {
     $display['home'] = prepare_number($Contact['phone_home'], 1, $conf);
     $dial['home'] = prepare_number($Contact['phone_home'], 0, $conf);
 }
 if ($Contact['phone_work'] != '') {
     $display['work'] = prepare_number($Contact['phone_work'], 1, $conf);
     $dial['work'] = prepare_number($Contact['phone_work'], 0, $conf);
 }
 if ($Contact['phone_mobile'] != '') {
     $display['mobile'] = prepare_number($Contact['phone_mobile'], 1, $conf);
     $dial['mobile'] = prepare_number($Contact['phone_mobile'], 0, $conf);
 }
 if ($Contact['phone_other'] != '') {
     $display['other'] = prepare_number($Contact['phone_other'], 1, $conf);
     $dial['other'] = prepare_number($Contact['phone_other'], 0, $conf);
 }
 # Dialable object
 $object = new AastraIPPhoneTextMenu();
 $object->setDestroyOnExit();
 $object->setTitle($Contact['last_name'] . ' ' . $Contact['first_name']);
 if ($is_style_textmenu) {
     $object->setStyle('none');
 }
 $title = array('W' => Aastra_get_label('W', $language), 'M' => Aastra_get_label('M', $language), 'H' => Aastra_get_label('H', $language), 'O' => Aastra_get_label('O', $language));
 switch ($header['model']) {
     case 'Aastra480i':
     case 'Aastra480i Cordless':
         if ($display['work'] != '') {
             $object->addEntry($title['W'] . ' ' . $display['work'], $dial['work']);
         }
예제 #2
0
     $name = $directory[$index]['first'] . ' ' . $directory[$index]['last'];
 } else {
     $name = $directory[$index]['last'] . ' ' . $directory[$index]['first'];
 }
 if ($name == ' ') {
     $name = $directory[$index]['company'];
 }
 $conf_speed[$speed]['name'] = $name;
 if ($directory[$index]['work'] != '') {
     $conf_speed[$speed]['work'] = prepare_number($directory[$index]['work'], 2, $ARRAY_CONFIG['Dialplan']);
 }
 if ($directory[$index]['mobile'] != '') {
     $conf_speed[$speed]['mobile'] = prepare_number($directory[$index]['mobile'], 2, $ARRAY_CONFIG['Dialplan']);
 }
 if ($directory[$index]['home'] != '') {
     $conf_speed[$speed]['home'] = prepare_number($directory[$index]['home'], 2, $ARRAY_CONFIG['Dialplan']);
 }
 $conf_speed[$speed]['other'] = '';
 if ($asterisk) {
     Aastra_save_user_context(Aastra_get_userdevice_Asterisk($user), 'speed', $conf_speed);
 } else {
     Aastra_save_user_context($user, 'speed', $conf_speed);
 }
 # Display update
 require_once 'AastraIPPhoneTextScreen.class.php';
 $object = new AastraIPPhoneTextScreen();
 $object->setDestroyOnExit();
 $object->setTitle(Aastra_get_label('List Updated', $language));
 $object->setText(sprintf(Aastra_get_label('%s stored in speed dial list at position %d.', $language), $name, $speed + 1));
 # Softkeys
 if ($nb_softkeys) {
예제 #3
0
function query_ldap($lookup, $firstn, $lastn, $source)
{
    global $LANGUAGE;
    # Retrieve LDAP basic configuration
    $system = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '=');
    $LDAP_SERVER = $system[$source]['hostname'];
    $LDAP_PORT = $system[$source]['port'];
    $LDAP_ROOT_DN = $system[$source]['basedn'];
    $LDAP_USERDOMAIN = $system[$source]['userdomain'];
    $LDAP_USERNAME = $system[$source]['username'];
    $LDAP_PASSWORD = $system[$source]['userpassword'];
    ########################################### Advanced LDAP Configuration #########################################
    $LDAP_SIZELIMIT = 400;
    // limits the number of entries fetched. 0 means no limit.
    $LDAP_TIMELIMIT = 5;
    // max number of seconds spent on the search. 0 means no limit.
    # What additional attributes are retrieved from LDAP. Possible attributes: "title", "department", "company"
    #$LDAP_ADDITIONAL_ATTRIBUTES = array("title", "department", "company");
    # LDAP attribute mapping. Put empty string if attribute does not exist in LDAP.
    $LDAP_PHONE_ATTRIBUTE = 'telephonenumber';
    // name of the LDAP attribute that contains the office phone number
    $LDAP_MOBILE_ATTRIBUTE = 'mobile';
    // name of the LDAP attribute that contains the mobile (cell) phone number. "mobile" or "mobiletelephonenumber".
    $LDAP_HOMEPHONE_ATTRIBUTE = 'homephone';
    // name of the LDAP attribute that contains the home phone number, typically "homephone"
    ########################################### Advanced LDAP Configuration #########################################
    # Prepare search filter
    if ($lookup != '') {
        $searchfilter = '(|(sn=' . $lookup . '*)(givenName=' . $lookup . '*))';
    } else {
        if ($firstn != '' and $lastn != '') {
            $searchfilter = '(&(sn=' . $lastn . '*)(givenName=' . $firstn . '*))';
        } else {
            if ($firstn != '') {
                $searchfilter = '(givenName=' . $firstn . '*)';
            } else {
                $searchfilter = '(sn=' . $lastn . '*)';
            }
        }
    }
    # Refine searchfilter in order to exclude "contacts"
    #$searchfilter="(&".$searchfilter."(!(objectclass=contact)))";
    # Prepare LDAP attributes to look for
    $ldap_attribues = array('cn', 'sn', 'givenname');
    array_push($ldap_attribues, $LDAP_PHONE_ATTRIBUTE, $LDAP_MOBILE_ATTRIBUTE, $LDAP_HOMEPHONE_ATTRIBUTE);
    # Complete with optional attributes
    if (is_array($LDAP_ADDITIONAL_ATTRIBUTES)) {
        $ldap_attribues = array_merge($ldap_attribues, $LDAP_ADDITIONAL_ATTRIBUTES);
    }
    # Connect to LDAP SERVER
    $ds = ldap_connect($LDAP_SERVER, $LDAP_PORT);
    # Connected to the LDAPserver
    if ($ds) {
        # Bind type
        if (trim($LDAP_USERNAME) != '') {
            # bind with credentials
            if ($LDAP_USERDOMAIN != '') {
                $username = $LDAP_USERDOMAIN . chr(92) . $LDAP_USERNAME;
            } else {
                $username = $LDAP_USERNAME;
            }
            $lb = ldap_bind($ds, $username, $LDAP_PASSWORD);
        } else {
            # anonymous bind
            $lb = ldap_bind($ds);
        }
        # Bind successful
        if ($lb) {
            # Launch the search
            $sr = ldap_search($ds, $LDAP_ROOT_DN, $searchfilter, $ldap_attribues, 0, $LDAP_SIZELIMIT, $LDAP_TIMELIMIT);
            # Search is successful
            if ($sr) {
                # Retrieve dialplan configuration
                $dialplan = $system['Dialplan'];
                # Convert comma/semicolon/whitespace separated list into array
                $dialplan['local'] = preg_split('/,|;|\\s/', $system['Dialplan']['local']);
                # Retrieve results
                $entries = ldap_get_entries($ds, $sr);
                $j = 0;
                # Process each answer
                for ($i = 0; $i < $entries['count']; $i++) {
                    # Retrieve phone numbers
                    $office = $entries[$i][$LDAP_PHONE_ATTRIBUTE][0];
                    $mobile = $entries[$i][$LDAP_MOBILE_ATTRIBUTE][0];
                    $home = $entries[$i][$LDAP_HOMEPHONE_ATTRIBUTE][0];
                    # Keep entries that contain at least one phone number (office, mobile, home). Number must have at least one digit.
                    if (preg_match("/[0-9]+/", $office) or preg_match("/[0-9]+/", $mobile) or preg_match("/[0-9]+/", $home)) {
                        $result_array[$j]['office'] = $office;
                        $result_array[$j]['officeDigits'] = prepare_number($office, $dialplan);
                        $result_array[$j]['mobile'] = $mobile;
                        $result_array[$j]['mobileDigits'] = prepare_number($mobile, $dialplan);
                        $result_array[$j]['home'] = $home;
                        $result_array[$j]['homeDigits'] = prepare_number($home, $dialplan);
                        if (empty($entries[$i]["sn"][0])) {
                            $result_array[$j]['name'] = $entries[$i]["cn"][0];
                        } else {
                            $result_array[$j]['name'] = $entries[$i]["sn"][0];
                            $result_array[$j]['firstname'] = $entries[$i]["givenname"][0];
                        }
                        $result_array[$j]['title'] = $entries[$i]["title"][0];
                        $result_array[$j]['department'] = $entries[$i]["department"][0];
                        $result_array[$j]['company'] = $entries[$i]["company"][0];
                        $j++;
                    }
                }
                # Close LDAP connection
                ldap_close($ds);
                # Return results
                return empty($result_array) ? NULL : $result_array;
            } else {
                # Close LDAP connection
                ldap_close($ds);
                # Display error message
                display_message(Aastra_get_label('Server error', $LANGUAGE), Aastra_get_label('Cannot send query to LDAP Server. Please contact your administrator.', $LANGUAGE));
                exit;
            }
        } else {
            # Close LDAP connection
            ldap_close($ds);
            # Display error message
            display_message(Aastra_get_label('Server error', $LANGUAGE), Aastra_get_label('Cannot bind to LDAP Server. Please contact your administrator.', $LANGUAGE));
            exit;
        }
    } else {
        # Display error message
        display_message(Aastra_get_label('Server error', $LANGUAGE), Aastra_get_label('Cannot connect to LDAP Server. Please contact your administrator.', $LANGUAGE));
        exit;
    }
}