Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Calendar / Setup / Initialize.php
1 <?php
2 /**
3  * Tine 2.0
4  * 
5  * @package     Calendar
6  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
7  * @author      Jonas Fischer <j.fischer@metaways.de>
8  * @copyright   Copyright (c) 2008-2011 Metaways Infosystems GmbH (http://www.metaways.de)
9  *
10  */
11
12 /**
13  * class for Calendar initialization
14  * 
15  * @package     Setup
16  */
17 class Calendar_Setup_Initialize extends Setup_Initialize
18 {
19     /**
20      * init favorites
21      */
22     protected function _initializeFavorites()
23     {
24         $pfe = Tinebase_PersistentFilter::getInstance();
25         
26         $commonValues = array(
27             'account_id'        => NULL,
28             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
29             'model'             => 'Calendar_Model_EventFilter',
30         );
31         
32         $myEventsPFilter = $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array(
33             'name'              => Calendar_Preference::DEFAULTPERSISTENTFILTER_NAME,
34             'description'       => "All events I attend", // _("All events I attend")
35             'filters'           => array(
36                 array('field' => 'attender'    , 'operator' => 'equals', 'value' => array(
37                     'user_type' => Calendar_Model_Attender::USERTYPE_USER,
38                     'user_id'   => Addressbook_Model_Contact::CURRENTCONTACT,
39                 )),
40                 array('field' => 'attender_status', 'operator' => 'notin', 'value' => array(
41                     'DECLINED'
42                 ))
43             )
44         ))));
45         
46         $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array(
47             'name'              => "Awaiting response", //_("Awaiting response")
48             'description'       => "Events I have not yet responded to", // _("Events I have not yet responded to")
49             'filters'           => array(
50                 array('field' => 'attender'    , 'operator' => 'equals', 'value' => array(
51                     'user_type' => Calendar_Model_Attender::USERTYPE_USER,
52                     'user_id'   => Addressbook_Model_Contact::CURRENTCONTACT,
53                 )),
54                 array('field' => 'attender_status'    , 'operator' => 'in', 'value' => array(
55                     Calendar_Model_Attender::STATUS_NEEDSACTION,
56                     Calendar_Model_Attender::STATUS_TENTATIVE,
57                     
58                 )),
59             )
60         ))));
61         
62         $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array(
63             'name'              => "Declined events", //_("Declined events")
64             'description'       => "Events I have declined", // _("Events I have declined")
65             'filters'           => array(
66                 array('field' => 'attender'    , 'operator' => 'equals', 'value' => array(
67                     'user_type' => Calendar_Model_Attender::USERTYPE_USER,
68                     'user_id'   => Addressbook_Model_Contact::CURRENTCONTACT,
69                 )),
70                 array('field' => 'attender_status'    , 'operator' => 'in', 'value' => array(
71                     Calendar_Model_Attender::STATUS_DECLINED,
72                 )),
73             )
74         ))));
75         
76         $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array(
77             'name'              => "I'm organizer", //_("I'm organizer")
78             'description'       => "Events I'm the organizer of", // _("Events I'm the organizer of")
79             'filters'           => array(
80                 array('field' => 'organizer', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT)
81             )
82         ))));
83     }
84     
85     /**
86      * init favorites
87      */
88     protected function _initializeKeyFields()
89     {
90         $cb = new Tinebase_Backend_Sql(array(
91             'modelName' => 'Tinebase_Model_Config', 
92             'tableName' => 'config',
93         ));
94         
95         $attendeeRolesConfig = array(
96             'name'    => Calendar_Config::ATTENDEE_ROLES,
97             'records' => array(
98                 array('id' => 'REQ', 'value' => 'Required', 'system' => true), //_('Required')
99                 array('id' => 'OPT', 'value' => 'Optional', 'system' => true), //_('Optional')
100             ),
101         );
102         
103         $cb->create(new Tinebase_Model_Config(array(
104             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
105             'name'              => Calendar_Config::ATTENDEE_ROLES,
106             'value'             => json_encode($attendeeRolesConfig),
107         )));
108         
109         $attendeeStatusConfig = array(
110             'name'    => Calendar_Config::ATTENDEE_STATUS,
111             'records' => array(
112                 array('id' => 'NEEDS-ACTION', 'value' => 'No response', 'icon' => 'images/oxygen/16x16/actions/mail-mark-unread-new.png', 'system' => true), //_('No response')
113                 array('id' => 'ACCEPTED',     'value' => 'Accepted',    'icon' => 'images/oxygen/16x16/actions/ok.png',                   'system' => true), //_('Accepted')
114                 array('id' => 'DECLINED',     'value' => 'Declined',    'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png',        'system' => true), //_('Declined')
115                 array('id' => 'TENTATIVE',    'value' => 'Tentative',   'icon' => 'images/calendar-response-tentative.png',               'system' => true), //_('Tentative')
116             ),
117         );
118         
119         $cb->create(new Tinebase_Model_Config(array(
120             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
121             'name'              => Calendar_Config::ATTENDEE_STATUS,
122             'value'             => json_encode($attendeeStatusConfig),
123         )));
124     }
125 }