// start which is always required). Allow desc with a missing summary for compatibility.
if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
- $sub = format_event_html($ev);
+ $sub = format_event_html($ev, $simplehtml);
$Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text);
$Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text);
$o = '';
$expanded = '';
- if($cnt == 1)
+ if($cnt == 1) {
$likers = $arr[0];
- else {
+ // Phrase if there is only one liker. In other cases it will be uses for the expanded
+ // list which show all likers
+ switch($type) {
+ case 'like' :
+ $phrase = sprintf( t('%s likes this.'), $likers);
+ break;
+ case 'dislike' :
+ $phrase = sprintf( t('%s doesn\'t like this.'), $likers);
+ break;
+ case 'attendyes' :
+ $phrase = sprintf( t('%s attends.'), $likers);
+ break;
+ case 'attendno' :
+ $phrase = sprintf( t('%s doesn\'t attend.'), $likers);
+ break;
+ case 'attendmaybe' :
+ $phrase = sprintf( t('%s attends maybe.'), $likers);
+ break;
+ }
+ }
+
+ if($cnt > 1) {
$total = count($arr);
if($total >= MAX_LIKERS)
$arr = array_slice($arr, 0, MAX_LIKERS - 1);
}
$likers = $str;
- }
-
- // Phrase if there is only one liker. In other cases it will be uses for the expanded
- // list which show all likers
- switch($type) {
- case 'like' :
- $phrase = sprintf( t('%s likes this.'), $likers);
- break;
- case 'dislike' :
- $phrase = sprintf( t('%s doesn\'t like this.'), $likers);
- break;
- case 'attendyes' :
- $phrase = sprintf( t('%s attends.'), $likers);
- break;
- case 'attendno' :
- $phrase = sprintf( t('%s doesn\'t attend.'), $likers);
- break;
- case 'attendmaybe' :
- $phrase = sprintf( t('%s attends maybe.'), $likers);
- break;
- }
-
- if($cnt > 1) {
+
$spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\"";
- $expanded .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $phrase . EOL . '</div>';
+
switch($type) {
case 'like':
$phrase = sprintf( t('<span %1$s>%2$d people</span> like this'), $spanatts, $cnt);
+ $explikers = sprintf( t('%s like this.'), $likers);
break;
case 'dislike':
$phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t like this'), $spanatts, $cnt);
+ $explikers = sprintf( t('%s don\'t like this.'), $likers);
break;
case 'attendyes':
$phrase = sprintf( t('<span %1$s>%2$d people</span> attend'), $spanatts, $cnt);
+ $explikers = sprintf( t('%s attend.'), $likers);
break;
case 'attendno':
$phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t attend'), $spanatts, $cnt);
+ $explikers = sprintf( t('%s don\'t attend.'), $likers);
break;
case 'attendmaybe':
$phrase = sprintf( t('<span %1$s>%2$d people</span> anttend maybe'), $spanatts, $cnt);
- case 'agree':
- $phrase = sprintf( t('<span %1$s>%2$d people</span> agree'), $spanatts, $cnt);
+ $explikers = sprintf( t('%s anttend maybe.'), $likers);
break;
- case 'disagree':
- $phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t agree'), $spanatts, $cnt);
- break;
- case 'abstain':
- $phrase = sprintf( t('<span %1$s>%2$d people</span> abstains'), $spanatts, $cnt);
}
+
+ $expanded .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $explikers . EOL . '</div>';
}
$phrase .= EOL ;
if($continent != t('Miscellaneous')) {
$o .= '</optgroup>';
$continent = t('Miscellaneous');
- $o .= '<optgroup label="' . t($continent) . '">';
+ $o .= '<optgroup label="' . t($continent) . '">';
}
}
$city = str_replace('_', ' ', t($city));
$selected = (($value == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"$value\" $selected >$city</option>";
- }
+ }
$o .= '</optgroup></select>';
return $o;
}}
-// return a select using 'field_select_raw' template, with timezones
+// return a select using 'field_select_raw' template, with timezones
// groupped (primarily) by continent
// arguments follow convetion as other field_* template array:
// 'name', 'label', $value, 'help'
$options = select_timezone($current);
$options = str_replace('<select id="timezone_select" name="timezone">','', $options);
$options = str_replace('</select>','', $options);
-
+
$tpl = get_markup_template('field_select_raw.tpl');
return replace_macros($tpl, array(
'$field' => array($name, $label, $current, $help, $options),
));
-
+
}}
// General purpose date parse/convert function.
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
// otherwise we end up with -0001-11-30 ...
- // add 32 days so that we at least get year 00, and then hack around the fact that
- // months and days always start with 1.
+ // add 32 days so that we at least get year 00, and then hack around the fact that
+ // months and days always start with 1.
if(substr($s,0,10) == '0000-00-00') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
* set maximum date from picker with id $maxfrom (none by default)
* @param boolean $required default false
* @return string Parsed HTML output.
- *
+ *
* @todo Once browser support is better this could probably be replaced with
* native HTML5 date picker.
*/
if(! function_exists('datetimesel')) {
function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
+ $a = get_app();
+
+ // First day of the week (0 = Sunday)
+ $firstDay = get_pconfig(local_user(),'system','first_day_of_week');
+ if ($firstDay === false) $firstDay=0;
+
+ $lang = substr(get_browser_language(), 0, 2);
+
+ // Check if the detected language is supported by the picker
+ if (!in_array($lang, array("ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu")))
+ $lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
+
$o = '';
$dateformat = '';
if($pickdate) $dateformat .= 'Y-m-d';
if($picktime) $dateformat .= 'H:i';
$minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
$maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
-
+
$input_text = $default ? 'value="' . date($dateformat, $default->getTimestamp()) . '"' : '';
$defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
$pickers = '';
if(!$pickdate) $pickers .= ',datepicker: false';
if(!$picktime) $pickers .= ',timepicker: false';
$extra_js = '';
- if($minfrom != '')
+ $pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
+ if($minfrom != '')
$extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
- if($maxfrom != '')
+ if($maxfrom != '')
$extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
$readable_format = $dateformat;
$readable_format = str_replace('Y','yyyy',$readable_format);
$readable_format = str_replace('i','MM',$readable_format);
$o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />";
$o .= '</div>';
- $o .= "<script type='text/javascript'>\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})</script>";
+ $o .= "<script type='text/javascript'>";
+ $o .= "\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
+ $o .= "</script>";
return $o;
}}
if(! function_exists('relative_date')) {
function relative_date($posted_date,$format = null) {
- $localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date);
+ $localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date);
$abs = strtotime($localtime);
-
- if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) {
+
+ if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) {
return t('never');
}
$etime = time() - $abs;
-
+
if ($etime < 1) {
return t('less than a second ago');
}
-
+
/*
$time_append = '';
if ($etime >= 86400) {
$time_append = ' ('.$localtime.')';
}
*/
-
+
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')),
30 * 24 * 60 * 60 => array( t('month'), t('months')),
7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
60 => array( t('minute'), t('minutes')),
1 => array( t('second'), t('seconds'))
);
-
+
foreach ($a as $secs => $str) {
$d = $etime / $secs;
if ($d >= 1) {
// Returns age in years, given a date of birth,
// the timezone of the person whose date of birth is provided,
// and the timezone of the person viewing the result.
-// Why? Bear with me. Let's say I live in Mittagong, Australia, and my
+// Why? Bear with me. Let's say I live in Mittagong, Australia, and my
// birthday is on New Year's. You live in San Bruno, California.
// When exactly are you going to see my age increase?
-// A: 5:00 AM Dec 31 San Bruno time. That's precisely when I start
-// celebrating and become a year older. If you wish me happy birthday
-// on January 1 (San Bruno time), you'll be a day late.
-
+// A: 5:00 AM Dec 31 San Bruno time. That's precisely when I start
+// celebrating and become a year older. If you wish me happy birthday
+// on January 1 (San Bruno time), you'll be a day late.
+
function age($dob,$owner_tz = '',$viewer_tz = '') {
if(! intval($dob))
return 0;
// output a calendar for the given month, year.
// if $links are provided (array), e.g. $links[12] => 'http://mylink' ,
-// date 12 will be linked appropriately. Today's date is also noted by
+// date 12 will be linked appropriately. Today's date is also noted by
// altering td class.
// Months count from 1.
'April','May','June',
'July','August','September',
'October','November','December'
- );
+ );
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
if($dow)
for($a = $dow; $a < 7; $a ++)
$o .= '<td> </td>';
- $o .= '</tr></table>'."\r\n";
-
+ $o .= '</tr></table>'."\r\n";
+
return $o;
}}
*
* $bdtext is just a readable placeholder in case the event is shared
* with others. We will replace it during presentation to our $importer
- * to contain a sparkle link and perhaps a photo.
+ * to contain a sparkle link and perhaps a photo.
*
*/
-
+
$bdtext = sprintf( t('%s\'s birthday'), $rr['name']);
$bdtext2 = sprintf( t('Happy Birthday %s'), ' [url=' . $rr['url'] . ']' . $rr['name'] . '[/url]') ;
$birthday = str_replace('1000','1901',$birthday);
- $birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d');
+ if ($birthday != "")
+ $birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d');
// this is to prevent multiple birthday notifications in a single year
// if we already have a stored birthday and the 'm-d' part hasn't changed, preserve the entry, which will preserve the notify year
require_once('include/bbcode.php');
require_once('include/map.php');
-function format_event_html($ev) {
+function format_event_html($ev, $simple = false) {
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
+ $event_start = (($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_end = (($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 )));
+
+ if ($simple) {
+ $o = "<h3>".bbcode($ev['summary'])."</h3>";
+
+ $o .= "<p>".bbcode($ev['desc'])."</p>";
+
+ $o .= "<h4>".t('Starts:')."</h4><p>".$event_start."</p>";
+
+ if(! $ev['nofinish'])
+ $o .= "<h4>".t('Finishes:')."</h4><p>".$event_end."</p>";
+
+ if(strlen($ev['location']))
+ $o .= "<h4>".t('Location:')."</h4><p>".$ev['location']."</p>";
+
+ return $o;
+ }
+
$o = '<div class="vevent">' . "\r\n";
$o .= '<p class="event-start">' . t('Starts:') . ' <abbr class="dtstart" title="'
. datetime_convert('UTC','UTC',$ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
- . '" >'
- . (($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
. '</abbr></p>' . "\r\n";
if(! $ev['nofinish'])
$o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="'
. datetime_convert('UTC','UTC',$ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
- . '" >'
- . (($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
. '</abbr></p>' . "\r\n";
if(strlen($ev['location'])){
- $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">'
- . bbcode($ev['location'])
+ $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">'
+ . bbcode($ev['location'])
. '</span></p>' . "\r\n";
-
+
if (strpos($ev['location'], "[map")===False) {
$map = generate_named_map($ev['location']);
if ($map!==$ev['location']) $o.=$map;
}
-
+
}
$o .= '</div>' . "\r\n";
if(($ev['finish']) && (! $ev['nofinish']))
$o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
-
+
if($ev['location'])
$o .= '[event-location]' . $ev['location'] . '[/event-location]';
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) {
}
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`)
$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'];
if(! $item['deleted'])
logger('consume_feed: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
+ if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ logger("Deleting event ".$item['event-id'], LOGGER_DEBUG);
+ event_delete($item['event-id']);
+ }
+
if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
if((x($datarray,'object-type')) && ($datarray['object-type'] === ACTIVITY_OBJ_EVENT)) {
$ev = bbtoevent($datarray['body']);
- if(x($ev,'desc') && x($ev,'start')) {
+ if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$ev['uid'] = $importer['uid'];
$ev['uri'] = $item_id;
$ev['edited'] = $datarray['edited'];
$ev['private'] = $datarray['private'];
+ $ev['guid'] = $datarray['guid'];
if(is_array($contact))
$ev['cid'] = $contact['id'];
logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
+ if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ logger("Deleting event ".$item['event-id'], LOGGER_DEBUG);
+ event_delete($item['event-id']);
+ }
+
if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
if((x($datarray,'object-type')) && ($datarray['object-type'] === ACTIVITY_OBJ_EVENT)) {
$ev = bbtoevent($datarray['body']);
- if(x($ev,'desc') && x($ev,'start')) {
+ if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$ev['cid'] = $importer['id'];
$ev['uid'] = $importer['uid'];
$ev['uri'] = $item_id;
$ev['edited'] = $datarray['edited'];
$ev['private'] = $datarray['private'];
+ $ev['guid'] = $datarray['guid'];
$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id),
if(! $cid)
proc_run('php',"include/notifier.php","event","$item_id");
+ goaway($_SESSION['return_url']);
}
return;
}
+ if($a->argc == 1)
+ $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+
if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 1 where id = %d and uid = %d",
intval($a->argv[2]),
else
$sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
- if($cid)
+ if($cid OR ($mode !== 'new'))
$sh_checked .= ' disabled="disabled" ';
require_once('include/acl_selectors.php');
+ if ($mode === 'new')
+ $acl = (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user)));
+
$tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array(
'$sh_text' => t('Share this event'),
'$sh_checked' => $sh_checked,
'$preview' => t('Preview'),
- '$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user))),
+ '$acl' => $acl,
'$submit' => t('Submit')
));
? t('Private Message')
: false);
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
- if(local_user() && link_compare($a->contact['url'],$item['author-link']))
- $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
- else
+ if(local_user() && link_compare($a->contact['url'],$item['author-link'])) {
+ if ($item["event-id"] != 0)
+ $edpost = array($a->get_baseurl($ssl_state)."/events/event/".$item['event-id'], t("Edit"));
+ else
+ $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
+ } else
$edpost = false;
if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
$dropping = true;