diff options
Diffstat (limited to 'include')
-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 |
4 files changed, 115 insertions, 32 deletions
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 |