Changeset 2193

Show
Ignore:
Timestamp:
07/26/06 23:09:44 (7 years ago)
Author:
gregmac
Message:

GUI for pbdirectory now working

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.2/pbdirectory/functions.inc.php

    r2180 r2193  
    22 /* $Id:$ */ 
    33 
    4 function gabcast_hook_core($viewing_itemid, $target_menuid) { 
    5   if ($viewing_itemid != "" & ($target_menuid == 'extensions' | $target_menuid == 'users')) {  
    6     $list = gabcast_get($viewing_itemid); 
    7     if (is_array($list)) { 
    8       $res = "<p><a href='".$_SERVER['PHP_SELF']."?display=gabcast&amp;ext=$viewing_itemid&amp;action=edit'>"; 
    9       $res .= _("Edit Gabcast Settings")."</a></p>"; 
    10     } else { 
    11       $res = "<p><a href='".$_SERVER['PHP_SELF']."?display=gabcast&amp;ext=$viewing_itemid&amp;action=add'>"; 
    12       $res .= _("Add Gabcast Settings")."</a></p>"; 
    13     } 
    14     return $res; 
    15   } 
     4// returns a associative arrays with keys 'destination' and 'description' 
     5function pbdirectory_destinations() { 
     6  // return an associative array with destination and description 
     7  $extens[] = array('destination' => 'app-pbdirectory,pbdirectory,1', 'description' => 'Phonebook Directory'); 
     8  return $extens; 
    169} 
    1710 
    18 // returns a associative arrays with keys 'destination' and 'description' 
    19 function pbdirectory_destinations() { 
    20   //get the list of meetmes 
    21   $results = gabcast_list(); 
    22  
    23   // return an associative array with destination and description 
    24   if (isset($results)) { 
    25     foreach($results as $result){ 
    26         $extens[] = array('destination' => 'gabcast,'.$result['0'].',1', 'description' => 'gabcast channel '. $result['1'].' <'.$result[0].'>'); 
    27     } 
    28   return $extens; 
    29   } else { 
    30   return null; 
    31   } 
    32 
    33  
    34 function gabcast_get_config($engine) { 
    35         $modulename = 'gabcast'; 
     11function pbdirectory_get_config($engine) { 
     12        $modulename = 'pbdirectory'; 
    3613 
    3714        // This generates the dialplan 
     
    3916        switch($engine) { 
    4017      case "asterisk": 
    41           if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) { 
    42               foreach($featurelist as $item) { 
    43                   $featurename = $item['featurename']; 
    44                   $fname = $modulename.'_'.$featurename; 
    45                   if (function_exists($fname)) { 
    46                       $fcc = new featurecode($modulename, $featurename); 
    47                       $fc = $fcc->getCodeActive(); 
    48                       unset($fcc); 
     18        $fcc = new featurecode('pbdirectory', 'app-pbdirectory'); 
     19        $code = $fcc->getCodeActive(); 
     20        unset($fcc); 
    4921 
    50                       if ($fc != '') 
    51                           $fname($fc); 
    52                   } else { 
    53                       $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename.": No func $fname")); 
    54                       var_dump($item); 
    55                   } 
    56               } 
    57            } else { 
    58             $ext->add('from-internal-additional', 'debug', new ext_noop($modulename.": No modules??")); 
    59            } 
    60             
    61            $context = "gabcast"; 
    62            $ext->add($context, '_X.', '', new ext_dial('IAX2/iax.gabcast.com/422,120')); 
    63            $ext->add($context, 's', '', new ext_dial('IAX2/iax.gabcast.com/422,120')); 
    64             
    65            $gablist = gabcast_list(); 
    66            if($gablist) { 
    67              foreach ($gablist as $gab) { 
    68                $extension = $gab[0]; 
    69                $channbr = $gab[1]; 
    70                $pin = $gab[2]; 
    71                 
    72                $ext->add($context, $extension, '', new ext_dial('IAX2/iax.gabcast.com/'.$channbr.'*'.$pin.',120')); 
    73              } 
    74            } 
     22        $ext->add('app-pbdirectory', $code, '', new ext_answer()); 
     23        $ext->add('app-pbdirectory', $code, '', new ext_wait(1)); 
     24        $ext->add('app-pbdirectory', $code, '', new ext_goto(1,'pbdirectory')); 
     25         
     26        $ext->add('app-pbdirectory', 'pbdirectory', '', new ext_agi('pbdirectory')); 
     27 
     28        $ext->addInclude('from-internal-additional', 'app-pbdirectory'); 
     29         
    7530      break; 
    7631        } 
    7732} 
    7833 
    79 function gabcast_list() { 
    80         global $db; 
    81  
    82         $sql = "SELECT * FROM gabcast ORDER BY channbr"; 
    83         $results = $db->getAll($sql); 
    84         if(DB::IsError($results)) { 
    85                 $results = null; 
    86         } 
    87         return $results; 
    88 } 
    89  
    90 function gabcast_get($xtn) { 
    91         global $db; 
    92  
    93         $sql = "SELECT * FROM gabcast where ext='$xtn'"; 
    94         $results = $db->getRow($sql); 
    95         if(DB::IsError($results)) { 
    96                 $results = null; 
    97         } 
    98         return $results; 
    99 } 
    100  
    101 function gabcast_add($xtn, $channbr, $pin) { 
    102     // fail if this exten already exists in DB 
    103     if(is_array(gabcast_get($xtn))) { 
    104       echo "<div class=error>An error occured when writing to database</div>"; 
    105       return; 
    106     } 
    107         sql("INSERT INTO gabcast (ext, channbr, pin) values ('{$xtn}','{$channbr}','{$pin}')"); 
    108 } 
    109  
    110 function gabcast_del($xtn) { 
    111   sql("DELETE FROM gabcast WHERE ext = '{$xtn}'"); 
    112 } 
    113  
    114 function gabcast_edit($xtn, $channbr, $pin) { 
    115   gabcast_del($xtn); 
    116   sql("INSERT INTO gabcast (ext, channbr, pin) values ('{$xtn}','{$channbr}','{$pin}')"); 
    117 } 
    118  
    119 function gabcast_gabdial($c) { 
    120         global $ext; 
    121  
    122         $id = "app-gabcast"; // The context to be included 
    123     $ext->addInclude('from-internal-additional', $id); 
    124     $ext->add($id, $c, '', new ext_goto('1','${CALLERID(num)}','gabcast')); 
    125 /*     
    126         $ext->add($id, $c, '', new ext_macro('user-callerid')); 
    127         $ext->add($id, $c, '', new ext_noop('Checking for ${CALLERID(num)}')); 
    128   $ext->add($id, $c, '', new ext_gotoif('$[ ${DB_EXISTS(GABCAST/${CALLERID(num)} = 1 ]', 'hasgabcast:nogabcast')); 
    129   $ext->add($id, $c, 'hasgabcast', new ext_setvar('DIALSTRING', 'IAX2/iax.gabcast.com/${DB_RESULT}')); 
    130   $ext->add($id, $c, '', new ext_goto('dodial')); 
    131   $ext->add($id, $c, 'nogabcast', new ext_setvar('DIALSTRING', 'IAX2/iax.gabcast.com/gab')); 
    132   $ext->add($id, $c, 'dodial', new ext_dial('${DIALSTRING},120')); 
    133 */ 
    134 } 
    135  
    13634?>