Changeset 12953

Show
Ignore:
Timestamp:
11/12/11 12:57:56 (2 years ago)
Author:
p_lindheimer
Message:

cache recording files directory search for legacy files, check only if CDR field check is unsuccessfull, remove context column, undefined vars

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/amp_conf/htdocs/recordings/modules/callmonitor.module

    r10735 r12953  
    3333   */ 
    3434  function navMenu($args) { 
    35  
    36     $ret .= "<small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small>"; 
    37  
    38     return $ret; 
     35    return "<small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small>"; 
    3936  } 
    4037 
     
    106103    global $CALLMONITOR_ALLOW_DELETE; 
    107104    global $AJAX_PAGE_REFRESH_ENABLE; 
     105    global $amp_conf; 
     106 
     107    $recording_header = ''; 
     108    $recording_body = ''; 
     109    $ret = ''; 
     110    $controls = ''; 
    108111 
    109112    $display = new DisplaySearch(); 
     
    155158    } 
    156159 
     160    $ari_duration_filter = isset($_COOKIE['ari_duration_filter']) ? $_COOKIE['ari_duration_filter'] : ''; 
    157161    $controls .= "  
    158162      <small>" . _("duration") . "</small> 
    159       <input name='duration_filter' type='text' size=4 maxlength=8 value='" . $_COOKIE['ari_duration_filter'] . "'> 
     163      <input name='duration_filter' type='text' size=4 maxlength=8 value='" . $ari_duration_filter . "'> 
    160164      <button class='infobar' type='submit' onclick=\"document.callmonitor_form.a.value='ignore'\"> 
    161165      " . _("ignore") . " 
     
    177181    $fields[4]['field'] = "dst"; 
    178182    $fields[4]['text'] = _("Destination"); 
    179     $fields[5]['field'] = "dcontext"; 
    180     $fields[5]['text'] = _("Context"); 
    181     $fields[6]['field'] = "duration"; 
    182     $fields[6]['text'] = _("Duration"); 
     183    $fields[5]['field'] = "duration"; 
     184    $fields[5]['text'] = _("Duration"); 
    183185 
    184186    $i = 0; 
    185     while ($fields[$i]) { 
    186  
    187       $field = $fields[$i]['field']; 
    188       $text = $fields[$i]['text']; 
     187   foreach ($fields as $col) { 
     188 
     189      $field = $col['field']; 
     190      $text = $col['text']; 
    189191      if ($order==$field) {  
    190192        if ($sort=='asc') { 
     
    207209 
    208210      $unicode_q = urlencode($q); 
     211      if (!isset($folder)) $folder = ''; 
    209212      $recording_header .= "<th><a href=" .  $_SESSION['ARI_ROOT'] . "?m=" . $m . "&f=" . $f . "&q=" . $unicode_q . "&folder=" . $folder . "&order=" . $field . "&sort=" . $currentSort . ">" . $text . $arrowImg . "</a></th>"; 
    210213 
     
    220223      $i++; 
    221224 
     225      // check if CDR has recording file in it 
     226      // 
     227      if ($value['recordingfile']) { 
     228        $rec_parts = explode('-',$value['recordingfile']); 
     229        $fyear = substr($rec_parts[3],0,4); 
     230        $fmonth = substr($rec_parts[3],4,2); 
     231        $fday = substr($rec_parts[3],6,2); 
     232        $monitor_base = $amp_conf['MIXMON_DIR'] ? $amp_conf['MIXMON_DIR'] : $amp_conf['ASTSPOOLDIR'] . '/monitor';  
     233        $recordingfile = "$monitor_base/$fyear/$fmonth/$fday/" . $value['recordingfile']; 
     234        if (!file_exists($recordingfile)) { 
     235          $recordingfile = ''; 
     236        } 
     237      } else { 
     238        $recordingfile = ''; 
     239      } 
     240 
    222241      // recording file 
    223       $recording = $recordings[$value['uniqueid'] . $value['calldate']]; 
     242      // 
     243      if ($recordingfile) { 
     244        $recording = $recordingfile; 
     245      } else { 
     246        // for legacy systems ... 
     247        $recording = isset($recordings[$value['uniqueid'] . $value['calldate']]) ? $recordings[$value['uniqueid'] . $value['calldate']] : ''; 
     248      } 
    224249 
    225250      // date and time 
    226       $buf = explode(' ', $value[calldate]); 
     251      $buf = explode(' ', $value['calldate']); 
    227252      $date = $buf[0]; 
    228253      $time = $buf[1]; 
     
    247272                 <td width=70>" . $date . "</td> 
    248273                 <td>" . $time . "</td> 
    249                  <td>" . $value[clid] . "</td> 
    250                  <td>" . $value[src] . "</td> 
    251                  <td>" . $value[dst] . "</td> 
    252                  <td>" . $value[dcontext] . "</td> 
    253                  <td width=90>" . $value[duration] . " sec</td> 
     274                 <td>" . $value['clid'] . "</td> 
     275                 <td>" . $value['src'] . "</td> 
     276                 <td>" . $value['dst'] . "</td> 
     277                 <td width=90>" . $value['duration'] . " sec</td> 
    254278           <td>" . $recordingLink . "&nbsp;&nbsp;" . $downloadLink . "</td> 
    255279               </tr>"; 
     
    407431    } 
    408432 
    409     $files = array(); 
    410     if (!$CALLMONITOR_ONLY_EXACT_MATCHING) { 
    411       $filter = ''; 
    412       $recursiveMax = 6; 
    413       $recursiveCount = 0; 
    414       foreach($paths as $key => $path) { 
    415         $path_files = getFiles($path,$filter,$recursiveMax,$recursiveCount); 
    416         if ($path_files) { 
    417           $files = array_merge($files,$path_files); 
    418         } 
    419       } 
    420       rsort($files); 
    421     } 
     433    // Once we've done the heavy lifting of searching for all file 
     434    // we don't need to do it again, if there are new recordings 
     435    // they will be found through the DB and a call to here 
     436    // won't be needed 
     437    // 
     438    if (isset($_SESSION['ari_user']['recordings_files'])) { 
     439      $files = $_SESSION['ari_user']['recordings_files']; 
     440    } else { 
     441      $files = array(); 
     442      if (!$CALLMONITOR_ONLY_EXACT_MATCHING) { 
     443        $filter = ''; 
     444        $recursiveMax = 6; 
     445        $recursiveCount = 0; 
     446        foreach($paths as $key => $path) { 
     447          $path_files = getFiles($path,$filter,$recursiveMax,$recursiveCount); 
     448          if ($path_files) { 
     449            $files = array_merge($files,$path_files); 
     450          } 
     451        } 
     452        rsort($files); 
     453      } 
     454      $_SESSION['ari_user']['recordings_files'] = $files; 
     455    } 
    422456 
    423457    if (is_array($data)) foreach($data as $data_key => $data_value) { 
     
    515549 
    516550          foreach($files as $key => $path) { 
    517             list($path,$filetype) = explode(".",$path,2); 
     551            $tmp_arr = explode(".",$path,2); 
     552            $path = $tmp_arr[0]; 
     553            $filetype = isset($tmp_arr[1]) ? $tmp_arr[1] : ''; 
    518554            $parts = explode("-", $path); 
    519555            if ((strlen($st)>1 && strpos($path,$st)!==FALSE && strlen($uniqueid)<=1) ||  
     
    600636                         OR dst regexp '" . $tok . "' 
    601637                         OR dstchannel regexp '" . $tok . "' 
    602                          OR dcontext regexp '" . $tok . "' 
    603638                         OR duration regexp '" . $tok . "' 
    604639                         OR disposition regexp '" . $tok . "' 
     
    626661    // admin 
    627662    if (!$_SESSION['ari_user']['admin_callmonitor']) { 
    628       if (!$searchText) { 
    629         $searchText .= "WHERE "; 
     663      if (empty($searchText)) { 
     664        $searchText = "WHERE "; 
    630665      } else { 
    631666        $searchText .= "AND ";