Page Multiple Tenants at Once
If you would require to page to all or to a certain number of tenants at once, you can create a very simple custom script. See our Custom Scripts page on Developer Resource Center.

2007-10-13

ScopServ Telephony 1.4.5, Asterisk 1.4.13 and Wanpipe 3.2.0
more...



ScopServ API

L'API de ScopServ vous laisse la possibilité d'ajouter ou d'enlever des informations de sa propre base de données, changer la valeur des champs, voir le contenu des différentes sections et plus. Voir toute les fonctions ici!

Veuillez noter que des connaissances en programmation PHP sont requises.

Fonctions

Voici une liste complête de toute les fonctions disponible, classée par ordre alphabetique, qui peuvent être exécuté à partir de scripts PHP personnalisé.


$telephony->convertExtensionToChannel ( string $extension [, string $tenant_name] )
Get the Channel for a specific Extension. If no Tenant Name is given and more than one extension exist on different Tenant, an array containing all possible channels will be returned as result.

$telephony->countExtensions ( string $type [, int $tenant_id] )
Compte le nombre d'items pour un type/section spécifique. Si un ID de Tenancier est spécifié, seulement les données correspondant à ce tenancier seront retourné.

$telephony->deleteExtension ( int $ext_id )
Efface de la base de donnée les information pour l'ID d'extension spécifié.

$telephony->deleteExtensions ( string $type )
Efface tous les items de la base de donnée pour le type/section spécifié.

$telephony->getExtension ( int $ext_id )
Récupérez les informations de la base de donnée pour l'ID d'extension spécifié.

$telephony->getExtensions ( string $type [, int $tenant_id] )
Get all items from database for the specified type/section. If a Tenant ID is given, only data from the given Tenant will be returned.

$telephony->getLastChange ( time $timestamp )
Retourne tous les items qui ont été modifiés depuis la date/heure spécifié.

$telephony->getPhonesChannels ( )
Liste tous les canaux pour chaque extensions sur le serveur.

$telephony->getTenants ( )
Récupere la liste de tous les Tenanciers (ID et Nom) qui sont configuré.

$telephony->getValue ( int $ext_id, string $field )
Get a specific item key for a specific Extension ID.

$telephony->saveExtension ( array $info )
Sauvegarder un item nouvellement créé ou modifié dans la base de donnée ScopServ

$telephony->setValue ( int $ext_id, string $field, string $value )
Set/Update the value of a key for a specific Extension ID.

$telephony->toggleEnable ( int $ext_id [, mixed $mode] )
Permet d'Activer/Désactiver tout item pour une ID d'extension spécifique. Si aucun mode n'est spécifié, la valeur courrante sera alterné. Attribué la valeur 'enable' si vous désiré activé l'item ou toute autres valeur pour désactivé.

Exemple #1

List all enabled Extensions (Phones) and display some informations (Extension, Full Name, Type and Tenant).


<?php

// No authentication mechanism
@define('AUTH_HANDLER'true);

// Define PHP include path
ini_set('include_path''/var/www/scopserv/framework');

// Define ScopServ Base directory
@define('TELEPHONY_BASE''/var/www/scopserv/telephony');

// Load ScopServ Telephony library
require_once TELEPHONY_BASE '/lib/base.php';

// Get the list of all Tenants
$tenants $telephony->getTenants();

// List all enabled Extensions (Phones) and display informations
$phones $telephony->getExtensions('phone');
foreach(
$phones as $id => $info) {
    
    
// If the item is not enable, continue to next
    
if (isset($info['ext_enable']) && !$info['ext_enable']) {
        continue;
    }
    
    
// Get Tenant Name
    
$tenant_id $info['tenant_id'];
    
$tenant    $tenants[$tenant_id];
    
    
// Get Extension Number
    
$extension $info['phone_extension'];
    
    
// Get Fullname
    
$fullname  $info['phone_fullname'];
    
    
// Get Phone Type
    
$type      $info['phone_type'];

    
// Channel
    
$channel   $telephony->convertExtensionToChannel($extension$tenant);
    
    
// Print Information about the Extensions
    
echo sprintf("%10s %30s %5s %20s %s\n"$extension$fullname$type$channel$tenant);
}


Exemple #2

Affiche les informations à propos de tous les appels rapide (Speeddial) configuré.


<?php

// No authentication mechanism
@define('AUTH_HANDLER'true);

// Define PHP include path
ini_set('include_path''/var/www/scopserv/framework');

// Define ScopServ Base directory
@define('TELEPHONY_BASE''/var/www/scopserv/telephony');

// Load ScopServ Telephony library
require_once TELEPHONY_BASE '/lib/base.php';

// Get the list of all Tenants
$tenants $telephony->getTenants();

// List all Speeddial (System)
$infos $telephony->getExtensions('speeddial');

// Sort data by Extension
Horde_Array::arraySort($infos'speeddial_ext');

// Loop through all items and 
foreach($infos as $id => $info) {
    
    
// Get Tenant Name
    
$tenant   $tenants[$info['tenant_id']];
    
    
// Get Speeddial Extension
    
$extension $info['speeddial_ext'];
    
    
// Get Destination Number
    
$number    $info['speeddial_number'];
    
    
// Print Information about the Speeddial
    
echo sprintf("%6s %15s %s\n"$extension$number$tenant);
}

Exemple #3

Import Speeddial from CSV file and check if item is already defined on the ScopServ database.


<?php

// No authentication mechanism
@define('AUTH_HANDLER'true);

// Define PHP include path
ini_set('include_path''/var/www/scopserv/framework');

// Define ScopServ Base directory
@define('TELEPHONY_BASE''/var/www/scopserv/telephony');

// Load ScopServ Telephony library
require_once TELEPHONY_BASE '/lib/base.php';

// List all Speeddial (System)
$infos $telephony->getExtensions('speeddial');

// Loop through all speeddial and add it to the $exists array
$exists = array();
foreach(
$infos as $id => $info) {
    
$exists[$info['speeddial_ext']] = $info['ext_id'];
}

// Open 'speeddial.csv' comma delimited file
$handle fopen('speeddial.csv'"r");
while ((
$data fgetcsv($handle1000',')) !== FALSE) {
    
    
// Get Speedial and Destination Number from CSV file
    
$ext    $data[0];
    
$number $data[1];
    
    
// Initialize the array
    
$info = array();
    
    
// Set the type to 'speeddial'
    
$info['type'] = 'speeddial';
    
    
// If the speeddial is already defined, set the Extension ID to update existing data
    
if (isset($exists[$ext])) {
    
$info['ext_id'] = $exists[$ext];
    }
    
    
// Set information for speeddial entry
    
$info['speeddial_ext']    = $ext;
    
$info['speeddial_number'] = $number;
    
    
// Save information on ScopServ database
    
$telephony->saveExtension($info);
}