Changeset 13466 for modules

Show
Ignore:
Timestamp:
02/17/12 16:05:52 (1 year ago)
Author:
p_lindheimer
Message:

fixes #5337 made music_conf class so retrieve_conf now generates new musiconhold_additional.conf still generated based on present structure of moh directory but require retrieve_conf to generate it meaning when Advanced Settings are changed, it will generate a new file based on the new path

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.10/music/functions.inc.php

    r13091 r13466  
    22if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33 
     4class music_conf { 
     5 
     6  // return the filename to write 
     7  function get_filename() { 
     8    return "musiconhold_additional.conf"; 
     9  } 
     10  // return the output that goes in the file 
     11  function generateConf() { 
     12    global $amp_conf; 
     13    $path_to_moh_dir = $amp_conf['ASTVARLIBDIR'].'/'.$amp_conf['MOHDIR']; 
     14    $output = ""; 
     15 
     16    $File_Write=""; 
     17    $tresults = music_list(); 
     18    if (isset($tresults)) { 
     19      foreach ($tresults as $tresult)  { 
     20        // hack - but his is all a hack until redone, in functions, etc. 
     21        // this puts a none category to allow no music to be chosen 
     22        // 
     23        if ($tresult == "none") { 
     24          $dir = $path_to_moh_dir."/.nomusic_reserved"; 
     25          if (!is_dir($dir)) { 
     26            music_makemusiccategory($dir); 
     27          } 
     28          touch($dir."/silence.wav"); 
     29        } elseif ($tresult != "default" ) { 
     30          $dir = $path_to_moh_dir."/{$tresult}/"; 
     31        } else { 
     32          $dir = $path_to_moh_dir.'/'; 
     33        } 
     34        if (file_exists("{$dir}.custom")) { 
     35          $application = file_get_contents("{$dir}.custom"); 
     36          $File_Write.="[{$tresult}]\nmode=custom\napplication=$application\n"; 
     37        } else if (file_exists("{$dir}.random")) { 
     38          $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}\nrandom=yes\n"; 
     39        } else { 
     40          $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}\n"; 
     41        } 
     42      } 
     43    } 
     44    return $File_Write; 
     45  } 
     46} 
     47 
     48function music_makemusiccategory($path_to_dir) { 
     49  mkdir("$path_to_dir", 0755);  
     50} 
     51  
    452function music_list($path=null) { 
    553  if ($path === null) { 
  • modules/branches/2.10/music/page.music.php

    r13091 r13466  
    4040if (strlen($randon)) { 
    4141  touch($path_to_dir."/.random"); 
    42   createmusicconf(); 
    4342  needreload(); 
    4443} 
    4544if (strlen($randoff)) { 
    4645  unlink($path_to_dir."/.random"); 
    47   createmusicconf(); 
    4846  needreload(); 
    4947} 
     
    5755    } 
    5856    makestreamcatergory($path_to_dir,$stream); 
    59     createmusicconf(); 
    6057    needreload(); 
    6158    redirect_standard(); 
    6259  case "addednew": 
    63     makemusiccategory($path_to_dir);  
    64     createmusicconf(); 
     60    music_makemusiccategory($path_to_dir);  
    6561    needreload(); 
    6662    redirect_standard(); 
    6763  break; 
    6864  case "addedfile": 
    69     createmusicconf(); 
    7065    needreload(); 
    7166//    redirect_standard(); 
     
    7772    $path_to_dir = $path_to_moh_dir; 
    7873    $category='default'; 
    79     createmusicconf(); 
    8074    needreload(); 
    8175    redirect_standard(); 
     
    10599 
    106100<?php 
    107 function createmusicconf() { 
    108   global $amp_conf; 
    109   global $path_to_moh_dir; 
    110  
    111   $File_Write=""; 
    112   $tresults = music_list(); 
    113   if (isset($tresults)) { 
    114     foreach ($tresults as $tresult)  { 
    115       // hack - but his is all a hack until redone, in functions, etc. 
    116       // this puts a none category to allow no music to be chosen 
    117       // 
    118       if ($tresult == "none") { 
    119         $dir = $path_to_moh_dir."/.nomusic_reserved"; 
    120         if (!is_dir($dir)) { 
    121           makemusiccategory($dir); 
    122         } 
    123         touch($dir."/silence.wav"); 
    124       } elseif ($tresult != "default" ) { 
    125         $dir = $path_to_moh_dir."/{$tresult}/"; 
    126       } else { 
    127         $dir = $path_to_moh_dir.'/'; 
    128       } 
    129       if (file_exists("{$dir}.custom")) { 
    130         $application = file_get_contents("{$dir}.custom"); 
    131         $File_Write.="[{$tresult}]\nmode=custom\napplication=$application\n"; 
    132       } else if (file_exists("{$dir}.random")) { 
    133         $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}\nrandom=yes\n"; 
    134       } else { 
    135         $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}\n"; 
    136       } 
    137     } 
    138   } 
    139  
    140  
    141   $handle = fopen($amp_conf['ASTETCDIR']."/musiconhold_additional.conf", "w"); 
    142  
    143   if (fwrite($handle, $File_Write) === FALSE) { 
    144     echo _("Cannot write to file")." ($tmpfname)"; 
    145     exit; 
    146   } 
    147  
    148   fclose($handle); 
    149 } 
    150  
    151101function makestreamcatergory($path_to_dir,$stream) { 
    152102  if (!is_dir($path_to_dir)) { 
    153     makemusiccategory($path_to_dir); 
     103    music_makemusiccategory($path_to_dir); 
    154104  } 
    155105  $fh=fopen("$path_to_dir/.custom","w"); 
     
    158108} 
    159109 
    160 function makemusiccategory($path_to_dir) { 
    161   mkdir("$path_to_dir", 0755);  
    162 } 
    163   
    164110function build_list() { 
    165111  global $path_to_dir;