CMS  Version 3.9
calendar_manager.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::using("component");
40 Fakoli::usingFeature("tab_bar");
41 
43 {
44  static function displayCalendar($identifier, &$continue)
45  {
46  try
47  {
49 
50  $page = ComponentPage::findByIdentifier("calendar_view", "WHERE enabled=1");
51  $_GET["cal"] = $identifier;
52 
53  $pageView = new ComponentPageView($page, "{$page->template}.tpl");
54 
55  $page_role = $page->role;
56 
57  if (!checkRole($page->role))
58  {
60  redirect("/login");
61  }
62 
63  echo $pageView->drawView();
64 
65  $continue = false;
66  }
67  catch(DataNotFoundException $e)
68  {
69 
70  }
71 
72  return $identifier;
73  }
74 
75  static function enumerateItems($items)
76  {
77  $calendars = Query::create(Calendar, "ORDER BY name")->execute();
78 
79  $items["Calendars"] = $calendars;
80  return $items;
81  }
82 
84  {
85  array_push($classes, "Event");
86 
87  return $classes;
88  }
89 
90  static function getTabs($key)
91  {
92  $tabs = array( "Details" => "/admin/calendar_form",
93  "Calendar" => "/admin/calendar_view",
94  "Event List" => "/admin/calendar_events"
95  );
96 
97  $qs = ($key) ? "calendar_id=$key" : "";
98  return new TabBar("tabs", $tabs, $qs);
99  }
100 
101  static function upgradeComponent($version)
102  {
104  $mgr->upgrade($version);
105  }
106 
114  static function deleteUser($user)
115  {
116  $pk = $user->getPrimaryKey();
117  $user_id = $user->$pk;
118 
119  trace("Component calendar is deleting objects dependent on user_id {$user_id}", 3);
120 
121  $calendar = new Calendar();
122  $calendar->delete("WHERE owner_id={$user_id}");
123 
124  return $user;
125  }
126 
128  {
129  $classes[] = Event;
130  return $classes;
131  }
132 
133  static function registerCommentAdapter()
134  {
136  }
137 
139  {
140  SerializationManager::registerHandler("calendar", "Calendars, Calendar Events and Event Types",
141  new CompoundSerializationHandler("CalendarMap",
142  'Calendar', 'Event', 'EventCommentXref',
143  'EventSiteXref', 'EventType',
144  'CalendarEventTypeXref'));
145  SerializationManager::registerHandler("timezones", "Time Zones", new SimpleSerializationHandler('TimeZone'));
146  return true;
147  }
148 
152  static function setDefaults()
153  {
154  Settings::setDefaultValue("calendar", "max_events_per_day", 5, Number, "For calendar monthly display; set to 0 if no maximum");
155  // There does not seem to be any use in a "view_events" since this would be controlled by
156  // page role and menu role access to the calendar pages.
157  Settings::setDefaultPermission("calendar", "edit_events", "Add or Edit Events", "admin");
158  Settings::setDefaultValue("calendar", "allow_comments", false, Boolean, "Allow users to comment on events");
159  }
160 }
161 ?>
$user_id
$tabs
$calendar
$calendars
Definition: calendars.inc:39
$page
Definition: help.inc:39
Defines the Event class.
Definition: calendar.inc:43
static findByIdentifier($identifier)
Definition: calendar.inc:73
static enumerateContextHelpClasses($classes)
static getTabs($key)
static upgradeComponent($version)
static registerSerializationHandler()
static deleteUser($user)
Respond to fired event DeleteUser.
static setDefaults()
params to setDefaultValue: component, name, value, field_type, annotation, category,...
static registerCommentAdapter()
static registerTaxonomyClasses($classes)
static enumerateItems($items)
static displayCalendar($identifier, &$continue)
static registerAdapter($component, $parentClass, $xrefClass)
static findByIdentifier($identifier, $constraint="")
ComponentPageView generates the page content for a component page, substituting page fields,...
Provides serialization for a number of DataItem classes, grouped under a common tag in the serialized...
Defines the Event class.
Definition: event.inc:43
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
Definition: login.inc:493
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
static setDefaultPermission($component, $name, $annotation, $value, $weight=0)
Set a default Permission value indicating which SiteRoles have the given permission.
Definition: settings.inc:230
Provides a simple implementation of a SerializationHandler that can serialize a single DataItem class...
global $user
$identifier
Definition: rss.inc:37