Changeset 13466
- Timestamp:
- 02/17/12 16:05:52 (1 year ago)
- Files:
-
- modules/branches/2.10/music/functions.inc.php (modified) (1 diff)
- modules/branches/2.10/music/page.music.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.10/music/functions.inc.php
r13091 r13466 2 2 if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 3 3 4 class 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 48 function music_makemusiccategory($path_to_dir) { 49 mkdir("$path_to_dir", 0755); 50 } 51 4 52 function music_list($path=null) { 5 53 if ($path === null) { modules/branches/2.10/music/page.music.php
r13091 r13466 40 40 if (strlen($randon)) { 41 41 touch($path_to_dir."/.random"); 42 createmusicconf();43 42 needreload(); 44 43 } 45 44 if (strlen($randoff)) { 46 45 unlink($path_to_dir."/.random"); 47 createmusicconf();48 46 needreload(); 49 47 } … … 57 55 } 58 56 makestreamcatergory($path_to_dir,$stream); 59 createmusicconf();60 57 needreload(); 61 58 redirect_standard(); 62 59 case "addednew": 63 makemusiccategory($path_to_dir); 64 createmusicconf(); 60 music_makemusiccategory($path_to_dir); 65 61 needreload(); 66 62 redirect_standard(); 67 63 break; 68 64 case "addedfile": 69 createmusicconf();70 65 needreload(); 71 66 // redirect_standard(); … … 77 72 $path_to_dir = $path_to_moh_dir; 78 73 $category='default'; 79 createmusicconf();80 74 needreload(); 81 75 redirect_standard(); … … 105 99 106 100 <?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 chosen117 //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 151 101 function makestreamcatergory($path_to_dir,$stream) { 152 102 if (!is_dir($path_to_dir)) { 153 m akemusiccategory($path_to_dir);103 music_makemusiccategory($path_to_dir); 154 104 } 155 105 $fh=fopen("$path_to_dir/.custom","w"); … … 158 108 } 159 109 160 function makemusiccategory($path_to_dir) {161 mkdir("$path_to_dir", 0755);162 }163 164 110 function build_list() { 165 111 global $path_to_dir;
