diff options
author | friendica <info@friendica.com> | 2015-01-15 17:34:53 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-01-15 17:34:53 -0800 |
commit | 6cd26c359054e188d41a97d3d97e3c659f2dede9 (patch) | |
tree | d5de7af38448da80d1770bee6aa05bb998ce09ae | |
parent | 35276c2da92a29132be2aaa75a63658d440e87e5 (diff) | |
parent | 597b07e8cc40144abce63f0779d28c2dbc376a22 (diff) | |
download | volse-hubzilla-6cd26c359054e188d41a97d3d97e3c659f2dede9.tar.gz volse-hubzilla-6cd26c359054e188d41a97d3d97e3c659f2dede9.tar.bz2 volse-hubzilla-6cd26c359054e188d41a97d3d97e3c659f2dede9.zip |
Merge branch 'pocorate'
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | include/socgraph.php | 7 | ||||
-rw-r--r-- | install/update.php | 12 | ||||
-rw-r--r-- | mod/connedit.php | 33 | ||||
-rw-r--r-- | mod/poco.php | 3 | ||||
-rw-r--r-- | mod/prep.php | 38 | ||||
-rw-r--r-- | view/css/mod_connedit.css | 9 | ||||
-rwxr-xr-x | view/tpl/abook_edit.tpl | 17 | ||||
-rwxr-xr-x | view/tpl/poco_entry_xml.tpl | 1 | ||||
-rw-r--r-- | view/tpl/prep.tpl | 36 | ||||
-rw-r--r-- | view/tpl/rating_slider.tpl | 4 |
11 files changed, 156 insertions, 6 deletions
@@ -49,7 +49,7 @@ define ( 'RED_PLATFORM', 'redmatrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1131 ); +define ( 'DB_UPDATE_VERSION', 1132 ); /** * Constant with a HTML line break. diff --git a/include/socgraph.php b/include/socgraph.php index 740886b1c..dbc25f9c1 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -117,6 +117,7 @@ function poco_load($xchan = '',$url = null) { $name = $entry['displayName']; $hash = $entry['hash']; $rating = ((array_key_exists('rating',$entry)) ? intval($entry['rating']) : 0); + $rating = ((array_key_exists('rating_text',$entry)) ? escape_tags($entry['rating_text']) :''); if(x($entry,'urls') && is_array($entry['urls'])) { foreach($entry['urls'] as $url) { @@ -188,17 +189,19 @@ function poco_load($xchan = '',$url = null) { ); if(! $r) { - q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_updated ) values ( '%s', '%s', %d, '%s' ) ", + q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated ) values ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($xchan), dbesc($hash), intval($rating), + dbesc($rating_text), dbesc(datetime_convert()) ); } else { - q("update xlink set xlink_updated = '%s', xlink_rating = %d where xlink_id = %d", + q("update xlink set xlink_updated = '%s', xlink_rating = %d, xlink_rating_text = '%s' where xlink_id = %d", dbesc(datetime_convert()), intval($rating), + dbesc($rating_text), intval($r[0]['xlink_id']) ); } diff --git a/install/update.php b/install/update.php index d6953cdbc..f7ccb8210 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1131 ); +define( 'UPDATE_VERSION' , 1132 ); /** * @@ -1483,4 +1483,14 @@ function update_r1130() { ); return UPDATE_SUCCESS; +} + +function update_r1131() { + $r1 = q("ALTER TABLE `abook` ADD `abook_rating_text` TEXT NOT NULL DEFAULT '' AFTER `abook_rating` "); + $r2 = q("ALTER TABLE `xlink` ADD `xlink_rating_text` TEXT NOT NULL DEFAULT '' AFTER `xlink_rating` "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + }
\ No newline at end of file diff --git a/mod/connedit.php b/mod/connedit.php index 5c36c3184..c27f4588a 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -107,6 +107,14 @@ function connedit_post(&$a) { if($closeness < 0) $closeness = 99; + $rating = intval($_POST['rating']); + if($rating < (-10)) + $rating = (-10); + if($rating > 10) + $rating = 10; + + $rating_text = escape_tags($_REQUEST['rating_text']); + $abook_my_perms = 0; foreach($_POST as $k => $v) { @@ -125,11 +133,13 @@ function connedit_post(&$a) { $new_friend = true; } - $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d + $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_rating = %d, abook_rating_text = '%s', abook_flags = %d where abook_id = %d AND abook_channel = %d", dbesc($profile_id), intval($abook_my_perms), intval($closeness), + intval($rating), + dbesc($rating_text), intval($abook_flags), intval($contact_id), intval(local_user()) @@ -524,6 +534,22 @@ function connedit_content(&$a) { )); } + $poco_rating = get_config('system','poco_rating_enable'); + // if unset default to enabled + if($poco_rating === false) + $poco_rating = true; + + if($poco_rating) { + $rating = replace_macros(get_markup_template('rating_slider.tpl'),array( + '$min' => -10, + '$val' => (($contact['abook_rating']) ? $contact['abook_rating'] : 0), + )); + } + else { + $rating = false; + } + + $perms = array(); $channel = $a->get_channel(); @@ -555,6 +581,11 @@ function connedit_content(&$a) { '$buttons' => (($self) ? '' : $buttons), '$viewprof' => t('View Profile'), '$lbl_slider' => t('Slide to adjust your degree of friendship'), + '$lbl_rating' => t('Rating (this information may be public)'), + '$lbl_rating_txt' => t('Optionally explain your rating (this information may be public)'), + '$rating_txt' => $contact['abook_rating_text'], + '$rating' => $rating, + '$rating_val' => $contact['abook_rating'], '$slide' => $slide, '$tabs' => $t, '$tab_str' => $tab_str, diff --git a/mod/poco.php b/mod/poco.php index 3f932e92f..892d79801 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -178,7 +178,8 @@ function poco_init(&$a) { if($fields_ret['photos']) $entry['photos'] = array(array('value' => $rr['xchan_photo_l'], 'mimetype' => $rr['xchan_photo_mimetype'], 'type' => 'profile')); if($fields_ret['rating']) { - $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? array(intval($rr['abook_rating'])) : 0); + $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? intval($rr['abook_rating'])) : 0); + $entry['rating_text'] = ((array_key_exists('abook_rating_text',$rr)) ? $rr['abook_rating_text'])) : ''); // maybe this should be a composite calculated rating in $system_mode if($system_mode) $entry['rating'] = 0; diff --git a/mod/prep.php b/mod/prep.php new file mode 100644 index 000000000..e53f7ac4e --- /dev/null +++ b/mod/prep.php @@ -0,0 +1,38 @@ +<?php + +function prep_content(&$a) { + + if(argc() > 1) + $hash = argv(1); + + if(! $hash) { + notice('Must supply a channel identififier.'); + return; + } + + $p = q("select * from xchan where xchan_hash like '%s'", + dbesc($hash . '%') + ); + + $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash where xlink_link like '%s' and xlink_rating != 0", + dbesc($hash . '%') + ); + + $ret = array(); + + if($p && $r) { + $ret['poi'] = $p[0]; + $ret['raters'] = $r; + + $o = replace_macros(get_markup_template('prep.tpl'),array( + '$header' => t('Ratings'), + '$poi' => $p[0], + '$raters' => $r + )); + + return $o; + } + return ''; +} + +
\ No newline at end of file diff --git a/view/css/mod_connedit.css b/view/css/mod_connedit.css index 98c53602b..44a0a1abf 100644 --- a/view/css/mod_connedit.css +++ b/view/css/mod_connedit.css @@ -52,6 +52,15 @@ width: 600px !important; } +#rating-slider { + width: 600px !important; +} + +#rating-text { + width: 400px; + height: 60px; +} + .abook-edit-them, .abook-edit-me { float: left; margin-left: 10px; diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl index 03b7e2440..7c75bfac4 100755 --- a/view/tpl/abook_edit.tpl +++ b/view/tpl/abook_edit.tpl @@ -43,6 +43,15 @@ {{$slide}} {{/if}} + +{{if $rating}} +<h3>{{$lbl_rating}}</h3> + +{{$rating}} + + +{{/if}} + {{/if}} @@ -57,6 +66,7 @@ <input type="hidden" name="contact_id" value="{{$contact_id}}"> <input id="contact-closeness-mirror" type="hidden" name="closeness" value="{{$close}}" /> +<input id="contact-rating-mirror" type="hidden" name="rating" value="{{$rating_val}}" /> @@ -66,6 +76,13 @@ </div> {{/if}} +{{if $rating}} +{{if $notself}} +<h3 class="abook-rating-text-desc">{{$lbl_rating_txt}}</h3> +<textarea name="rating_text" id="rating-text" >{{$rating_txt}}</textarea> +{{/if}} +{{/if}} + {{if $multiprofs }} <div> <h3>{{$lbl_vis1}}</h3> diff --git a/view/tpl/poco_entry_xml.tpl b/view/tpl/poco_entry_xml.tpl index 869894852..30b6268dc 100755 --- a/view/tpl/poco_entry_xml.tpl +++ b/view/tpl/poco_entry_xml.tpl @@ -2,6 +2,7 @@ {{if $entry.id}}<id>{{$entry.id}}</id>{{/if}} {{if $entry.displayName}}<displayName>{{$entry.displayName}}</displayName>{{/if}} {{if $entry.preferredUsername}}<preferredUsername>{{$entry.preferredUsername}}</preferredUsername>{{/if}} +{{if $entry.rating}}<rating>{{$entry.rating}}</rating>{{/if}} {{if $entry.urls}}{{foreach $entry.urls as $url}}<urls><value>{{$url.value}}</value><type>{{$url.type}}</type></urls>{{/foreach}}{{/if}} {{if $entry.photos}}{{foreach $entry.photos as $photo}}<photos><value>{{$photo.value}}</value><type>{{$photo.type}}</type></photos>{{/foreach}}{{/if}} </entry> diff --git a/view/tpl/prep.tpl b/view/tpl/prep.tpl new file mode 100644 index 000000000..d0c1e5ec6 --- /dev/null +++ b/view/tpl/prep.tpl @@ -0,0 +1,36 @@ +<h1>{{$header}}</h1> + +{{if $poi}} + +<div class="directory-item lframe" id="directory-item-{{$poi.xchan_hash}}" > + +<div class="contact-photo-wrapper" id="directory-photo-wrapper-{{$poi.xchan_hash}}" > +<div class="contact-photo" id="directory-photo-{{$poi.xchan_hash}}" > +<a href="{{$poi.xchan_url}}" class="directory-profile-link" id="directory-profile-link-{{$poi.xchan_hash}}" ><img class="directory-photo-img" src="{{$poi.xchan_photo_l}}" alt="{{$poi.xchan_addr}}" title="{{$poi.xchan_addr}}" /></a> +<div class="contact-name">{{$poi.xchan_name}}</div> +</div> +</div> +{{/if}} + +{{if $raters}} +{{foreach $raters as $r}} + +<div class="directory-item lframe" id="directory-item-{{$r.xchan_hash}}" > + +<div class="contact-photo-wrapper" id="directory-photo-wrapper-{{$r.xchan_hash}}" > +<div class="contact-photo" id="directory-photo-{{$r.xchan_hash}}" > +<a href="{{$r.xchan_url}}" class="directory-profile-link" id="directory-profile-link-{{$r.xchan_hash}}" ><img class="directory-photo-img" src="{{$r.xchan_photo_l}}" alt="{{$r.xchan_addr}}" title="{{$r.xchan_addr}}" /></a> +<div class="contact-name">{{$r.xchan_name}}</div> +</div> +Rating: {{$r.xlink_rating}} +{{if $r.xlink_rating_text}} +Reason: {{$r.xlink_rating_text}} +{{/if}} +</div> +{{/foreach}} +{{/if}} + + + + + diff --git a/view/tpl/rating_slider.tpl b/view/tpl/rating_slider.tpl new file mode 100644 index 000000000..4702fc65b --- /dev/null +++ b/view/tpl/rating_slider.tpl @@ -0,0 +1,4 @@ +<div id="rating-slider" class="slider" style="height: 32px; position: relative; left: 5%; width: 90%;"><input id="rating-range" type="text" name="fake-rating" value="{{$val}}" /></div> +<script> + $("#rating-range").jRange({ from: -10, to: 10, step: 1, width:'100%', showLabels: false, showScale: true, scale : [ '-10','-8','-6','-4','-2','0','2','4','6','8','10' ], onstatechange: function(v) { $("#contact-rating-mirror").val(v); } }); +</script> |