X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fevent.php;h=6c0e2bdec6e68608a5d8267200cb75ea6289f8e6;hb=d49325d177cf03b97df250ca3cb081421c541049;hp=f9f3b1320465c3b817a397329a12101b05395c13;hpb=1940905454b311fc5999a0d8020832bb92ee52f5;p=friendica.git
diff --git a/include/event.php b/include/event.php
index f9f3b13204..6c0e2bdec6 100644
--- a/include/event.php
+++ b/include/event.php
@@ -1,15 +1,46 @@
".bbcode($ev['summary'])."";
+
+ $o .= "
' . "\r\n";
@@ -19,28 +50,27 @@ function format_event_html($ev) {
$o .= '
' . t('Starts:') . ' '
- . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
- $ev['start'] , $bd_format ))
- : day_translate(datetime_convert('UTC', 'UTC',
- $ev['start'] , $bd_format)))
+ . '" >'.$event_start
. '
' . "\r\n";
if(! $ev['nofinish'])
$o .= '
' . t('Finishes:') . ' '
- . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
- $ev['finish'] , $bd_format ))
- : day_translate(datetime_convert('UTC', 'UTC',
- $ev['finish'] , $bd_format )))
+ . '" >'.$event_end
. '
' . "\r\n";
- if(strlen($ev['location']))
- $o .= '
' . t('Location:') . ' '
- . bbcode($ev['location'])
+ if(strlen($ev['location'])){
+ $o .= ' ' . t('Location:') . ' '
+ . bbcode($ev['location'])
. '
' . "\r\n";
+ if (strpos($ev['location'], "[map") !== False) {
+ $map = generate_named_map($ev['location']);
+ if ($map!==$ev['location']) $o.=$map;
+ }
+
+ }
+
$o .= '
' . "\r\n";
return $o;
}
@@ -49,7 +79,6 @@ function format_event_html($ev) {
function parse_event($h) {
require_once('include/Scrape.php');
- require_once('library/HTMLPurifier.auto.php');
require_once('include/html2bbcode');
$h = '' . $h . '';
@@ -128,7 +157,7 @@ function format_event_bbcode($ev) {
if(($ev['finish']) && (! $ev['nofinish']))
$o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
-
+
if($ev['location'])
$o .= '[event-location]' . $ev['location'] . '[/event-location]';
@@ -191,11 +220,17 @@ function ev_compare($a,$b) {
if($date_a === $date_b)
return strcasecmp($a['desc'],$b['desc']);
-
+
return strcmp($date_a,$date_b);
}
+function event_delete($event_id) {
+ if ($event_id == 0)
+ return;
+ q("DELETE FROM `event` WHERE `id` = %d", intval($event_id));
+ logger("Deleted event ".$event_id, LOGGER_DEBUG);
+}
function event_store($arr) {
@@ -258,11 +293,7 @@ function event_store($arr) {
`location` = '%s',
`type` = '%s',
`adjust` = %d,
- `nofinish` = %d,
- `allow_cid` = '%s',
- `allow_gid` = '%s',
- `deny_cid` = '%s',
- `deny_gid` = '%s'
+ `nofinish` = %d
WHERE `id` = %d AND `uid` = %d",
dbesc($arr['edited']),
@@ -274,10 +305,6 @@ function event_store($arr) {
dbesc($arr['type']),
intval($arr['adjust']),
intval($arr['nofinish']),
- dbesc($arr['allow_cid']),
- dbesc($arr['allow_gid']),
- dbesc($arr['deny_cid']),
- dbesc($arr['deny_gid']),
intval($arr['id']),
intval($arr['uid'])
);
@@ -291,22 +318,16 @@ function event_store($arr) {
$object .= '' . "\n";
- q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d",
+ q("UPDATE `item` SET `body` = '%s', `object` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc(format_event_bbcode($arr)),
dbesc($object),
- dbesc($arr['allow_cid']),
- dbesc($arr['allow_gid']),
- dbesc($arr['deny_cid']),
- dbesc($arr['deny_gid']),
dbesc($arr['edited']),
- intval($arr['private']),
intval($r[0]['id']),
intval($arr['uid'])
);
$item_id = $r[0]['id'];
- }
- else
+ } else
$item_id = 0;
call_hooks("event_updated", $arr['id']);
@@ -315,7 +336,7 @@ function event_store($arr) {
}
else {
- // New event. Store it.
+ // New event. Store it.
$r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
`adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
@@ -353,6 +374,7 @@ function event_store($arr) {
$item_arr['contact-id'] = $arr['cid'];
$item_arr['uri'] = $arr['uri'];
$item_arr['parent-uri'] = $arr['uri'];
+ $item_arr['guid'] = $arr['guid'];
$item_arr['type'] = 'activity';
$item_arr['wall'] = (($arr['cid']) ? 0 : 1);
$item_arr['contact-id'] = $contact['id'];
@@ -408,3 +430,427 @@ function event_store($arr) {
return $item_id;
}
}
+
+function get_event_strings() {
+ // First day of the week (0 = Sunday)
+ $firstDay = get_pconfig(local_user(),'system','first_day_of_week');
+ if ($firstDay === false) $firstDay=0;
+
+ $i18n = array(
+ "firstDay" => $firstDay,
+ "Sun" => t("Sun"),
+ "Mon" => t("Mon"),
+ "Tue" => t("Tue"),
+ "Wed" => t("Wed"),
+ "Thu" => t("Thu"),
+ "Fri" => t("Fri"),
+ "Sat" => t("Sat"),
+ "Sunday" => t("Sunday"),
+ "Monday" => t("Monday"),
+ "Tuesday" => t("Tuesday"),
+ "Wednesday" => t("Wednesday"),
+ "Thursday" => t("Thursday"),
+ "Friday" => t("Friday"),
+ "Saturday" => t("Saturday"),
+ "Jan" => t("Jan"),
+ "Feb" => t("Feb"),
+ "Mar" => t("Mar"),
+ "Apr" => t("Apr"),
+ "May" => t("May"),
+ "Jun" => t("Jun"),
+ "Jul" => t("Jul"),
+ "Aug" => t("Aug"),
+ "Sep" => t("Sept"),
+ "Oct" => t("Oct"),
+ "Nov" => t("Nov"),
+ "Dec" => t("Dec"),
+ "January" => t("January"),
+ "February" => t("February"),
+ "March" => t("March"),
+ "April" => t("April"),
+ "May" => t("May"),
+ "June" => t("June"),
+ "July" => t("July"),
+ "August" => t("August"),
+ "September" => t("September"),
+ "October" => t("October"),
+ "November" => t("November"),
+ "December" => t("December"),
+ "today" => t("today"),
+ "month" => t("month"),
+ "week" => t("week"),
+ "day" => t("day"),
+ "allday" => t("all-day"),
+
+ "noevent" => t("No events to display"),
+
+ "dtstart_label" => t("Starts:"),
+ "dtend_label" => t("Finishes:"),
+ "location_label" => t("Location:")
+ );
+
+ return $i18n;
+}
+
+/**
+ * @brief Get an event by its event ID
+ *
+ * @param type $owner_uid The User ID of the owner of the event
+ * @param type $event_params An assoziative array with
+ * int 'event_id' => The ID of the event in the event table
+ * @param type $sql_extra
+ * @return array Query result
+ */
+function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
+ // ownly allow events if there is a valid owner_id
+ if($owner_uid == 0)
+ return;
+
+ // query for the event by event id
+ $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
+ `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
+ STRAIGHT_JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
+ WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra",
+ intval($owner_uid),
+ intval($event_params["event_id"])
+ );
+
+ if(count($r))
+ return $r;
+
+}
+
+/**
+ * @brief Get all events in a specific timeframe
+ *
+ * @param int $owner_uid The User ID of the owner of the events
+ * @param array $event_params An assoziative array with
+ * int 'ignored' =>
+ * string 'start' => Start time of the timeframe
+ * string 'finish' => Finish time of the timeframe
+ * string 'adjust_start' =>
+ * string 'adjust_start' =>
+ *
+ * @param string $sql_extra Additional sql conditions (e.g. permission request)
+ * @return array Query results
+ */
+function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
+ // ownly allow events if there is a valid owner_id
+ if($owner_uid == 0)
+ return;
+
+ // query for the event by date
+ $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
+ `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
+ STRAIGHT_JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
+ WHERE `event`.`uid` = %d AND event.ignore = %d
+ AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
+ OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s'))
+ $sql_extra ",
+ intval($owner_uid),
+ intval($event_params["ignored"]),
+ dbesc($event_params["start"]),
+ dbesc($event_params["start"]),
+ dbesc($event_params["finish"]),
+ dbesc($event_params["adjust_start"]),
+ dbesc($event_params["adjust_start"]),
+ dbesc($event_params["adjust_finish"])
+ );
+
+ if(count($r))
+ return $r;
+}
+
+/**
+ * @brief Convert an array query results in an arry which could be used by the events template
+ *
+ * @param array $arr Event query array
+ * @return array Event array for the template
+ */
+function process_events ($arr) {
+ $events=array();
+
+ $last_date = '';
+ $fmt = t('l, F j');
+ if (count($arr)) {
+ foreach($arr as $rr) {
+
+ $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
+ $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt));
+ $d = day_translate($d);
+
+ $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c'));
+ if ($rr['nofinish']){
+ $end = null;
+ } else {
+ $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c'));
+ }
+
+
+ $is_first = ($d !== $last_date);
+
+ $last_date = $d;
+ $edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
+ $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
+ if(! $title) {
+ list($title, $_trash) = explode("