Changeset 5920

Show
Ignore:
Timestamp:
07/06/08 04:16:38 (5 years ago)
Author:
p_lindheimer
Message:

merged timegroups and timecondition mods into timeconditions module. Originally submitted as #1695 by naftali5 as 2 modules, now merged and moved over from contributed_modules repository

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/timeconditions/functions.inc.php

    r5752 r5920  
    11<?php /* $Id */ 
    2  
    3 // returns a associative arrays with keys 'destination' and 'description' 
    4 function timeconditions_destinations() { 
    5   //get the list of meetmes 
    6   $results = timeconditions_list(true); 
    7  
    8   // return an associative array with destination and description 
    9   if (isset($results)) { 
    10     foreach($results as $result){ 
    11         $extens[] = array('destination' => 'timeconditions,'.$result['timeconditions_id'].',1', 'description' => $result['displayname']); 
    12     } 
    13     return $extens; 
    14   } else { 
    15     return null; 
    16   } 
    17 } 
    182 
    193function timeconditions_getdest($exten) { 
     
    3418      return array('description' => 'Time Conditon : '.$thisexten['displayname'], 
    3519                   'edit_url' => 'config.php?display=timeconditions&itemid='.urlencode($exten), 
    36                  ); 
     20                  ); 
    3721    } 
    3822  } else { 
     
    4125} 
    4226 
     27// returns a associative arrays with keys 'destination' and 'description' 
     28function timeconditions_destinations() { 
     29  //get the list of timeconditions 
     30  $results = timeconditions_list(true); 
     31 
     32  // return an associative array with destination and description 
     33  if (isset($results)) { 
     34    foreach($results as $result){ 
     35        $extens[] = array('destination' => 'timeconditions,'.$result['timeconditions_id'].',1', 'description' => $result['displayname']); 
     36    } 
     37    return $extens; 
     38  } else { 
     39    return null; 
     40  } 
     41} 
    4342 
    4443/*  Generates dialplan for conferences 
     
    4847  global $ext;  // is this the best way to pass this? 
    4948  global $conferences_conf; 
     49 
    5050  switch($engine) { 
    5151    case "asterisk": 
     
    5555          $thisitem = timeconditions_get(ltrim($item['timeconditions_id'])); 
    5656          // add dialplan 
    57           $ext->add('timeconditions', $item['timeconditions_id'], '', new ext_gotoiftime($item['time'],$item['truegoto'])); 
     57          $times = timeconditions_timegroups_get_times($item['time']); 
     58          if (is_array($times)) { 
     59            foreach ($times as $time) { 
     60              $ext->add('timeconditions', $item['timeconditions_id'], '', new ext_gotoiftime($time[1],$item['truegoto'])); 
     61            } 
     62          } 
    5863          $ext->add('timeconditions', $item['timeconditions_id'], '', new ext_goto($item['falsegoto'])); 
    5964        } 
     
    122127 
    123128function timeconditions_get($id){ 
    124   //get all the variables for the meetme 
     129  //get all the variables for the timecondition 
    125130  $results = sql("SELECT * FROM timeconditions WHERE timeconditions_id = '$id'","getRow",DB_FETCHMODE_ASSOC); 
    126131  return $results; 
     
    131136} 
    132137 
     138//obsolete handled in timegroups module 
    133139function timeconditions_get_time( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish) { 
    134140 
    135         //----- Time Hour Interval proccess ---- 
    136         if ($minute_start == '-') { 
    137             $time_minute_start = "*"; 
    138          } else { 
    139             $time_minute_start = sprintf("%02d",$minute_start); 
    140          } 
    141          if ($minute_finish == '-') { 
    142             $time_minute_finish = "*"; 
    143          } else { 
    144              $time_minute_finish = sprintf("%02d",$minute_finish); 
    145          } 
    146          if ($hour_start == '-') { 
    147              $time_hour_start = '*'; 
    148           } else { 
    149              $time_hour_start = sprintf("%02d",$hour_start) . ':' . $time_minute_start; 
    150           } 
    151           if ($hour_finish == '-') { 
    152              $time_hour_finish = '*'; 
    153           } else { 
    154              $time_hour_finish = sprintf("%02d",$hour_finish) . ':' . $time_minute_finish; 
    155           } 
    156           if ($time_hour_start == $time_hour_finish) { 
    157               $time_hour = $time_hour_start; 
    158           } else { 
    159               $time_hour = $time_hour_start . '-' . $time_hour_finish; 
    160           } 
    161           //----- Time Week Day Interval proccess ----- 
    162           if ($wday_start == '-') { 
    163               $time_wday_start = '*'; 
    164            } else { 
    165               $time_wday_start = $wday_start; 
    166            } 
    167            if ($wday_finish == '-') { 
    168               $time_wday_finish = '*'; 
    169            } else { 
    170               $time_wday_finish = $wday_finish; 
    171            } 
    172            if ($time_wday_start == $time_wday_finish) { 
    173                $time_wday = $time_wday_start; 
    174             } else { 
    175                $time_wday = $time_wday_start . '-' . $time_wday_finish; 
    176             } 
    177             //----- Time Month Day Interval proccess ----- 
    178             if ($mday_start == '-') { 
    179                $time_mday_start = '*'; 
    180             } else { 
    181                 $time_mday_start = $mday_start; 
    182             } 
    183             if ($mday_finish == '-') { 
    184                 $time_mday_finish = '*'; 
    185             } else { 
    186                 $time_mday_finish = $mday_finish; 
    187             } 
    188             if ($time_mday_start == $time_mday_finish) { 
    189                 $time_mday = $time_mday_start; 
    190             } else { 
    191                 $time_mday = $time_mday_start . '-' . $time_mday_finish; 
    192             } 
    193             //----- Time Month Interval proccess ----- 
    194             if ($month_start == '-') { 
    195                 $time_month_start = '*'; 
    196             } else { 
    197                 $time_month_start = $month_start; 
    198             } 
    199             if ($month_finish == '-') { 
    200                 $time_month_finish = '*'; 
    201             } else { 
    202                 $time_month_finish = $month_finish; 
    203             } 
    204             if ($time_month_start == $time_month_finish) { 
    205                 $time_month = $time_month_start; 
    206             } else { 
    207                 $time_month = $time_month_start . '-' . $time_month_finish; 
    208             } 
    209       $time = $time_hour . '|' . $time_wday . '|' . $time_mday . '|' . $time_month; 
    210       return $time; 
     141  //----- Time Hour Interval proccess ---- 
     142  // 
     143  if ($minute_start == '-') { 
     144    $time_minute_start = "*"; 
     145  } else { 
     146    $time_minute_start = sprintf("%02d",$minute_start); 
     147  } 
     148  if ($minute_finish == '-') { 
     149    $time_minute_finish = "*"; 
     150  } else { 
     151    $time_minute_finish = sprintf("%02d",$minute_finish); 
     152  } 
     153  if ($hour_start == '-') { 
     154    $time_hour_start = '*'; 
     155  } else { 
     156    $time_hour_start = sprintf("%02d",$hour_start) . ':' . $time_minute_start; 
     157  } 
     158  if ($hour_finish == '-') { 
     159    $time_hour_finish = '*'; 
     160  } else { 
     161    $time_hour_finish = sprintf("%02d",$hour_finish) . ':' . $time_minute_finish; 
     162  } 
     163  if ($time_hour_start == $time_hour_finish) { 
     164    $time_hour = $time_hour_start; 
     165  } else { 
     166    $time_hour = $time_hour_start . '-' . $time_hour_finish; 
     167  } 
     168 
     169  //----- Time Week Day Interval proccess ----- 
     170  // 
     171  if ($wday_start == '-') { 
     172    $time_wday_start = '*'; 
     173  } else { 
     174    $time_wday_start = $wday_start; 
     175  } 
     176  if ($wday_finish == '-') { 
     177    $time_wday_finish = '*'; 
     178  } else { 
     179    $time_wday_finish = $wday_finish; 
     180  } 
     181  if ($time_wday_start == $time_wday_finish) { 
     182    $time_wday = $time_wday_start; 
     183  } else { 
     184    $time_wday = $time_wday_start . '-' . $time_wday_finish; 
     185  } 
     186 
     187  //----- Time Month Day Interval proccess ----- 
     188  // 
     189  if ($mday_start == '-') { 
     190    $time_mday_start = '*'; 
     191  } else { 
     192    $time_mday_start = $mday_start; 
     193  } 
     194  if ($mday_finish == '-') { 
     195    $time_mday_finish = '*'; 
     196  } else { 
     197    $time_mday_finish = $mday_finish; 
     198  } 
     199  if ($time_mday_start == $time_mday_finish) { 
     200    $time_mday = $time_mday_start; 
     201  } else { 
     202    $time_mday = $time_mday_start . '-' . $time_mday_finish; 
     203  } 
     204 
     205  //----- Time Month Interval proccess ----- 
     206  // 
     207  if ($month_start == '-') { 
     208    $time_month_start = '*'; 
     209  } else { 
     210    $time_month_start = $month_start; 
     211  } 
     212  if ($month_finish == '-') { 
     213    $time_month_finish = '*'; 
     214  } else { 
     215    $time_month_finish = $month_finish; 
     216  } 
     217  if ($time_month_start == $time_month_finish) { 
     218    $time_month = $time_month_start; 
     219  } else { 
     220    $time_month = $time_month_start . '-' . $time_month_finish; 
     221  } 
     222  $time = $time_hour . '|' . $time_wday . '|' . $time_mday . '|' . $time_month; 
     223  return $time; 
    211224} 
    212225 
    213226function timeconditions_add($post){ 
    214   if(!timeconditions_chk($post)) 
     227  if(!timeconditions_chk($post)) { 
    215228    return false; 
     229  } 
    216230  extract($post); 
    217231 
    218         $time = timeconditions_get_time( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish); 
    219  
    220   if(empty($displayname)) $displayname = "unnamed"; 
     232  // $time = timeconditions_get_time( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish); 
     233 
     234  if(empty($displayname)) { 
     235    $displayname = "unnamed"; 
     236  } 
    221237  $results = sql("INSERT INTO timeconditions (displayname,time,truegoto,falsegoto,deptname) values (\"$displayname\",\"$time\",\"${$goto0.'0'}\",\"${$goto1.'1'}\",\"$deptname\")"); 
    222238} 
    223239 
    224240function timeconditions_edit($id,$post){ 
    225   if(!timeconditions_chk($post)) 
     241  if(!timeconditions_chk($post)) { 
    226242    return false; 
     243  } 
    227244  extract($post); 
    228245 
    229         $time = timeconditions_get_time( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish); 
     246 // $time = timeconditions_get_time( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish); 
    230247   
    231   if(empty($displayname)) $displayname = "unnamed"; 
     248  if(empty($displayname)) {  
     249    $displayname = "unnamed"; 
     250  } 
    232251  $results = sql("UPDATE timeconditions SET displayname = \"$displayname\", time = \"$time\", truegoto = \"${$goto0.'0'}\", falsegoto = \"${$goto1.'1'}\", deptname = \"$deptname\" WHERE timeconditions_id = \"$id\""); 
    233252} 
     
    237256  return true; 
    238257} 
     258 
     259 
     260 
     261/* 
     262The following functions are available to other modules. 
     263 
     264function timeconditions_timegroups_add_group($description,$times=null) return the inserted id 
     265  expects an array of times, each an associative array 
     266  Array ( [0] => Array ( [hour_start] => - [minute_start] => - [hour_finish] => -  
     267  [minute_finish] => - [wday_start] => - [wday_finish] => - [mday_start] => -  
     268  [mday_finish] => - [month_start] => - [month_finish] => - ) ) 
     269 
     270function timeconditions_timegroups_add_group_timestrings($description,$times=null) return the inserted id 
     271  alternative to above. expects an array of time strings instead of associative array of hours minutes etc. 
     272 
     273function timeconditions_timegroups_list_groups() 
     274  returns an array of id and descriptions for any time groups defined by the user 
     275  the array contains inidces 0 and 1 for the rnav and associative value and text for select boxes 
     276 
     277function timeconditions_timegroups_get_times($timegroup) 
     278  returns an array of id and time string of the users time selections for the selected timegroup 
     279 
     280function timeconditions_timegroups_buildtime( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish)  
     281  should never be needed by another module, as this module should be the only place creating the time string, as it returns the string to other modules. 
     282 
     283function timeconditions_timegroups_drawtimeselects($name, $time) 
     284  should never be needed by another module, as this module should be the only place drawing the time selects 
     285*/ 
     286 
     287//lists any time groups defined by the user 
     288function timeconditions_timegroups_list_groups() { 
     289  global $db; 
     290 
     291  $sql = "select id, description from timegroups_groups order by description"; 
     292  $results = $db->getAll($sql); 
     293  if(DB::IsError($results)) { 
     294    $results = null; 
     295  } 
     296  foreach ($results as $val) { 
     297    $tmparray[] = array($val[0], $val[1], "value" => $val[0], "text" => $val[1]); 
     298  } 
     299  return $tmparray; 
     300} 
     301 
     302//--------------------------------------------- 
     303 
     304//timegroups page helper 
     305//we are using gui styles so there is very little on the page 
     306//the timegroups page is used to create time string  
     307//to be used by other modules for gotoif or includes or IFTIME func 
     308function timeconditions_timegroups_configpageinit($dispnum) { 
     309global $currentcomponent; 
     310 
     311  switch ($dispnum) { 
     312    case 'timegroups': 
     313      $currentcomponent->addguifunc('timeconditions_timegroups_configpageload'); 
     314      $currentcomponent->addprocessfunc('timeconditions_timegroups_configprocess', 5);   
     315    break; 
     316  } 
     317} 
     318 
     319//actually render the timegroups page 
     320function timeconditions_timegroups_configpageload() { 
     321  global $currentcomponent; 
     322 
     323  $descerr = 'Description must be alpha-numeric, and may not be left blank'; 
     324  $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 
     325  $action= isset($_REQUEST['action'])?$_REQUEST['action']:null; 
     326  if ($action == 'del') { 
     327    $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Time Group").": $extdisplay"." deleted!", false), 0); 
     328    unset($extdisplay); 
     329  } 
     330//need to get page name/type dynamically 
     331  $query = ($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'type=setup&display=timegroups&extdisplay='.$extdisplay; 
     332  $delURL = $_SERVER['PHP_SELF'].'?'.$query.'&action=del'; 
     333  $info = ''; 
     334  if (!$extdisplay) { 
     335    $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Time Group"), false), 0); 
     336    $currentcomponent->addguielem('Time Group', new gui_textbox('description', '', 'Description', 'This will display as the name of this Time Group.', '!isAlphanumeric() || isWhitespace()', $descerr, false), 3); 
     337  } else { 
     338    $savedtimegroup= timeconditions_timegroups_get_group($extdisplay); 
     339    $timegroup = $savedtimegroup[0]; 
     340    $description = $savedtimegroup[1]; 
     341    $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay)); 
     342    $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Edit Time Group").": $description", false), 0); 
     343    $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Time Group")." $timegroup", $delURL, true, false), 0); 
     344    $currentcomponent->addguielem('Time Group', new gui_textbox('description', $description, 'Description', 'This will display as the name of this Time Group.', '', '', false), 3); 
     345    $timelist = timeconditions_timegroups_get_times($extdisplay); 
     346    foreach ($timelist as $val) { 
     347      $timehtml = timeconditions_timegroups_drawtimeselects('times['.$val[0].']',$val[1]); 
     348      $timehtml = '<tr><td colspan="2"><table>'.$timehtml.'</table></td></tr>'; 
     349      $currentcomponent->addguielem($val[1], new guielement('dest0', $timehtml, ''),5); 
     350    } 
     351  } 
     352  $timehtml = timeconditions_timegroups_drawtimeselects('times[new]',null); 
     353  $timehtml = '<tr><td colspan="2"><table>'.$timehtml.'</table></td></tr>'; 
     354  $currentcomponent->addguielem('New Time', new guielement('dest0', $timehtml, ''),6); 
     355  $currentcomponent->addguielem('_top', new gui_hidden('action', ($extdisplay ? 'edit' : 'add'))); 
     356} 
     357 
     358//handle timegroups page submit button 
     359function timeconditions_timegroups_configprocess() { 
     360  $action= isset($_REQUEST['action'])?$_REQUEST['action']:null; 
     361  $timegroup= isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 
     362  $description= isset($_REQUEST['description'])?$_REQUEST['description']:null; 
     363  $times = isset($_REQUEST['times'])?$_REQUEST['times']:null; 
     364 
     365  //addslashes   
     366  switch ($action) { 
     367    case 'add': 
     368      timeconditions_timegroups_add_group($description,$times); 
     369      break; 
     370    case 'edit': 
     371      timeconditions_timegroups_edit_group($timegroup,$description); 
     372      timeconditions_timegroups_edit_times($timegroup,$times); 
     373      break; 
     374    case 'del': 
     375      timeconditions_timegroups_del_group($timegroup); 
     376      break; 
     377  } 
     378} 
     379 
     380//these are the users time selections for the current timegroup 
     381function timeconditions_timegroups_get_times($timegroup) { 
     382  global $db; 
     383 
     384  $sql = "select id, time from timegroups_details where timegroupid = $timegroup"; 
     385  $results = $db->getAll($sql); 
     386  if(DB::IsError($results)) { 
     387    $results = null; 
     388  } 
     389  foreach ($results as $val) { 
     390    $tmparray[] = array($val[0], $val[1]); 
     391  } 
     392  return $tmparray; 
     393} 
     394 
     395//retrieve a single timegroup for the timegroups page 
     396function timeconditions_timegroups_get_group($timegroup) { 
     397  global $db; 
     398 
     399  $sql = "select id, description from timegroups_groups where id = $timegroup"; 
     400  $results = $db->getAll($sql); 
     401  if(DB::IsError($results)) { 
     402    $results = null; 
     403  } 
     404  $tmparray = array($results[0][0], $results[0][1]); 
     405  return $tmparray; 
     406} 
     407 
     408//add a new timegroup for timegroups page 
     409//expects an array of times, each an associative array 
     410//Array ( [0] => Array ( [hour_start] => - [minute_start] => - [hour_finish] => -  
     411//[minute_finish] => - [wday_start] => - [wday_finish] => - [mday_start] => -  
     412//[mday_finish] => - [month_start] => - [month_finish] => - ) ) 
     413function timeconditions_timegroups_add_group($description,$times=null) { 
     414  global $db; 
     415 
     416  $sql = "insert timegroups_groups(description) VALUES ('$description')"; 
     417  $db->query($sql); 
     418  $timegroup=mysql_insert_id(); 
     419  if (isset($times)) { 
     420    timeconditions_timegroups_edit_times($timegroup,$times); 
     421  } 
     422  needreload(); 
     423  return $timegroup; 
     424} 
     425 
     426function timeconditions_timegroups_add_group_timestrings($description,$timestrings) { 
     427  global $db; 
     428 
     429  $sql = "insert timegroups_groups(description) VALUES ('$description')"; 
     430  $db->query($sql); 
     431  $timegroup=mysql_insert_id(); 
     432  timeconditions_timegroups_edit_timestrings($timegroup,$timestrings); 
     433  needreload(); 
     434  return $timegroup; 
     435} 
     436 
     437//delete a single timegroup from the timegroups page 
     438function timeconditions_timegroups_del_group($timegroup) { 
     439  global $db; 
     440 
     441  $sql = "delete from timegroups_details where timegroupid = $timegroup"; 
     442  $db->query($sql); 
     443  $sql = "delete from timegroups_groups where id = $timegroup"; 
     444  $db->query($sql); 
     445  needreload(); 
     446} 
     447 
     448//update a single timegroup from the timegroups page 
     449function timeconditions_timegroups_edit_group($timegroup,$description) { 
     450  global $db; 
     451 
     452  $sql = "update timegroups_groups set description = '$description' where id = $timegroup"; 
     453  $db->query($sql); 
     454  needreload(); 
     455} 
     456 
     457//update the timegroup_detail under a single timegroup from the timegroups page 
     458function timeconditions_timegroups_edit_times($timegroup,$times) { 
     459  global $db; 
     460 
     461  $sql = "delete from timegroups_details where timegroupid = $timegroup"; 
     462  $db->query($sql); 
     463  foreach ($times as $key=>$val) { 
     464    extract($val); 
     465    $time = timeconditions_timegroups_buildtime( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish); 
     466    if (isset($time) && $time != '' && $time <> '*|*|*|*') { 
     467      $sql = "insert timegroups_details (timegroupid, time) values ($timegroup, '$time')"; 
     468      $db->query($sql); 
     469    } 
     470  } 
     471  needreload(); 
     472} 
     473 
     474//update the timegroup_detail under a single timegroup  
     475function timeconditions_timegroups_edit_timestrings($timegroup,$timestrings) { 
     476  global $db; 
     477 
     478  $sql = "delete from timegroups_details where timegroupid = $timegroup"; 
     479  $db->query($sql); 
     480  foreach ($timestrings as $key=>$val) { 
     481    $time = $val; 
     482    if (isset($time) && $time != '' && $time <> '*|*|*|*') { 
     483      $sql = "insert timegroups_details (timegroupid, time) values ($timegroup, '$time')"; 
     484      $db->query($sql); 
     485    } 
     486  } 
     487  needreload(); 
     488} 
     489 
     490function timeconditions_timegroups_drawgroupselect($elemname, $currentvalue = '', $canbeempty = true, $onchange = '') { 
     491  global $tabindex; 
     492  $output = ''; 
     493  $onchange = ($onchange != '') ? " onchange=\"$onchange\"" : ''; 
     494   
     495  $output .= "\n\t\t\t<select name=\"$elemname\" tabindex=\"".++$tabindex."\" id=\"$elemname\"$onchange>\n"; 
     496  // include blank option if required 
     497  if ($canbeempty) { 
     498    $output .= '<option value="">'._("--Select a Group--").'</option>';      
     499  } 
     500  // build the options 
     501  $valarray = timeconditions_timegroups_list_groups(); 
     502  foreach ($valarray as $item) { 
     503    $itemvalue = (isset($item['value']) ? $item['value'] : ''); 
     504    $itemtext = (isset($item['text']) ? _($item['text']) : ''); 
     505    $itemselected = ($currentvalue == $itemvalue) ? ' selected' : ''; 
     506     
     507    $output .= "\t\t\t\t<option value=\"$itemvalue\"$itemselected>$itemtext</option>\n"; 
     508  } 
     509  $output .= "\t\t\t</select>\n\t\t"; 
     510  return $output; 
     511} 
     512 
     513//---------------------------------stolen from time conditions and heavily modified------------------------------------------ 
     514 
     515function timeconditions_timegroups_drawtimeselects($name, $time) { 
     516  $html = ''; 
     517  // ----- Load Time Pattern Variables ----- 
     518  if (isset($time)) { 
     519    list($time_hour, $time_wday, $time_mday, $time_month) = explode('|', $time); 
     520  } else { 
     521    list($time_hour, $time_wday, $time_mday, $time_month) = Array('*','-','-','-'); 
     522  } 
     523  $html = $html.'<tr>'; 
     524  $html = $html.'<td>'._("Time to start:").'</td>'; 
     525  $html = $html.'<td>'; 
     526  // Hour could be *, hh:mm, hh:mm-hhmm 
     527  if ( $time_hour === '*' ) { 
     528    $hour_start = $hour_finish = '-'; 
     529    $minute_start = $minute_finish = '-'; 
     530  } else { 
     531    list($hour_start_string, $hour_finish_string) = explode('-', $time_hour); 
     532    if ($hour_start_string === '*') { 
     533      $hour_start_string = $hour_finish_string; 
     534    } 
     535    if ($hour_finish_string === '*') { 
     536      $hour_finish_string = $hour_start_string; 
     537    } 
     538    list($hour_start, $minute_start) = explode( ':', $hour_start_string); 
     539    list($hour_finish, $minute_finish) = explode( ':', $hour_finish_string); 
     540    if ( !$hour_finish) { 
     541      $hour_finish = $hour_start; 
     542    } 
     543    if ( !$minute_finish) { 
     544      $minute_finish = $minute_start; 
     545    } 
     546  } 
     547  $html = $html.'<select name="'.$name.'[hour_start]"/>'; 
     548  $default = ''; 
     549  if ( $hour_start === '-' ) { 
     550    $default = ' selected'; 
     551  } 
     552  $html = $html."<option value=\"-\" $default>-"; 
     553  for ($i = 0 ; $i < 24 ; $i++) { 
     554    $default = ""; 
     555    if ( sprintf("%02d", $i) === $hour_start ) { 
     556      $default = ' selected'; 
     557    } 
     558    $html = $html."<option value=\"$i\" $default> ".sprintf("%02d", $i); 
     559  } 
     560  $html = $html.'</select>'; 
     561  $html = $html.'<nbsp>:<nbsp>'; 
     562  $html = $html.'<select name="'.$name.'[minute_start]"/>'; 
     563  $default = ''; 
     564  if ( $minute_start === '-' ) { 
     565    $default = ' selected'; 
     566  } 
     567  $html = $html."<option value=\"-\" $default>-"; 
     568  for ($i = 0 ; $i < 60 ; $i++) { 
     569    $default = ""; 
     570    if ( sprintf("%02d", $i) === $minute_start ) { 
     571      $default = ' selected'; 
     572    } 
     573    $html = $html."<option value=\"$i\" $default> ".sprintf("%02d", $i); 
     574  } 
     575  $html = $html.'</select>'; 
     576  $html = $html.'</td>'; 
     577  $html = $html.'</tr>'; 
     578  $html = $html.'<tr>'; 
     579  $html = $html.'<td>'._("Time to finish:").'</td>'; 
     580  $html = $html.'<td>'; 
     581  $html = $html.'<select name="'.$name.'[hour_finish]"/>'; 
     582  $default = ''; 
     583  if ( $hour_finish === '-' ) { 
     584    $default = ' selected'; 
     585  } 
     586  $html = $html."<option value=\"-\" $default>-"; 
     587  for ($i = 0 ; $i < 24 ; $i++) { 
     588    $default = ""; 
     589    if ( sprintf("%02d", $i) === $hour_finish) { 
     590      $default = ' selected'; 
     591    } 
     592    $html = $html."<option value=\"$i\" $default> ".sprintf("%02d", $i); 
     593  } 
     594  $html = $html.'</select>'; 
     595  $html = $html.'<nbsp>:<nbsp>'; 
     596  $html = $html.'<select name="'.$name.'[minute_finish]"/>'; 
     597  $default = ''; 
     598  if ( $minute_finish === '-' ) { 
     599    $default = ' selected'; 
     600  } 
     601  $html = $html."<option value=\"-\" $default>-"; 
     602  for ($i = 0 ; $i < 60 ; $i++) { 
     603    $default = ''; 
     604    if ( sprintf("%02d", $i) === $minute_finish ) { 
     605      $default = ' selected'; 
     606    } 
     607    $html = $html."<option value=\"$i\" $default> ".sprintf("%02d", $i); 
     608  } 
     609  $html = $html.'</select>'; 
     610  $html = $html.'</td>'; 
     611  $html = $html.'</tr>'; 
     612  $html = $html.'<tr>'; 
     613 
     614  // WDay could be *, day, day1-day2 
     615  if ( $time_wday != '*' ) { 
     616    list($wday_start, $wday_finish) = explode('-', $time_wday); 
     617    if ($wday_start === '*') { 
     618      $wday_start = $wday_finish; 
     619    } 
     620    if ($wday_finish === '*') { 
     621      $wday_finish = $wday_start; 
     622    } 
     623    if ( !$wday_finish) { 
     624      $wday_finish = $wday_start; 
     625    } 
     626  } else { 
     627    $wday_start = $wday_finish = '-'; 
     628  } 
     629  $html = $html.'<td>'._("Week Day Start:").'</td>'; 
     630  $html = $html.'<td>'; 
     631  $html = $html.'<select name="'.$name.'[wday_start]"/>'; 
     632  if ( $wday_start == '-' ) {  
     633    $default = ' selected';  
     634  } else { 
     635    $default = ''; 
     636  } 
     637  $html = $html."<option value=\"-\" $default>-"; 
     638  
     639  if ( $wday_start == 'mon' ) {  
     640    $default = ' selected';  
     641  } else { 
     642    $default = ''; 
     643  } 
     644  $html = $html."<option value=\"mon\" $default>" . _("Monday"); 
     645 
     646  if ( $wday_start == 'tue' ) {  
     647    $default = ' selected';  
     648  } else { 
     649    $default = ''; 
     650  } 
     651  $html = $html."<option value=\"tue\" $default>" . _("Tuesday"); 
     652 
     653  if ( $wday_start == 'wed' ) {  
     654    $default = ' selected';  
     655  } else { 
     656    $default = ''; 
     657  } 
     658  $html = $html."<option value=\"wed\" $default>" . _("Wednesday"); 
     659 
     660  if ( $wday_start == 'thu' ) {  
     661    $default = ' selected';  
     662  } else { 
     663    $default = ''; 
     664  } 
     665  $html = $html."<option value=\"thu\" $default>" . _("Thursday"); 
     666 
     667  if ( $wday_start == 'fri' ) {  
     668    $default = ' selected';  
     669  } else { 
     670    $default = ''; 
     671  } 
     672  $html = $html."<option value=\"fri\" $default>" . _("Friday"); 
     673 
     674  if ( $wday_start == 'sat' ) {  
     675    $default = ' selected';  
     676  } else { 
     677    $default = ''; 
     678  } 
     679  $html = $html."<option value=\"sat\" $default>" . _("Saturday"); 
     680 
     681  if ( $wday_start == 'sun' ) {  
     682    $default = ' selected';  
     683  } else { 
     684    $default = ''; 
     685  } 
     686  $html = $html."<option value=\"sun\" $default>" . _("Sunday"); 
     687 
     688  $html = $html.'</td>'; 
     689  $html = $html.'</tr>'; 
     690  $html = $html.'<tr>'; 
     691  $html = $html.'<td>'._("Week Day finish:").'</td>'; 
     692  $html = $html.'<td>'; 
     693  $html = $html.'<select name="'.$name.'[wday_finish]"/>'; 
     694 
     695  if ( $wday_finish == '-' ) {  
     696    $default = ' selected';  
     697  } else { 
     698    $default = ''; 
     699  } 
     700  $html = $html."<option value=\"-\" $default>-"; 
     701  
     702  if ( $wday_finish == 'mon' ) {  
     703    $default = ' selected';  
     704  } else { 
     705    $default = ''; 
     706  } 
     707  $html = $html."<option value=\"mon\" $default>" . _("Monday"); 
     708 
     709  if ( $wday_finish == 'tue' ) {  
     710    $default = ' selected';  
     711  } else { 
     712    $default = ''; 
     713  } 
     714  $html = $html."<option value=\"tue\" $default>" . _("Tuesday"); 
     715 
     716  if ( $wday_finish == 'wed' ) {  
     717    $default = ' selected';  
     718  } else { 
     719    $default = ''; 
     720  } 
     721  $html = $html."<option value=\"wed\" $default>" . _("Wednesday"); 
     722 
     723  if ( $wday_finish == 'thu' ) {  
     724    $default = ' selected';  
     725  } else { 
     726    $default = ''; 
     727  } 
     728  $html = $html."<option value=\"thu\" $default>" . _("Thursday"); 
     729 
     730  if ( $wday_finish == 'fri' ) {  
     731    $default = ' selected';  
     732  } else { 
     733    $default = ''; 
     734  } 
     735  $html = $html."<option value=\"fri\" $default>" . _("Friday"); 
     736 
     737  if ( $wday_finish == 'sat' ) {  
     738    $default = ' selected';  
     739  } else { 
     740    $default = ''; 
     741  } 
     742  $html = $html."<option value=\"sat\" $default>" . _("Saturday"); 
     743 
     744  if ( $wday_finish == 'sun' ) {  
     745    $default = ' selected';  
     746  } else { 
     747    $default = ''; 
     748  } 
     749  $html = $html."<option value=\"sun\" $default>" . _("Sunday"); 
     750 
     751  $html = $html.'</td>'; 
     752  $html = $html.'</tr>'; 
     753  $html = $html.'<tr>'; 
     754  $html = $html.'<td>'._("Month Day start:").'</td>'; 
     755 
     756  // MDay could be *, day, day1-day2 
     757  if ( $time_mday != '*' ) { 
     758    list($mday_start, $mday_finish) = explode('-', $time_mday); 
     759    if ($mday_start === '*') { 
     760      $mday_start = $mday_finish; 
     761    } 
     762    if ($mday_finish === '*') { 
     763      $mday_finish = $mday_start; 
     764    } 
     765    if ( !$mday_finish) {  
     766      $mday_finish = $mday_start; 
     767    } 
     768  } else { 
     769    $mday_start = $mday_finish = '-'; 
     770  } 
     771 
     772  $html = $html.'<td>'; 
     773  $html = $html.'<select name="'.$name.'[mday_start]"/>'; 
     774  $default = ''; 
     775  if ( $mday_start == '-' ) { 
     776    $default = ' selected'; 
     777  } 
     778  $html = $html."<option value=\"-\" $default>-"; 
     779  for ($i = 1 ; $i < 32 ; $i++) { 
     780    $default = ''; 
     781    if ( $i == $mday_start ) { 
     782      $default = ' selected'; 
     783    } 
     784    $html = $html."<option value=\"$i\" $default> $i"; 
     785  } 
     786  $html = $html.'</select>'; 
     787  $html = $html.'</td>'; 
     788  $html = $html.'<tr>'; 
     789  $html = $html.'<td>'._("Month Day finish:").'</td>'; 
     790  $html = $html.'<td>'; 
     791  $html = $html.'<select name="'.$name.'[mday_finish]"/>'; 
     792  $default = ''; 
     793  if ( $mday_finish == '-' ) { 
     794    $default = ' selected'; 
     795  } 
     796  $html = $html."<option value=\"-\" $default>-"; 
     797  for ($i = 1 ; $i < 32 ; $i++) { 
     798    $default = ''; 
     799    if ( $i == $mday_finish ) { 
     800      $default = ' selected'; 
     801    } 
     802    $html = $html."<option value=\"$i\" $default> $i"; 
     803  } 
     804  $html = $html.'</select>'; 
     805  $html = $html.'</td>'; 
     806  $html = $html.'</tr>'; 
     807  $html = $html.'<tr>'; 
     808  $html = $html.'<td>'._("Month start:").'</td>'; 
     809 
     810  // Month could be *, month, month1-month2 
     811  if ( $time_month != '*' ) { 
     812    list($month_start, $month_finish) = explode('-', $time_month); 
     813    if ($month_start === '*') { 
     814      $month_start = $month_finish; 
     815    } 
     816    if ($month_finish === '*') { 
     817      $month_finish = $month_start; 
     818    } 
     819    if ( !$month_finish) { 
     820      $month_finish = $month_start; 
     821    } 
     822  } else { 
     823    $month_start = $month_finish = '-'; 
     824  } 
     825  $html = $html.'<td>'; 
     826  $html = $html.'<select name="'.$name.'[month_start]"/>'; 
     827 
     828  if ( $month_start == '-' ) {  
     829    $default = ' selected';  
     830  } else { 
     831    $default = ''; 
     832  } 
     833  $html = $html."<option value=\"-\" $default>-"; 
     834 
     835  if ( $month_start == 'jan' ) {  
     836    $default = ' selected';  
     837  } else { 
     838    $default = ''; 
     839  } 
     840  $html = $html."<option value=\"jan\" $default>" . _("January"); 
     841                                  
     842  if ( $month_start == 'feb' ) {  
     843    $default = ' selected';  
     844  } else { 
     845    $default = ''; 
     846  } 
     847  $html = $html."<option value=\"feb\" $default>" . _("February"); 
     848   
     849  if ( $month_start == 'mar' ) {  
     850    $default = ' selected';  
     851  } else { 
     852    $default = ''; 
     853  } 
     854  $html = $html."<option value=\"mar\" $default>" . _("March"); 
     855                                  
     856  if ( $month_start == 'apr' ) {  
     857    $default = ' selected';  
     858  } else { 
     859    $default = ''; 
     860  } 
     861  $html = $html."<option value=\"apr\" $default>" . _("April"); 
     862    
     863  if ( $month_start == 'may' ) {  
     864    $default = ' selected';  
     865  } else { 
     866    $default = ''; 
     867  } 
     868  $html = $html."<option value=\"may\" $default>" . _("May"); 
     869                                
     870  if ( $month_start == 'jun' ) {  
     871    $default = ' selected';  
     872  } else { 
     873    $default = ''; 
     874  } 
     875  $html = $html."<option value=\"jun\" $default>" . _("June"); 
     876 
     877  if ( $month_start == 'jul' ) {  
     878    $default = ' selected';  
     879  } else { 
     880    $default = ''; 
     881  } 
     882  $html = $html."<option value=\"jul\" $default>" . _("July"); 
     883                                  
     884  if ( $month_start == 'aug' ) {  
     885    $default = ' selected';  
     886  } else { 
     887    $default = ''; 
     888  } 
     889  $html = $html."<option value=\"aug\" $default>" . _("August"); 
     890    
     891  if ( $month_start == 'sep' ) {  
     892    $default = ' selected';  
     893  } else { 
     894    $default = ''; 
     895  } 
     896  $html = $html."<option value=\"sep\" $default>" . _("September"); 
     897                                
     898  if ( $month_start == 'oct' ) {  
     899    $default = ' selected';  
     900  } else { 
     901    $default = ''; 
     902  } 
     903  $html = $html."<option value=\"oct\" $default>" . _("October"); 
     904 
     905  if ( $month_start == 'nov' ) {  
     906    $default = ' selected';  
     907  } else { 
     908    $default = ''; 
     909  } 
     910  $html = $html."<option value=\"nov\" $default>" . _("November"); 
     911                                  
     912  if ( $month_start == 'dec' ) {  
     913    $default = ' selected';  
     914  } else { 
     915    $default = ''; 
     916  } 
     917  $html = $html."<option value=\"dec\" $default>" . _("December"); 
     918 
     919  $html = $html.'</select>'; 
     920  $html = $html.'</td>'; 
     921  $html = $html.'</tr>'; 
     922  $html = $html.'<tr>'; 
     923  $html = $html.'<td>'._("Month finish:").'</td>'; 
     924  $html = $html.'<td>'; 
     925  $html = $html.'<select name="'.$name.'[month_finish]"/>'; 
     926 
     927  if ( $month_finish == '-' ) {  
     928    $default = ' selected';  
     929  } else { 
     930    $default = ''; 
     931  } 
     932  $html = $html."<option value=\"-\" $default>-"; 
     933 
     934  if ( $month_finish == 'jan' ) {  
     935    $default = ' selected';  
     936  } else { 
     937    $default = ''; 
     938  } 
     939  $html = $html."<option value=\"jan\" $default>" . _("January"); 
     940                                  
     941  if ( $month_finish == 'feb' ) {  
     942    $default = ' selected';  
     943  } else { 
     944    $default = ''; 
     945  } 
     946  $html = $html."<option value=\"feb\" $default>" . _("February"); 
     947   
     948  if ( $month_finish == 'mar' ) {  
     949    $default = ' selected';  
     950  } else { 
     951    $default = ''; 
     952  } 
     953  $html = $html."<option value=\"mar\" $default>" . _("March"); 
     954                                  
     955  if ( $month_finish == 'apr' ) {  
     956    $default = ' selected';  
     957  } else { 
     958    $default = ''; 
     959  } 
     960  $html = $html."<option value=\"apr\" $default>" . _("April"); 
     961    
     962  if ( $month_finish == 'may' ) {  
     963    $default = ' selected';  
     964  } else { 
     965    $default = ''; 
     966  } 
     967  $html = $html."<option value=\"may\" $default>" . _("May"); 
     968                                  
     969  if ( $month_finish == 'jun' ) {  
     970    $default = ' selected';  
     971  } else { 
     972    $default = ''; 
     973  } 
     974  $html = $html."<option value=\"jun\" $default>" . _("June"); 
     975   
     976  if ( $month_finish == 'jul' ) {  
     977    $default = ' selected';  
     978  } else { 
     979    $default = ''; 
     980  } 
     981  $html = $html."<option value=\"jul\" $default>" . _("July"); 
     982                                  
     983  if ( $month_finish == 'aug' ) {  
     984    $default = ' selected';  
     985  } else { 
     986    $default = ''; 
     987  } 
     988  $html = $html."<option value=\"aug\" $default>" . _("August"); 
     989    
     990  if ( $month_finish == 'sep' ) {  
     991    $default = ' selected';  
     992  } else { 
     993    $default = ''; 
     994  } 
     995  $html = $html."<option value=\"sep\" $default>" . _("September"); 
     996                                  
     997  if ( $month_finish == 'oct' ) {  
     998    $default = ' selected';  
     999  } else { 
     1000    $default = ''; 
     1001  } 
     1002  $html = $html."<option value=\"oct\" $default>" . _("October"); 
     1003   
     1004  if ( $month_finish == 'nov' ) {  
     1005    $default = ' selected';  
     1006  } else { 
     1007    $default = ''; 
     1008  } 
     1009  $html = $html."<option value=\"nov\" $default>" . _("November"); 
     1010                                  
     1011  if ( $month_finish == 'dec' ) {  
     1012    $default = ' selected';  
     1013  } else { 
     1014    $default = ''; 
     1015  } 
     1016  $html = $html."<option value=\"dec\" $default>" . _("December"); 
     1017 
     1018  $html = $html.'</select>'; 
     1019  $html = $html.'</td>'; 
     1020  $html = $html.'</tr>'; 
     1021  $html = $html.'</tr>'; 
     1022  return $html; 
     1023} 
     1024 
     1025function timeconditions_timegroups_buildtime( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish) { 
     1026 
     1027  //----- Time Hour Interval proccess ---- 
     1028  // 
     1029  if ($minute_start == '-') { 
     1030    $time_minute_start = "00"; 
     1031  } else { 
     1032    $time_minute_start = sprintf("%02d",$minute_start); 
     1033  } 
     1034  if ($minute_finish == '-') { 
     1035    $time_minute_finish = "00"; 
     1036  } else { 
     1037    $time_minute_finish = sprintf("%02d",$minute_finish); 
     1038  } 
     1039  if ($hour_start == '-') { 
     1040    $time_hour_start = '*'; 
     1041  } else { 
     1042    $time_hour_start = sprintf("%02d",$hour_start) . ':' . $time_minute_start; 
     1043  } 
     1044  if ($hour_finish == '-') { 
     1045    $time_hour_finish = '*'; 
     1046  } else { 
     1047    $time_hour_finish = sprintf("%02d",$hour_finish) . ':' . $time_minute_finish; 
     1048  } 
     1049  if ($time_hour_start === '*') { 
     1050    $time_hour_start = $time_hour_finish; 
     1051  } 
     1052  if ($time_hour_finish === '*') {$time_hour_finish = $time_hour_start;} 
     1053  if ($time_hour_start == $time_hour_finish) { 
     1054    $time_hour = $time_hour_start; 
     1055  } else { 
     1056    $time_hour = $time_hour_start . '-' . $time_hour_finish; 
     1057  } 
     1058 
     1059  //----- Time Week Day Interval proccess ----- 
     1060  // 
     1061  if ($wday_start == '-') { 
     1062    $time_wday_start = '*'; 
     1063  } else { 
     1064    $time_wday_start = $wday_start; 
     1065  } 
     1066  if ($wday_finish == '-') { 
     1067    $time_wday_finish = '*'; 
     1068  } else { 
     1069    $time_wday_finish = $wday_finish; 
     1070  } 
     1071  if ($time_wday_start === '*') { 
     1072    $time_wday_start = $time_wday_finish; 
     1073  } 
     1074  if ($time_wday_finish === '*') { 
     1075    $time_wday_finish = $time_wday_start; 
     1076  } 
     1077  if ($time_wday_start == $time_wday_finish) { 
     1078    $time_wday = $time_wday_start; 
     1079  } else { 
     1080    $time_wday = $time_wday_start . '-' . $time_wday_finish; 
     1081  } 
     1082 
     1083  //----- Time Month Day Interval proccess ----- 
     1084  // 
     1085  if ($mday_start == '-') { 
     1086    $time_mday_start = '*'; 
     1087  } else { 
     1088    $time_mday_start = $mday_start; 
     1089  } 
     1090  if ($mday_finish == '-') { 
     1091    $time_mday_finish = '*'; 
     1092  } else { 
     1093    $time_mday_finish = $mday_finish; 
     1094  } 
     1095  if ($time_mday_start === '*') { 
     1096    $time_mday_start = $time_mday_finish; 
     1097  } 
     1098  if ($time_mday_finish === '*') { 
     1099    $time_mday_finish = $time_mday_start; 
     1100  } 
     1101  if ($time_mday_start == $time_mday_finish) { 
     1102    $time_mday = $time_mday_start; 
     1103  } else { 
     1104    $time_mday = $time_mday_start . '-' . $time_mday_finish; 
     1105  } 
     1106 
     1107  //----- Time Month Interval proccess ----- 
     1108  // 
     1109  if ($month_start == '-') { 
     1110    $time_month_start = '*'; 
     1111  } else { 
     1112    $time_month_start = $month_start; 
     1113  } 
     1114  if ($month_finish == '-') { 
     1115    $time_month_finish = '*'; 
     1116  } else { 
     1117    $time_month_finish = $month_finish; 
     1118  } 
     1119  if ($time_month_start === '*') { 
     1120    $time_month_start = $time_month_finish; 
     1121  } 
     1122  if ($time_month_finish === '*') { 
     1123    $time_month_finish = $time_month_start; 
     1124  } 
     1125  if ($time_month_start == $time_month_finish) { 
     1126    $time_month = $time_month_start; 
     1127  } else { 
     1128    $time_month = $time_month_start . '-' . $time_month_finish; 
     1129  } 
     1130  $time = $time_hour . '|' . $time_wday . '|' . $time_mday . '|' . $time_month; 
     1131  return $time; 
     1132} 
     1133 
     1134//---------------------------end stolen from timeconditions------------------------------------- 
     1135 
    2391136?> 
  • modules/branches/2.5/timeconditions/install.php

    r4767 r5920  
    1 <?php 
     1<?php /* $Id: install.php $ */ 
     2 
     3require_once dirname(__FILE__)."/functions.inc.php"; 
    24 
    35global $db; 
    46global $amp_conf; 
    57 
     8if (! function_exists("out")) { 
     9  function out($text) { 
     10    echo $text."<br />"; 
     11  } 
     12} 
     13 
     14if (! function_exists("outn")) { 
     15  function outn($text) { 
     16    echo $text; 
     17  } 
     18} 
     19 
    620$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT"; 
    721 
    8 $sql = "CREATE TABLE IF NOT EXISTS timeconditions ( 
     22$sql = " 
     23CREATE TABLE IF NOT EXISTS timeconditions ( 
    924  timeconditions_id INTEGER NOT NULL PRIMARY KEY $autoincrement, 
    1025  displayname VARCHAR( 50 ) , 
     
    1429  deptname VARCHAR( 50 ) 
    1530)"; 
    16  
    1731$check = $db->query($sql); 
    1832if(DB::IsError($check)) { 
     
    2034} 
    2135 
     36$sql = " 
     37CREATE TABLE IF NOT EXISTS `timegroups_groups` ( 
     38  `id` int(11) NOT NULL PRIMARY KEY $autoincrement, 
     39  `description` varchar(50) NOT NULL default '', 
     40  UNIQUE KEY `display` (`description`) 
     41) $autoincrement = 1  
     42"; 
     43$check = $db->query($sql); 
     44if(DB::IsError($check)) { 
     45  die_freepbx("Can not create `timeconditions` table: " .  $check->getMessage() .  "\n"); 
     46} 
     47 
     48$sql = " 
     49CREATE TABLE IF NOT EXISTS `timegroups_details` ( 
     50  `id` int(11) NOT NULL PRIMARY KEY $autoincrement, 
     51  `timegroupid` int(11) NOT NULL default '0', 
     52  `time` varchar(100) NOT NULL default '' 
     53) $autoincrement = 1  
     54"; 
     55$check = $db->query($sql); 
     56if(DB::IsError($check)) { 
     57  die_freepbx("Can not create `timeconditions` table: " .  $check->getMessage() .  "\n"); 
     58} 
     59 
     60// Merge old findmefollow destinations to extension 
     61// 
    2262$results = array(); 
    2363$sql = "SELECT timeconditions_id, truegoto, falsegoto FROM timeconditions"; 
     
    4181} 
    4282 
     83/* Upgrade to 2.5 
     84 * Migrate time condtions to new time condtions groups 
     85 */ 
     86timeconditions_updatedb(); 
     87 
     88/* Alter the time field to int now that it refernces the id field in groups 
     89 */ 
     90outn(_("converting timeconditions time field to int..")); 
     91$sql = "ALTER TABLE `timeconditions` CHANGE `time` `time` INT (11)"; 
     92$results = $db->query($sql); 
     93if(DB::IsError($results)) { 
     94  out(_("ERROR: failed to convert field ").$results->getMessage()); 
     95} else { 
     96  out(_("OK")); 
     97} 
     98 
     99// bring db up to date on install/upgrade 
     100// 
     101function timeconditions_updatedb() { 
     102  $modinfo = module_getinfo('timeconditions'); 
     103  if (is_array($modinfo)) { 
     104    $ver = $modinfo['timeconditions']['dbversion']; 
     105 
     106    // If previous version was older than 2.5 then migrate the timeconditions to groups 
     107    // 
     108    if (version_compare_freepbx($ver,'2.5','lt')) {  
     109      outn(_("Checking for old timeconditions to upgrade..")); 
     110      $upgradelist = timeconditions_list_forupgrade(); 
     111      if (isset($upgradelist)) {  
     112        // we have old conditions to upgrade 
     113        // 
     114        out(_("starting migration")); 
     115        foreach($upgradelist as $upgrade) { 
     116          $times[] = $upgrade['time']; 
     117          $newid = timeconditions_timegroups_add_group_timestrings('migrated-'.$upgrade['displayname'],$times); 
     118          timeconditions_set_timegroupid($upgrade['timeconditions_id'],$newid); 
     119          $newtimes = timeconditions_timegroups_get_times($newid); 
     120          out(sprintf(_("Upgraded %s and created group %s"), $upgrade['displayname'], 'migrated-'.$upgrade['displayname'])); 
     121          if (!is_array($newtimes)) { 
     122            out(sprintf(_("%sWARNING:%s Not time defined for this condtion, please review"),"<font color='red'>","</font>")); 
     123          } 
     124          unset($times); 
     125        } 
     126      } else { 
     127        out(_("no upgrade needed")); 
     128      } 
     129    } 
     130  } 
     131} 
     132 
     133function timeconditions_list_forupgrade() { 
     134  $results = sql("SELECT * FROM timeconditions","getAll",DB_FETCHMODE_ASSOC); 
     135  if(is_array($results)){ 
     136    foreach($results as $result){ 
     137      $list[] = $result; 
     138    } 
     139  } 
     140  if (isset($list)) { 
     141    return $list; 
     142  } else {  
     143    return null; 
     144  } 
     145} 
     146 
     147function timeconditions_set_timegroupid($id, $timegroup) { 
     148  sql("UPDATE timeconditions SET time = $timegroup WHERE timeconditions_id = $id;"); 
     149} 
    43150?> 
  • modules/branches/2.5/timeconditions/module.xml

    r5812 r5920  
    22  <rawname>timeconditions</rawname> 
    33  <name>Time Conditions</name> 
    4   <version>2.4.4.3</version> 
     4  <version>2.5.0</version> 
    55  <type>setup</type> 
    66  <category>Inbound Call Control</category> 
     
    99  </description> 
    1010  <changelog> 
     11    *2.5.0* #1695: Merged timegroups and timecondition changes from contributed_modules originally submitted by naftali5 
    1112    *2.4.4.3* #2604, #2765, #2843 fix mal-formed html tags, Russian Translation 
    1213    *2.4.4.2* generate all timeconditions when using database mode authorization and deptarments 
     
    2526  <menuitems> 
    2627    <timeconditions>Time Conditions</timeconditions> 
     28    <timegroups>Time Groups</timegroups> 
    2729  </menuitems> 
    2830  <location>release/2.4/timeconditions-2.4.4.3.tgz</location> 
  • modules/branches/2.5/timeconditions/page.timeconditions.php

    r5919 r5920  
    1818 
    1919$dispnum = "timeconditions"; //used for switch on config.php 
     20$tabindex = 0; 
    2021 
    2122//if submitting form, update database 
     
    5758</ul></div> 
    5859 
    59 <div class="rnav" style="margin:15px 10px; padding: 5px; background: #e0e0ff; border: #2E78A7 solid 1px;"> 
    60   <?php echo _("Server time:")?> <span id="idTime">00:00:00</span> 
    61 </div> 
    62  
    63 <script> 
    64 var hour = <?php $l = localtime(); echo $l[2]?>; 
    65 var min  = <?php $l = localtime(); echo $l[1]?>; 
    66 var sec  = <?php $l = localtime(); echo $l[0]?>; 
    67  
    68 // happily stollen from http://www.aspfaq.com/show.asp?id=2300 
    69 function PadDigits(n, totalDigits)  
    70 {  
    71   n = n.toString();  
    72   var pd = '';  
    73   if (totalDigits > n.length)  
    74   {  
    75     for (i=0; i < (totalDigits-n.length); i++)  
    76     {  
    77       pd += '0';  
    78     }  
    79   }  
    80   return pd + n.toString();  
    81 }  
    82  
    83 function updateTime() 
    84 { 
    85   sec++; 
    86   if (sec==60) 
    87   { 
    88     min++; 
    89     sec = 0; 
    90   }  
    91      
    92   if (min==60) 
    93   { 
    94     hour++; 
    95     min = 0; 
    96   } 
    97  
    98   if (hour==24) 
    99   { 
    100     hour = 0; 
    101   } 
    102    
    103   document.getElementById("idTime").innerHTML = PadDigits(hour,2)+":"+PadDigits(min,2)+":"+PadDigits(sec,2); 
    104   setTimeout('updateTime()',1000); 
    105 } 
    106  
    107 updateTime(); 
    108 </script> 
    109  
    110  
    11160<div class="content"> 
    11261<?php 
     
    12473  <h2><?php echo ($itemid ? _("Time Condition:")." ". $itemid : _("Add Time Condition")); ?></h2> 
    12574<?php   if ($itemid){ ?> 
    126   <a href="<?php echo $delURL ?>"><?php echo _("Delete Time Condition")?> <?php echo $itemid; ?></a> 
    127 <?php 
    128           $usage_list = framework_display_destination_usage(timeconditions_getdest($itemid)); 
    129           if (!empty($usage_list)) { 
    130 ?> 
    131             <br /><a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> 
    132 <?php 
    133           } 
    134       }  
    135 ?> 
     75  <p><a href="<?php echo $delURL ?>"><?php echo _("Delete Time Condition")?> <?php echo $itemid; ?></a></p> 
     76<?php   } ?> 
    13677  <form autocomplete="off" name="edit" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return edit_onsubmit();"> 
    13778  <input type="hidden" name="display" value="<?php echo $dispnum?>"> 
     
    15091  </tr> 
    15192  <tr> 
    152     <td><a href="#" class="info"><?php echo _("Time to match:")?><span><?php echo _("time range|days of week|days of month|months<br><br>you can use an * as a wildcard.<br><br>ex: <b>9:00-17:00|mon-fri|*|*</b>")?></span></a></td> 
    153                <?php 
    154                    // ----- Load Time Pattern Variables ----- 
    155     if (isset($thisItem)) { 
    156       list($time_hour, $time_wday, $time_mday, $time_month) = explode( '|', $thisItem['time'] ); 
    157     } else { 
    158       list($time_hour, $time_wday, $time_mday, $time_month) = Array('*','-','-','-'); 
    159     } 
    160        
    161                ?> 
    162                <tr> 
    163                    <td><?php echo _("Time to start:")?></td> 
    164                    <td> 
    165                        <?php 
    166                            // Hour could be *, hh:mm, hh:mm-hhmm 
    167                            if ( $time_hour === '*' ) { 
    168                                $hour_start = $hour_finish = '-'; 
    169                                $minute_start = $minute_finish = '-'; 
    170          } else { 
    171                                list($hour_start_string, $hour_finish_string) = explode('-', $time_hour); 
    172                                list($hour_start, $minute_start) = explode( ':', $hour_start_string); 
    173                                list($hour_finish, $minute_finish) = explode( ':', $hour_finish_string); 
    174                                if ( !$hour_finish ) $hour_finish = $hour_start; 
    175                                if ( !$minute_finish ) $minute_finish = $minute_start; 
    176                            } 
    177                        ?> 
    178                         <select name="hour_start" tabindex="<?php echo ++$tabindex;?>"> 
    179                         <?php 
    180                            $default = ''; 
    181                             if ( $hour_start === '-' ) $default = ' selected'; 
    182                             echo "<option value=\"-\" $default>-"; 
    183                             for ($i = 0 ; $i < 24 ; $i++) { 
    184                                $default = ""; 
    185                                if ( sprintf("%02d", $i) === $hour_start ) $default = ' selected'; 
    186                                 echo "<option value=\"$i\" $default> ".sprintf("%02d", $i); 
    187                             } 
    188                         ?> 
    189                         </select> 
    190                        : 
    191                         <select name="minute_start" tabindex="<?php echo ++$tabindex;?>"> 
    192                         <?php 
    193                            $default = ''; 
    194                             if ( $minute_start === '-' ) $default = ' selected'; 
    195                             echo "<option value=\"-\" $default>-"; 
    196                             for ($i = 0 ; $i < 60 ; $i++) { 
    197                                 $default = ""; 
    198                                 if ( sprintf("%02d", $i) === $minute_start ) $default = ' selected'; 
    199                                 echo "<option value=\"$i\" $default> ".sprintf("%02d", $i); 
    200                             } 
    201                         ?> 
    202                         </select> 
    203                     </td> 
    204                </tr> 
    205                <tr> 
    206                    <td><?php echo _("Time to finish:")?></td> 
    207                    <td> 
    208                         <select name="hour_finish" tabindex="<?php echo ++$tabindex;?>"> 
    209                         <?php 
    210                            $default = ''; 
    211                             if ( $hour_finish === '-' ) $default = ' selected'; 
    212                             echo "<option value=\"-\" $default>-"; 
    213                             for ($i = 0 ; $i < 24 ; $i++) { 
    214                                 $default = ""; 
    215                                 if ( sprintf("%02d", $i) === $hour_finish) $default = ' selected'; 
    216                                 echo "<option value=\"$i\" $default> ".sprintf("%02d", $i); 
    217                             } 
    218                         ?> 
    219                         </select> 
    220                        : 
    221                         <select name="minute_finish" tabindex="<?php echo ++$tabindex;?>"> 
    222                         <?php 
    223                             $default = ''; 
    224                             if ( $minute_finish === '-' ) $default = ' selected'; 
    225                             echo "<option value=\"-\" $default>-"; 
    226                             for ($i = 0 ; $i < 60 ; $i++) { 
    227                                $default = ''; 
    228                                 if ( sprintf("%02d", $i) === $minute_finish ) $default = ' selected'; 
    229                                 echo "<option value=\"$i\" $default> ".sprintf("%02d", $i); 
    230                             } 
    231                         ?> 
    232                         </select> 
    233                     </td> 
    234                </tr> 
    235                 <tr> 
    236                    <?php  
    237                          // WDay could be *, day, day1-day2 
    238                          if ( $time_wday != '*' ) { 
    239                              list($wday_start, $wday_finish) = explode('-', $time_wday); 
    240                              if ( !$wday_finish) $wday_finish = $wday_start; 
    241                          } else { 
    242                              $wday_start = $wday_finish = '-'; 
    243                          } 
    244                     ?> 
    245                    <td><?php echo _("Week Day Start:")?></td> 
    246                    <td> 
    247                        <select name="wday_start" tabindex="<?php echo ++$tabindex;?>"> 
    248                            <?php  
    249                                if ( $wday_start == '-' ) { $default = ' selected'; } 
    250                                else {$default = '';} 
    251                                echo "<option value=\"-\" $default>-"; 
    252   
    253                                if ( $wday_start == 'mon' ) { $default = ' selected'; } 
    254                                 else {$default = '';} 
    255                                echo "<option value=\"mon\" $default>" . _("Monday"); 
    256  
    257                                 if ( $wday_start == 'tue' ) { $default = ' selected'; } 
    258                                else {$default = '';} 
    259                                 echo "<option value=\"tue\" $default>" . _("Tuesday"); 
    260  
    261                                 if ( $wday_start == 'wed' ) { $default = ' selected'; } 
    262                                else {$default = '';} 
    263                                 echo "<option value=\"wed\" $default>" . _("Wednesday"); 
    264  
    265                                 if ( $wday_start == 'thu' ) { $default = ' selected'; } 
    266                                 else {$default = '';} 
    267                                 echo "<option value=\"thu\" $default>" . _("Thursday"); 
    268  
    269                                 if ( $wday_start == 'fri' ) { $default = ' selected'; } 
    270                                 else {$default = '';} 
    271                                 echo "<option value=\"fri\" $default>" . _("Friday"); 
    272  
    273                                 if ( $wday_start == 'sat' ) { $default = ' selected'; } 
    274                                 else {$default = '';} 
    275                                 echo "<option value=\"sat\" $default>" . _("Saturday"); 
    276  
    277                                if ( $wday_start == 'sun' ) { $default = ' selected'; } 
    278                                 else {$default = '';} 
    279                                 echo "<option value=\"sun\" $default>" . _("Sunday"); 
    280                        ?> 
    281            </td> 
    282                </tr> 
    283                <tr> 
    284                    <td><?php echo _("Week Day finish:")?></td> 
    285                    <td> 
    286                        <select name="wday_finish" tabindex="<?php echo ++$tabindex;?>"> 
    287                        <?php  
    288                                if ( $wday_finish == '-' ) { $default = ' selected'; } 
    289                                else {$default = '';} 
    290                                echo "<option value=\"-\" $default>-"; 
    291   
    292                                if ( $wday_finish == 'mon' ) { $default = ' selected'; } 
    293                                 else {$default = '';} 
    294                                echo "<option value=\"mon\" $default>" . _("Monday"); 
    295  
    296                                 if ( $wday_finish == 'tue' ) { $default = ' selected'; } 
    297                                else {$default = '';} 
    298                                 echo "<option value=\"tue\" $default>" . _("Tuesday"); 
    299  
    300                                 if ( $wday_finish == 'wed' ) { $default = ' selected'; } 
    301                                else {$default = '';} 
    302                                 echo "<option value=\"wed\" $default>" . _("Wednesday"); 
    303  
    304                                 if ( $wday_finish == 'thu' ) { $default = ' selected'; } 
    305                                 else {$default = '';} 
    306                                 echo "<option value=\"thu\" $default>" . _("Thursday"); 
    307  
    308                                 if ( $wday_finish == 'fri' ) { $default = ' selected'; } 
    309                                 else {$default = '';} 
    310                                 echo "<option value=\"fri\" $default>" . _("Friday"); 
    311  
    312                                 if ( $wday_finish == 'sat' ) { $default = ' selected'; } 
    313                                 else {$default = '';} 
    314                                 echo "<option value=\"sat\" $default>" . _("Saturday"); 
    315  
    316                                if ( $wday_finish == 'sun' ) { $default = ' selected'; } 
    317                                 else {$default = '';} 
    318                                 echo "<option value=\"sun\" $default>" . _("Sunday"); 
    319                        ?> 
    320                    </td> 
    321                 </tr> 
    322                 <tr> 
    323                    <td><?php echo _("Month Day start:")?></td> 
    324                     <?php 
    325                          // MDay could be *, day, day1-day2 
    326                          if ( $time_mday != '*' ) { 
    327                              list($mday_start, $mday_finish) = explode('-', $time_mday); 
    328                              if ( !$mday_finish) $mday_finish = $mday_start; 
    329                          } else { 
    330                              $mday_start = $mday_finish = '-'; 
    331                          } 
    332                    ?> 
    333                   <td> 
    334                         <select name="mday_start" tabindex="<?php echo ++$tabindex;?>"> 
    335                          <?php 
    336                             $default = ''; 
    337                             if ( $mday_start == '-' ) $default = ' selected'; 
    338                             echo "<option value=\"-\" $default>-"; 
    339                             for ($i = 1 ; $i < 32 ; $i++) { 
    340                                 $default = ''; 
    341                                 if ( $i == $mday_start ) $default = ' selected'; 
    342                                 echo "<option value=\"$i\" $default> $i"; 
    343                             } 
    344                         ?> 
    345                         </select> 
    346                     </td> 
    347                <tr> 
    348                    <td><?php echo _("Month Day finish:")?></td> 
    349                   <td> 
    350                         <select name="mday_finish" tabindex="<?php echo ++$tabindex;?>"> 
    351                         <?php 
    352                             $default = ''; 
    353                             if ( $mday_finish == '-' ) $default = ' selected'; 
    354                             echo "<option value=\"-\" $default>-"; 
    355                             for ($i = 1 ; $i < 32 ; $i++) { 
    356                                 $default = ''; 
    357                                 if ( $i == $mday_finish ) $default = ' selected'; 
    358                                 echo "<option value=\"$i\" $default> $i"; 
    359                             } 
    360                         ?> 
    361                         </select> 
    362                     </td> 
    363                </tr> 
    364                 <tr> 
    365                    <td><?php echo _("Month start:")?></td> 
    366                      <?php 
    367                          // Month could be *, month, month1-month2 
    368                          if ( $time_month != '*' ) { 
    369                              list($month_start, $month_finish) = explode('-', $time_month); 
    370                              if ( !$month_finish) $month_finish = $month_start; 
    371                          } else { 
    372                              $month_start = $month_finish = '-'; 
    373                          } 
    374                    ?> 
    375                   <td> 
    376                         <select name="month_start" tabindex="<?php echo ++$tabindex;?>"> 
    377                             <?php    
    378                                 if ( $month_start == '-' ) { $default = ' selected'; } 
    379                                 else {$default = '';} 
    380                                 echo "<option value=\"-\" $default>-"; 
    381                                 if ( $month_start == 'jan' ) { $default = ' selected'; } 
    382                                 else {$default = '';} 
    383                                 echo "<option value=\"jan\" $default>" . _("January"); 
    384                                 
    385                                 if ( $month_start == 'feb' ) { $default = ' selected'; } 
    386                                 else {$default = '';} 
    387                                 echo "<option value=\"feb\" $default>" . _("February"); 
    388  
    389                                 if ( $month_start == 'mar' ) { $default = ' selected'; } 
    390                                 else {$default = '';} 
    391                                 echo "<option value=\"mar\" $default>" . _("March"); 
    392                                 
    393                                 if ( $month_start == 'apr' ) { $default = ' selected'; } 
    394                                 else {$default = '';} 
    395                                 echo "<option value=\"apr\" $default>" . _("April"); 
    396   
    397                                if ( $month_start == 'may' ) { $default = ' selected'; } 
    398                                 else {$default = '';} 
    399                                 echo "<option value=\"may\" $default>" . _("May"); 
    400                                 
    401                                 if ( $month_start == 'jun' ) { $default = ' selected'; } 
    402                                else {$default = '';} 
    403                                 echo "<option value=\"jun\" $default>" . _("June"); 
    404  
    405                                 if ( $month_start == 'jul' ) { $default = ' selected'; } 
    406                                 else {$default = '';} 
    407                                 echo "<option value=\"jul\" $default>" . _("July"); 
    408                                 
    409                                 if ( $month_start == 'aug' ) { $default = ' selected'; } 
    410                                 else {$default = '';} 
    411                                 echo "<option value=\"aug\" $default>" . _("August"); 
    412   
    413                                if ( $month_start == 'sep' ) { $default = ' selected'; } 
    414                                 else {$default = '';} 
    415                                 echo "<option value=\"sep\" $default>" . _("September"); 
    416                                 
    417                                 if ( $month_start == 'oct' ) { $default = ' selected'; } 
    418                                 else {$default = '';} 
    419                                 echo "<option value=\"oct\" $default>" . _("October"); 
    420                                 if ( $month_start == 'nov' ) { $default = ' selected'; } 
    421                                 else {$default = '';} 
    422                                 echo "<option value=\"nov\" $default>" . _("November"); 
    423                                 
    424                                 if ( $month_start == 'dec' ) { $default = ' selected'; } 
    425                                 else {$default = '';} 
    426                                 echo "<option value=\"dec\" $default>" . _("December"); 
    427                          ?> 
    428                        </select> 
    429                      </td> 
    430         </tr> 
    431                 <tr> 
    432                     <td><?php echo _("Month finish:")?></td> 
    433                     <td> 
    434                         <select name="month_finish" tabindex="<?php echo ++$tabindex;?>"> 
    435                         <?php    
    436                                 if ( $month_finish == '-' ) { $default = ' selected'; } 
    437                                 else {$default = '';} 
    438                                 echo "<option value=\"-\" $default>-"; 
    439                                 if ( $month_finish == 'jan' ) { $default = ' selected'; } 
    440                                 else {$default = '';} 
    441                                 echo "<option value=\"jan\" $default>" . _("January"); 
    442                                 
    443                                 if ( $month_finish == 'feb' ) { $default = ' selected'; } 
    444                                 else {$default = '';} 
    445                                 echo "<option value=\"feb\" $default>" . _("February"); 
    446  
    447                                 if ( $month_finish == 'mar' ) { $default = ' selected'; } 
    448                                 else {$default = '';} 
    449                                 echo "<option value=\"mar\" $default>" . _("March"); 
    450                                 
    451                                 if ( $month_finish == 'apr' ) { $default = ' selected'; } 
    452                                 else {$default = '';} 
    453                                 echo "<option value=\"apr\" $default>" . _("April"); 
    454   
    455                                if ( $month_finish == 'may' ) { $default = ' selected'; } 
    456                                 else {$default = '';} 
    457                                 echo "<option value=\"may\" $default>" . _("May"); 
    458                                 
    459                                 if ( $month_finish == 'jun' ) { $default = ' selected'; } 
    460                                 else {$default = '';} 
    461                                 echo "<option value=\"jun\" $default>" . _("June"); 
    462  
    463                                 if ( $month_finish == 'jul' ) { $default = ' selected'; } 
    464                                 else {$default = '';} 
    465                                 echo "<option value=\"jul\" $default>" . _("July"); 
    466                                 
    467                                 if ( $month_finish == 'aug' ) { $default = ' selected'; } 
    468                                 else {$default = '';} 
    469                                 echo "<option value=\"aug\" $default>" . _("August"); 
    470   
    471                                if ( $month_finish == 'sep' ) { $default = ' selected'; } 
    472                                 else {$default = '';} 
    473                                 echo "<option value=\"sep\" $default>" . _("September"); 
    474                                 
    475                                if ( $month_finish == 'oct' ) { $default = ' selected'; } 
    476                                 else {$default = '';} 
    477                                 echo "<option value=\"oct\" $default>" . _("October"); 
    478  
    479                                 if ( $month_finish == 'nov' ) { $default = ' selected'; } 
    480                                 else {$default = '';} 
    481                                 echo "<option value=\"nov\" $default>" . _("November"); 
    482                                 
    483                                 if ( $month_finish == 'dec' ) { $default = ' selected'; } 
    484                                 else {$default = '';} 
    485                                 echo "<option value=\"dec\" $default>" . _("December"); 
    486                          ?> 
    487                          </select> 
    488                      </td> 
    489                 </tr> 
     93    <td><a href="#" class="info"><?php echo _("Time Group:")?><span><?php echo _("Select a Time Group created under Time Groups. Matching times will be sent to matching destination. If no group is selected, call will always go to no-match destination.")?></span></a></td> 
     94    <td><?php echo timeconditions_timegroups_drawgroupselect('time', (isset($thisItem['time']) ? $thisItem['time'] : ''), true, ''); ?></td> 
    49095  </tr> 
    49196  <tr><td colspan="2"><br><h5><?php echo _("Destination if time matches")?>:<hr></h5></td></tr> 
     
    522127function edit_onsubmit() { 
    523128  var msgInvalidTimeCondName = "<?php echo _('Please enter a valid Time Conditions Name'); ?>"; 
    524   var msgInvalidTimeMatch = "<?php echo _('Please enter the Time to Match, or set all to - to match all times.'); ?>"; 
    525   var msgInvalidDay = "<?php echo _('Please select BOTH or NO days, not just one.'); ?>"; 
    526   var msgInvalidMday = "<?php echo _('Please select BOTH or NO days of the month, not just one.'); ?>"; 
    527   var msgInvalidMth = "<?php echo _('Please select BOTH or NO months, not just one.'); ?>"; 
    528  
     129  var msgInvalidTimeGroup = "<?php echo _('You have not selected a time group to associate with this timecondtion. It will got to the un-matching destination until you update it with a valid grop'); ?>"; 
    529130   
    530131  defaultEmptyOK = false; 
    531132  if (!isAlphanumeric(theForm.displayname.value)) 
    532133    return warnInvalid(theForm.displayname, msgInvalidTimeCondName); 
     134  if (isEmpty(theForm.time.value)) 
     135    return confirm(msgInvalidTimeGroup) 
    533136   
    534   // Check to see that they're either all '-' or all numbers. 
    535   if ((theForm.hour_start.value == "-" || theForm.hour_finish.value == "-"  || theForm.minute_start.value == "-" || theForm.minute_finish.value == "-") && (theForm.hour_start.value != "-" || theForm.hour_finish.value != "-"  || theForm.minute_start.value != "-" || theForm.minute_finish.value != "-"))  
    536     return warnInvalid(theForm.displayname, msgInvalidTimeMatch); 
    537  
    538   if ((theForm.wday_start.value == "-" || theForm.wday_finish.value == "-") && (theForm.wday_start.value != "-" ||theForm.wday_finish.value != "-" )) 
    539     return warnInvalid(theForm.displayname, msgInvalidDay); 
    540  
    541   if ((theForm.mday_start.value == "-" || theForm.mday_finish.value == "-") && (theForm.mday_start.value != "-" || theForm.mday_finish.value != "-" )) 
    542     return warnInvalid(theForm.displayname, msgInvalidMday); 
    543  
    544   if ((theForm.month_start.value == "-" || theForm.month_finish.value == "-") && (theForm.month_start.value != "-" || theForm.month_finish.value != "-" )) 
    545     return warnInvalid(theForm.displayname, msgInvalidMth); 
    546      
    547137  if (!validateDestinations(edit,2,true)) 
    548138    return false; 
  • modules/branches/2.5/timeconditions/uninstall.sql

    r4243 r5920  
     1DROP TABLE IF EXISTS `timegroups_groups`; 
     2DROP TABLE IF EXISTS `timegroups_detail`; 
    13DROP TABLE IF EXISTS `timeconditions`;