diff options
-rw-r--r-- | app/lang.apd | 3 | ||||
-rw-r--r-- | app/lang.png | bin | 0 -> 7556 bytes | |||
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | include/identity.php | 4 | ||||
-rwxr-xr-x | include/items.php | 9 | ||||
-rw-r--r-- | include/reddav.php | 116 | ||||
-rw-r--r-- | include/taxonomy.php | 18 | ||||
-rw-r--r-- | install/database.sql | 4 | ||||
-rw-r--r-- | install/update.php | 10 | ||||
-rwxr-xr-x | mod/like.php | 11 | ||||
-rw-r--r-- | mod/thing.php | 9 | ||||
-rw-r--r-- | version.inc | 2 | ||||
-rw-r--r-- | view/js/main.js | 3 | ||||
-rw-r--r-- | view/theme/redbasic/css/style.css | 8 | ||||
-rwxr-xr-x | view/tpl/profile_advanced.tpl | 15 | ||||
-rw-r--r-- | view/tpl/show_thing.tpl | 4 |
16 files changed, 172 insertions, 46 deletions
diff --git a/app/lang.apd b/app/lang.apd new file mode 100644 index 000000000..afe049866 --- /dev/null +++ b/app/lang.apd @@ -0,0 +1,3 @@ +url: $baseurl/lang +name: Language +photo: $baseurl/app/lang.png diff --git a/app/lang.png b/app/lang.png Binary files differnew file mode 100644 index 000000000..4c0b9aad1 --- /dev/null +++ b/app/lang.png @@ -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/items.php b/include/items.php index c35a442b2..b80f18b72 100755 --- a/include/items.php +++ b/include/items.php @@ -3722,6 +3722,15 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { break; } + + // immediately remove any undesired profile likes. + + q("delete from likes where iid = %d and channel_id = %d limit 1", + intval($item['id']), + intval($item['uid']) + ); + + // network deletion request. Keep the message structure so that we can deliver delete notifications. // Come back after several days (or perhaps a month) to do the lowlevel delete (DROPITEM_PHASE2). diff --git a/include/reddav.php b/include/reddav.php index 3c2801e89..852a18869 100644 --- a/include/reddav.php +++ b/include/reddav.php @@ -880,6 +880,8 @@ class RedBrowser extends DAV\Browser\Plugin { public function generateDirectoryIndex($path) { + $is_owner = ((local_user() && $this->auth->owner_id == local_user()) ? true : false); + if($this->auth->timezone) date_default_timezone_set($this->auth->timezone); @@ -887,14 +889,21 @@ class RedBrowser extends DAV\Browser\Plugin { require_once('include/conversation.php'); if($this->auth->channel_name) - $html = profile_tabs(get_app(),(($this->auth->owner_id == local_user()) ? true : false),$this->auth->owner_nick); + $html = profile_tabs(get_app(),(($is_owner) ? true : false),$this->auth->owner_nick); $html .= " -<body> - <h1>Index for " . $this->escapeHTML($path) . "/</h1> - <table id=\"cloud-index\"> - <tr><th width=\"24\"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr> - <tr><td colspan=\"5\"><hr /></td></tr>"; + <body> + <h1>".t('Files').": ".$this->escapeHTML($path) . "/</h1> + <table id=\"cloud-index\"> + <tr> + <th></th> + <th>".t('Name')."</th> + <th></th><th></th><th></th> + <th>Type</th> + <th>Size</th> + <th>Last modified</th> + </tr> + <tr><td colspan=\"8\"><hr /></td></tr>"; $files = $this->server->getPropertiesForPath($path,array( '{DAV:}displayname', @@ -913,13 +922,15 @@ class RedBrowser extends DAV\Browser\Plugin { $fullPath = DAV\URLUtil::encodePath($this->server->getBaseUri() . $parentUri); $icon = $this->enableAssets?'<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="Parent" /></a>':''; - $html.= "<tr> - <td>$icon</td> - <td><a href=\"{$fullPath}\">..</a></td> - <td>[parent]</td> - <td></td> - <td></td> - </tr>"; + $html.= " + <tr> + <td>$icon</td> + <td><a href=\"{$fullPath}\">..</a></td> + <td></td><td></td><th></td> + <td>[parent]</td> + <td></td> + <td></td> + </tr>"; } @@ -1005,18 +1016,41 @@ class RedBrowser extends DAV\Browser\Plugin { } } - - $html.= "<tr> - <td>$icon</td> - <td><a href=\"{$fullPath}\">{$displayName}</a></td> - <td>{$type}</td> - <td>{$size}</td> - <td>" . (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(),$lastmodified) : '') . "</td> - </tr>"; + + $parentHash=""; + $owner=$this->auth->owner_id; + $splitPath = split("/",$fullPath); + if (count($splitPath) > 3) { + for ($i=3; $i<count($splitPath); $i++) { + $attachName = urldecode($splitPath[$i]); + $attachHash = $this->findAttachHash($owner,$parentHash,$attachName); + $parentHash = $attachHash; + } + } + $attachId = $this->findAttachIdByHash($attachHash); + $fileStorageUrl = str_replace("cloud/","filestorage/",$path); + $attachIcon = ""; // "<a href=\"attach/".$attachHash."\" title=\"".$displayName."\"><i class=\"icon-download\"></i></a>"; + $html.= "<tr> + <td>$icon</td> + <td><a href=\"{$fullPath}\">{$displayName}</a></td>"; + + if($is_owner) { + $html .= "<td>" . (($size) ? $attachIcon : '') . "</td> + <td><a href=\"".$fileStorageUrl."/".$attachId."/edit\" title=\"".t('Edit')."\"><i class=\"icon-pencil btn btn-default\"></i></a></td> + <td><a href=\"".$fileStorageUrl."/".$attachId."/delete\" title=\"".t('Delete')."\"><i class=\"icon-remove btn btn-default drop-icons\"></i></a></td>"; + } + else { + $html .= "<td></td><td></td><td></td>"; + } + $html .= + "<td>{$type}</td> + <td>". $size ."</td> + <td>" . (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(),$lastmodified) : '') . "</td> + </tr>"; } - $html.= "<tr><td colspan=\"5\"><hr /></td></tr>"; + $html.= "<tr><td colspan=\"8\"><hr /></td></tr>"; $output = ''; @@ -1039,12 +1073,13 @@ class RedBrowser extends DAV\Browser\Plugin { public function htmlActionsPanel(DAV\INode $node, &$output) { - if($this->auth->owner_id && $this->auth->owner_id == $this->auth->channel_id) { - $channel = get_app()->get_channel(); - if($channel) { - $output .= '<tr><td colspan="2"><a href="filestorage/' . $channel['channel_address'] . '" >' . t('Edit File properties') . '</a></td></tr><tr><td> </td></tr>'; - } - } + //Removed link to filestorage page + //if($this->auth->owner_id && $this->auth->owner_id == $this->auth->channel_id) { + // $channel = get_app()->get_channel(); + // if($channel) { + // $output .= '<tr><td colspan="2"><a href="filestorage/' . $channel['channel_address'] . '" >' . t('Edit File properties') . '</a></td></tr><tr><td> </td></tr>'; + // } + //} if (!$node instanceof DAV\ICollection) return; @@ -1083,4 +1118,29 @@ class RedBrowser extends DAV\Browser\Plugin { return z_root() .'/cloud/?sabreAction=asset&assetName=' . urlencode($assetName); } + protected function findAttachHash($owner, $parentHash, $attachName) { + $r = q("select * from attach where uid = %d and folder = '%s' and filename = '%s' order by edited desc limit 1", + intval($owner), dbesc($parentHash), dbesc($attachName) + ); + $hash = ""; + if($r) { + foreach($r as $rr) { + $hash = $rr['hash']; + } + } + return $hash; + } + + protected function findAttachIdByHash($attachHash) { + $r = q("select * from attach where hash = '%s' order by edited desc limit 1", + dbesc($attachHash) + ); + $id = ""; + if($r) { + foreach($r as $rr) { + $id = $rr['id']; + } + } + return $id; + } } diff --git a/include/taxonomy.php b/include/taxonomy.php index 4f2b5e8fd..92003328f 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -266,7 +266,7 @@ function obj_verb_selector($current = '') { $o .= '<select class="obj-verb-selector" name="verb" >'; foreach($verbs as $k => $v) { $selected = (($k == $current) ? ' selected="selected" ' : ''); - $o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[0] . '</option>'; + $o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[1] . '</option>'; } $o .= '</select>'; return $o; @@ -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/mod/thing.php b/mod/thing.php index cbf83fdf8..b6d59a3ee 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -243,12 +243,15 @@ function thing_content(&$a) { } } - if(! local_user()) { + $channel = $a->get_channel(); + + if(! (local_user() && $channel)) { notice( t('Permission denied.') . EOL); return; } $thing_hash = ''; + if(argc() == 3 && argv(1) === 'edit') { $thing_hash = argv(2); @@ -270,7 +273,7 @@ function thing_content(&$a) { '$multiprof' => feature_enabled(local_user(),'multi_profiles'), '$profile_lbl' => t('Select a profile'), '$profile_select' => contact_profile_assign($r[0]['obj_page']), - '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$verb_lbl' => $channel['channel_name'], '$verb_select' => obj_verb_selector($r[0]['obj_verb']), '$activity' => array('activity',t('Post an activity'),true,t('Only sends to viewers of the applicable profile')), '$thing_hash' => $thing_hash, @@ -317,7 +320,7 @@ function thing_content(&$a) { '$multiprof' => feature_enabled(local_user(),'multi_profiles'), '$profile_lbl' => t('Select a profile'), '$profile_select' => contact_profile_assign(''), - '$verb_lbl' => t('Select a category of stuff. e.g. I ______ something'), + '$verb_lbl' => $channel['channel_name'], '$activity' => array('activity',t('Post an activity'),true,t('Only sends to viewers of the applicable profile')), '$verb_select' => obj_verb_selector(), '$thing_lbl' => t('Name of thing e.g. something'), diff --git a/version.inc b/version.inc index 70a8e48e8..c7b1ae0bc 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2014-06-22.714 +2014-06-23.715 diff --git a/view/js/main.js b/view/js/main.js index cb492b9de..a7745cbaf 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -615,11 +615,12 @@ function updateConvItems(mode,data) { update_mode = 'append'; page_load = false; scroll_next = false; - in_progress = false; updateConvItems(update_mode,data); $("#page-spinner").spin(false); $("#profile-jot-text-loading").spin(false); + in_progress = false; + // FIXME - the following lines were added so that almost // immediately after we update the posts on the page, we // re-check and update the notification counts. 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}} |