1<?php
2/**
3 * Utility class for dealing with Kronolith_Resource objects
4 *
5 * Copyright 2009-2017 Horde LLC (http://www.horde.org/)
6 *
7 * See the enclosed file COPYING for license information (GPL). If you
8 * did not receive this file, see http://www.horde.org/licenses/gpl.
9 *
10 * @author  Michael J. Rubinsky <mrubinsk@horde.org>
11 *
12 * @package Kronolith
13 */
14class Kronolith_Resource
15{
16    /* ResponseType constants */
17    const RESPONSETYPE_NONE = 0;
18    const RESPONSETYPE_AUTO = 1;
19    const RESPONSETYPE_ALWAYS_ACCEPT = 2;
20    const RESPONSETYPE_ALWAYS_DECLINE = 3;
21    const RESPONSETYPE_MANUAL = 4;
22
23    /* Resource Type constants */
24    const TYPE_SINGLE = 'Single';
25    const TYPE_GROUP = 'Group';
26
27   /**
28    * Adds a new resource to storage
29    *
30    * @param Kronolith_Resource_Base $resource
31    *
32    * @return unknown_type
33    */
34    static public function addResource(Kronolith_Resource_Base $resource)
35    {
36        // Create a new calendar id.
37        $calendar = uniqid(mt_rand());
38        $resource->set('calendar', $calendar);
39        $driver = Kronolith::getDriver('Resource');
40
41        return $driver->save($resource);
42    }
43
44}
45