]> git.mxchange.org Git - friendica.git/commitdiff
Merge dir into template_rework
authorrabuzarus <trebor@central-unit>
Sat, 17 Oct 2015 20:22:20 +0000 (22:22 +0200)
committerrabuzarus <trebor@central-unit>
Sat, 17 Oct 2015 20:22:20 +0000 (22:22 +0200)
include/bbcode.php
include/conversation.php
include/datetime.php
include/diaspora.php
include/event.php
include/items.php
mod/events.php
object/Item.php

index 2fcf6c3247a572a8404b78c97716799465427fc9..81536d37200fdd5083a38685c306282856f8d0cb 100644 (file)
@@ -1210,7 +1210,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        // 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);
index 0907b5dce23cfe2ac0b569a3a9e5453c44dbe4c7..8e1793d699513aaff0c87020e8185805437ec033 100644 (file)
@@ -1025,10 +1025,31 @@ function format_like($cnt,$arr,$type,$id) {
        $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);
@@ -1043,55 +1064,33 @@ function format_like($cnt,$arr,$type,$id) {
                }
 
                $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 ;
index 6461298ba2f155cc24db192554d6120c5e1dd2f9..79964ef404525e5074d226f836040aa1894a5298 100644 (file)
@@ -43,18 +43,18 @@ function select_timezone($current = 'America/Los_Angeles') {
                        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'
@@ -63,12 +63,12 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
        $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.
@@ -92,8 +92,8 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
 
        // 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'));
@@ -203,13 +203,25 @@ function timesel($format, $h, $m, $id='timepicker') {
  *  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';
@@ -217,16 +229,17 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
        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);
@@ -236,7 +249,9 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
        $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;
 }}
 
@@ -248,27 +263,27 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
 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')),
@@ -277,7 +292,7 @@ function relative_date($posted_date,$format = null) {
                                60                      =>  array( t('minute'), t('minutes')),
                                1                       =>  array( t('second'), t('seconds'))
        );
-    
+
        foreach ($a as $secs => $str) {
                $d = $etime / $secs;
                if ($d >= 1) {
@@ -295,13 +310,13 @@ function relative_date($posted_date,$format = null) {
 // 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;
@@ -357,7 +372,7 @@ function get_first_dim($y,$m) {
 
 // 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.
 
@@ -376,7 +391,7 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
          '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');
@@ -427,8 +442,8 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
   if($dow)
     for($a = $dow; $a < 7; $a ++)
        $o .= '<td>&nbsp;</td>';
-  $o .= '</tr></table>'."\r\n";  
-  
+  $o .= '</tr></table>'."\r\n";
+
   return $o;
 }}
 
@@ -452,10 +467,10 @@ function update_contact_birthdays() {
                         *
                         * $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]') ;
 
index 757cf1a6bade158c8a827da9f1a5ed72a7e5f340..c97abc28cdec81b8049f5cf401cc39bee7b2b3b7 100644 (file)
@@ -2421,7 +2421,8 @@ function diaspora_profile($importer,$xml,$msg) {
 
        $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
index fedbe24468ab67a4085422375974013e279bd77e..c4111dc0b174869be3fff15d6b58599a10d06bcd 100644 (file)
@@ -3,7 +3,7 @@
 require_once('include/bbcode.php');
 require_once('include/map.php');
 
-function format_event_html($ev) {
+function format_event_html($ev, $simple = false) {
 
 
 
@@ -12,6 +12,32 @@ function format_event_html($ev) {
 
        $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";
 
 
@@ -21,33 +47,25 @@ function format_event_html($ev) {
 
        $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";
@@ -137,7 +155,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]';
 
@@ -200,11 +218,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) {
 
@@ -324,7 +348,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`)
@@ -362,6 +386,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'];
index 4e86a5200af6d3a74e2e1939c624d0bca07555da..7d1ab1cb36c52398a62f4b5f1c10adac68c55a60 100644 (file)
@@ -2558,6 +2558,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
                                        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);
@@ -2849,11 +2854,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
 
                                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'];
@@ -3543,6 +3549,11 @@ function local_delivery($importer,$data) {
 
                                        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);
@@ -4073,12 +4084,13 @@ function local_delivery($importer,$data) {
 
                        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),
index bf53286c2032173488da80cab4900a404c488bed..653ae489b8f97c8022fe68fcd6f7513e4b5fe009 100644 (file)
@@ -154,6 +154,7 @@ function events_post(&$a) {
        if(! $cid)
                proc_run('php',"include/notifier.php","event","$item_id");
 
+       goaway($_SESSION['return_url']);
 }
 
 
@@ -165,6 +166,9 @@ function events_content(&$a) {
                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]),
@@ -505,7 +509,7 @@ function events_content(&$a) {
                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" ';
 
 
@@ -536,6 +540,9 @@ function events_content(&$a) {
 
                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(
@@ -563,7 +570,7 @@ function events_content(&$a) {
                        '$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')
 
                ));
index 3050365f921fd23ad463ccf354a3cdae9bbab71e..04c1a707e3a6e3eb6fef18ac4006dbe3252200c2 100644 (file)
@@ -117,9 +117,12 @@ class Item extends BaseObject {
                        ? 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;