diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 1 | ||||
-rw-r--r-- | include/conversation.php | 25 | ||||
-rw-r--r-- | include/event.php | 50 | ||||
-rw-r--r-- | include/html2bbcode.php | 2 | ||||
-rw-r--r-- | include/items.php | 126 | ||||
-rw-r--r-- | include/main.js | 20 |
6 files changed, 181 insertions, 43 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index a44838c24..40f4935fb 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -97,6 +97,7 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text); + $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text); // [img=widthxheight]image source[/img] $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $Text); diff --git a/include/conversation.php b/include/conversation.php index 9ffcbe157..0d3123831 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -114,6 +114,8 @@ function conversation(&$a, $items, $mode, $update) { $noshare_tpl = get_markup_template('like_noshare.tpl'); $tpl = get_markup_template('wall_item.tpl'); $wallwall = get_markup_template('wallwall_item.tpl'); + $droptpl = get_markup_template('wall_item_drop.tpl'); + $fakedrop = get_markup_template('wall_fake_drop.tpl'); $alike = array(); $dlike = array(); @@ -126,7 +128,6 @@ function conversation(&$a, $items, $mode, $update) { // - just loop through the items and format them minimally for display $tpl = get_markup_template('search_item.tpl'); - $droptpl = get_markup_template('wall_fake_drop.tpl'); foreach($items as $item) { @@ -171,14 +172,7 @@ function conversation(&$a, $items, $mode, $update) { } $drop = ''; - $dropping = false; - if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) - $dropping = true; - - $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete'))); - - // localize_item($item); $drop = replace_macros($droptpl,array('$id' => $item['id'])); @@ -390,7 +384,16 @@ function conversation(&$a, $items, $mode, $update) { ? '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>' : ''); - $drop = replace_macros(get_markup_template('wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete'))); + + + $drop = ''; + $dropping = false; + + if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) + $dropping = true; + + $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete'))); + $photo = $item['photo']; $thumb = $item['thumb']; @@ -477,6 +480,7 @@ function conversation(&$a, $items, $mode, $update) { '$comment' => $comment )); + $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); @@ -491,6 +495,9 @@ function conversation(&$a, $items, $mode, $update) { if($blowhard_count >= 3) $o .= '</div>'; + if($dropping) + $o .= '<div id="item-delete-selected" class="fakelink" onclick="deleteCheckedItems();"><div id="item-delete-selected-icon" class="icon drophide" title="' . t('Delete Selected Items') . '" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></div><div id="item-delete-selected-desc" >' . t('Delete Selected Items') . '</div></div><div id="item-delete-selected-end"></div>'; + return $o; } diff --git a/include/event.php b/include/event.php index 2cfc52408..9d4a8df59 100644 --- a/include/event.php +++ b/include/event.php @@ -10,9 +10,9 @@ function format_event_html($ev) { $bd_format = t('l F d, Y \@ g A') ; // Friday January 18, 2011 @ 8 AM - $o = '<div class="vevent">'; + $o = '<div class="vevent">' . "\r\n"; - $o .= '<p class="description event-description">' . bbcode($ev['desc']) . '</p>'; + $o .= '<p class="description event-description">' . bbcode($ev['desc']) . '</p>' . "\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' )) @@ -21,7 +21,7 @@ function format_event_html($ev) { $ev['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['start'] , $bd_format))) - . '</abbr></p>'; + . '</abbr></p>' . "\r\n"; if(! $ev['nofinish']) $o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="' @@ -31,14 +31,14 @@ function format_event_html($ev) { $ev['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['finish'] , $bd_format ))) - . '</abbr></p>'; + . '</abbr></p>' . "\r\n"; if(strlen($ev['location'])) $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">' . bbcode($ev['location']) - . '</span></p>'; + . '</span></p>' . "\r\n"; - $o .= '</div>'; + $o .= '</div>' . "\r\n"; return $o; } @@ -175,6 +175,9 @@ function ev_compare($a,$b) { $date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']); $date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['start']) : $b['start']); + + if($date_a === $date_b) + return strcasecmp($a['desc'],$b['desc']); return strcmp($date_a,$date_b); } @@ -190,10 +193,10 @@ function event_store($arr) { $a = get_app(); $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert()); - $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); - $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); - $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); - $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid'])); + $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); + $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); + $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); + $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid'])); if($arr['cid']) $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -244,8 +247,26 @@ function event_store($arr) { intval($arr['id']), intval($arr['uid']) ); - if(count($r)) + if(count($r)) { + $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>'; + $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>'; + $object .= '</object>' . "\n"; + + + q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc(format_event_bbcode($arr)), + dbesc($object), + dbesc($arr['allow_cid']), + dbesc($arr['allow_gid']), + dbesc($arr['deny_cid']), + dbesc($arr['deny_gid']), + dbesc(datetime_convert()), + intval($r[0]['id']), + intval($arr['uid']) + ); + return $r[0]['id']; + } else return 0; } @@ -274,7 +295,7 @@ function event_store($arr) { ); $r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", - dbesc($uri), + dbesc($arr['uri']), intval($arr['uid']) ); if(count($r)) @@ -284,8 +305,8 @@ function event_store($arr) { $item_arr['uid'] = $arr['uid']; $item_arr['contact-id'] = $arr['cid']; - $item_arr['uri'] = $uri; - $item_arr['parent-uri'] = $uri; + $item_arr['uri'] = $arr['uri']; + $item_arr['parent-uri'] = $arr['uri']; $item_arr['type'] = 'activity'; $item_arr['wall'] = 1; $item_arr['contact-id'] = $contact['id']; @@ -329,6 +350,7 @@ function event_store($arr) { intval($item_id) ); } + return $item_id; } } diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 734282d95..d4e8cce66 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -35,6 +35,7 @@ function html2bbcode($s) { '/\<blockquote\>(.*?)\<\/blockquote\>/is', '/\<video(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/video\>/is', '/\<audio(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/audio\>/is', + '/\<iframe(.*?) src=\"(.*?)\" (.*?)\>(.*?)\<\/iframe\>/is', ); @@ -60,6 +61,7 @@ function html2bbcode($s) { '[quote]$1[/quote]', '[video]$1[/video]', '[audio]$1[/audio]', + '[iframe]$1[/iframe]', ); // Replace $htmltags in $text with $bbtags diff --git a/include/items.php b/include/items.php index dc177c468..a003b84bb 100644 --- a/include/items.php +++ b/include/items.php @@ -1772,3 +1772,129 @@ function item_expire($uid,$days) { } + +function drop_items($items) { + $uid = 0; + + if(count($items)) { + foreach($items as $item) { + $owner = drop_item($item,false); + if($owner && ! $uid) + $uid = $owner; + } + } + + // multiple threads may have been deleted, send an expire notification + + if($uid) + proc_run('php',"include/notifier.php","expire","$uid"); +} + + +function drop_item($id,$interactive = true) { + + $a = get_app(); + + // locate item to be deleted + + $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", + intval($id) + ); + + if(! count($r)) { + if(! $interactive) + return 0; + notice( t('Item not found.') . EOL); + goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + } + + $item = $r[0]; + + $owner = $item['uid']; + + // check if logged in user is either the author or owner of this item + + if((local_user() == $item['uid']) || (remote_user() == $item['contact-id'])) { + + // delete the item + + $r = q("UPDATE `item` SET `deleted` = 1, `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + + // If item is a link to a photo resource, nuke all the associated photos + // (visitors will not have photo resources) + // This only applies to photos uploaded from the photos page. Photos inserted into a post do not + // generate a resource-id and therefore aren't intimately linked to the item. + + if(strlen($item['resource-id'])) { + q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ", + dbesc($item['resource-id']), + intval($item['uid']) + ); + // ignore the result + } + + // If item is a link to an event, nuke the event record. + + if(intval($item['event-id'])) { + q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($item['event-id']), + intval($item['uid']) + ); + // ignore the result + } + + + // If it's the parent of a comment thread, kill all the kids + + if($item['uri'] == $item['parent-uri']) { + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' + WHERE `parent-uri` = '%s' AND `uid` = %d ", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($item['parent-uri']), + intval($item['uid']) + ); + // ignore the result + } + else { + // ensure that last-child is set in case the comment that had it just got wiped. + q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", + dbesc(datetime_convert()), + dbesc($item['parent-uri']), + intval($item['uid']) + ); + // who is the last child now? + $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1", + dbesc($item['parent-uri']), + intval($item['uid']) + ); + if(count($r)) { + q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1", + intval($r[0]['id']) + ); + } + } + $drop_id = intval($item['id']); + + // send the notification upstream/downstream as the case may be + + if(! $interactive) + return $owner; + + proc_run('php',"include/notifier.php","drop","$drop_id"); + goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + //NOTREACHED + } + else { + if(! $interactive) + return 0; + notice( t('Permission denied.') . EOL); + goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + //NOTREACHED + } + +}
\ No newline at end of file diff --git a/include/main.js b/include/main.js index 1a377a1a4..3cc607977 100644 --- a/include/main.js +++ b/include/main.js @@ -70,26 +70,6 @@ $('#pause').html(''); } } -// // F8 - show/hide language selector -// if(event.keyCode == '119') { -// if(langSelect) { -// langSelect = false; -// $('#language-selector').hide(); -// } -// else { -// langSelect = true; -// $('#language-selector').show(); -// } -// } -// -// this is shift-home on FF, but $ on IE, disabling until I figure out why the diff. -// update: incompatible usage of onKeyDown vs onKeyPress -// if(event.keyCode == '36' && event.shiftKey == true) { -// if(homebase !== undefined) { -// event.preventDefault(); -// document.location = homebase; -// } -// } }); }); |