diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/blocks.php | 6 | ||||
-rw-r--r-- | mod/chanview.php | 17 | ||||
-rw-r--r-- | mod/connect.php | 4 | ||||
-rw-r--r-- | mod/connections.php | 25 | ||||
-rw-r--r-- | mod/connedit.php | 42 | ||||
-rw-r--r-- | mod/directory.php | 20 | ||||
-rw-r--r-- | mod/group.php | 6 | ||||
-rw-r--r-- | mod/help.php | 27 | ||||
-rw-r--r-- | mod/layouts.php | 6 | ||||
-rw-r--r-- | mod/menu.php | 2 | ||||
-rw-r--r-- | mod/message.php | 399 | ||||
-rw-r--r-- | mod/mitem.php | 5 | ||||
-rw-r--r-- | mod/photo.php | 12 | ||||
-rw-r--r-- | mod/photos.php | 17 | ||||
-rw-r--r-- | mod/ping.php | 2 | ||||
-rw-r--r-- | mod/qsearch.php | 50 | ||||
-rw-r--r-- | mod/redir.php | 60 | ||||
-rw-r--r-- | mod/search.php | 124 | ||||
-rw-r--r-- | mod/settings.php | 108 | ||||
-rw-r--r-- | mod/siteinfo.php | 20 | ||||
-rw-r--r-- | mod/suggest.php | 7 | ||||
-rw-r--r-- | mod/webpages.php | 6 |
22 files changed, 97 insertions, 868 deletions
diff --git a/mod/blocks.php b/mod/blocks.php index 4604790c3..9a4e0b1ca 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -45,9 +45,9 @@ function blocks_content(&$a) { return; } - if(local_user() && local_user() == $owner) { - $a->set_widget('design',design_tools()); - } +// if(local_user() && local_user() == $owner) { + // $a->set_widget('design',design_tools()); + // } diff --git a/mod/chanview.php b/mod/chanview.php index f183fbdf1..55f7e95d6 100644 --- a/mod/chanview.php +++ b/mod/chanview.php @@ -38,17 +38,16 @@ function chanview_content(&$a) { ); } if($r) { - $xchan = $r[0]; + $a->poi = $r[0]; } - // Here, let's see if we have an xchan. If we don't, how we proceed is determined by what // info we do have. If it's a URL, we can offer to visit it directly. If it's a webbie or // address, we can and should try to import it. If it's just a hash, we can't continue, but we // probably wouldn't have a hash if we don't already have an xchan for this channel. - if(! $xchan) { + if(! $a->poi) { logger('mod_chanview: fallback'); // This is hackish - construct a zot address from the url if($_REQUEST['url']) { @@ -68,20 +67,20 @@ function chanview_content(&$a) { dbesc($_REQUEST['address']) ); if($r) - $xchan = $r[0]; + $a->poi = $r[0]; } } } - if(! $xchan) { + if(! $a->poi) { notice( t('Channel not found.') . EOL); return; } $url = (($observer) - ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] - : $xchan['xchan_url'] + ? z_root() . '/magic?f=&dest=' . $a->poi['xchan_url'] . '&addr=' . $a->poi['xchan_addr'] + : $a->poi['xchan_url'] ); // let somebody over-ride the iframed viewport presentation @@ -89,10 +88,6 @@ function chanview_content(&$a) { if(local_user() && get_pconfig(local_user(),'system','chanview_full')) goaway($url); - - if($xchan['xchan_hash']) - $a->set_widget('vcard',vcard_from_xchan($xchan,$observer,'chanview')); - $o = replace_macros(get_markup_template('chanview.tpl'),array( '$url' => $url, '$full' => t('toggle full screen mode') diff --git a/mod/connect.php b/mod/connect.php index 93f994af5..f7748bcaf 100644 --- a/mod/connect.php +++ b/mod/connect.php @@ -23,10 +23,6 @@ function connect_init(&$a) { $a->data['channel'] = $r[0]; profile_load($a,$which,''); - - profile_create_sidebar($a,false); - - } function connect_post(&$a) { diff --git a/mod/connections.php b/mod/connections.php index 10f0468b6..2119c69c7 100644 --- a/mod/connections.php +++ b/mod/connections.php @@ -19,23 +19,6 @@ function connections_init(&$a) { } -function connections_aside(&$a) { - - - if (! local_user()) - return; - - - $a->set_widget('follow', widget_follow(array())); - - - $a->set_widget('suggest',widget_suggestions(array())); - $a->set_widget('findpeople',findpeople_widget()); - -} - - - function connections_post(&$a) { if(! local_user()) @@ -317,9 +300,10 @@ function connections_content(&$a) { $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash - where abook_channel = %d and not (abook_flags & %d) $sql_extra $sql_extra2 ", + where abook_channel = %d and not (abook_flags & %d) and not (xchan_flags & %d ) $sql_extra $sql_extra2 ", intval(local_user()), - intval(ABOOK_FLAG_SELF) + intval(ABOOK_FLAG_SELF), + intval(XCHAN_FLAGS_DELETED) ); if(count($r)) { $a->set_pager_total($r[0]['total']); @@ -327,9 +311,10 @@ function connections_content(&$a) { } $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash - WHERE abook_channel = %d and not (abook_flags & %d) $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d , %d ", + WHERE abook_channel = %d and not (abook_flags & %d) and not ( xchan_flags & %d) $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d , %d ", intval(local_user()), intval(ABOOK_FLAG_SELF), + intval(XCHAN_FLAGS_DELETED), intval($a->pager['start']), intval($a->pager['itemspage']) ); diff --git a/mod/connedit.php b/mod/connedit.php index 7fc4bfaf8..e2d4b861c 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -21,7 +21,7 @@ function connedit_init(&$a) { intval(argv(1)) ); if($r) { - $a->data['abook'] = $r[0]; + $a->poi = $r[0]; } } @@ -31,24 +31,6 @@ function connedit_init(&$a) { } -function connedit_aside(&$a) { - - - if (! local_user()) - return; - - if(x($a->data,'abook')) { - $a->set_widget('vcard',vcard_from_xchan($a->data['abook'],$a->get_observer())); - $a->set_widget('collections', group_side('connections','group',false,0,$a->data['abook']['abook_xchan'])); - } - - $a->set_widget('suggest',widget_suggestions(array())); - $a->set_widget('findpeople',findpeople_widget()); - -} - - - function connedit_post(&$a) { if(! local_user()) @@ -123,8 +105,8 @@ function connedit_post(&$a) { else notice( t('Failed to update connection record.') . EOL); - if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms - && (! ($a->data['abook']['abook_flags'] & ABOOK_FLAG_SELF))) { + if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms + && (! ($a->poi['abook_flags'] & ABOOK_FLAG_SELF))) { proc_run('php', 'include/notifier.php', 'permission_update', $contact_id); } @@ -135,7 +117,7 @@ function connedit_post(&$a) { require_once('include/group.php'); $g = group_rec_byhash(local_user(),$default_group); if($g) - group_add_member(local_user(),'',$a->data['abook_xchan'],$g['id']); + group_add_member(local_user(),'',$a->poi['abook_xchan'],$g['id']); } @@ -159,11 +141,11 @@ function connedit_post(&$a) { intval($contact_id) ); if($r) { - $a->data['abook'] = $r[0]; + $a->poi = $r[0]; } if($new_friend) { - $arr = array('channel_id' => local_user(), 'abook' => $a->data['abook']); + $arr = array('channel_id' => local_user(), 'abook' => $a->poi); call_hooks('accept_follow', $arr); } @@ -175,9 +157,9 @@ function connedit_post(&$a) { function connedit_clone(&$a) { - if(! array_key_exists('abook',$a->data)) + if(! $a->poi) return; - $clone = $a->data['abook']; + $clone = $a->poi; unset($clone['abook_id']); unset($clone['abook_account']); @@ -315,10 +297,10 @@ function connedit_content(&$a) { } } - if((x($a->data,'abook')) && (is_array($a->data['abook']))) { + if($a->poi) { - $contact_id = $a->data['abook']['abook_id']; - $contact = $a->data['abook']; + $contact_id = $a->poi['abook_id']; + $contact = $a->poi; $tabs = array( @@ -482,7 +464,7 @@ function connedit_content(&$a) { '$lastupdtext' => t('Last update:'), '$lost_contact' => $lost_contact, '$updpub' => t('Update public posts'), - '$last_update' => $last_update, + '$last_update' => relative_date($contact['abook_connected']), '$udnow' => t('Update now'), '$profile_select' => contact_profile_assign($contact['abook_profile']), '$multiprofs' => feature_enabled(local_user(),'multi_profiles'), diff --git a/mod/directory.php b/mod/directory.php index 92fb36ea7..9e4c37fae 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -9,22 +9,6 @@ function directory_init(&$a) { } -function directory_aside(&$a) { - - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { - return; - } - - require_once('include/contact_widgets.php'); - $a->set_widget('find_people',findpeople_widget()); - - $a->set_widget('safe_search',dir_safe_mode()); - - $a->set_widget('dir_sort_order',dir_sort_links()); - -} - - function directory_content(&$a) { if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { @@ -210,10 +194,8 @@ function directory_content(&$a) { } if($j['keywords']) { - $a->set_widget('dirtagblock',dir_tagblock(z_root() . '/directory',$j['keywords'])); + $a->data['directory_keywords'] = $j['keywords']; } - $a->set_widget('suggest',widget_suggestions(array())); - // logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA); diff --git a/mod/group.php b/mod/group.php index 5a34ab6fb..352484e25 100644 --- a/mod/group.php +++ b/mod/group.php @@ -2,12 +2,6 @@ require_once('include/group.php'); -function group_aside(&$a) { - if(local_user()) { - $a->set_widget('groups_edit',group_side('connections','group',false,(($a->argc > 1) ? intval($a->argv[1]) : 0))); - } -} - function group_post(&$a) { diff --git a/mod/help.php b/mod/help.php index e78f9e61c..cd2dfd87e 100644 --- a/mod/help.php +++ b/mod/help.php @@ -32,6 +32,8 @@ function help_content(&$a) { global $lang; + $doctype = 'markdown'; + require_once('library/markdown.php'); $text = ''; @@ -41,6 +43,19 @@ function help_content(&$a) { $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags(argv(1))); } if(! $text) { + $text = load_doc_file('doc/' . $a->argv[1] . '.bb'); + if($text) + $doctype = 'bbcode'; + $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags(argv(1))); + } + if(! $text) { + $text = load_doc_file('doc/' . $a->argv[1] . '.html'); + if($text) + $doctype = 'html'; + $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags(argv(1))); + } + + if(! $text) { $text = load_doc_file('doc/Site.md'); $a->page['title'] = t('Help'); } @@ -58,9 +73,15 @@ function help_content(&$a) { } $text = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $text); - - - return Markdown($text); + + if($doctype === 'html') + return $text; + if($doctype === 'markdown') + return Markdown($text); + if($doctype === 'bbcode') { + require_once('include/bbcode.php'); + return bbcode($text); + } } diff --git a/mod/layouts.php b/mod/layouts.php index b1f53d4d8..9ed349850 100644 --- a/mod/layouts.php +++ b/mod/layouts.php @@ -43,9 +43,9 @@ function layouts_content(&$a) { return; } - if(local_user() && local_user() == $owner) { - $a->set_widget('design',design_tools()); - } +// if(local_user() && local_user() == $owner) { + // $a->set_widget('design',design_tools()); + // } $tabs = array( array( diff --git a/mod/menu.php b/mod/menu.php index 1ec3c7996..47eed6484 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -42,7 +42,7 @@ function menu_content(&$a) { } - $a->set_widget('design',design_tools()); +// $a->set_widget('design',design_tools()); if(argc() == 1) { diff --git a/mod/message.php b/mod/message.php index 6a33f1db7..c14bf2161 100644 --- a/mod/message.php +++ b/mod/message.php @@ -7,175 +7,6 @@ require_once("include/bbcode.php"); require_once('include/Contact.php'); -function message_post(&$a) { - - if(! local_user()) - return; - - $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); - $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); - $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); - $recipient = ((x($_REQUEST,'messageto')) ? notags(trim($_REQUEST['messageto'])) : ''); - $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); - $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : '0000-00-00 00:00:00'); - - // If we have a raw string for a recipient which hasn't been auto-filled, - // it means they probably aren't in our address book, hence we don't know - // if we have permission to send them private messages. - // finger them and find out before we try and send it. - - if(! $recipient) { - $channel = $a->get_channel(); - - $ret = zot_finger($rstr,$channel); - - if(! $ret['success']) { - notice( t('Unable to lookup recipient.') . EOL); - return; - } - $j = json_decode($ret['body'],true); - - logger('message_post: lookup: ' . $url . ' ' . print_r($j,true)); - - if(! ($j['success'] && $j['guid'])) { - notice( t('Unable to communicate with requested channel.')); - return; - } - - $x = import_xchan($j); - - if(! $x['success']) { - notice( t('Cannot verify requested channel.')); - return; - } - - $recipient = $x['hash']; - - $their_perms = 0; - - $global_perms = get_perms(); - - if($j['permissions']['data']) { - $permissions = crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']); - if($permissions) - $permissions = json_decode($permissions); - logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA); - } - else - $permissions = $j['permissions']; - - foreach($permissions as $k => $v) { - if($v) { - $their_perms = $their_perms | intval($global_perms[$k][1]); - } - } - - if(! ($their_perms & PERMS_W_MAIL)) { - notice( t('Selected channel has private message restrictions. Send failed.')); - return; - } - } - - if(feature_enabled(local_user(),'richtext')) { - $body = fix_mce_lf($body); - } - - if(! $recipient) { - notice('No recipient found.'); - $a->argc = 2; - $a->argv[1] = 'new'; - return; - } - - // We have a local_user, let send_message use the session channel and save a lookup - - $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires); - - if(! $ret['success']) { - notice($ret['message']); - } - -} - -// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images' -// is identical to the code in include/conversation.php -if(! function_exists('item_extract_images')) { -function item_extract_images($body) { - - $saved_image = array(); - $orig_body = $body; - $new_body = ''; - - $cnt = 0; - $img_start = strpos($orig_body, '[img'); - $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); - $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); - while(($img_st_close !== false) && ($img_end !== false)) { - - $img_st_close++; // make it point to AFTER the closing bracket - $img_end += $img_start; - - if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) { - // This is an embedded image - - $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close)); - $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]'; - - $cnt++; - } - else - $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]')); - - $orig_body = substr($orig_body, $img_end + strlen('[/img]')); - - if($orig_body === false) // in case the body ends on a closing image tag - $orig_body = ''; - - $img_start = strpos($orig_body, '[img'); - $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); - $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); - } - - $new_body = $new_body . $orig_body; - - return array('body' => $new_body, 'images' => $saved_image); -}} - -if(! function_exists('item_redir_and_replace_images')) { -function item_redir_and_replace_images($body, $images, $cid) { - - $origbody = $body; - $newbody = ''; - - for($i = 0; $i < count($images); $i++) { - $search = '/\[zrl\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/zrl\]' . '/is'; -//FIXME - $replace = '[zrl=' . z_path() . '/redir/' . $cid - . '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/zrl]' ; - - $img_end = strpos($origbody, '[!#saved_image' . $i . '#!][/url]') + strlen('[!#saved_image' . $i . '#!][/url]'); - $process_part = substr($origbody, 0, $img_end); - $origbody = substr($origbody, $img_end); - - $process_part = preg_replace($search, $replace, $process_part); - $newbody = $newbody . $process_part; - } - $newbody = $newbody . $origbody; - - $cnt = 0; - foreach($images as $image) { - // We're depending on the property of 'foreach' (specified on the PHP website) that - // it loops over the array starting from the first element and going sequentially - // to the last element - $newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody); - $cnt++; - } - - return $newbody; -}} - - - function message_content(&$a) { $o = ''; @@ -201,126 +32,15 @@ function message_content(&$a) { '$tab_content' => $tab_content )); - if((argc() == 3) && (argv(1) === 'drop' || argv(1) === 'dropconv')) { - if(! intval(argv(2))) - return; - $cmd = argv(1); - if($cmd === 'drop') { - $r = private_messages_drop(local_user(), argv(2)); - if($r) { - info( t('Message deleted.') . EOL ); - } - goaway($a->get_baseurl(true) . '/message' ); - } - else { - $r = private_messages_drop(local_user(), argv(2), true); - if($r) - info( t('Conversation removed.') . EOL ); - goaway($a->get_baseurl(true) . '/message' ); - } - } - - if((argc() == 3) && (argv(1) === 'recall')) { + if((argc() == 3) && (argv(1) === 'dropconv')) { if(! intval(argv(2))) return; $cmd = argv(1); - $r = q("update mail set mail_flags = mail_flags | %d where id = %d and channel_id = %d limit 1", - intval(MAIL_RECALLED), - intval(argv(2)), - intval(local_user()) - ); - proc_run('php','include/notifier.php','mail',intval(argv(2))); - - if($r) { - info( t('Message recalled.') . EOL ); - } + $r = private_messages_drop(local_user(), argv(2), true); + if($r) + info( t('Conversation removed.') . EOL ); goaway($a->get_baseurl(true) . '/message' ); - - } - - - if((argc() > 1) && ($a->argv[1] === 'new')) { - - $o .= $header; - - $plaintext = false; - if(intval(get_pconfig(local_user(),'system','plaintext'))) - $plaintext = true; - if(! feature_enabled(local_user(),'richtext')) - $plaintext = true; - - $tpl = get_markup_template('msg-header.tpl'); - - $a->page['htmlhead'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$nickname' => $channel['channel_address'], - '$linkurl' => t('Please enter a link URL:'), - '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') - )); - - $preselect = (isset($a->argv[2])?array($a->argv[2]):false); - - - $prename = $preurl = $preid = ''; - - if($preselect) { - $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash - where abook_channel = %d and abook_id = %d limit 1", - intval(local_user()), - intval(argv(2)) - ); - if($r) { - $prename = $r[0]['xchan_name']; - $preurl = $r[0]['xchan_url']; - $preid = $r[0]['abook_id']; - } - } - - $prefill = (($preselect) ? $prename : ''); - - if(! $prefill) { - if(array_key_exists('to',$_REQUEST)) - $prefill = $_REQUEST['to']; - } - - // the ugly select box - - $select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10); - - $tpl = get_markup_template('prv_message.tpl'); - $o .= replace_macros($tpl,array( - '$header' => t('Send Private Message'), - '$to' => t('To:'), - '$showinputs' => 'true', - '$prefill' => $prefill, - '$autocomp' => $autocomp, - '$preid' => $preid, - '$subject' => t('Subject:'), - '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''), - '$text' => ((x($_REQUEST,'body')) ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : ''), - '$readonly' => '', - '$yourmessage' => t('Your message:'), - '$select' => $select, - '$parent' => '', - '$upload' => t('Upload photo'), - '$attach' => t('Attach file'), - '$insert' => t('Insert web link'), - '$wait' => t('Please wait'), - '$submit' => t('Submit'), - '$defexpire' => '', - '$feature_expire' => ((feature_enabled(local_user(),'content_expire')) ? 'block' : 'none'), - '$expires' => t('Set expiration date'), - '$feature_encrypt' => ((feature_enabled(local_user(),'content_encrypt')) ? 'block' : 'none'), - '$encrypt' => t('Encrypt text'), - '$cipher' => $cipher, - - - )); - - return $o; } - if(argc() == 1) { // list messages @@ -359,116 +79,5 @@ function message_content(&$a) { return $o; } - if((argc() > 1) && (intval(argv(1)))) { - - $o .= $header; - - $plaintext = true; - if( local_user() && feature_enabled(local_user(),'richtext') ) - $plaintext = false; - - $messages = private_messages_fetch_conversation(local_user(), argv(1), true); - - if(! $messages) { - info( t('Message not found.') . EOL); - return $o; - } - - $other_channel = null; - if($messages[0]['to_xchan'] === $channel['channel_hash']) - $other_channel = $messages[0]['from']; - else - $other_channel = $messages[0]['to']; - - require_once('include/Contact.php'); - - $a->set_widget('mail_conversant',vcard_from_xchan($other_channel,$get_observer_hash,'mail')); - - - $tpl = get_markup_template('msg-header.tpl'); - - $a->page['htmlhead'] .= replace_macros($tpl, array( - '$nickname' => $channel['channel_addr'], - '$baseurl' => $a->get_baseurl(true), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$linkurl' => t('Please enter a link URL:'), - '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') - )); - - - $mails = array(); - $seen = 0; - $unknown = false; - - foreach($messages as $message) { - - $s = theme_attachments($message); - - $mails[] = array( - 'id' => $message['id'], - 'from_name' => $message['from']['xchan_name'], - 'from_url' => chanlink_hash($message['from_xchan']), - 'from_photo' => $message['from']['xchan_photo_m'], - 'to_name' => $message['to']['xchan_name'], - 'to_url' => chanlink_hash($message['to_xchan']), - 'to_photo' => $message['to']['xchan_photo_m'], - 'subject' => $message['title'], - 'body' => smilies(bbcode($message['body']) . $s), - 'delete' => t('Delete message'), - 'recall' => t('Recall message'), - 'can_recall' => (($channel['channel_hash'] == $message['from_xchan']) ? true : false), - 'is_recalled' => (($message['mail_flags'] & MAIL_RECALLED) ? t('Message has been recalled.') : ''), - 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'), - ); - - $seen = $message['seen']; - - } - - $recp = (($message['from_xchan'] === $channel['channel_hash']) ? 'to' : 'from'); - -// FIXME - move this HTML to template - - $select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />'; - $parent = '<input type="hidden" name="replyto" value="' . $message['parent_mid'] . '" />'; - - $tpl = get_markup_template('mail_display.tpl'); - $o = replace_macros($tpl, array( - '$prvmsg_header' => t('Private Conversation'), - '$thread_id' => $a->argv[1], - '$thread_subject' => $message['title'], - '$thread_seen' => $seen, - '$delete' => t('Delete conversation'), - '$canreply' => (($unknown) ? false : '1'), - '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), - '$mails' => $mails, - - // reply - '$header' => t('Send Reply'), - '$to' => t('To:'), - '$showinputs' => '', - '$subject' => t('Subject:'), - '$subjtxt' => $message['title'], - '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', - '$yourmessage' => t('Your message:'), - '$text' => '', - '$select' => $select, - '$parent' => $parent, - '$upload' => t('Upload photo'), - '$attach' => t('Attach file'), - '$insert' => t('Insert web link'), - '$submit' => t('Submit'), - '$wait' => t('Please wait'), - '$defexpire' => '', - '$feature_expire' => ((feature_enabled(local_user(),'content_expire')) ? 'block' : 'none'), - '$expires' => t('Set expiration date'), - '$feature_encrypt' => ((feature_enabled(local_user(),'content_encrypt')) ? 'block' : 'none'), - '$encrypt' => t('Encrypt text'), - '$cipher' => $cipher, - - )); - - return $o; - } } diff --git a/mod/mitem.php b/mod/mitem.php index 8e60e2d65..e0aa1b87a 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -81,11 +81,8 @@ function mitem_content(&$a) { $channel = $a->get_channel(); - $a->set_widget('design',design_tools()); - - $m = menu_fetch($a->data['menu']['menu_name'],local_user(), get_observer_hash()); - $a->set_widget('menu_preview',menu_render($m)); + $a->data['menu_item'] = $m; if(argc() == 2) { diff --git a/mod/photo.php b/mod/photo.php index 591d7198a..6f047bea1 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -24,7 +24,7 @@ function photo_init(&$a) { $observer_xchan = get_observer_hash(); - $default = 'images/default_profile_photos/rainbow_man/175.jpg'; + $default = get_default_profile_photo(); if(isset($type)) { @@ -38,11 +38,11 @@ function photo_init(&$a) { case 'm': $resolution = 5; - $default = 'images/default_profile_photos/rainbow_man/80.jpg'; + $default = get_default_profile_photo(80); break; case 's': $resolution = 6; - $default = 'images/default_profile_photos/rainbow_man/48.jpg'; + $default = get_default_profile_photo(48); break; case 'l': default: @@ -135,15 +135,15 @@ function photo_init(&$a) { switch($resolution) { case 4: - $data = file_get_contents('images/default_profile_photos/rainbow_man/175.jpg'); + $data = file_get_contents(get_default_profile_photo()); $mimetype = 'image/jpeg'; break; case 5: - $data = file_get_contents('images/default_profile_photos/rainbow_man/80.jpg'); + $data = file_get_contents(get_default_profile_photo(80)); $mimetype = 'image/jpeg'; break; case 6: - $data = file_get_contents('images/default_profile_photos/rainbow_man/48.jpg'); + $data = file_get_contents(get_default_profile_photo(48)); $mimetype = 'image/jpeg'; break; default: diff --git a/mod/photos.php b/mod/photos.php index 0e23aa5bf..63806896b 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -34,16 +34,7 @@ function photos_init(&$a) { $observer_xchan = (($observer) ? $observer['xchan_hash'] : ''); - $a->data['perms'] = get_all_perms($channelx[0]['channel_id'],$observer_xchan); - - - - $a->set_widget('vcard',vcard_from_xchan('',$observer)); head_set_icon($a->data['channel']['xchan_photo_s']); - if($a->data['perms']['view_photos']) { - $a->data['albums'] = photos_albums_list($a->data['channel'],$observer); - $a->set_widget('photo_albums',photos_album_widget($a->data['channel'],$observer,$a->data['albums'])); - } $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "'; var profile_uid = " . (($a->data['channel']) ? $a->data['channel']['channel_id'] : 0) . "; </script>" ; @@ -599,6 +590,8 @@ function photos_content(&$a) { // Parse arguments // + $can_comment = perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'post_comments'); + if(argc() > 3) { $datatype = argv(2); $datum = argv(3); @@ -1066,7 +1059,7 @@ function photos_content(&$a) { $likebuttons = ''; - if($can_post || $a->data['perms']['post_comments']) { + if($can_post || $can_comment) { $likebuttons = replace_macros($like_tpl,array( '$id' => $link_item['id'], '$likethis' => t("I like this \x28toggle\x29"), @@ -1078,7 +1071,7 @@ function photos_content(&$a) { $comments = ''; if(! count($r)) { - if($can_post || $a->data['perms']['post_comments']) { + if($can_post || $can_comment) { $comments .= replace_macros($cmnt_tpl,array( '$return_path' => '', '$mode' => 'photos', @@ -1166,7 +1159,7 @@ function photos_content(&$a) { } - if($can_post || $a->data['perms']['post_comments']) { + if($can_post || $can_comment) { $comments .= replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => $return_url, diff --git a/mod/ping.php b/mod/ping.php index 414f06e53..a0938cb15 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -151,7 +151,7 @@ function ping_init(&$a) { foreach($t as $zz) { // $msg = sprintf( t('sent you a private message.'), $zz['xchan_name']); $notifs[] = array( - 'notify_link' => $a->get_baseurl() . '/message/' . $zz['id'], + 'notify_link' => $a->get_baseurl() . '/mail/' . $zz['id'], 'name' => $zz['xchan_name'], 'url' => $zz['xchan_url'], 'photo' => $zz['xchan_photo_s'], diff --git a/mod/qsearch.php b/mod/qsearch.php deleted file mode 100644 index c35e253b6..000000000 --- a/mod/qsearch.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -function qsearch_init(&$a) { - - if(! local_user()) - killme(); - - $limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100); - - $search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : ''); - - if(! strlen($search)) - killme(); - - - if($search) - $search = dbesc($search); - - $results = array(); - - $r = q("SELECT * FROM `group` WHERE `name` REGEXP '$search' AND `deleted` = 0 AND `uid` = %d LIMIT 0, %d ", - intval(local_user()), - intval($limit) - ); - - if(count($r)) { - - foreach($r as $rr) - $results[] = array( 0, (int) $rr['id'], $rr['name'], '', ''); - } - - $sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : ""); - - - $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra ORDER BY `name` ASC LIMIT 0, %d ", - intval(local_user()), - intval($limit) - ); - - - if(count($r)) { - - foreach($r as $rr) - $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']); - } - - echo json_encode((object) $results); - killme(); -} - diff --git a/mod/redir.php b/mod/redir.php deleted file mode 100644 index 113f6c200..000000000 --- a/mod/redir.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -function redir_init(&$a) { - - $url = ((x($_GET,'url')) ? $_GET['url'] : ''); - - // traditional DFRN - - if(local_user() && $a->argc > 1 && intval($a->argv[1])) { - - $cid = $a->argv[1]; - - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($cid), - intval(local_user()) - ); - - if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN)) - goaway(z_root()); - - $dfrn_id = $orig_id = (($r[0]['issued_id']) ? $r[0]['issued_id'] : $r[0]['dfrn_id']); - - if($r[0]['duplex'] && $r[0]['issued_id']) { - $orig_id = $r[0]['issued_id']; - $dfrn_id = '1:' . $orig_id; - } - if($r[0]['duplex'] && $r[0]['dfrn_id']) { - $orig_id = $r[0]['dfrn_id']; - $dfrn_id = '0:' . $orig_id; - } - - $sec = random_string(); - - q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`) - VALUES( %d, %s, '%s', '%s', %d )", - intval(local_user()), - intval($cid), - dbesc($dfrn_id), - dbesc($sec), - intval(time() + 45) - ); - - logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); - $dest = (($url) ? '&destination_url=' . $url : ''); - goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id - . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest ); - } - - if(local_user()) - $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3); - if(remote_user()) - $handle = $_SESSION['handle']; - - if($url) { - $url = str_replace('{zid}','&zid=' . $handle,$url); - goaway($url); - } - - goaway(z_root()); -} diff --git a/mod/search.php b/mod/search.php index 2b31002fa..32c8ca38e 100644 --- a/mod/search.php +++ b/mod/search.php @@ -1,76 +1,8 @@ <?php -function search_saved_searches() { - - if(! feature_enabled(local_user(),'savedsearch')) - return ''; - - $o = ''; - - $r = q("select `tid`,`term` from `term` WHERE `uid` = %d and type = %d", - intval(local_user()), - intval(TERM_SAVEDSEARCH) - ); - - if(count($r)) { - $o .= '<div id="saved-search-list" class="widget">'; - $o .= '<h3>' . t('Saved Searches') . '</h3>' . "\r\n"; - $o .= '<ul id="saved-search-ul">' . "\r\n"; - foreach($r as $rr) { - $o .= '<li class="saved-search-li clear"><a href="search/?f=&remove=1&search=' . rawurlencode($rr['term']) . '" title="' . t('Remove term') . '" onclick="return confirmDelete();"><i class="icon-remove drop-icons"></i></a> <a href="search/?f=&search=' . $rr['term'] . '" class="savedsearchterm" >' . htmlspecialchars($rr['term'], ENT_COMPAT,'UTF-8') . '</a></li>' . "\r\n"; - } - $o .= '</ul><div class="clear"></div></div>' . "\r\n"; - } - - return $o; - -} - - function search_init(&$a) { - - $search = ((x($_GET,'search')) ? trim(rawurldecode($_GET['search'])) : ''); - - if(local_user()) { - if(x($_GET,'save') && $search) { - $r = q("select `tid` from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1", - intval(local_user()), - intval(TERM_SAVEDSEARCH), - dbesc($search) - ); - if(! count($r)) { - q("insert into `term` ( `uid`,`type`,`term` ) values ( %d, %d, '%s') ", - intval(local_user()), - intval(TERM_SAVEDSEARCH), - dbesc($search) - ); - } - } - if(x($_GET,'remove') && $search) { - q("delete from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1", - intval(local_user()), - intval(TERM_SAVEDSEARCH), - dbesc($search) - ); - } - - $a->page['aside'] .= search_saved_searches(); - - } - else { - unset($_SESSION['theme']); - unset($_SESSION['mobile_theme']); - } - - - -} - - - -function search_post(&$a) { - if(x($_POST,'search')) - $a->data['search'] = $_POST['search']; + if(x($_REQUEST,'search')) + $a->data['search'] = $_REQUEST['search']; } @@ -133,10 +65,7 @@ function search_content(&$a,$update = 0, $load = false) { ); } else { - if (get_config('system','use_fulltext_engine')) - $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search))); - else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } // Here is the way permissions work in the search module... @@ -144,9 +73,6 @@ function search_content(&$a,$update = 0, $load = false) { // OR your own posts if you are a logged in member // No items will be shown if the member has a blocked profile wall. - - - if((! $update) && (! $load)) { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, @@ -223,54 +149,12 @@ function search_content(&$a,$update = 0, $load = false) { } if($r) { - -// $parents_str = ids_to_querystr($r,'item_id'); - -// $items = q("SELECT `item`.*, `item`.`id` AS `item_id` -// FROM `item` -// WHERE item_restrict = 0 -// $sql_extra and parent in ( $parents_str ) " -// ); - xchan_query($r); $items = fetch_post_tags($r,true); -// $items = conv_sort($items,'created'); - } else { $items = array(); } -//logger('mod_search: items ' . count($items)); - -// $r = q("SELECT distinct(`item`.`mid`), `item`.*, `item`.`id` AS `item_id`, -// `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, -// `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, -// `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, -// `user`.`nickname` -// FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` -// LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` -// WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 -// AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) -// OR `item`.`uid` = %d ) -// AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 -// $sql_extra -// group by `item`.`mid` -// ORDER BY `received` DESC LIMIT %d , %d ", -// intval(local_user()), -// intval($a->pager['start']), -// intval($a->pager['itemspage']) - -// ); - - -// $a = fetch_post_tags($a,true); - -// if(! $items) {// -// info( t('No results.') . EOL); -// return $o; -// } - - if($tag) $o .= '<h2>Items tagged with: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>'; else @@ -278,8 +162,6 @@ function search_content(&$a,$update = 0, $load = false) { $o .= conversation($a,$items,'search',$update,'client'); -// $o .= alt_pager($a,count($r)); - return $o; } diff --git a/mod/settings.php b/mod/settings.php index 7fb6f8317..5aa018cc2 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -16,14 +16,10 @@ function get_theme_config_file($theme){ } function settings_init(&$a) { - $a->profile_uid = local_user(); -} - - -function settings_aside(&$a) { + if(! local_user()) + return; -if (! local_user()) - return; + $a->profile_uid = local_user(); // default is channel settings in the absence of other arguments @@ -32,107 +28,9 @@ if (! local_user()) $a->argc = 2; $a->argv[] = 'channel'; } -/* - $channel = $a->get_channel(); - - $abook_self_id = 0; - - // Retrieve the 'self' address book entry for use in the auto-permissions link - if(local_user()) { - $abk = q("select abook_id from abook where abook_channel = %d and ( abook_flags & %d ) limit 1", - intval(local_user()), - intval(ABOOK_FLAG_SELF) - ); - if($abk) - $abook_self_id = $abk[0]['abook_id']; - } - - - $tabs = array( - array( - 'label' => t('Account settings'), - 'url' => $a->get_baseurl(true).'/settings/account', - 'selected' => ((argv(1) === 'account') ? 'active' : ''), - ), - - array( - 'label' => t('Channel settings'), - 'url' => $a->get_baseurl(true).'/settings/channel', - 'selected' => ((argv(1) === 'channel') ? 'active' : ''), - ), - - array( - 'label' => t('Additional features'), - 'url' => $a->get_baseurl(true).'/settings/features', - 'selected' => ((argv(1) === 'features') ? 'active' : ''), - ), - - array( - 'label' => t('Feature settings'), - 'url' => $a->get_baseurl(true).'/settings/featured', - 'selected' => ((argv(1) === 'featured') ? 'active' : ''), - ), - - array( - 'label' => t('Display settings'), - 'url' => $a->get_baseurl(true).'/settings/display', - 'selected' => ((argv(1) === 'display') ? 'active' : ''), - ), - - array( - 'label' => t('Connected apps'), - 'url' => $a->get_baseurl(true) . '/settings/oauth', - 'selected' => ((argv(1) === 'oauth') ? 'active' : ''), - ), - - array( - 'label' => t('Export channel'), - 'url' => $a->get_baseurl(true) . '/uexport/basic', - 'selected' => '' - ), - -// array( -// 'label' => t('Export account'), -// 'url' => $a->get_baseurl(true) . '/uexport/complete', -// 'selected' => '' -// ), - - array( - 'label' => t('Automatic Permissions (Advanced)'), - 'url' => $a->get_baseurl(true) . '/connedit/' . $abook_self_id, - 'selected' => '' - ), - - - ); - - if(feature_enabled(local_user(),'premium_channel')) { - $tabs[] = array( - 'label' => t('Premium Channel Settings'), - 'url' => $a->get_baseurl(true) . '/connect/' . $channel['channel_address'], - 'selected' => '' - ); - - } - if(feature_enabled(local_user(),'channel_sources')) { - $tabs[] = array( - 'label' => t('Channel Sources'), - 'url' => $a->get_baseurl(true) . '/sources', - 'selected' => '' - ); - - } - - $tabtpl = get_markup_template("generic_links_widget.tpl"); - $a->page['aside'] = replace_macros($tabtpl, array( - '$title' => t('Settings'), - '$class' => 'settings-widget', - '$items' => $tabs, - )); -*/ } diff --git a/mod/siteinfo.php b/mod/siteinfo.php index a64b5df20..9f65f59e4 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -27,8 +27,14 @@ function siteinfo_init(&$a) { $visible_plugins[] = $rr['name']; } + if(@is_dir('.git') && function_exists('shell_exec')) + $commit = @shell_exec('git log -1 --format="%h"'); + if(! isset($commit) || strlen($commit) > 16) + $commit = ''; + $data = Array( 'version' => RED_VERSION, + 'commit' => $commit, 'url' => z_root(), 'plugins' => $visible_plugins, 'register_policy' => $register_policy[$a->config['system']['register_policy']], @@ -47,11 +53,16 @@ function siteinfo_init(&$a) { function siteinfo_content(&$a) { - if(! get_config('system','hidden_version_siteinfo')) + if(! get_config('system','hidden_version_siteinfo')) { $version = sprintf( t('Version %s'), RED_VERSION ); - else - $version = ""; - + if(@is_dir('.git') && function_exists('shell_exec')) + $commit = @shell_exec('git log -1 --format="%h"'); + if(! isset($commit) || strlen($commit) > 16) + $commit = ''; + } + else { + $version = $commit = ''; + } $visible_plugins = array(); if(is_array($a->plugins) && count($a->plugins)) { $r = q("select * from addon where hidden = 0"); @@ -81,6 +92,7 @@ function siteinfo_content(&$a) { '$title' => t('Red'), '$description' => t('This is a hub of the Red Matrix - a global cooperative network of decentralised privacy enhanced websites.'), '$version' => $version, + '$commit' => $commit, '$web_location' => t('Running at web location') . ' ' . z_root(), '$visit' => t('Please visit <a href="http://getzot.com">GetZot.com</a> to learn more about the Red Matrix.'), '$bug_text' => t('Bug reports and issues: please visit'), diff --git a/mod/suggest.php b/mod/suggest.php index baccbd38f..8a6b50b22 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -19,13 +19,6 @@ function suggest_init(&$a) { } -function suggest_aside(&$a) { - - $a->set_widget('follow', widget_follow(array())); - $a->set_widget('findpeople', findpeople_widget()); -} - - function suggest_content(&$a) { $o = ''; diff --git a/mod/webpages.php b/mod/webpages.php index 90004faa1..7e1b32f36 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -41,9 +41,9 @@ function webpages_content(&$a) { return; } - if(local_user() && local_user() == $owner) { - $a->set_widget('design',design_tools()); - } +// if(local_user() && local_user() == $owner) { +// $a->set_widget('design',design_tools()); +// } $mimetype = get_config('system','page_mimetype'); |