diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/connedit.php | 33 | ||||
-rw-r--r-- | mod/filestorage.php | 9 | ||||
-rw-r--r-- | mod/poco.php | 11 | ||||
-rw-r--r-- | mod/prep.php | 75 | ||||
-rw-r--r-- | mod/sharedwithme.php | 114 |
5 files changed, 236 insertions, 6 deletions
diff --git a/mod/connedit.php b/mod/connedit.php index 5c36c3184..c27f4588a 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -107,6 +107,14 @@ function connedit_post(&$a) { if($closeness < 0) $closeness = 99; + $rating = intval($_POST['rating']); + if($rating < (-10)) + $rating = (-10); + if($rating > 10) + $rating = 10; + + $rating_text = escape_tags($_REQUEST['rating_text']); + $abook_my_perms = 0; foreach($_POST as $k => $v) { @@ -125,11 +133,13 @@ function connedit_post(&$a) { $new_friend = true; } - $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d + $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_rating = %d, abook_rating_text = '%s', abook_flags = %d where abook_id = %d AND abook_channel = %d", dbesc($profile_id), intval($abook_my_perms), intval($closeness), + intval($rating), + dbesc($rating_text), intval($abook_flags), intval($contact_id), intval(local_user()) @@ -524,6 +534,22 @@ function connedit_content(&$a) { )); } + $poco_rating = get_config('system','poco_rating_enable'); + // if unset default to enabled + if($poco_rating === false) + $poco_rating = true; + + if($poco_rating) { + $rating = replace_macros(get_markup_template('rating_slider.tpl'),array( + '$min' => -10, + '$val' => (($contact['abook_rating']) ? $contact['abook_rating'] : 0), + )); + } + else { + $rating = false; + } + + $perms = array(); $channel = $a->get_channel(); @@ -555,6 +581,11 @@ function connedit_content(&$a) { '$buttons' => (($self) ? '' : $buttons), '$viewprof' => t('View Profile'), '$lbl_slider' => t('Slide to adjust your degree of friendship'), + '$lbl_rating' => t('Rating (this information may be public)'), + '$lbl_rating_txt' => t('Optionally explain your rating (this information may be public)'), + '$rating_txt' => $contact['abook_rating_text'], + '$rating' => $rating, + '$rating_val' => $contact['abook_rating'], '$slide' => $slide, '$tabs' => $t, '$tab_str' => $tab_str, diff --git a/mod/filestorage.php b/mod/filestorage.php index 0a25617f0..67abc2eab 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -22,6 +22,8 @@ function filestorage_post(&$a) { $recurse = ((x($_POST, 'recurse')) ? intval($_POST['recurse']) : 0); $resource = ((x($_POST, 'filehash')) ? notags($_POST['filehash']) : ''); + $no_activity = ((x($_POST, 'no_activity')) ? intval($_POST['no_activity']) : 0); + if(! $resource) { notice(t('Item not found.') . EOL); return; @@ -37,6 +39,12 @@ function filestorage_post(&$a) { //Build directory tree and redirect $channel = $a->get_channel(); $cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource); + + $filename = find_filename_by_hash($channel_id, $resource); + $url = $cloudPath . $filename; + + file_activity($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $url, 'post', $no_activity); + goaway($cloudPath); } @@ -150,6 +158,7 @@ function filestorage_content(&$a) { '$submit' => t('Submit'), '$attach_btn_title' => t('Attach this file to a new post'), '$link_btn_title' => t('Show URL to this file'), + '$activity_btn_title' => t('Do not show in shared with me folder of your connections') )); echo $o; diff --git a/mod/poco.php b/mod/poco.php index 3f932e92f..152f5a143 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -76,7 +76,7 @@ function poco_init(&$a) { $sql_extra ", intval($channel_id) ); - $c = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " )>0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", + $rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " )>0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", intval($channel_id) ); } @@ -119,10 +119,10 @@ function poco_init(&$a) { $ret['itemsPerPage'] = (string) $itemsPerPage; $ret['totalResults'] = (string) $totalResults; - if($c) { + if($rooms) { $ret['chatrooms'] = array(); - foreach($c as $d) { - $ret['chatrooms'][] = array('url' => $d['mitem_link'], 'desc' => $d['mitem_desc']); + foreach($rooms as $room) { + $ret['chatrooms'][] = array('url' => $room['mitem_link'], 'desc' => $room['mitem_desc']); } } @@ -178,7 +178,8 @@ function poco_init(&$a) { if($fields_ret['photos']) $entry['photos'] = array(array('value' => $rr['xchan_photo_l'], 'mimetype' => $rr['xchan_photo_mimetype'], 'type' => 'profile')); if($fields_ret['rating']) { - $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? array(intval($rr['abook_rating'])) : 0); + $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? intval($rr['abook_rating']) : 0); + $entry['rating_text'] = ((array_key_exists('abook_rating_text',$rr)) ? $rr['abook_rating_text'] : ''); // maybe this should be a composite calculated rating in $system_mode if($system_mode) $entry['rating'] = 0; diff --git a/mod/prep.php b/mod/prep.php new file mode 100644 index 000000000..896717826 --- /dev/null +++ b/mod/prep.php @@ -0,0 +1,75 @@ +<?php + + +function prep_init(&$a) { + + $poco_rating = get_config('system','poco_rating_enable'); + // if unset default to enabled + if($poco_rating === false) + $poco_rating = true; + + if(! $poco_rating) + return; + + if(argc() > 1) + $hash = argv(1); + + if(! $hash) { + notice('Must supply a channel identififier.'); + return; + } + + if(strpos($hash,'@')) { + $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", + dbesc($hash) + ); + if($r) + $hash = $r[0]['hubloc_hash']; + } + + $p = q("select * from xchan where xchan_hash like '%s'", + dbesc($hash . '%') + ); + + if($p) + $a->poi = $p[0]; + +} + + + + + +function prep_content(&$a) { + + + $poco_rating = get_config('system','poco_rating_enable'); + // if unset default to enabled + if($poco_rating === false) + $poco_rating = true; + + if(! $poco_rating) + return; + + if(! $a->poi) + return; + + $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash where xlink_link like '%s' and xlink_rating != 0", + dbesc($a->poi['xchan_hash']) + ); + + if(! $r) + notice( t('No ratings available') . EOL); + + + $o = replace_macros(get_markup_template('prep.tpl'),array( + '$header' => t('Ratings'), + '$rating_lbl' => t('Rating: ' ), + '$rating_text_lbl' => t('Description: '), + '$raters' => $r + )); + + return $o; +} + +
\ No newline at end of file diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php new file mode 100644 index 000000000..d4aa129ac --- /dev/null +++ b/mod/sharedwithme.php @@ -0,0 +1,114 @@ +<?php +require_once('include/text.php'); +require_once('include/conversation.php'); + +function sharedwithme_content(&$a) { + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } + + $channel = $a->get_channel(); + + $is_owner = (local_user() && (local_user() == $channel['channel_id'])); + + $postverb = ACTIVITY_FILE . '/post/'; + $dropverb = ACTIVITY_FILE . '/drop/'; + + //maintenance - see if a file got dropped and remove it systemwide + $x = q("SELECT * FROM item WHERE verb LIKE '%s' AND uid = %d", + dbesc($dropverb . '%'), + intval(local_user()) + ); + + if($x) { + + foreach($x as $xx) { + + $hash = substr($xx['verb'], 39); + + $update = strpos($hash, '#'); + + if($update === false) { + q("DELETE FROM item WHERE verb = '%s' OR verb = '%s'", + dbesc($postverb . $hash), + dbesc($dropverb . $hash) + ); + } + + else { + + $arr = explode('#', $hash); + + q("DELETE FROM item WHERE mid != '%s' AND verb = '%s' OR verb = '%s'", + dbesc($arr[1]), + dbesc($postverb . $arr[0]), + dbesc($dropverb . $hash) + ); + + } + + } + + } + + //drop single file - localuser + if((argc() > 2) && (argv(2) === 'drop')) { + + $id = intval(argv(1)); + + q("DELETE FROM item WHERE id = %d AND uid = %d", + intval($id), + intval(local_user()) + ); + + goaway(z_root() . '/sharedwithme'); + } + + //drop all files - localuser + if((argc() > 1) && (argv(1) === 'dropall')) { + + q("DELETE FROM item WHERE verb LIKE '%s' AND uid = %d", + dbesc($postverb . '%'), + intval(local_user()) + ); + + goaway(z_root() . '/sharedwithme'); + } + + //list files + $r = q("SELECT * FROM item WHERE verb LIKE '%s' AND uid = %d", + dbesc($postverb . '%'), + intval(local_user()) + ); + + $o = profile_tabs($a, $is_owner, $channel['channel_address']); + + $o .= '<div class="section-title-wrapper">'; + + $o .= '<a href="/sharedwithme/dropall" onclick="return confirmDelete();" class="btn btn-xs btn-default pull-right"><i class="icon-trash"></i> ' . t('Remove all entries') . '</a>'; + + $o .= '<h2>' . t('Files shared with me') . '</h2>'; + + $o .= '</div>'; + + $o .= '<div class="section-content-wrapper">'; + + if($r) { + foreach($r as $rr) { + //don't display the files we shared with others + if($rr['owner_xchan'] != $channel['channel_hash']) { + unobscure($rr); + $url = rawurldecode($rr['body']); + $o .= '<a href="' . $url . '?f=&zid=' . $channel['xchan_addr'] . '">' . $url . '</a> <a href="/sharedwithme/' . $rr['id'] . '/drop" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a><br><br>'; + } + } + } + + $o .= '</div>'; + + return $o; + + +} + |