#!/usr/bin/php
<?php
/*
  vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
  Codificación: UTF-8
  +----------------------------------------------------------------------+
  | Issabel version 0.5                                                  |
  | http://www.issabel.org                                               |
  +----------------------------------------------------------------------+
  | Copyright (c) 2006 Palosanto Solutions S. A.                         |
  | Copyright (c) 1997-2003 Palosanto Solutions S. A.                    |
  +----------------------------------------------------------------------+
  | The contents of this file are subject to the General Public License  |
  | (GPL) Version 2 (the "License"); you may not use this file except in |
  | compliance with the License. You may obtain a copy of the License at |
  | http://www.opensource.org/licenses/gpl-license.php                   |
  |                                                                      |
  | Software distributed under the License is distributed on an "AS IS"  |
  | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See  |
  | the License for the specific language governing rights and           |
  | limitations under the License.                                       |
  +----------------------------------------------------------------------+
  | The Initial Developer of the Original Code is PaloSanto Solutions    |
  +----------------------------------------------------------------------+
  | Autor: Eduardo Cueva <ecueva@palosanto.com>                          |
  +----------------------------------------------------------------------+
  $Id: vacations_config.php,v 1.1 2010/08/16 13:49:36 ecueva Exp $
*/

require_once 'Console/Getopt.php';

if(!isset($argv[1]))
    exit(1);

$response = FALSE;

switch($argv[1]){
    case "create_cron":
	$response = create_cron();
	break;
    case "exist_cron":
	$response = exist_cron();
	break;
    default:
	exit(1);
	break;
}

return $response;


function create_cron()
{
    $file = "/etc/cron.d/vacations";
    $status = touch("/etc/cron.d/vacations");
    $content = "59 00 * * *  root /usr/bin/php -q /var/www/disable_vacations.php\n";
    if($status)
	$status = file_put_contents($file, $content);
    if(!$status)
	exit(1);
    return TRUE;
}

function exist_cron()
{
    $file = "/etc/cron.d/vacations";
    if(is_file($file))
	return TRUE;
    exit(1);
}

?>
