diff options
author | habeascodice <habeascodice@federated.social> | 2014-10-07 16:13:22 -0700 |
---|---|---|
committer | habeascodice <habeascodice@federated.social> | 2014-10-07 16:13:22 -0700 |
commit | c01a9839577a5fc3a8965713e206616edc586c74 (patch) | |
tree | c9aa6cf42c2146bf5cee0a11a37ba6c93ef401d3 /mod | |
parent | 6b40c2cd090d1c406b3e1cd7ad135baff21bfd54 (diff) | |
parent | d94f6f7c53fbb01a76a6d3beb14968d02ebb3afa (diff) | |
download | volse-hubzilla-c01a9839577a5fc3a8965713e206616edc586c74.tar.gz volse-hubzilla-c01a9839577a5fc3a8965713e206616edc586c74.tar.bz2 volse-hubzilla-c01a9839577a5fc3a8965713e206616edc586c74.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r-- | mod/cloud.php | 30 | ||||
-rw-r--r-- | mod/editblock.php | 17 | ||||
-rw-r--r-- | mod/editlayout.php | 17 | ||||
-rw-r--r-- | mod/editwebpage.php | 15 | ||||
-rw-r--r-- | mod/impel.php | 30 | ||||
-rw-r--r-- | mod/message.php | 22 |
6 files changed, 97 insertions, 34 deletions
diff --git a/mod/cloud.php b/mod/cloud.php index c21c4c4b6..28c59872d 100644 --- a/mod/cloud.php +++ b/mod/cloud.php @@ -7,12 +7,13 @@ */ use Sabre\DAV; +use RedMatrix\RedDAV; // composer autoloader for SabreDAV require_once('vendor/autoload.php'); // workaround for HTTP-auth in CGI mode -if(x($_SERVER, 'REDIRECT_REMOTE_USER')) { +if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; if(strlen($userpass)) { list($name, $password) = explode(':', $userpass); @@ -21,7 +22,7 @@ if(x($_SERVER, 'REDIRECT_REMOTE_USER')) { } } -if(x($_SERVER, 'HTTP_AUTHORIZATION')) { +if (x($_SERVER, 'HTTP_AUTHORIZATION')) { $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; if(strlen($userpass)) { list($name, $password) = explode(':', $userpass); @@ -40,7 +41,7 @@ function cloud_init(&$a) { $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; if (file_exists($theme_info_file)){ require_once($theme_info_file); - if(function_exists(str_replace('-', '_', current_theme()) . '_init')) { + if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { $func = str_replace('-', '_', current_theme()) . '_init'; $func($a); } @@ -48,26 +49,26 @@ function cloud_init(&$a) { require_once('include/reddav.php'); - if(! is_dir('store')) + if (! is_dir('store')) os_mkdir('store', STORAGE_DEFAULT_PERMISSIONS, false); $which = null; - if(argc() > 1) + if (argc() > 1) $which = argv(1); $profile = 0; $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n"; - if($which) + if ($which) profile_load($a, $which, $profile); $auth = new RedBasicAuth(); $ob_hash = get_observer_hash(); - if($ob_hash) { - if(local_user()) { + if ($ob_hash) { + if (local_user()) { $channel = $a->get_channel(); $auth->setCurrentUser($channel['channel_address']); $auth->channel_id = $channel['channel_id']; @@ -79,7 +80,7 @@ function cloud_init(&$a) { $auth->observer = $ob_hash; } - if($_GET['davguest']) + if ($_GET['davguest']) $_SESSION['davguest'] = true; $_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']); @@ -113,7 +114,7 @@ function cloud_init(&$a) { $isapublic_file = false; $davguest = ((x($_SESSION, 'davguest')) ? true : false); - if((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) { + if ((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) { try { $x = RedFileData('/' . $a->cmd, $auth); if($x instanceof RedFile) @@ -124,7 +125,7 @@ function cloud_init(&$a) { } } - if((! $auth->observer) && (! $isapublic_file) && (! $davguest)) { + if ((! $auth->observer) && (! $isapublic_file) && (! $davguest)) { try { $auth->Authenticate($server, t('RedMatrix - Guests: Username: {your email address}, Password: +++')); } @@ -134,13 +135,18 @@ function cloud_init(&$a) { } } + require_once('include/RedDAV/RedBrowser.php'); // provide a directory view for the cloud in Red Matrix - $browser = new RedBrowser($auth); + $browser = new RedDAV\RedBrowser($auth); $auth->setBrowserPlugin($browser); $server->addPlugin($browser); + // Experimental QuotaPlugin +// require_once('include/RedDAV/QuotaPlugin.php'); +// $server->addPlugin(new RedDAV\QuotaPlugin($auth)); + // All we need to do now, is to fire up the server $server->exec(); diff --git a/mod/editblock.php b/mod/editblock.php index 536ddd7d2..3b6ce4bbf 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -152,6 +152,23 @@ function editblock_content(&$a) { if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob)) $o .= '<br /><br /><a class="block-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Block') . '</a><br />'; + + $x = array( + 'type' => 'block', + 'title' => $itm[0]['title'], + 'body' => $itm[0]['body'], + 'term' => $itm[0]['term'], + 'created' => $itm[0]['created'], + 'edited' => $itm[0]['edited'], + 'mimetype' => $itm[0]['mimetype'], + 'pagetitle' => $page_title, + 'mid' => $itm[0]['mid'] + ); + + $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL; + + + return $o; } diff --git a/mod/editlayout.php b/mod/editlayout.php index 1e8a6e990..89cae2b0c 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -145,6 +145,23 @@ function editlayout_content(&$a) { if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob)) $o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />'; + + $x = array( + 'type' => 'layout', + 'title' => $itm[0]['title'], + 'body' => $itm[0]['body'], + 'term' => $itm[0]['term'], + 'created' => $itm[0]['created'], + 'edited' => $itm[0]['edited'], + 'mimetype' => $itm[0]['mimetype'], + 'pagetitle' => $page_title, + 'mid' => $itm[0]['mid'] + ); + + $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL; + + + return $o; } diff --git a/mod/editwebpage.php b/mod/editwebpage.php index 9fe76ba98..41b5bb3e7 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -185,6 +185,21 @@ function editwebpage_content(&$a) { if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob)) $o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />'; + + $x = array( + 'type' => 'webpage', + 'title' => $itm[0]['title'], + 'body' => $itm[0]['body'], + 'term' => $itm[0]['term'], + 'created' => $itm[0]['created'], + 'edited' => $itm[0]['edited'], + 'mimetype' => $itm[0]['mimetype'], + 'pagetitle' => $page_title, + 'mid' => $itm[0]['mid'] + ); + + $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL; + return $o; } diff --git a/mod/impel.php b/mod/impel.php index 3c29d7cdb..1c7541bef 100644 --- a/mod/impel.php +++ b/mod/impel.php @@ -7,11 +7,13 @@ function impel_init(&$a) { $ret = array('success' => false); - if(! $local_user()) + if(! local_user()) json_return_and_die($ret); + logger('impel: ' . print_r($_REQUEST,true), LOGGER_DATA); + $elm = $_REQUEST['element']; - $x = base64_urldecode($elm); + $x = base64url_decode($elm); if(! $x) json_return_and_die($ret); @@ -20,7 +22,7 @@ function impel_init(&$a) { json_return_and_die($ret); - $channel = get_channel(); + $channel = $a->get_channel(); $arr = array(); @@ -28,14 +30,17 @@ function impel_init(&$a) { case 'webpage': $arr['item_restrict'] = ITEM_WEBPAGE; $namespace = 'WEBPAGE'; + $installed_type = t('webpage'); break; case 'block': $arr['item_restrict'] = ITEM_BUILDBLOCK; $namespace = 'BUILDBLOCK'; + $installed_type = t('block'); break; case 'layout': $arr['item_restrict'] = ITEM_PDL; $namespace = 'PDL'; + $installed_type = t('layout'); break; default: logger('mod_impel: unrecognised element type' . print_r($j,true)); @@ -46,8 +51,10 @@ function impel_init(&$a) { $arr['title'] = $j['title']; $arr['body'] = $j['body']; $arr['term'] = $j['term']; + $arr['created'] = datetime_convert('UTC','UTC', $j['created']); + $arr['edited'] = datetime_convert('UTC','UTC',$j['edited']); $arr['owner_xchan'] = get_observer_hash(); - $arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : $get_observer_hash()); + $arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : get_observer_hash()); $arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode'); if(! $j['mid']) @@ -63,9 +70,6 @@ function impel_init(&$a) { - - $channel = get_channel(); - // Verify ability to use html or php!!! $execflag = false; @@ -82,19 +86,21 @@ function impel_init(&$a) { $remote_id = 0; - $z = q("select * from item_id where $sid = '%s' and service = '%s' and uid = %d limit 1", + $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1", dbesc($pagetitle), dbesc($namespace), intval(local_user()) ); - $i = q("select id from item where mid = '%s' and $uid = %d limit 1", + $i = q("select id from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_user()) ); if($z && $i) { $remote_id = $z[0]['id']; $arr['id'] = $i[0]['id']; - $x = item_store_update($arr,$execflag); + // don't update if it has the same timestamp as the original + if($arr['edited'] > $i[0]['edited']) + $x = item_store_update($arr,$execflag); } else { $x = item_store($arr,$execflag); @@ -102,12 +108,14 @@ function impel_init(&$a) { if($x['success']) $item_id = $x['item_id']; - $channel = get_channel(); update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']); $ret['success'] = true; + + info( sprintf( t('%s element installed'), $installed_type)); + json_return_and_die(true); }
\ No newline at end of file diff --git a/mod/message.php b/mod/message.php index c14bf2161..7f3b6180a 100644 --- a/mod/message.php +++ b/mod/message.php @@ -61,18 +61,18 @@ function message_content(&$a) { foreach($r as $rr) { $o .= replace_macros($tpl, array( - '$id' => $rr['id'], - '$from_name' => $rr['from']['xchan_name'], - '$from_url' => chanlink_hash($rr['from_xchan']), + '$id' => $rr['id'], + '$from_name' => $rr['from']['xchan_name'], + '$from_url' => chanlink_hash($rr['from_xchan']), '$from_photo' => $rr['from']['xchan_photo_s'], - '$to_name' => $rr['to']['xchan_name'], - '$to_url' => chanlink_hash($rr['to_xchan']), - '$to_photo' => $rr['to']['xchan_photo_s'], - '$subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'), - '$delete' => t('Delete message'), - '$body' => smilies(bbcode($rr['body'])), - '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')), - '$seen' => $rr['seen'] + '$to_name' => $rr['to']['xchan_name'], + '$to_url' => chanlink_hash($rr['to_xchan']), + '$to_photo' => $rr['to']['xchan_photo_s'], + '$subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'), + '$delete' => t('Delete conversation'), + '$body' => smilies(bbcode($rr['body'])), + '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')), + '$seen' => $rr['seen'] )); } $o .= alt_pager($a,count($r)); |