aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-06-23 05:19:28 -0700
committerfriendica <info@friendica.com>2014-06-23 05:19:28 -0700
commit0cfcb023118444bac29014e06a14fc1af2d0cf75 (patch)
tree5f63da84a1ee111cd68481a184c314ae5407c8fd
parentd43227a730927c88745c5c35029fd57562265e3e (diff)
downloadvolse-hubzilla-0cfcb023118444bac29014e06a14fc1af2d0cf75.tar.gz
volse-hubzilla-0cfcb023118444bac29014e06a14fc1af2d0cf75.tar.bz2
volse-hubzilla-0cfcb023118444bac29014e06a14fc1af2d0cf75.zip
ability to like things
-rwxr-xr-xboot.php2
-rw-r--r--include/identity.php4
-rw-r--r--include/taxonomy.php16
-rw-r--r--install/database.sql4
-rw-r--r--install/update.php10
-rwxr-xr-xmod/like.php11
-rw-r--r--view/theme/redbasic/css/style.css8
-rwxr-xr-xview/tpl/profile_advanced.tpl15
-rw-r--r--view/tpl/show_thing.tpl4
9 files changed, 62 insertions, 12 deletions
diff --git a/boot.php b/boot.php
index 4c93cd117..db2401847 100755
--- a/boot.php
+++ b/boot.php
@@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1114 );
+define ( 'DB_UPDATE_VERSION', 1115 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/include/identity.php b/include/identity.php
index b086da94f..1cbe43b1e 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -1044,10 +1044,12 @@ function advanced_profile(&$a) {
$things = get_things($a->profile['profile_guid'],$a->profile['profile_uid']);
- logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
+// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
return replace_macros($tpl, array(
'$title' => t('Profile'),
+ '$canlike' => (($profile['canlike'])? true : false),
+ '$likethis' => t('Like this thing'),
'$profile' => $profile,
'$things' => $things
));
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 4f2b5e8fd..803e1ae0a 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -322,9 +322,21 @@ function get_things($profile_hash,$uid) {
foreach($v as $k => $foo)
$things[$k] = null;
foreach($r as $rr) {
+
+ $l = q("select xchan_name, xchan_url from likes left join xchan on likee = xchan_hash where
+ target_type = '%s' and target_id = '%s' and channel_id = %d",
+ dbesc(ACTIVITY_OBJ_THING),
+ dbesc($rr['term_hash']),
+ intval($uid)
+ );
+
+ for($x = 0; $x < count($l); $x ++)
+ $l[$x]['xchan_url'] = zid($l[$x]['xchan_url']);
+
if(! $things[$rr['obj_verb']])
$things[$rr['obj_verb']] = array();
- $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name']);
+ $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
+
}
$sorted_things = array();
if($things) {
@@ -335,7 +347,7 @@ function get_things($profile_hash,$uid) {
}
}
}
-
+//logger('things: ' . print_r($sorted_things,true));
return $sorted_things;
} \ No newline at end of file
diff --git a/install/database.sql b/install/database.sql
index cb4846b52..e2b814067 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -581,6 +581,7 @@ CREATE TABLE IF NOT EXISTS `likes` (
`iid` int(10) unsigned NOT NULL DEFAULT '0',
`verb` char(255) NOT NULL DEFAULT '',
`target_type` char(255) NOT NULL DEFAULT '',
+ `target_id` char(128) NOT NULL DEFAULT '',
`target` mediumtext NOT NULL,
PRIMARY KEY (`id`),
KEY `channel_id` (`channel_id`),
@@ -588,7 +589,8 @@ CREATE TABLE IF NOT EXISTS `likes` (
KEY `likee` (`likee`),
KEY `iid` (`iid`),
KEY `verb` (`verb`),
- KEY `target_type` (`target_type`)
+ KEY `target_type` (`target_type`),
+ KEY `target_id` (`target_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `mail` (
diff --git a/install/update.php b/install/update.php
index b6bcfa237..bdf84144c 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1114 );
+define( 'UPDATE_VERSION' , 1115 );
/**
*
@@ -1283,3 +1283,11 @@ ADD INDEX ( `channel_id` )");
return UPDATE_FAILED;
}
+function update_r1114() {
+ $r = q("ALTER TABLE `likes` ADD `target_id` CHAR( 128 ) NOT NULL DEFAULT '' AFTER `target_type` ,
+ADD INDEX ( `target_id` )");
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
+
diff --git a/mod/like.php b/mod/like.php
index aae96e753..ececb31c7 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -151,12 +151,12 @@ function like_content(&$a) {
// second like of the same thing is "undo" for the first like
- $z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target = '%s' limit 1",
+ $z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' limit 1",
intval($ch[0]['channel_id']),
dbesc($observer['xchan_hash']),
dbesc($activity),
dbesc(($tgttype)?$tgttype:$objtype),
- dbesc(json_encode(($target)?$target:$object))
+ dbesc($obj_id)
);
if($z) {
@@ -328,6 +328,10 @@ function like_content(&$a) {
$arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );
+ if($obj_type === 'thing' && $r[0]['imgurl']) {
+ $arr['body'] .= "\n\n[zmg=80x80]" . $r[0]['imgurl'] . '[/zmg]';
+ }
+
$arr['verb'] = $activity;
$arr['obj_type'] = $objtype;
@@ -354,13 +358,14 @@ function like_content(&$a) {
if($extended_like) {
- $r = q("insert into likes (channel_id,liker,likee,iid,verb,target_type,target) values (%d,'%s','%s',%d,'%s','%s','%s')",
+ $r = q("insert into likes (channel_id,liker,likee,iid,verb,target_type,target_id,target) values (%d,'%s','%s',%d,'%s','%s','%s','%s')",
intval($ch[0]['channel_id']),
dbesc($observer['xchan_hash']),
dbesc($ch[0]['channel_hash']),
intval($post_id),
dbesc($activity),
dbesc(($tgttype)?$tgttype:$objtype),
+ dbesc($obj_id),
dbesc(json_encode(($target)?$target:$object))
);
};
diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css
index 589a48192..4ee8a7477 100644
--- a/view/theme/redbasic/css/style.css
+++ b/view/theme/redbasic/css/style.css
@@ -1743,6 +1743,14 @@ header {
list-style-type: none;
}
+.profile-thing-list img {
+ margin-bottom: 5px;
+}
+
+.profile-thing-list li {
+ margin-bottom: 15px;
+}
+
div.page-list-item {
margin: 20px;
}
diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl
index 0faa54637..73033fe40 100755
--- a/view/tpl/profile_advanced.tpl
+++ b/view/tpl/profile_advanced.tpl
@@ -4,7 +4,7 @@
{{if $profile.canlike || $profile.like_count}}
<div id="profile-like-wrapper">
{{if $profile.canlike}}
- <button type="button" class="btn btn-default btn-sm" onclick="doprofilelike('profile/' + '{{$profile.profile_guid}}','like'); return false;">
+ <button type="button" class="btn btn-default btn-sm" onclick="doprofilelike('profile/' + '{{$profile.profile_guid}}','like'); return false;" title="{{$profile.likethis}}" >
<i class="icon-thumbs-up-alt" title="{{$profile.likethis}}"></i>
</button>
{{/if}}
@@ -200,6 +200,19 @@
{{foreach $items as $item}}
<li>{{if $item.img}}<img src="{{$item.img}}" width="100" height="100" alt="{{$item.term}}" />{{/if}}
<a href="{{$item.url}}" >{{$item.term}}</a>
+{{if $profile.canlike}}<br />
+<button type="button" class="btn btn-default btn-sm" onclick="doprofilelike('thing/' + '{{$item.term_hash}}','like'); return false;" title="{{$likethis}}" >
+<i class="icon-thumbs-up-alt" title="{{$likethis}}"></i>
+</button>
+{{/if}}
+{{if $item.like_count}}
+<div class="btn-group">
+<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="thing-like-{{$item.term_hash}}">{{$item.like_count}} {{$item.like_label}}</button>
+{{if $item.likes}}
+<ul class="dropdown-menu" role="menu" aria-labelledby="thing-like-{{$item.term_hash}}">{{foreach $item.likes as $liker}}<li role="presentation"><a href="{{$liker.xchan_url}}">{{$liker.xchan_name}}</a></li>{{/foreach}}</ul>
+{{/if}}
+</div>
+{{/if}}
</li>
{{/foreach}}
</ul>
diff --git a/view/tpl/show_thing.tpl b/view/tpl/show_thing.tpl
index 2a8c06076..c48912918 100644
--- a/view/tpl/show_thing.tpl
+++ b/view/tpl/show_thing.tpl
@@ -6,8 +6,8 @@
</div>
{{if $canedit}}
<div class="thing-edit-links">
-<a href="thing/edit/{{$thing.term_hash}}" title="{{$edit}}"><i class="icon-pencil thing-edit-icon"></i></a>
-<a href="thing/drop/{{$thing.term_hash}}" onclick="return confirmDelete();" title="{{$delete}}" ><i class="icon-remove drop-icons"></i></a>
+<a href="thing/edit/{{$thing.term_hash}}" title="{{$edit}}" class="btn btn-default" ><i class="icon-pencil thing-edit-icon"></i></a>
+<a href="thing/drop/{{$thing.term_hash}}" onclick="return confirmDelete();" title="{{$delete}}" class="btn btn-default" ><i class="icon-remove drop-icons"></i></a>
</div>
<div class="thing-edit-links-end"></div>
{{/if}}