diff options
author | mrjive <mrjive@mrjive.it> | 2016-01-21 09:51:32 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2016-01-21 09:51:32 +0100 |
commit | c49e4f52ae83441c4a1dcf52e433dded8d767679 (patch) | |
tree | 0a558e33ed4b77a56186721cf13844ba7b28af24 /include | |
parent | 763c700372ee91f3f840c6fba915cb4d941c34a0 (diff) | |
parent | 1d891984441fa2f4aa8e311191da23e9ddd6e928 (diff) | |
download | volse-hubzilla-c49e4f52ae83441c4a1dcf52e433dded8d767679.tar.gz volse-hubzilla-c49e4f52ae83441c4a1dcf52e433dded8d767679.tar.bz2 volse-hubzilla-c49e4f52ae83441c4a1dcf52e433dded8d767679.zip |
Merge pull request #18 from redmatrix/master
updating from original codebase
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 6 | ||||
-rw-r--r-- | include/api.php | 10 | ||||
-rw-r--r-- | include/conversation.php | 22 | ||||
-rw-r--r-- | include/enotify.php | 1 | ||||
-rw-r--r-- | include/event.php | 2 | ||||
-rw-r--r-- | include/features.php | 3 | ||||
-rw-r--r-- | include/identity.php | 8 | ||||
-rw-r--r-- | include/import.php | 7 | ||||
-rwxr-xr-x | include/items.php | 16 | ||||
-rw-r--r-- | include/language.php | 2 | ||||
-rw-r--r-- | include/network.php | 58 | ||||
-rwxr-xr-x | include/plugin.php | 4 | ||||
-rw-r--r-- | include/security.php | 23 | ||||
-rw-r--r-- | include/widgets.php | 8 | ||||
-rw-r--r-- | include/zot.php | 4 |
15 files changed, 97 insertions, 77 deletions
diff --git a/include/Contact.php b/include/Contact.php index 3bd5f9936..611371db6 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -331,6 +331,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { dbesc(datetime_convert()), intval($channel_id) ); + // if this was the default channel, set another one as default if($a->account['account_default_channel'] == $channel_id) { $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", @@ -344,12 +345,11 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { } else { $rr = q("update account set account_default_channel = 0 where account_id = %d", - intval($r[0]['channel_id']), - intval($a->account['account_id'])); + intval($a->account['account_id']) + ); } } - logger('deleting hublocs',LOGGER_DEBUG); $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", diff --git a/include/api.php b/include/api.php index 5053977c5..ef41a4912 100644 --- a/include/api.php +++ b/include/api.php @@ -2106,10 +2106,10 @@ require_once('include/api_auth.php'); 'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl, 'shorturllength' => '30', 'hubzilla' => array( - 'PLATFORM_NAME' => PLATFORM_NAME, - 'RED_VERSION' => RED_VERSION, + 'PLATFORM_NAME' => get_platform_name(), + 'RED_VERSION' => get_project_version(), 'ZOT_REVISION' => ZOT_REVISION, - 'DB_UPDATE_VERSION' => DB_UPDATE_VERSION + 'DB_UPDATE_VERSION' => get_update_version() ) )); @@ -2142,12 +2142,12 @@ require_once('include/api_auth.php'); if($type === 'xml') { header("Content-type: application/xml"); - echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>' . RED_VERSION . '</version>' . "\r\n"; + echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>' . get_project_version() . '</version>' . "\r\n"; killme(); } elseif($type === 'json') { header("Content-type: application/json"); - echo '"' . RED_VERSION . '"'; + echo '"' . get_project_version() . '"'; killme(); } } diff --git a/include/conversation.php b/include/conversation.php index 747bb5d0a..1ade8ed3a 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -942,25 +942,35 @@ function item_photo_menu($item){ $clean_url = normalise_link($item['author-link']); } - $menu = Array( + $poco_rating = get_config('system','poco_rating_enable'); + // if unset default to enabled + if($poco_rating === false) + $poco_rating = true; + + $ratings_url = (($poco_rating) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : ''); + + $post_menu = Array( t("View Source") => $vsrc_link, t("Follow Thread") => $sub_link, t("Unfollow Thread") => $unsub_link, - t("View Status") => $status_link, + ); + + $author_menu = array( t("View Profile") => $profile_link, - t("View Photos") => $photos_link, t("Activity/Posts") => $posts_link, t("Connect") => $follow_url, t("Edit Connection") => $contact_url, - t("Send PM") => $pm_url, + t("Message") => $pm_url, + t('Ratings') => $ratings_url, t("Poke") => $poke_link ); - $args = array('item' => $item, 'menu' => $menu); + + $args = array('item' => $item, 'post_menu' => $post_menu, 'author_menu' => $author_menu); call_hooks('item_photo_menu', $args); - $menu = $args['menu']; + $menu = array_merge($args['post_menu'],$args['author_menu']); $o = ""; foreach($menu as $k=>$v){ diff --git a/include/enotify.php b/include/enotify.php index c9b6e0463..5bb53aa0e 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -529,6 +529,7 @@ function notification($params) { $tpl = get_markup_template('email_notify_html.tpl'); $email_html_body = replace_macros($tpl,array( '$banner' => $datarray['banner'], + '$notify_icon' => get_notify_icon(), '$product' => $datarray['product'], '$preamble' => $datarray['preamble'], '$sitename' => $datarray['sitename'], diff --git a/include/event.php b/include/event.php index 539bfe484..51988acac 100644 --- a/include/event.php +++ b/include/event.php @@ -67,7 +67,7 @@ function ical_wrapper($ev) { $o .= "BEGIN:VCALENDAR"; $o .= "\r\nVERSION:2.0"; $o .= "\r\nMETHOD:PUBLISH"; - $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . PLATFORM_NAME . "//" . strtoupper(get_app()->language). "\r\n"; + $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . get_platform_name() . "//" . strtoupper(get_app()->language). "\r\n"; if(array_key_exists('start', $ev)) $o .= format_event_ical($ev); else { diff --git a/include/features.php b/include/features.php index 3cbbf5b7d..b18a58ed4 100644 --- a/include/features.php +++ b/include/features.php @@ -49,6 +49,7 @@ function get_features($filtered = true) { array('advanced_profiles', t('Advanced Profiles'), t('Additional profile sections and selections'),false,get_config('feature_lock','advanced_profiles')), array('profile_export', t('Profile Import/Export'), t('Save and load profile details across sites/channels'),false,get_config('feature_lock','profile_export')), array('webpages', t('Web Pages'), t('Provide managed web pages on your channel'),false,get_config('feature_lock','webpages')), + array('hide_rating', t('Hide Rating'), t('Hide the rating buttons on your channel and profile pages. Note: People can still rate you somewhere else.'),false,get_config('feature_lock','hide_rating')), array('private_notes', t('Private Notes'), t('Enables a tool to store notes and reminders'),false,get_config('feature_lock','private_notes')), array('nav_channel_select', t('Navigation Channel Select'), t('Change channels directly from within the navigation dropdown menu'),false,get_config('feature_lock','nav_channel_select')), array('photo_location', t('Photo Location'), t('If location data is available on uploaded photos, link this to a map.'),false,get_config('feature_lock','photo_location')), @@ -75,7 +76,7 @@ function get_features($filtered = true) { 'net_module' => array( t('Network and Stream Filtering'), array('archives', t('Search by Date'), t('Ability to select posts by date ranges'),false,get_config('feature_lock','archives')), - array('groups', t('Collections Filter'), t('Enable widget to display Network posts only from selected collections'),false,get_config('feature_lock','groups')), + array('groups', t('Collections (Privacy Groups)'), t('Enable widget to display Network posts only from selected collections'),false,get_config('feature_lock','groups')), array('savedsearch', t('Saved Searches'), t('Save search terms for re-use'),false,get_config('feature_lock','savedsearch')), array('personal_tab', t('Network Personal Tab'), t('Enable tab to display only Network posts that you\'ve interacted on'),false,get_config('feature_lock','personal_tab')), array('new_tab', t('Network New Tab'), t('Enable tab to display all new Network activity'),false,get_config('feature_lock','new_tab')), diff --git a/include/identity.php b/include/identity.php index deccaa299..32c4dd130 100644 --- a/include/identity.php +++ b/include/identity.php @@ -482,6 +482,8 @@ function identity_basic_export($channel_id, $items = false) { $ret = array(); + // use constants here as otherwise we will have no idea if we can import from a site + // with a non-standard platform and version. $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION); $r = q("select * from channel where channel_id = %d limit 1", @@ -1049,8 +1051,10 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) { $tpl = get_markup_template('profile_vcard.tpl'); require_once('include/widgets.php'); - $z = widget_rating(array('target' => $profile['channel_hash'])); + if(! feature_enabled($profile['uid'],'hide_rating')) + $z = widget_rating(array('target' => $profile['channel_hash'])); + $o .= replace_macros($tpl, array( '$profile' => $profile, '$connect' => $connect, @@ -1771,4 +1775,4 @@ function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_ return $output; -}
\ No newline at end of file +} diff --git a/include/import.php b/include/import.php index ffaea6c1a..e208c3b00 100644 --- a/include/import.php +++ b/include/import.php @@ -496,6 +496,8 @@ function import_items($channel,$items) { } } + $deliver = false; // Don't deliver any messages or notifications when importing + foreach($items as $i) { $item = get_item_elements($i,$allow_code); if(! $item) @@ -509,16 +511,15 @@ function import_items($channel,$items) { if($item['edited'] > $r[0]['edited']) { $item['id'] = $r[0]['id']; $item['uid'] = $channel['channel_id']; - item_store_update($item); + item_store_update($item,$allow_code,$deliver); continue; } } else { $item['aid'] = $channel['channel_account_id']; $item['uid'] = $channel['channel_id']; - $item_result = item_store($item); + $item_result = item_store($item,$allow_code,$deliver); } - } } } diff --git a/include/items.php b/include/items.php index 44f9633a9..6acf1c883 100755 --- a/include/items.php +++ b/include/items.php @@ -604,8 +604,8 @@ function get_feed_for($channel, $observer_hash, $params) { $atom = ''; $atom .= replace_macros($feed_template, array( - '$version' => xmlify(RED_VERSION), - '$red' => xmlify(PLATFORM_NAME), + '$version' => xmlify(get_project_version()), + '$red' => xmlify(get_platform_name()), '$feed_id' => xmlify($channel['xchan_url']), '$feed_title' => xmlify($channel['channel_name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now' , ATOM_TIME)) , @@ -2160,7 +2160,7 @@ function encode_rel_links($links) { * * \e boolean \b success * * \e int \b item_id */ -function item_store($arr, $allow_exec = false) { +function item_store($arr, $allow_exec = false, $deliver = true) { $d = array('item' => $arr, 'allow_exec' => $allow_exec); call_hooks('item_store', $d ); @@ -2537,7 +2537,7 @@ function item_store($arr, $allow_exec = false) { // so that we have an item in the DB that's marked deleted and won't store a fresh post // that isn't aware that we were already told to delete it. - if(! intval($arr['item_deleted'])) { + if(($deliver) && (! intval($arr['item_deleted']))) { send_status_notifications($current_post,$arr); tag_deliver($arr['uid'],$current_post); } @@ -2550,7 +2550,7 @@ function item_store($arr, $allow_exec = false) { -function item_store_update($arr,$allow_exec = false) { +function item_store_update($arr,$allow_exec = false, $deliver = true) { $d = array('item' => $arr, 'allow_exec' => $allow_exec); call_hooks('item_store_update', $d ); @@ -2780,9 +2780,11 @@ function item_store_update($arr,$allow_exec = false) { call_hooks('post_remote_update_end',$arr); - send_status_notifications($orig_post_id,$arr); + if($deliver) { + send_status_notifications($orig_post_id,$arr); + tag_deliver($uid,$orig_post_id); + } - tag_deliver($uid,$orig_post_id); $ret['success'] = true; $ret['item_id'] = $orig_post_id; diff --git a/include/language.php b/include/language.php index 59979aa85..cea31924c 100644 --- a/include/language.php +++ b/include/language.php @@ -182,7 +182,7 @@ function t($s, $ctx = '') { function translate_projectname($s) { - return str_replace(array('$projectname','$Projectname'),array(PLATFORM_NAME,ucfirst(PLATFORM_NAME)),$s); + return str_replace(array('$projectname','$Projectname'),array(get_platform_name(),ucfirst(get_platform_name())),$s); } diff --git a/include/network.php b/include/network.php index 94298abef..fe6b553e9 100644 --- a/include/network.php +++ b/include/network.php @@ -1619,18 +1619,19 @@ function format_and_send_email($sender,$xchan,$item) { // load the template for private message notifications $tpl = get_markup_template('email_notify_html.tpl'); $email_html_body = replace_macros($tpl,array( - '$banner' => $banner, - '$product' => $product, - '$preamble' => '', - '$sitename' => $sitename, - '$siteurl' => $siteurl, + '$banner' => $banner, + '$notify_icon' => get_notify_icon(), + '$product' => $product, + '$preamble' => '', + '$sitename' => $sitename, + '$siteurl' => $siteurl, '$source_name' => $sender['xchan_name'], '$source_link' => $sender['xchan_url'], '$source_photo' => $sender['xchan_photo_m'], - '$username' => $xchan['xchan_name'], + '$username' => $xchan['xchan_name'], '$hsitelink' => $datarray['hsitelink'], '$hitemlink' => $datarray['hitemlink'], - '$thanks' => $thanks, + '$thanks' => $thanks, '$site_admin' => $site_admin, '$title' => $title, '$htmlversion' => $htmlversion, @@ -1639,20 +1640,20 @@ function format_and_send_email($sender,$xchan,$item) { // load the template for private message notifications $tpl = get_markup_template('email_notify_text.tpl'); $email_text_body = replace_macros($tpl, array( - '$banner' => $banner, - '$product' => $product, - '$preamble' => '', - '$sitename' => $sitename, - '$siteurl' => $siteurl, + '$banner' => $banner, + '$product' => $product, + '$preamble' => '', + '$sitename' => $sitename, + '$siteurl' => $siteurl, '$source_name' => $sender['xchan_name'], '$source_link' => $sender['xchan_url'], '$source_photo' => $sender['xchan_photo_m'], - '$username' => $xchan['xchan_name'], - '$hsitelink' => $datarray['hsitelink'], - '$hitemlink' => $datarray['hitemlink'], - '$thanks' => $thanks, + '$username' => $xchan['xchan_name'], + '$hsitelink' => $datarray['hsitelink'], + '$hitemlink' => $datarray['hitemlink'], + '$thanks' => $thanks, '$site_admin' => $site_admin, - '$title' => $title, + '$title' => $title, '$textversion' => $textversion )); @@ -1666,13 +1667,13 @@ function format_and_send_email($sender,$xchan,$item) { // use the EmailNotification library to send the message enotify::send(array( - 'fromName' => $product, - 'fromEmail' => $sender_email, - 'replyTo' => $sender_email, - 'toEmail' => str_replace('mailto:','',$xchan['xchan_addr']), - 'messageSubject' => (($title) ? $title : t('No Subject')), - 'htmlVersion' => $email_html_body, - 'textVersion' => $email_text_body, + 'fromName' => $product, + 'fromEmail' => $sender_email, + 'replyTo' => $sender_email, + 'toEmail' => str_replace('mailto:','',$xchan['xchan_addr']), + 'messageSubject' => (($title) ? $title : t('No Subject')), + 'htmlVersion' => $email_html_body, + 'textVersion' => $email_text_body, 'additionalMailHeader' => '', )); @@ -1767,16 +1768,13 @@ function get_site_info() { $site_info = get_config('system','info'); $site_name = get_config('system','sitename'); if(! get_config('system','hidden_version_siteinfo')) { - $version = RED_VERSION; + $version = get_project_version(); $tag = get_std_version(); if(@is_dir('.git') && function_exists('shell_exec')) { $commit = trim( @shell_exec('git log -1 --format="%h"')); -// if(! get_config('system','hidden_tag_siteinfo')) -// $tag = trim( @shell_exec('git describe --tags --abbrev=0')); -// else -// $tag = ''; } + if(! isset($commit) || strlen($commit) > 16) $commit = ''; } @@ -1820,7 +1818,7 @@ function get_site_info() { 'locked_features' => $locked_features, 'admin' => $admin, 'site_name' => (($site_name) ? $site_name : ''), - 'platform' => PLATFORM_NAME, + 'platform' => get_platform_name(), 'dbdriver' => $db->getdriver(), 'lastpoll' => get_config('system','lastpoll'), 'info' => (($site_info) ? $site_info : ''), diff --git a/include/plugin.php b/include/plugin.php index 2bc363556..a47558b63 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -365,7 +365,7 @@ function check_plugin_versions($info) { return true; if(array_key_exists('minversion',$info)) { - if(version_compare(trim($info['minversion']),STD_VERSION, '>=')) { + if(! version_compare(STD_VERSION,trim($info['minversion']), '>=')) { logger('minversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); return false; } @@ -377,7 +377,7 @@ function check_plugin_versions($info) { } } if(array_key_exists('minphpversion',$info)) { - if(version_compare(trim($info['minphpversion']),PHP_VERSION, '>=')) { + if(! version_compare(PHP_VERSION,trim($info['minphpversion']), '>=')) { logger('minphpversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); return false; } diff --git a/include/security.php b/include/security.php index d4ebe0024..2a9a6e39e 100644 --- a/include/security.php +++ b/include/security.php @@ -18,20 +18,13 @@ function authenticate_success($user_record, $login_initial = false, $interactive $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; + $lastlog_updated = false; + if(x($user_record, 'account_id')) { $a->account = $user_record; $_SESSION['account_id'] = $user_record['account_id']; $_SESSION['authenticated'] = 1; - if($login_initial || $update_lastlog) { - q("update account set account_lastlog = '%s' where account_id = %d", - dbesc(datetime_convert()), - intval($_SESSION['account_id']) - ); - $a->account['account_lastlog'] = datetime_convert(); - call_hooks('logged_in', $a->account); - - } $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid']))) ? intval($_SESSION['uid']) @@ -42,9 +35,19 @@ function authenticate_success($user_record, $login_initial = false, $interactive change_channel($uid_to_load); } + if($login_initial || $update_lastlog) { + q("update account set account_lastlog = '%s' where account_id = %d", + dbesc(datetime_convert()), + intval($_SESSION['account_id']) + ); + $a->account['account_lastlog'] = datetime_convert(); + $lastlog_updated = true; + call_hooks('logged_in', $a->account); + } + } - if($login_initial) { + if(($login_initial) && (! $lastlog_updated)) { call_hooks('logged_in', $user_record); diff --git a/include/widgets.php b/include/widgets.php index 7021ef49d..60605cb51 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -915,8 +915,8 @@ function widget_photo($arr) { // ensure they can't sneak in an eval(js) function - if(strpos($style,'(') !== false) - return ''; + if(strpbrk($style,'(\'"<>') !== false) + $style = ''; if(array_key_exists('zrl', $arr) && isset($arr['zrl'])) $zrl = (($arr['zrl']) ? true : false); @@ -956,8 +956,8 @@ function widget_cover_photo($arr) { // ensure they can't sneak in an eval(js) function - if(strpos($style,'(') !== false) - return ''; + if(strpbrk($style,'(\'"<>') !== false) + $style = ''; $c = get_cover_photo($channel_id,'html'); diff --git a/include/zot.php b/include/zot.php index beaa54126..9d09aaf58 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3828,7 +3828,7 @@ function zotinfo($arr) { $ret['site']['channels'] = channel_total(); - $ret['site']['version'] = PLATFORM_NAME . ' ' . RED_VERSION . '[' . DB_UPDATE_VERSION . ']'; + $ret['site']['version'] = get_platform_name() . ' ' . RED_VERSION . '[' . DB_UPDATE_VERSION . ']'; $ret['site']['admin'] = get_config('system','admin_email'); @@ -3848,7 +3848,7 @@ function zotinfo($arr) { $ret['site']['sellpage'] = get_config('system','sellpage'); $ret['site']['location'] = get_config('system','site_location'); $ret['site']['realm'] = get_directory_realm(); - $ret['site']['project'] = PLATFORM_NAME; + $ret['site']['project'] = get_platform_name(); } |