CMS  Version 3.9
event.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 
42 class Event extends DataItem
43 {
44  var $fields = array("event_id" => Number,
45  "title" => String,
46  "calendar_id" => Number,
47  "start_date" => DateTime,
48  "end_date" => DateTime,
49  "time_zone_id" => Number,
50  "location" => String,
51  "event_type" => String,
52  "description" => HTML,
53  "published" => Boolean,
54  "allow_access" => String,
55  "owner_id" => Number,
56  "last_modified" => Timestamp,
57  "event_invitation_id" => Number,
58  "composite_class" => String,);
59 
60  // Relations
61 
62  var $relations = array(
63  "Sites" => Site,
64  "Calendar" => Calendar,
65  "Invitation" => EventInvitation,
66  "TimeZone" => TimeZone,
67  "Comments" => Comment,
68  "Owner" => "", // person who created the event
69  );
70 
71  function Sites($constraint = "")
72  {
73  return $this->crossReference(Site, EventSiteXref, $constraint);
74  }
75 
76  function Calendar()
77  {
78  return $this->getRelated(Calendar);
79  }
80 
81  function Owner()
82  {
83  $mgr = new UserManager();
84  return $mgr->getUser($this->owner_id);
85  }
86 
87  function Comments($constraint = "")
88  {
89  return $this->crossReference(Comment, EventCommentXref, $constraint);
90  }
91 
92  function setOwner()
93  {
94  global $user;
95 
96  $pk = $user->getPrimaryKey();
97  $this->owner_id = $user->$pk;
98  }
99 
100  function isOwner()
101  {
102  global $user;
103  if(!$user) return false;
104 
105  $pk = $user->getPrimaryKey();
106 
107  return (checkRole("admin") || $user->$pk == $this->owner_id) ? true : false;
108  }
109 
110  function Invitation()
111  {
112  if(!$this->event_invitation_id) return null;
113 
114  return $this->getRelated(EventInvitation);
115  }
116 
117  function TimeZone()
118  {
119  if(!$this->time_zone_id) return null;
120 
121  return $this->getRelated(TimeZone);
122  }
123 
124  function Event()
125  {
126  $this->table = "event";
127  $this->primary_key = "event_id";
128 
129  $this->DataItem(func_get_args());
130  }
131 }
132 
133 class EventSiteXref extends DataItem
134 {
135  var $fields = array("event_site_xref_id" => Number,
136  "event_id" => Number,
137  "site_id" => Number);
138 
139  // Relations
140 
141  var $relations = array( "Event" => Event,
142  "Site" => Site);
143 
144  function Event()
145  {
146  return $this->getRelated(Event);
147  }
148 
149  function Site()
150  {
151  return $this->getRelated(Site);
152  }
153 
154  function EventSiteXref()
155  {
156  $this->primary_key = "event_site_xref_id";
157  $this->table = "event_site_xref";
158 
159  $this->DataItem(func_get_args());
160  }
161 }
162 
163 
164 class EventCommentXref extends DataItem
165 {
166  var $table = "event_comment_xref";
167  var $primary_key = "event_comment_id";
168 
169  var $fields = array("event_comment_id" => Number,
170  "event_id" => Number,
171  "comment_id" => Number);
172 
173  var $relations = array( "Event" => Event,
174  "Comment" => Comment);
175 
177  {
178  return Settings::getValue("calendar", "allow_comments");
179  }
180 
181  function getURL()
182  {
183  if(!$this->event_id) return "";
184 
185  $url = "event_details?event_id={$this->event_id}";
186  return $url . $this->format("#comment{comment_id}");
187  }
188 
189  function Event()
190  {
191  return $this->getRelated(Event);
192  }
193 
194  function Comment()
195  {
196  return $this->getRelated(Comment);
197  }
198 
199 }
200 ?>
$constraint
$calendar owner_id
$event_id
Definition: event_form.inc:41
Defines the Event class.
Definition: calendar.inc:43
verifyEnabled($event_id)
Definition: event.inc:176
Defines the Event class.
Definition: event.inc:43
TimeZone()
Definition: event.inc:117
Invitation()
Definition: event.inc:110
isOwner()
Definition: event.inc:100
$fields
Definition: event.inc:44
setOwner()
Definition: event.inc:92
Event()
Definition: event.inc:124
Owner()
Definition: event.inc:81
$relations
Definition: event.inc:62
Comments($constraint="")
Definition: event.inc:87
Sites($constraint="")
Definition: event.inc:71
Calendar()
Definition: event.inc:76
EventSiteXref()
Definition: event.inc:154
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
Definition: site.inc:40
Provides the interface to the user model for the application.
global $user
$table column("Redirect From", "<a href='redirect_form?redirect_id={redirect_id}'>{redirect_from}</a>", true, "width: 30%") -> column("Redirect To", "<a href='{redirect_to}' target='_blank'>{redirect_to}</a>", true, "width: 30%") ->column("Last Modified", "{last_modified}", true, "width: 20%; text-align: center") ->column("Override", "{ override true
Definition: redirects.inc:9
if(! $blog->published||! $blog->enable_rss_feed||!checkRole($blog->allow_read)) $url
Definition: rss.inc:58