aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-15 14:05:18 -0800
committerfriendica <info@friendica.com>2015-01-15 14:05:18 -0800
commit1c9299ed4224d37716079be173d75319d2501b71 (patch)
tree27a72ac0d09bcb67bdea55a8d24f9fd7ea8f4b9d
parent56bc3bcdcee41d5ca6920c878aa8576dc673d039 (diff)
downloadvolse-hubzilla-1c9299ed4224d37716079be173d75319d2501b71.tar.gz
volse-hubzilla-1c9299ed4224d37716079be173d75319d2501b71.tar.bz2
volse-hubzilla-1c9299ed4224d37716079be173d75319d2501b71.zip
more backend work on poco rating
-rwxr-xr-xboot.php2
-rw-r--r--include/socgraph.php7
-rw-r--r--install/update.php12
-rw-r--r--mod/connedit.php8
-rw-r--r--mod/poco.php3
-rwxr-xr-xview/tpl/abook_edit.tpl8
-rwxr-xr-xview/tpl/poco_entry_xml.tpl1
-rw-r--r--view/tpl/rating_slider.tpl4
8 files changed, 40 insertions, 5 deletions
diff --git a/boot.php b/boot.php
index e71f164a3..7d051e5f2 100755
--- a/boot.php
+++ b/boot.php
@@ -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..cf6ff6aad 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -524,6 +524,12 @@ function connedit_content(&$a) {
));
}
+
+ $rating = replace_macros(get_markup_template('rating_slider.tpl'),array(
+ '$min' => -10,
+ '$val' => (($contact['abook_rating']) ? $contact['abook_rating'] : 0),
+ ));
+
$perms = array();
$channel = $a->get_channel();
@@ -555,6 +561,8 @@ 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 is public)'),
+ '$rating' => $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/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl
index 03b7e2440..c38cc8ffb 100755
--- a/view/tpl/abook_edit.tpl
+++ b/view/tpl/abook_edit.tpl
@@ -43,6 +43,14 @@
{{$slide}}
{{/if}}
+
+{{if $rating}}
+<h3>{{$lbl_rating}}</h3>
+
+{{$rating}}
+
+{{/if}}
+
{{/if}}
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/rating_slider.tpl b/view/tpl/rating_slider.tpl
new file mode 100644
index 000000000..6bdb57cd1
--- /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: {{$min|default:'-10'}}, to: 10, step: 1, width:'100%', showLabels: false, onstatechange: function(v) { $("#contact-rating-mirror").val(v); } });
+</script>