diff options
-rw-r--r-- | doc/sv/roles.md (renamed from doc/sv/roles.bb) | 0 | ||||
-rw-r--r-- | include/bbcode.php | 21 | ||||
-rw-r--r-- | include/notifier.php | 10 | ||||
-rw-r--r-- | mod/connedit.php | 41 | ||||
-rw-r--r-- | mod/dirsearch.php | 12 | ||||
-rw-r--r-- | mod/prate.php | 91 | ||||
-rw-r--r-- | mod/tagger.php | 6 | ||||
-rw-r--r-- | view/js/autocomplete.js | 2 | ||||
-rwxr-xr-x | view/tpl/direntry.tpl | 12 | ||||
-rwxr-xr-x | view/tpl/event_form.tpl | 2 |
10 files changed, 182 insertions, 15 deletions
diff --git a/doc/sv/roles.bb b/doc/sv/roles.md index 47147c6bf..47147c6bf 100644 --- a/doc/sv/roles.bb +++ b/doc/sv/roles.md diff --git a/include/bbcode.php b/include/bbcode.php index 5504dce7a..7067fcd39 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -57,7 +57,7 @@ function bb_unspacefy_and_trim($st) { return $unspacefied; } -if(! function_exists('bb_extract_images')) { + function bb_extract_images($body) { $saved_image = array(); @@ -97,24 +97,27 @@ function bb_extract_images($body) { $new_body = $new_body . $orig_body; return array('body' => $new_body, 'images' => $saved_image); -}} +} + -if(! function_exists('bb_replace_images')) { function bb_replace_images($body, $images) { $newbody = $body; $cnt = 0; + if(! $images) + return $newbody; + foreach($images as $image) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '<img class="zrl" src="' . $image .'" alt="' . t('Image/photo') . '" />', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '<img src="' . $image .'" alt="' . t('Image/photo') . '" />', $newbody); $cnt++; } - +// logger('replace_images: ' . $newbody); return $newbody; -}} +} @@ -404,6 +407,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { } + $x = bb_extract_images($Text); + $Text = $x['body']; + $saved_images = $x['images']; + $Text = str_replace(array('[baseurl]','[sitename]'),array(z_root(),get_config('system','sitename')),$Text); @@ -853,6 +860,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("/\<(.*?)(src|href)=\"[^hfm#](.*?)\>/ism",'<$1$2="">',$Text); + $Text = bb_replace_images($Text,$saved_images); + call_hooks('bbcode',$Text); return $Text; diff --git a/include/notifier.php b/include/notifier.php index 06ef7bc94..edb2f1946 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -59,6 +59,7 @@ require_once('include/html2plain.php'); * relay item_id (item was relayed to owner, we will deliver it as owner) * location channel_id * request channel_id xchan_hash message_id + * rating xlink_id * */ @@ -296,6 +297,15 @@ function notifier_run($argv, $argc){ $private = false; $packet_type = 'purge'; } + elseif($cmd === 'rating') { + $r = q("select * from xlink where xlink_id = %d and xlink_static = 1 limit 1", + intval($item_id) + ); + if($r) { + logger('rating message: ' . print_r($r[0],true)); + return; + } + } else { // Normal items diff --git a/mod/connedit.php b/mod/connedit.php index c082e03a8..8c0212afe 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -55,6 +55,8 @@ function connedit_post(&$a) { if(! $contact_id) return; + $channel = $a->get_channel(); + // TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the // connection enable is toggled to a special autopost url and set permissions immediately, leaving // the other form elements alone pending a manual submit of the form. The downside is that there @@ -79,9 +81,11 @@ function connedit_post(&$a) { if($orig_record[0]['abook_flags'] & ABOOK_FLAG_SELF) { $autoperms = intval($_POST['autoperms']); + $is_self = true; } else { $autoperms = null; + $is_self = false; } @@ -126,7 +130,40 @@ function connedit_post(&$a) { $abook_flags = $orig_record[0]['abook_flags']; $new_friend = false; - + if(! $is_self) { + $z = q("select * from xlink where xlink_xchan = '%s' and xlink_xlink = '%s' and xlink_static = 1 limit 1", + dbesc($channel['channel_hash']), + dbesc($orig_record[0]['abook_xchan']) + ); + if($z) { + $record = $z[0]['xlink_id']; + $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_updated = '%s' + where xlink_id = %d", + intval($rating), + dbesc($rating_text), + dbesc(datetime_convert()), + intval($record) + ); + } + else { + $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', 1 ) ", + dbesc($channel['channel_hash']), + dbesc($orig_record[0]['abook_xchan']), + intval($rating), + dbesc($rating_text), + dbesc(datetime_convert()) + ); + $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", + dbesc($channel['channel_hash']), + dbesc($orig_record[0]['abook_xchan']) + ); + if($z) + $record = $z[0]['xlink_id']; + } + if($record) { + proc_run('php','include/notifier.php','rating',$record); + } + } if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) { $abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING ); @@ -167,7 +204,6 @@ function connedit_post(&$a) { } if($new_friend) { - $channel = $a->get_channel(); $default_group = $channel['channel_default_group']; if($default_group) { require_once('include/group.php'); @@ -528,6 +564,7 @@ function connedit_content(&$a) { } $poco_rating = get_config('system','poco_rating_enable'); + $poco_rating = 0; // if unset default to enabled if($poco_rating === false) $poco_rating = true; diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 06d530849..52a3d02cf 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -125,7 +125,7 @@ function dirsearch_content(&$a) { if($hash) { - $sql_extra = " AND xchan_hash = '" . dbesc($hash) . "' "; + $sql_extra = " AND xchan_hash like '" . dbesc($hash) . protect_sprintf('%') . "' "; } @@ -229,8 +229,18 @@ function dirsearch_content(&$a) { foreach($r as $rr) { + $entry = array(); + $pc = q("select count(xlink_rating) as total_ratings from xlink where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 group by xlink_rating", + dbesc($rr['xchan_hash']) + ); + + if($pc) + $entry['total_ratings'] = intval($pc[0]['total_ratings']); + else + $entry['total_ratings'] = 0; + $entry['name'] = $rr['xchan_name']; $entry['hash'] = $rr['xchan_hash']; diff --git a/mod/prate.php b/mod/prate.php new file mode 100644 index 000000000..28703d414 --- /dev/null +++ b/mod/prate.php @@ -0,0 +1,91 @@ +<?php + + +function prate_post(&$a) { + if(! local_channel()) + return; + + $channel = $a->get_channel(); + + $target = $_REQUEST['target']; + if(! $target) + return; + + if($target === $channel['channel_hash']) + return; + + $rating = intval($_POST['rating']); + if($rating < (-10)) + $rating = (-10); + if($rating > 10) + $rating = 10; + + $rating_text = escape_tags($_REQUEST['rating_text']); + + $z = q("select * from xlink where xlink_xchan = '%s' and xlink_xlink = '%s' and xlink_static = 1 limit 1", + dbesc($channel['channel_hash']), + dbesc($target) + ); + if($z) { + $record = $z[0]['xlink_id']; + $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_updated = '%s' + where xlink_id = %d", + intval($rating), + dbesc($rating_text), + dbesc(datetime_convert()), + intval($record) + ); + } + else { + $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', 1 ) ", + dbesc($channel['channel_hash']), + dbesc($target), + intval($rating), + dbesc($rating_text), + dbesc(datetime_convert()) + ); + $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", + dbesc($channel['channel_hash']), + dbesc($orig_record[0]['abook_xchan']) + ); + if($z) + $record = $z[0]['xlink_id']; + } + if($record) { + proc_run('php','include/notifier.php','rating',$record); + } + + $x = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($target), + intval($local_channel()) + ); + if($x) { + $w = q("update abook set abook_rating = %d, abook_rating_text = '%s' where abook_xchan = '%s' and abook_channel = %d", + intval($rating), + dbesc($rating_text), + dbesc($target), + intval(local_channel()) + ); + $x = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($target), + intval($local_channel()) + ); + if($x) { + unset($x[0]['abook_id']); + unset($x[0]['abook_account']); + unset($x[0]['abook_channel']); + build_sync_packet(0, array('abook' => array($x[0]))); + } + } + return; +} + + + + + + + + + + diff --git a/mod/tagger.php b/mod/tagger.php index a93609c3c..aafad58cf 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -12,11 +12,9 @@ function tagger_content(&$a) { } $observer_hash = get_observer_hash(); - + //strip html-tags $term = notags(trim($_GET['term'])); - // no commas allowed - $term = str_replace(array(',',' '),array('','_'),$term); - + //check if empty if(! $term) return; diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 86847cb35..b93cc16b3 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -77,7 +77,7 @@ function editor_replace(item) { // 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id). if(id.length > 16) id = item.id.substring(0,16); - return '$1$2'+item.nick.replace(' ','') + '+' + id; + return '$1$2'+item.nick.replace(' ','') + '+' + id + ' '; } function basic_replace(item) { diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index cdc6f1f97..6ba86a085 100755 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -15,6 +15,18 @@ <div class='contact-info'> <div class="contact-name" id="directory-name-{{$entry.id}}" ><a href='{{$entry.profile_link}}' >{{$entry.name}}</a>{{if $entry.online}} <i class="icon-asterisk online-now" title="{{$entry.online}}"></i>{{/if}}</div> +{{if $entry.rateme}} +<div id="dir-rating-wrapper-{{$entry.id}}" style="float:right; width: 20%;"> +62 ratings<br /> +<div id="dir-rating-slider-{{$entry.id}}" class="dir-slider" style="height: 32px; margin-right:10px;"> +<input id="dir-rating-range-{{$entry.id}}" type="text" value="0" name="fake-rating-{{$entry.id}}" style="display: none;"> +</div> +</div> +<div class="clear"></div> +<script> +$("#dir-rating-range-{{$entry.id}}").jRange({ from: -10, to: 10, step: 1, width:'100%', showLabels: false, showScale: true, scale : [ '-10','-5','0','5','10' ], onstatechange: function(v) { $("#contact-rating-mirror").val(v); } }); +</script> +{{/if}} {{if $entry.public_forum}} <div class="contact-forum"> {{$entry.forum_label}} @{{$entry.nickname}}+ diff --git a/view/tpl/event_form.tpl b/view/tpl/event_form.tpl index a4717415e..2479068f3 100755 --- a/view/tpl/event_form.tpl +++ b/view/tpl/event_form.tpl @@ -41,7 +41,7 @@ {{if $catsenabled}} <div id="event-category-wrap"> - <input name="category" id="event-category" type="text" placeholder="{{$placeholdercategory}}" value="{{$category}}" class="event-cats" style="display: block;" /> + <input name="category" id="event-category" type="text" placeholder="{{$placeholdercategory}}" value="{{$category}}" class="event-cats" style="display: block;" data-role="tagsinput" /> </div> {{/if}} |