diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 1 | ||||
-rw-r--r-- | include/RedDAV/RedBrowser.php | 5 | ||||
-rw-r--r-- | include/RedDAV/RedDirectory.php | 18 | ||||
-rw-r--r-- | include/RedDAV/RedFile.php | 13 | ||||
-rw-r--r-- | include/attach.php | 113 | ||||
-rw-r--r-- | include/conversation.php | 2 | ||||
-rw-r--r-- | include/dir_fns.php | 33 | ||||
-rw-r--r-- | include/enotify.php | 8 | ||||
-rw-r--r-- | include/socgraph.php | 10 |
9 files changed, 174 insertions, 29 deletions
diff --git a/include/Contact.php b/include/Contact.php index 4f7a2a19f..4c80f5d6a 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -119,6 +119,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { '$name' => $xchan['xchan_name'], '$photo' => ((is_array($a->profile) && array_key_exists('photo',$a->profile)) ? $a->profile['photo'] : $xchan['xchan_photo_l']), '$follow' => $xchan['xchan_addr'], + '$link' => zid($xchan['xchan_url']), '$connect' => $connect, '$newwin' => (($mode === 'chanview') ? t('New window') : ''), '$newtit' => t('Open the selected location in a different window or browser tab'), diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index 9ea2b9808..93a546086 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -249,7 +249,10 @@ class RedBrowser extends DAV\Browser\Plugin { '$header' => t('Files') . ": " . $this->escapeHTML($path) . "/", '$quota' => $quota, '$total' => t('Total'), - '$actionspanel' => $output + '$actionspanel' => $output, + '$shared' => t('Shared'), + '$create' => t('Create'), + 'upload' => t('Upload') )); $html .= replace_macros(get_markup_template('cloud_directory.tpl'), array( diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php index 85af0d57f..68186d21b 100644 --- a/include/RedDAV/RedDirectory.php +++ b/include/RedDAV/RedDirectory.php @@ -52,7 +52,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { //logger('directory ' . $ext_path, LOGGER_DATA); $this->ext_path = $ext_path; // remove "/cloud" from the beginning of the path - $this->red_path = ((strpos($ext_path, '/cloud') === 0) ? substr($ext_path, 6) : $ext_path); + $modulename = get_app()->module; + $this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path); if (! $this->red_path) { $this->red_path = '/'; } @@ -112,8 +113,9 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { throw new DAV\Exception\Forbidden('Permission denied.'); } - if ($this->red_path === '/' && $name === 'cloud') { - return new RedDirectory('/cloud', $this->auth); + $modulename = get_app()->module; + if ($this->red_path === '/' && $name === $modulename) { + return new RedDirectory('/' . $modulename, $this->auth); } $x = RedFileData($this->ext_path . '/' . $name, $this->auth); @@ -316,8 +318,9 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { public function childExists($name) { // On /cloud we show a list of available channels. // @todo what happens if no channels are available? - if ($this->red_path === '/' && $name === 'cloud') { - //logger('We are at /cloud show a channel list', LOGGER_DEBUG); + $modulename = get_app()->module; + if ($this->red_path === '/' && $name === $modulename) { + //logger('We are at ' $modulename . ' show a channel list', LOGGER_DEBUG); return true; } @@ -338,14 +341,15 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { function getDir() { //logger($this->ext_path, LOGGER_DEBUG); $this->auth->log(); + $modulename = get_app()->module; $file = $this->ext_path; - $x = strpos($file, '/cloud'); + $x = strpos($file, '/' . $modulename); if ($x === false) return; if ($x === 0) { - $file = substr($file, 6); + $file = substr($file, strlen($modulename) + 1); } if ((! $file) || ($file === '/')) { diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php index 3a5230dc1..9ce6490a7 100644 --- a/include/RedDAV/RedFile.php +++ b/include/RedDAV/RedFile.php @@ -96,7 +96,7 @@ class RedFile extends DAV\Node implements DAV\IFile { $size = 0; // @todo only 3 values are needed - $c = q("SELECT * FROM channel WHERE channel_id = %d AND NOT (channel_pageflags & %d)>0 LIMIT 1", + $c = q("SELECT * FROM channel WHERE channel_id = %d AND (channel_pageflags & %d) = 0 LIMIT 1", intval($this->auth->owner_id), intval(PAGE_REMOVED) ); @@ -107,14 +107,15 @@ class RedFile extends DAV\Node implements DAV\IFile { ); if ($r) { if ($r[0]['flags'] & ATTACH_FLAG_OS) { - $f = 'store/' . $this->auth->owner_nick . '/' . (($r[0]['data']) ? $r[0]['data'] : ''); + $fname = dbunescbin($r[0]['data']); + $f = 'store/' . $this->auth->owner_nick . '/' . (($fname) ? $fname : ''); // @todo check return value and set $size directly @file_put_contents($f, $data); $size = @filesize($f); logger('filename: ' . $f . ' size: ' . $size, LOGGER_DEBUG); } else { $r = q("UPDATE attach SET data = '%s' WHERE hash = '%s' AND uid = %d", - dbesc(stream_get_contents($data)), + dbescbin(stream_get_contents($data)), dbesc($this->data['hash']), intval($this->data['uid']) ); @@ -191,10 +192,10 @@ class RedFile extends DAV\Node implements DAV\IFile { } if ($r[0]['flags'] & ATTACH_FLAG_OS ) { - $f = 'store/' . $this->auth->owner_nick . '/' . (($this->os_path) ? $this->os_path . '/' : '') . $r[0]['data']; + $f = 'store/' . $this->auth->owner_nick . '/' . (($this->os_path) ? $this->os_path . '/' : '') . dbunescbin($r[0]['data']); return fopen($f, 'rb'); } - return $r[0]['data']; + return dbunescbin($r[0]['data']); } } @@ -276,4 +277,4 @@ class RedFile extends DAV\Node implements DAV\IFile { attach_delete($this->auth->owner_id, $this->data['hash']); } -}
\ No newline at end of file +} diff --git a/include/attach.php b/include/attach.php index a76dd4b28..dd4f89d09 100644 --- a/include/attach.php +++ b/include/attach.php @@ -753,14 +753,17 @@ function attach_delete($channel_id, $resource) { $channel_address = (($c) ? $c[0]['channel_address'] : 'notfound'); - $r = q("SELECT hash, flags, folder FROM attach WHERE hash = '%s' AND uid = %d limit 1", + $r = q("SELECT hash, filename, flags, folder FROM attach WHERE hash = '%s' AND uid = %d limit 1", dbesc($resource), intval($channel_id) ); + if(! $r) return; + $url = get_parent_cloudpath($channel_id, $channel_address, $resource) . $r[0]['filename']; + // If resource is a directory delete everything in the directory recursive if($r[0]['flags'] & ATTACH_FLAG_DIR) { $x = q("SELECT hash, flags FROM attach WHERE folder = '%s' AND uid = %d", @@ -802,6 +805,8 @@ function attach_delete($channel_id, $resource) { dbesc($r[0]['folder']), intval($channel_id) ); + + file_activity($channel_id, $resource, $allow_cid='', $allow_gid='', $deny_cid='', $deny_gid='', $url, 'drop', $no_activity=false); } /** @@ -815,7 +820,7 @@ function attach_delete($channel_id, $resource) { * path to the file in cloud/ */ function get_cloudpath($arr) { - $basepath = 'cloud/'; + $basepath = get_app()->module . '/'; if($arr['uid']) { $r = q("select channel_address from channel where channel_id = %d limit 1", @@ -875,7 +880,7 @@ function get_parent_cloudpath($channel_id, $channel_name, $attachHash) { $parentFullPath = $parentName . '/' . $parentFullPath; } } while ($parentHash); - $parentFullPath = z_root() . '/cloud/' . $channel_name . '/' . $parentFullPath; + $parentFullPath = z_root() . '/' . get_app()->module . '/' . $channel_name . '/' . $parentFullPath; return $parentFullPath; } @@ -934,3 +939,105 @@ function pipe_streams($in, $out) { $size += fwrite($out, fread($in, 8192)); return $size; } + +function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $url, $action, $no_activity) { + + require_once('include/items.php'); + + $url = rawurlencode($url); + + $poster = get_app()->get_observer(); + + $verb = ACTIVITY_FILE . '/' . $action . '/' . $hash; + + $mid = item_message_id(); + + $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; + + if($action == 'post') { + //check if activity item exists + //if yes send drop activity and create a new one + + $r = q("SELECT * FROM item WHERE verb = '%s'", + dbesc($verb) + ); + + if($r) { + + $dmid = item_message_id(); + $updateverb = ACTIVITY_FILE . '/drop/' . $hash . '#' . $mid; + + $arr = array(); + + $arr['aid'] = get_account_id(); + $arr['uid'] = $channel_id; + $arr['mid'] = $dmid; + $arr['parent_mid'] = $dmid; + $arr['item_flags'] = $item_flags; + $arr['author_xchan'] = $poster['xchan_hash']; + $arr['owner_xchan'] = $poster['xchan_hash']; + $arr['title'] = ''; + $arr['allow_cid'] = $allow_cid; + $arr['allow_gid'] = $allow_gid; + $arr['deny_cid'] = $deny_cid; + $arr['deny_gid'] = $deny_gid; + $arr['item_restrict'] = ITEM_HIDDEN; + $arr['item_private'] = 0; + $arr['verb'] = $updateverb; + $arr['body'] = $url; + + $post = item_store($arr); + $item_id = $post['item_id']; + + if($item_id) { + proc_run('php',"include/notifier.php","activity",$item_id); + } + + //call_hooks('post_local_end', $arr); + + //notice( t('File activity updated') . EOL); + + if($no_activity) { + return; + } + + } + } + + if($no_activity) { + return; + } + + $arr = array(); + + $arr['aid'] = get_account_id(); + $arr['uid'] = $channel_id; + $arr['mid'] = $mid; + $arr['parent_mid'] = $mid; + $arr['item_flags'] = $item_flags; + $arr['author_xchan'] = $poster['xchan_hash']; + $arr['owner_xchan'] = $poster['xchan_hash']; + $arr['title'] = ''; + $arr['allow_cid'] = $allow_cid; + $arr['allow_gid'] = $allow_gid; + $arr['deny_cid'] = $deny_cid; + $arr['deny_gid'] = $deny_gid; + $arr['item_restrict'] = ITEM_HIDDEN; + $arr['item_private'] = 0; + $arr['verb'] = $verb; + $arr['body'] = $url; + + $post = item_store($arr); + $item_id = $post['item_id']; + + if($item_id) { + proc_run('php',"include/notifier.php","activity",$item_id); + } + + //call_hooks('post_local_end', $arr); + + //(($action === 'post') ? notice( t('File activity posted') . EOL) : notice( t('File activity dropped') . EOL)); + + return; + +} diff --git a/include/conversation.php b/include/conversation.php index 0d59ff92e..25c844fef 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1572,7 +1572,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ $tabs[] = array( 'label' => t('Files'), 'url' => $a->get_baseurl() . '/cloud/' . $nickname . ((get_observer_hash()) ? '' : '?f=&davguest=1'), - 'sel' => ((argv(0) == 'cloud') ? 'active' : ''), + 'sel' => ((argv(0) == 'cloud' || argv(0) == 'sharedwithme') ? 'active' : ''), 'title' => t('Files and Storage'), 'id' => 'files-tab', ); diff --git a/include/dir_fns.php b/include/dir_fns.php index 371ee0fbc..6d06fddd1 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -31,22 +31,37 @@ function find_upstream_directory($dirmode) { } function check_upstream_directory() { + /** * Directories may come and go over time. We will need to check that our * directory server is still valid occasionally, and reset to something that * is if our directory has gone offline for any reason */ + $directory = get_config('system','directory_server'); - if ($directory) { - $r = q("select * from site where site_url = '%s' and (site_flags & %d) > 0 ", - dbesc($directory), - intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY|DIRECTORY_MODE_STANDALONE) - ); - } - // If we've got something, it's still a directory. If we haven't, we need to reset and let find_upstream_directory() fix it - if (! $r) { - set_config('system','directory_server',''); + + // it's possible there is no directory server configured and the local hub is being used. + // If so, default to preserving the absence of a specific server setting. + + $isadir = true; + + if($directory) { + $h = parse_url($directory); + if($h) { + $x = zot_finger('sys@' . $h['host']); + if($x['success']) { + $j = json_decode($x['body'],true); + if(array_key_exists('site',$j) && array_key_exists('directory_mode',$j['site'])) { + if($j['site']['directory_mode'] === 'normal') { + $isadir = false; + } + } + } } + } + + if(! $isadir) + set_config('system','directory_server',''); return; } diff --git a/include/enotify.php b/include/enotify.php index 3fef3ba0a..6fc771c58 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -421,6 +421,14 @@ function notification($params) { logger('notification: sending notification email'); + $hn = get_pconfig($recip['channel_id'],'system','email_notify_host'); + if($hn && (! stristr(get_app()->get_hostname(),$hn))) { + // this isn't the email notification host + pop_lang(); + return; + } + + $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"), array( "", "\n"), $body))),ENT_QUOTES,'UTF-8')); diff --git a/include/socgraph.php b/include/socgraph.php index 740886b1c..0cdf43ec7 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -72,6 +72,9 @@ function poco_load($xchan = '',$url = null) { if($xchan) { if(array_key_exists('chatrooms',$j) && is_array($j['chatrooms'])) { foreach($j['chatrooms'] as $room) { + if((! $room['url']) || (! $room['desc'])) + continue; + $r = q("select * from xchat where xchat_url = '%s' and xchat_xchan = '%s' limit 1", dbesc($room['url']), dbesc($xchan) @@ -117,6 +120,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 +192,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']) ); } |