Jörg Nissen - 2011-03-28

I was in need of per weekday open hours. So I made a little extension to the function isChatOpen() in lib/class/AJAXChat.php. First of all change the order of the code in  "Check the opening hours" and " Check the opening weekdays" as when the day is not open there is no need to check the hours.
Then replace the code under " Check the opening hours"

if(($this->getConfig('openingHour') > date('G', $time)) || ($this->getConfig('closingHour') <= date('G', $time)))
                        return false;

with

if (is_array($this->getConfig('openingHour'))) {
  $currWeekDay = date('w', $time);
  $openingHours = $this->getConfig('openingHour');
  $closingHours = $this->getConfig('closingHour');
  if (! array_key_exists($currWeekDay, $openingHours)) {
     return false;
  }
  else {
    if(($openingHours[$currWeekDay] > date('G', $time)) || ($closingHours[$currWeekDay] <= date('G', $time)))
      return false;
    return true;
  }
}
else {
  if(($this->getConfig('openingHour') > date('G', $time)) || ($this->getConfig('closingHour') <= date('G', $time)))
    return false;
}
return true;

Now you can enter an associative array in lib/config.php like this:

// Defines the hour of the day the chat is opened (0 - closingHour):
$config['openingHour'] = array(0=>8,1=>15,2=>15,3=>15,4=>15,5=>14,6=>8);
// Defines the hour of the day the chat is closed (openingHour - 24):
$config['closingHour'] = array(0=>20,1=>18,2=>18,3=>18,4=>18,5=>20,6=>20);

The index in the array represents the week of day starting at 0 for sunday. The value is the starting resp. end hour of chat service time.