diff options
author | zottel <github@zottel.net> | 2012-04-15 14:11:11 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2012-04-15 14:11:11 +0200 |
commit | a2c4ce74871dbe9e640cdeafc1574bda5b7fe144 (patch) | |
tree | fce1c1b2d497adae72d77e09c6bf005c8900256b /mod | |
parent | 0bad8de0562a50fa93b0af5fd4cf8d7123a11b46 (diff) | |
parent | f299749758112361ee6384cd75d11b2c3a57352a (diff) | |
download | volse-hubzilla-a2c4ce74871dbe9e640cdeafc1574bda5b7fe144.tar.gz volse-hubzilla-a2c4ce74871dbe9e640cdeafc1574bda5b7fe144.tar.bz2 volse-hubzilla-a2c4ce74871dbe9e640cdeafc1574bda5b7fe144.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r-- | mod/admin.php | 52 | ||||
-rw-r--r-- | mod/community.php | 8 | ||||
-rw-r--r-- | mod/contacts.php | 12 | ||||
-rw-r--r-- | mod/dfrn_poll.php | 6 | ||||
-rw-r--r-- | mod/dfrn_request.php | 63 | ||||
-rw-r--r-- | mod/directory.php | 2 | ||||
-rw-r--r-- | mod/install.php | 2 | ||||
-rw-r--r-- | mod/item.php | 5 | ||||
-rw-r--r-- | mod/message.php | 3 | ||||
-rw-r--r-- | mod/newmember.php | 4 | ||||
-rw-r--r-- | mod/nogroup.php | 65 | ||||
-rw-r--r-- | mod/notifications.php | 4 | ||||
-rw-r--r-- | mod/profile.php | 2 | ||||
-rw-r--r-- | mod/profiles.php | 140 | ||||
-rw-r--r-- | mod/randprof.php | 10 | ||||
-rw-r--r-- | mod/register.php | 16 | ||||
-rw-r--r-- | mod/settings.php | 105 |
17 files changed, 380 insertions, 119 deletions
diff --git a/mod/admin.php b/mod/admin.php index a395027c1..7386dc5a3 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -40,6 +40,20 @@ function admin_post(&$a){ goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] ); return; // NOTREACHED break; + case 'themes': + $theme = $a->argv[2]; + if (is_file("view/theme/$theme/config.php")){ + require_once("view/theme/$theme/config.php"); + if (function_exists("theme_admin_post")){ + theme_admin_post($a); + } + } + info(t('Theme settings updated.')); + if(is_ajax()) return; + + goaway($a->get_baseurl(true) . '/admin/themes/' . $theme ); + return; + break; case 'logs': admin_page_logs_post($a); break; @@ -129,7 +143,13 @@ function admin_content(&$a) { } else { $o = admin_page_summary($a); } - return $o; + + if(is_ajax()) { + echo $o; + killme(); + } else { + return $o; + } } @@ -174,7 +194,6 @@ function admin_page_site_post(&$a){ return; } - $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : ''); $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); @@ -194,7 +213,6 @@ function admin_page_site_post(&$a){ $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False); $no_openid = !((x($_POST,'no_openid')) ? True : False); - $no_gravatar = !((x($_POST,'no_gravatar')) ? True : False); $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False); $no_utf = !((x($_POST,'no_utf')) ? True : False); $no_community_page = !((x($_POST,'no_community_page')) ? True : False); @@ -204,7 +222,7 @@ function admin_page_site_post(&$a){ $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : ''); $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); - $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); + $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False); $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0); @@ -283,7 +301,6 @@ function admin_page_site_post(&$a){ set_config('system','directory_search_url', $global_search_url); set_config('system','block_extended_register', $no_multi_reg); set_config('system','no_openid', $no_openid); - set_config('system','no_gravatar', $no_gravatar); set_config('system','no_regfullname', $no_regfullname); set_config('system','no_community_page', $no_community_page); set_config('system','no_utf', $no_utf); @@ -365,7 +382,7 @@ function admin_page_site(&$a) { '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""), '$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices), - '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles"), $theme_choices), + '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices), '$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices), '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")), @@ -380,7 +397,6 @@ function admin_page_site(&$a) { '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")), '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")), - '$no_gravatar' => array('no_gravatar', t("Gravatar support"), !get_config('system','no_gravatar'), t("Search new user's photo on Gravatar.")), '$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")), '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")), '$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), t("Display a Community page showing all recent public postings on this site.")), @@ -772,14 +788,22 @@ function admin_page_themes(&$a){ } $readme=Null; - if (is_file("view/$theme/README.md")){ - $readme = file_get_contents("view/$theme/README.md"); + if (is_file("view/theme/$theme/README.md")){ + $readme = file_get_contents("view/theme/$theme/README.md"); $readme = Markdown($readme); - } else if (is_file("view/$theme/README")){ - $readme = "<pre>". file_get_contents("view/$theme/README") ."</pre>"; + } else if (is_file("view/theme/$theme/README")){ + $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>"; } $admin_form=""; + if (is_file("view/theme/$theme/config.php")){ + require_once("view/theme/$theme/config.php"); + if(function_exists("theme_admin")){ + $admin_form = theme_admin($a); + } + + } + $screenshot = array( get_theme_screenshot($theme), t('Screenshot')); if(! stristr($screenshot[0],$theme)) @@ -797,10 +821,10 @@ function admin_page_themes(&$a){ '$status' => $status, '$action' => $action, '$info' => get_theme_info($theme), - '$function' => 'themes', + '$function' => 'themes', '$admin_form' => $admin_form, '$str_author' => t('Author: '), - '$str_maintainer' => t('Maintainer: '), + '$str_maintainer' => t('Maintainer: '), '$screenshot' => $screenshot, '$readme' => $readme )); @@ -809,7 +833,7 @@ function admin_page_themes(&$a){ /** - * List plugins + * List themes */ $xthemes = array(); diff --git a/mod/community.php b/mod/community.php index f8cc3305b..bfe5a3089 100644 --- a/mod/community.php +++ b/mod/community.php @@ -45,13 +45,13 @@ function community_content(&$a, $update = 0) { // OR your own posts if you are a logged in member - $r = q("SELECT COUNT(*) AS `total` + $r = q("SELECT distinct(`item`.`uri`) AS `total` 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 `item`.`wall` = 1 AND `user`.`hidewall` = 0 - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 " + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri` " ); if(count($r)) @@ -62,7 +62,7 @@ function community_content(&$a, $update = 0) { return $o; } - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, @@ -73,7 +73,7 @@ function community_content(&$a, $update = 0) { AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri` ORDER BY `received` DESC LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']) diff --git a/mod/contacts.php b/mod/contacts.php index 8aa51d00a..9d29d4bd1 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -85,7 +85,7 @@ function contacts_post(&$a) { if($priority > 5 || $priority < 0) $priority = 0; - $info = escape_tags(trim($_POST['info'])); + $info = fix_mce_lf(escape_tags(trim($_POST['info']))); $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s', `hidden` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -232,8 +232,14 @@ function contacts_content(&$a) { $contact_id = $a->data['contact']['id']; $contact = $a->data['contact']; - $tpl = get_markup_template('contact_head.tpl'); - $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true))); + $editselect = 'exact'; + if(intval(get_pconfig(local_user(),'system','plaintext'))) + $editselect = 'none'; + + $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( + '$baseurl' => $a->get_baseurl(true), + '$editselect' => $editselect, + )); require_once('include/contact_selectors.php'); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 5c2788983..436727a78 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -428,11 +428,13 @@ function dfrn_poll_content(&$a) { break; // NOTREACHED } + $nickname = $a->argv[1]; + $r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`nickname` = '%s' $sql_extra LIMIT 1", - dbesc($a->argv[1]) + dbesc($nickname) ); if(count($r)) { @@ -482,7 +484,7 @@ function dfrn_poll_content(&$a) { )); } - $profile = $r[0]['nickname']; + $profile = ((count($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); switch($destination_url) { case 'profile': diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 80d27ac30..77a3124f7 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -261,7 +261,7 @@ function dfrn_request_post(&$a) { WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 AND `contact`.`network` != '%s' AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ", - dbesc(NETWORK_MAIL) + dbesc(NETWORK_MAIL2) ); if(count($r)) { foreach($r as $rr) { @@ -286,7 +286,7 @@ function dfrn_request_post(&$a) { WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 AND `contact`.`network` = '%s' AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ", - dbesc(NETWORK_MAIL) + dbesc(NETWORK_MAIL2) ); if(count($r)) { foreach($r as $rr) { @@ -301,6 +301,8 @@ function dfrn_request_post(&$a) { } } + $email_follow = (x($_POST,'email_follow') ? intval($_POST['email_follow']) : 0); + $real_name = (x($_POST,'realname') ? notags(trim($_POST['realname'])) : ''); $url = trim($_POST['dfrn_url']); if(! strlen($url)) { @@ -308,17 +310,60 @@ function dfrn_request_post(&$a) { return; } - // Canonicalise email-style profile locator - $hcard = ''; - $url = webfinger_dfrn($url,$hcard); - if(substr($url,0,5) === 'stat:') { - $network = NETWORK_OSTATUS; - $url = substr($url,5); + if($email_follow) { + + if(! strpos($url,'@')) { + notice( t('Invalid email address.') . EOL); + return; + } + + $addr = $url; + $name = ($realname) ? $realname : $addr; + $nick = substr($addr,0,strpos($addr,'@')); + $url = 'http://' . substr($addr,strpos($addr,'@') + 1); + $nurl = normalise_url($host); + $poll = 'email ' . random_string(); + $notify = 'smtp ' . random_string(); + $blocked = 1; + $pending = 1; + $network = NETWORK_MAIL2; + $rel = CONTACT_IS_FOLLOWER; + + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + if(get_config('system','dfrn_only')) + $mail_disabled = 1; + + if(! $mail_disabled) { + $failed = false; + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + intval($uid) + ); + if(! count($r)) { + notice( t('This account has not been configured for email. Request failed.') . EOL); + return; + } + } + + + + + } else { - $network = NETWORK_DFRN; + + // Canonicalise email-style profile locator + + $url = webfinger_dfrn($url,$hcard); + + if(substr($url,0,5) === 'stat:') { + $network = NETWORK_OSTATUS; + $url = substr($url,5); + } + else { + $network = NETWORK_DFRN; + } } logger('dfrn_request: url: ' . $url); diff --git a/mod/directory.php b/mod/directory.php index 7f18bd026..367438845 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -44,7 +44,7 @@ function directory_content(&$a) { $gdirpath = dirname(get_config('system','directory_submit_url')); if(strlen($gdirpath)) { $globaldir = '<ul><li><div id="global-directory-link"><a href="' - . $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>'; + . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>'; } $admin = ''; diff --git a/mod/install.php b/mod/install.php index d1142248a..2eb98ee91 100644 --- a/mod/install.php +++ b/mod/install.php @@ -451,7 +451,7 @@ function load_database_rem($v, $i){ function load_database($db) { $str = file_get_contents('database.sql'); - $str = array_reduce(explode("\n", $str),"load_database_rem",""); +// $str = array_reduce(explode("\n", $str),"load_database_rem",""); $arr = explode(';',$str); $errors = false; foreach($arr as $a) { diff --git a/mod/item.php b/mod/item.php index 82fb0bf72..7f0ca3fc3 100644 --- a/mod/item.php +++ b/mod/item.php @@ -272,8 +272,7 @@ function item_post(&$a) { $plaintext = (local_user() ? intval(get_pconfig(local_user(),'system','plaintext')) : 0); if((! $parent) && (! $api_source) && (! $plaintext)) { - $body = str_replace("\r\n","\n",$body); - $body = str_replace("\n\n","\n",$body); + $body = fix_mce_lf($body); } @@ -447,7 +446,7 @@ function item_post(&$a) { if(count($tags)) { foreach($tags as $tag) { - handle_tag($a, $body, $inform, $str_tags, $profile_uid, $tag); + handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag); } } diff --git a/mod/message.php b/mod/message.php index 1369fde2e..260f4bb14 100644 --- a/mod/message.php +++ b/mod/message.php @@ -48,8 +48,7 @@ function message_post(&$a) { $plaintext = intval(get_pconfig(local_user(),'system','plaintext')); if(! $plaintext) { - $body = str_replace("\r\n","\n",$body); - $body = str_replace("\n\n","\n",$body); + $body = fix_mce_lf($body); } $ret = send_message($recipient, $body, $subject, $replyto); diff --git a/mod/newmember.php b/mod/newmember.php index 683463ecb..a423d11b8 100644 --- a/mod/newmember.php +++ b/mod/newmember.php @@ -13,7 +13,7 @@ function newmember_content(&$a) { $o .= '<ul>'; - $o .= '<li>' . '<a target="newmember" href="/help/guide">' . t('On your <em>Quick Start</em> page - find a brief introduction to your profile and network tabs, connect to Facebook, make some new connections, and find some groups to join.') . '</a></li>' . EOL; + $o .= '<li>' . '<a target="newmember" href="help/guide">' . t('On your <em>Quick Start</em> page - find a brief introduction to your profile and network tabs, connect to Facebook, make some new connections, and find some groups to join.') . '</a></li>' . EOL; $o .= '<li>' . '<a target="newmember" href="settings">' . t('On your <em>Settings</em> page - change your initial password. Also make a note of your Identity Address. This looks just like an email address - and will be useful in making friends on the free social web.') . '</a></li>' . EOL; @@ -48,4 +48,4 @@ function newmember_content(&$a) { $o .= '</div>'; return $o; -}
\ No newline at end of file +} diff --git a/mod/nogroup.php b/mod/nogroup.php new file mode 100644 index 000000000..bd1ec82ed --- /dev/null +++ b/mod/nogroup.php @@ -0,0 +1,65 @@ +<?php + +require_once('include/Contact.php'); +require_once('include/socgraph.php'); +require_once('include/contact_selectors.php'); + +function nogroup_init(&$a) { + + if(! local_user()) + return; + + require_once('include/group.php'); + require_once('include/contact_widgets.php'); + + if(! x($a->page,'aside')) + $a->page['aside'] = ''; + + $a->page['aside'] .= group_side('contacts','group',false,0,$contact_id); +} + + +function nogroup_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return ''; + } + + require_once('include/Contact.php'); + $r = contacts_not_grouped(local_user()); + if(count($r)) { + $a->set_pager_total($r[0]['total']); + } + $r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']); + if(count($r)) { + foreach($r as $rr) { + + + $contacts[] = array( + 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']), + 'edit_hover' => t('Edit contact'), + 'photo_menu' => contact_photo_menu($rr), + 'id' => $rr['id'], + 'alt_text' => $alt_text, + 'dir_icon' => $dir_icon, + 'thumb' => $rr['thumb'], + 'name' => $rr['name'], + 'username' => $rr['name'], + 'sparkle' => $sparkle, + 'itemurl' => $rr['url'], + 'url' => $url, + 'network' => network_to_name($rr['network']), + ); + } + } + $tpl = get_markup_template("nogroup-template.tpl"); + $o .= replace_macros($tpl,array( + '$header' => t('Contacts who are not members of a group'), + '$contacts' => $contacts, + '$paginate' => paginate($a), + )); + + return $o; + +} diff --git a/mod/notifications.php b/mod/notifications.php index 690a99562..b28b1478d 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -151,7 +151,7 @@ function notifications_content(&$a) { '$fullname' => $rr['fname'], '$url' => zrl($rr['furl']), '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), - '$activity' => array('activity', t('Post a new friend activity'), 1, t('if applicable')), + '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), '$knowyou' => $knowyou, '$approve' => t('Approve'), @@ -198,7 +198,7 @@ function notifications_content(&$a) { '$photo' => ((x($rr,'photo')) ? $rr['photo'] : "images/person-175.jpg"), '$fullname' => $rr['name'], '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), - '$activity' => array('activity', t('Post a new friend activity'), 1, t('if applicable')), + '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), '$url' => zrl($rr['url']), '$knowyou' => $knowyou, '$approve' => t('Approve'), diff --git a/mod/profile.php b/mod/profile.php index 68d73fba3..51f944412 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -14,7 +14,7 @@ function profile_init(&$a) { else { $r = q("select nickname from user where blocked = 0 and account_expired = 0 and verified = 1 order by rand() limit 1"); if(count($r)) { - $which = $r[0]['nickname']; + goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']); } else { notice( t('Requested profile is not available.') . EOL ); diff --git a/mod/profiles.php b/mod/profiles.php index 7b3b6ccc1..7a33a03e4 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -51,6 +51,7 @@ function profiles_post(&$a) { if($orig[0]['name'] != $name) $namechanged = true; + $pdesc = notags(trim($_POST['pdesc'])); $gender = notags(trim($_POST['gender'])); $address = notags(trim($_POST['address'])); @@ -61,15 +62,16 @@ function profiles_post(&$a) { $pub_keywords = notags(trim($_POST['pub_keywords'])); $prv_keywords = notags(trim($_POST['prv_keywords'])); $marital = notags(trim($_POST['marital'])); - if($marital != $orig[0]['marital']) - $maritalchanged = true; $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); // linkify the relationship target if applicable + $withchanged = false; + if(strlen($with)) { if($with != strip_tags($orig[0]['with'])) { + $withchanged = true; $prf = ''; $lookup = $with; if(strpos($lookup,'@') === 0) @@ -121,18 +123,40 @@ function profiles_post(&$a) { $politic = notags(trim($_POST['politic'])); $religion = notags(trim($_POST['religion'])); - $about = escape_tags(trim($_POST['about'])); - $interest = escape_tags(trim($_POST['interest'])); - $contact = escape_tags(trim($_POST['contact'])); - $music = escape_tags(trim($_POST['music'])); - $book = escape_tags(trim($_POST['book'])); - $tv = escape_tags(trim($_POST['tv'])); - $film = escape_tags(trim($_POST['film'])); - $romance = escape_tags(trim($_POST['romance'])); - $work = escape_tags(trim($_POST['work'])); - $education = escape_tags(trim($_POST['education'])); + $about = fix_mce_lf(escape_tags(trim($_POST['about']))); + $interest = fix_mce_lf(escape_tags(trim($_POST['interest']))); + $contact = fix_mce_lf(escape_tags(trim($_POST['contact']))); + $music = fix_mce_lf(escape_tags(trim($_POST['music']))); + $book = fix_mce_lf(escape_tags(trim($_POST['book']))); + $tv = fix_mce_lf(escape_tags(trim($_POST['tv']))); + $film = fix_mce_lf(escape_tags(trim($_POST['film']))); + $romance = fix_mce_lf(escape_tags(trim($_POST['romance']))); + $work = fix_mce_lf(escape_tags(trim($_POST['work']))); + $education = fix_mce_lf(escape_tags(trim($_POST['education']))); + $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); + + + $changes = array(); + if($is_default) { + if($marital != $orig[0]['marital']) $changes[] = '♥ ' . t('Marital Status'); + if($withchanged) $changes[] = '♥ ' . t('Romantic Partner'); + if($work != $orig[0]['work']) $changes[] = t('Work/Employment'); + if($religion != $orig[0]['religion']) $changes[] = t('Religion'); + if($politic != $orig[0]['politic']) $changes[] = t('Political Views'); + if($gender != $orig[0]['gender']) $changes[] = t('Gender'); + if($sexual != $orig[0]['sexual']) $changes[] = t('Sexual Preference'); + if($homepage != $orig[0]['homepage']) $changes[] = t('Homepage'); + if($interest != $orig[0]['interest']) $changes[] = t('Interests'); + if($address != $orig[0]['address'] || $locality != $orig[0]['locality'] || $region != $orig[0]['region'] + || $country_name != $orig[0]['country_name']) + $changes[] = t('Location'); + + profile_activity($changes); + + } + $r = q("UPDATE `profile` SET `profile-name` = '%s', `name` = '%s', @@ -194,7 +218,7 @@ function profiles_post(&$a) { dbesc($education), intval($hide_friends), intval($a->argv[1]), - intval($_SESSION['uid']) + intval(local_user()) ); if($r) @@ -221,6 +245,79 @@ function profiles_post(&$a) { } +function profile_activity($changed) { + $a = get_app(); + + if(! local_user() || ! is_array($changed) || ! count($changed)) + return; + + if($a->user['hidewall'] || get_config('system','block_public')) + return; + + if(! get_pconfig(local_user(),'system','post_profilechange')) + return; + + require_once('include/items.php'); + + $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", + intval(local_user()) + ); + + if(! count($self)) + return; + + $arr = array(); + $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); + $arr['uid'] = local_user(); + $arr['contact-id'] = $self[0]['id']; + $arr['wall'] = 1; + $arr['type'] = 'wall'; + $arr['gravity'] = 0; + $arr['origin'] = 1; + $arr['author-name'] = $arr['owner-name'] = $self[0]['name']; + $arr['author-link'] = $arr['owner-link'] = $self[0]['url']; + $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb']; + $arr['verb'] = ACTIVITY_UPDATE; + $arr['object-type'] = ACTIVITY_OBJ_PROFILE; + + $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]'; + + + $changes = ''; + $t = count($changed); + $z = 0; + foreach($changed as $ch) { + if(strlen($changes)) { + if ($z == ($t - 1)) + $changes .= ' and '; + else + $changes .= ', '; + } + $z ++; + $changes .= $ch; + } + + $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; + + $arr['body'] = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes); + + $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>' + . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>'; + $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n"); + $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n"); + $arr['object'] .= '</link></object>' . "\n"; + $arr['last-child'] = 1; + + $arr['allow_cid'] = $a->user['allow_cid']; + $arr['allow_gid'] = $a->user['allow_gid']; + $arr['deny_cid'] = $a->user['deny_cid']; + $arr['deny_gid'] = $a->user['deny_gid']; + + $i = item_store($arr); + if($i) + proc_run('php',"include/notifier.php","activity","$i"); + +} function profiles_content(&$a) { @@ -361,7 +458,16 @@ function profiles_content(&$a) { require_once('include/profile_selectors.php'); - $tpl = get_markup_template('profed_head.tpl'); + + $editselect = 'textareas'; + if(intval(get_pconfig(local_user(),'system','plaintext'))) + $editselect = 'none'; + + $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( + '$baseurl' => $a->get_baseurl(true), + '$editselect' => $editselect, + )); + $opt_tpl = get_markup_template("profile-hide-friends.tpl"); $hide_friends = replace_macros($opt_tpl,array( @@ -372,10 +478,12 @@ function profiles_content(&$a) { '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "") )); - - $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true))); $a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"js/country.js\" ></script>"; + + + + $f = get_config('system','birthday_input_format'); if(! $f) $f = 'ymd'; diff --git a/mod/randprof.php b/mod/randprof.php new file mode 100644 index 000000000..6713a81d9 --- /dev/null +++ b/mod/randprof.php @@ -0,0 +1,10 @@ +<?php + + +function randprof_init(&$a) { + require_once('include/Contact.php'); + $x = random_profile(); + if($x) + goaway(zrl($x)); + goaway($a->get_baseurl() . '/profile'); +} diff --git a/mod/register.php b/mod/register.php index 630c0a675..b60707d45 100644 --- a/mod/register.php +++ b/mod/register.php @@ -314,17 +314,13 @@ function register_post(&$a) { } - $use_gravatar = ((get_config('system','no_gravatar')) ? false : true); - - // if we have an openid photo use it. - // otherwise unless it is disabled, use gravatar - - if($use_gravatar || strlen($photo)) { + // if we have no OpenID photo try to look up an avatar + if(! strlen($photo)) + $photo = avatar_img($email); + // unless there is no avatar-plugin loaded + if(strlen($photo)) { require_once('include/Photo.php'); - - if(($use_gravatar) && (! strlen($photo))) - $photo = gravatar_img($email); $photo_failure = false; $filename = basename($photo); @@ -333,7 +329,7 @@ function register_post(&$a) { if($img->is_valid()) { $img->scaleImageSquare(175); - + $hash = photo_new_resource(); $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 ); diff --git a/mod/settings.php b/mod/settings.php index 6879da285..721468437 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -15,10 +15,6 @@ function get_theme_config_file($theme){ } function settings_init(&$a) { - if(local_user()) { - profile_load($a,$a->user['nickname']); - } - // These lines provide the javascript needed by the acl selector $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "';" ; @@ -47,6 +43,47 @@ function settings_init(&$a) { EOT; + + $tabs = array( + array( + 'label' => t('Account settings'), + 'url' => $a->get_baseurl(true).'/settings', + 'selected' => (($a->argc == 1)?'active':''), + ), + array( + 'label' => t('Display settings'), + 'url' => $a->get_baseurl(true).'/settings/display', + 'selected' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''), + ), + + array( + 'label' => t('Connector settings'), + 'url' => $a->get_baseurl(true).'/settings/connectors', + 'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''), + ), + array( + 'label' => t('Plugin settings'), + 'url' => $a->get_baseurl(true).'/settings/addon', + 'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''), + ), + array( + 'label' => t('Connected apps'), + 'url' => $a->get_baseurl(true) . '/settings/oauth', + 'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''), + ), + array( + 'label' => t('Export personal data'), + 'url' => $a->get_baseurl(true) . '/uexport', + 'selected' => '' + ) + ); + + $tabtpl = get_markup_template("generic_links_widget.tpl"); + $a->page['aside'] = replace_macros($tabtpl, array( + '$title' => t('Settings'), + '$items' => $tabs, + )); + } @@ -309,6 +346,8 @@ function settings_post(&$a) { $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0); $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0); + $post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0); + $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0); $notify = 0; @@ -391,6 +430,8 @@ function settings_post(&$a) { set_pconfig(local_user(),'expire','photos', $expire_photos); set_pconfig(local_user(),'system','suggestme', $suggestme); + set_pconfig(local_user(),'system','post_newfriend', $post_newfriend); + set_pconfig(local_user(),'system','post_profilechange', $post_profilechange); $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d WHERE `uid` = %d LIMIT 1", @@ -479,44 +520,7 @@ function settings_content(&$a) { return; } - $tabs = array( - array( - 'label' => t('Account settings'), - 'url' => $a->get_baseurl(true).'/settings', - 'sel' => (($a->argc == 1)?'active':''), - ), - array( - 'label' => t('Display settings'), - 'url' => $a->get_baseurl(true).'/settings/display', - 'sel' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''), - ), - - array( - 'label' => t('Connector settings'), - 'url' => $a->get_baseurl(true).'/settings/connectors', - 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''), - ), - array( - 'label' => t('Plugin settings'), - 'url' => $a->get_baseurl(true).'/settings/addon', - 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''), - ), - array( - 'label' => t('Connections'), - 'url' => $a->get_baseurl(true) . '/settings/oauth', - 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''), - ), - array( - 'label' => t('Export personal data'), - 'url' => $a->get_baseurl(true) . '/uexport', - 'sel' => '' - ) - ); - - $tabtpl = get_markup_template("common_tabs.tpl"); - $tabs = replace_macros($tabtpl, array( - '$tabs' => $tabs, - )); + if(($a->argc > 1) && ($a->argv[1] === 'oauth')) { @@ -524,7 +528,6 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_oauth"), - '$tabs' => $tabs, '$title' => t('Add application'), '$submit' => t('Submit'), '$cancel' => t('Cancel'), @@ -551,7 +554,6 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_oauth"), - '$tabs' => $tabs, '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), @@ -594,7 +596,6 @@ function settings_content(&$a) { '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), - '$tabs' => $tabs, '$apps' => $r, )); return $o; @@ -614,7 +615,6 @@ function settings_content(&$a) { $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_addon"), '$title' => t('Plugin Settings'), - '$tabs' => $tabs, '$settings_addons' => $settings_addons )); return $o; @@ -658,7 +658,6 @@ function settings_content(&$a) { '$form_security_token' => get_form_security_token("settings_connectors"), '$title' => t('Connector Settings'), - '$tabs' => $tabs, '$diasp_enabled' => $diasp_enabled, '$ostat_enabled' => $ostat_enabled, @@ -735,7 +734,6 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_display.tpl"); $o = replace_macros($tpl, array( - '$tabs' => $tabs, '$ptitle' => t('Display Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), @@ -796,6 +794,11 @@ function settings_content(&$a) { $suggestme = get_pconfig(local_user(), 'system','suggestme'); $suggestme = (($suggestme===false)? '0': $suggestme); // default if not set: 0 + $post_newfriend = get_pconfig(local_user(), 'system','post_newfriend'); + $post_newfriend = (($post_newfriend===false)? '0': $post_newfriend); // default if not set: 0 + + $post_profilechange = get_pconfig(local_user(), 'system','post_profilechange'); + $post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0 if(! strlen($a->user['timezone'])) @@ -884,6 +887,8 @@ function settings_content(&$a) { )); + + $invisible = (((! $profile['publish']) && (! $profile['net-publish'])) ? true : false); @@ -920,7 +925,6 @@ function settings_content(&$a) { ); $o .= replace_macros($stpl,array( - '$tabs' => $tabs, '$ptitle' => t('Account Settings'), '$submit' => t('Submit'), @@ -965,6 +969,9 @@ function settings_content(&$a) { '$h_not' => t('Notification Settings'), + '$activity_options' => t('By default post a status message when:'), + '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, ''), + '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, ''), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''), '$notify2' => array('notify2', t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''), |