From ddff2e0da01cea3ca3d3f4da778e0e3602b450cc Mon Sep 17 00:00:00 2001 From: Silke Meyer Date: Wed, 14 Jan 2015 13:50:01 +0100 Subject: [PATCH 01/16] Removed part about sponsored bugs. --- doc/Bugs-and-Issues.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/doc/Bugs-and-Issues.md b/doc/Bugs-and-Issues.md index 251f91e936..c9f845c001 100644 --- a/doc/Bugs-and-Issues.md +++ b/doc/Bugs-and-Issues.md @@ -11,21 +11,3 @@ If you're a technical user, or your site doesn't have a support page, you'll nee Try to provide as much information as you can about the bug, including the **full** text of any error messages or notices, and any steps required to replicate the problem in as much detail as possible. It's generally better to provide too much information than not enough. See this article to learn more about submitting **good** bug reports. - - -**Bug Sponsorship** - -If you find a bug, and it is caused by a problem in main branch (ie, is not specific to our site), you may sponsor it. - -The bug/issue database allows you to sponsor issues. This provides an incentive for developers to work on your issue. This isn't necessary - we don't like bugs and will try to fix them. This has more importance for future development projects and feature requests. - -Bug sponsorship works on the honour system. If you agree to pay $10 to fix a bug, when the fix has been checked in and verified you should send a paypal payment to the developer assigned to the bug. Don't ever think you can get away with not paying a developer for work performed. Some of these guys could hack into your credit card account if you make them mad. - -At the present time, one has to be approved as a "developer" to be able to assign themselves to a sponsored bug. This requires the developer to have some history fixing Friendica bugs. This is for everybody's assurance that the bug fix will work well with Friendica. If you wish to become approved as a developer, work on and check in some non-sponsored issues or your own projects and we will move you up the ladder. - -If you truly feel you have the solution to a sponsored bug but aren't an approved developer, you risk a sponsored developer assigning the bug to themselves before you check it in, but if they haven't done so - include a short note with your pull request. Assuming that it meets our code standards, we'll see that you get credit. - -If you sponsor a project at greater than a $50 level, you may be requested by the developer for payment up front before work has begun (typically half). Again this is on the honour system - and is mostly to avoid payment issues and disagreements later. You should also expect to see some progress updates or demonstrations if the work takes more than a week or two. If the work is not completed within a reasonable time (as decided by those involved), you are entitled to get your money back. - -Friendica is not involved in these transactions. It is purely a personal agreement between sponsors and developers. If there are any issues, the parties will need to work it out between themselves. We're just providing some guidelines to help avoid potential problems. - From ce259c1cc7e5852cce616768aa8c9baa1de426ed Mon Sep 17 00:00:00 2001 From: Silke Meyer Date: Wed, 14 Jan 2015 14:05:21 +0100 Subject: [PATCH 02/16] Updated "Tips for new members" section --- doc/Account-Basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Account-Basics.md b/doc/Account-Basics.md index 2c3c05e8bf..91e19b6493 100644 --- a/doc/Account-Basics.md +++ b/doc/Account-Basics.md @@ -59,7 +59,7 @@ After your first login, please visit the 'Settings' page from the top menu bar a **Getting Started** -A ['Tips for New Members'](newmember) link will show up on your home page for two weeks to provide some important Getting Started information. +A ['Tips for New Members'](newmember) link will show up on your network and home pages for two weeks to provide some important Getting Started information. **Retrieving Personal Data** From 86623bcdae7a530a53d73a1a897091036509db49 Mon Sep 17 00:00:00 2001 From: Silke Meyer Date: Wed, 14 Jan 2015 17:57:25 +0100 Subject: [PATCH 03/16] Script now installs missing add-apt-repository tool. --- util/vagrant_provision.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/vagrant_provision.sh b/util/vagrant_provision.sh index ae354bb42c..9988f36256 100644 --- a/util/vagrant_provision.sh +++ b/util/vagrant_provision.sh @@ -28,6 +28,8 @@ sudo openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xi #Install apache2 echo ">>> Installing Apache2 webserver" +# The package python-software-properties provides add-apt-repository on Ubuntu Precise Server +sudo apt-get install python-software-properties sudo add-apt-repository -y ppa:ondrej/apache2 sudo apt-key update sudo apt-get update From f6b8553d3e75f3ff04b25badaafdf5f8372bb44f Mon Sep 17 00:00:00 2001 From: Silke Meyer Date: Wed, 14 Jan 2015 18:32:10 +0100 Subject: [PATCH 04/16] Added more explanation to developing with Vagrant --- doc/Github.md | 10 +--------- doc/Home.md | 1 + doc/Vagrant.md | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 doc/Vagrant.md diff --git a/doc/Github.md b/doc/Github.md index a59f574cfb..efee32d5ba 100644 --- a/doc/Github.md +++ b/doc/Github.md @@ -24,13 +24,5 @@ Please pull in any changes from the project repository and merge them with your Also - **test your changes**. Don't assume that a simple fix won't break something else. If possible get an experienced Friendica developer to review the code. -**Vagrant** - -[Vagrant](https://www.vagrantup.com/) is a virtualization solution for developers. No need to setup up a webserver etc. before actually starting. Vagrant creates a virtual machine (an Ubuntu 12.04) for you that you can just run inside VirtualBox and start to work directly on Friendica. What you need to do: - -1. Install VirtualBox and vagrant. -2. git clone Friendica (note the Vagrantfile inside). -3. Run vagrant up, have some patience. -4. Run vagrant ssh to log into the virtual machine. -5. It depends on the network setup of your host and virtual box guest how you reach the friendica web interface of the VM. +Check out how to work with [our Vagrant](help/Vagrant) to save a lot of setup time! diff --git a/doc/Home.md b/doc/Home.md index 62fd216659..031bec8058 100644 --- a/doc/Home.md +++ b/doc/Home.md @@ -37,6 +37,7 @@ Friendica Documentation and Resources * [Where to get started?](help/Developers-Intro) * [Help on Github](help/Github) +* [Help on Vagrant](help/Vagrant) * [How to translate Friendica](help/translations) * [Bugs and Issues](help/Bugs-and-Issues) diff --git a/doc/Vagrant.md b/doc/Vagrant.md new file mode 100644 index 0000000000..dec8112edc --- /dev/null +++ b/doc/Vagrant.md @@ -0,0 +1,15 @@ +Vagrant for Friendica Developers +=================== + +* [Home](help) + +[Vagrant](https://www.vagrantup.com/) is a virtualization solution for developers. No need to setup up a webserver, database etc. before actually starting. Vagrant creates a virtual machine (an Ubuntu 12.04) for you that you can just run inside VirtualBox and start to work directly on Friendica. What you need to do: + +1. Install VirtualBox and vagrant. +2. Git clone your Friendica repository. Inside, you'll find a "Vagrantfile" and some scripts in the utils folder. +3. Run "vagrant up" from inside the friendica clone. Be patient: When it runs for the first time, it downloads an Ubuntu Server image. +4. Run "vagrant ssh" to log into the virtual machine to log in to the VM. +5. Open 192.168.22.10 in a browser to finish the Friendica installation. The mysql database is called "friendica", the mysql user and password both are "root". +6. Work on Friendica's code in your git clone on your machine (not in the VM). +7. Check the changes in your browser in the VM. Debug via the "vagrant ssh" login. +8. Commit and push your changes directly back to Github. From b45a4b398be2324a39ee23de07864b797b60a64b Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Thu, 15 Jan 2015 18:15:06 +0100 Subject: [PATCH 05/16] api: call hook 'authenticate' from api_login() --- include/api.php | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/include/api.php b/include/api.php index 90d49b49f7..1cfada7f64 100644 --- a/include/api.php +++ b/include/api.php @@ -96,24 +96,49 @@ } $user = $_SERVER['PHP_AUTH_USER']; - $encrypted = hash('whirlpool',trim($_SERVER['PHP_AUTH_PW'])); + $password = $_SERVER['PHP_AUTH_PW']; + $encrypted = hash('whirlpool',trim($password)); /** * next code from mod/auth.php. needs better solution */ + $record = null; - // process normal login request - - $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) - AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1", - dbesc(trim($user)), - dbesc(trim($user)), - dbesc($encrypted) + $addon_auth = array( + 'username' => trim($user), + 'password' => trim($password), + 'authenticated' => 0, + 'user_record' => null ); - if(count($r)){ - $record = $r[0]; - } else { + + /** + * + * A plugin indicates successful login by setting 'authenticated' to non-zero value and returning a user record + * Plugins should never set 'authenticated' except to indicate success - as hooks may be chained + * and later plugins should not interfere with an earlier one that succeeded. + * + */ + + call_hooks('authenticate', $addon_auth); + + if(($addon_auth['authenticated']) && (count($addon_auth['user_record']))) { + $record = $addon_auth['user_record']; + } + else { + // process normal login request + + $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) + AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1", + dbesc(trim($user)), + dbesc(trim($user)), + dbesc($encrypted) + ); + if(count($r)) + $record = $r[0]; + } + + if((! $record) || (! count($record))) { logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); header('HTTP/1.0 401 Unauthorized'); From 9cb3a4188e38c2b3991261b1f7045d44dd67f12e Mon Sep 17 00:00:00 2001 From: Johannes Schwab Date: Fri, 16 Jan 2015 02:25:17 +0100 Subject: [PATCH 06/16] fix network tab urls --- mod/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/network.php b/mod/network.php index 1cb72aebab..355f6edcdb 100644 --- a/mod/network.php +++ b/mod/network.php @@ -369,7 +369,7 @@ function network_content(&$a, $update = 0) { if(feature_enabled(local_user(),'personal_tab')) { $tabs[] = array( 'label' => t('Personal'), - 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1', + 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1', 'sel' => $conv_active, 'title' => t('Posts that mention or involve you'), ); @@ -387,7 +387,7 @@ function network_content(&$a, $update = 0) { if(feature_enabled(local_user(),'link_tab')) { $tabs[] = array( 'label' => t('Shared Links'), - 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1', + 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', 'sel'=>$bookmarked_active, 'title'=> t('Interesting Links'), ); @@ -396,7 +396,7 @@ function network_content(&$a, $update = 0) { if(feature_enabled(local_user(),'star_posts')) { $tabs[] = array( 'label' => t('Starred'), - 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1', + 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1', 'sel'=>$starred_active, 'title' => t('Favourite Posts'), ); From 80abd1bd41d5f13b60e053a1ac9d0359cb8d2f5d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 16 Jan 2015 11:20:48 +0100 Subject: [PATCH 07/16] added info how to halt the VM to the vagrant docs. --- doc/Vagrant.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/Vagrant.md b/doc/Vagrant.md index dec8112edc..fd6b818e78 100644 --- a/doc/Vagrant.md +++ b/doc/Vagrant.md @@ -13,3 +13,11 @@ Vagrant for Friendica Developers 6. Work on Friendica's code in your git clone on your machine (not in the VM). 7. Check the changes in your browser in the VM. Debug via the "vagrant ssh" login. 8. Commit and push your changes directly back to Github. + +If you want to stop vagrant after finishing your work, run the following command + + $> vagrant halt + +in the development directory. + +For further documentation of vagrant, please see [the vagrant*docs*](https://docs.vagrantup.com/v2/). From 8b20af6ef536e34c3bc9c412cbffa4cf9c0cea53 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 16 Jan 2015 19:31:23 +0100 Subject: [PATCH 08/16] template for input fields now supports required, autofocus and types email, url --- view/templates/field_input.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/templates/field_input.tpl b/view/templates/field_input.tpl index 41a636fca4..457ae946e3 100644 --- a/view/templates/field_input.tpl +++ b/view/templates/field_input.tpl @@ -1,6 +1,6 @@
- + {{$field.3}}
From 3483cd35f8b6cb62f3571a3024929a4acd5dac37 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 16 Jan 2015 19:32:31 +0100 Subject: [PATCH 09/16] use HTML5 attributes in the installer wizard --- mod/install.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/install.php b/mod/install.php index 484846ccd6..c6fe708362 100755 --- a/mod/install.php +++ b/mod/install.php @@ -231,11 +231,11 @@ function install_content(&$a) { '$status' => $wizard_status, - '$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, ''), - '$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, ''), - '$dbpass' => array('dbpass', t('Database Login Password'), $dbpass, ''), - '$dbdata' => array('dbdata', t('Database Name'), $dbdata, ''), - '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), + '$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, '', 'required'), + '$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, '', 'required', 'autofocus'), + '$dbpass' => array('dbpass', t('Database Login Password'), $dbpass, '', 'required'), + '$dbdata' => array('dbdata', t('Database Name'), $dbdata, '', 'required'), + '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'), @@ -274,7 +274,7 @@ function install_content(&$a) { '$dbdata' => $dbdata, '$phpath' => $phpath, - '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')), + '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'), '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''), From d58bac113840b9bc5e2186d2164c5530ef57a8a0 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 16 Jan 2015 19:36:09 +0100 Subject: [PATCH 10/16] template for password now support required and autofocus --- view/templates/field_input.tpl | 2 +- view/templates/field_password.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/view/templates/field_input.tpl b/view/templates/field_input.tpl index 457ae946e3..ae8fe844a3 100644 --- a/view/templates/field_input.tpl +++ b/view/templates/field_input.tpl @@ -1,6 +1,6 @@
- + {{$field.3}}
diff --git a/view/templates/field_password.tpl b/view/templates/field_password.tpl index 5dd2c5d3f8..2e9e91529a 100644 --- a/view/templates/field_password.tpl +++ b/view/templates/field_password.tpl @@ -1,6 +1,6 @@
- + {{$field.3}}
From b1b1fe495be6b8a4c2dfe5f51ae148884262a6e8 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 18 Jan 2015 16:15:37 +0100 Subject: [PATCH 11/16] some documentation for the templating engine and basic templates for forms --- doc/Home.md | 1 + doc/snarty3-templates.md | 173 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 doc/snarty3-templates.md diff --git a/doc/Home.md b/doc/Home.md index 031bec8058..592ee977b2 100644 --- a/doc/Home.md +++ b/doc/Home.md @@ -40,6 +40,7 @@ Friendica Documentation and Resources * [Help on Vagrant](help/Vagrant) * [How to translate Friendica](help/translations) * [Bugs and Issues](help/Bugs-and-Issues) +* [Smarty 3 Templates](help/smarty3-templates) **External Resources** diff --git a/doc/snarty3-templates.md b/doc/snarty3-templates.md new file mode 100644 index 0000000000..d23806a00b --- /dev/null +++ b/doc/snarty3-templates.md @@ -0,0 +1,173 @@ +Friendica Templating Documentation +================================== + +* [Home](help) + +Friendica uses [Smarty 3](http://www.smarty.net/) as PHP templating engine. The main templates are found in + + /view/templates + +theme authors may overwrite the default templates by putting a files with the same name into the + + /view/themes/$themename/templates + +directory. + +Templates that are only used by addons shall be placed in the + + /addon/$addonname/templates + +directory. + +To render a template use the function *get_markup_template* to load the template and *replace_macros* to replace the markros/variables in the just loaded template file. + + $tpl = get_markup_template('install_settings.tpl'); + $o .= replace_macros($tpl, array( ... )); + +the array consists of an association of an identifier and the value for that identifier, i.e. + + '$title' => $install_title, + +where the value may as well be an array by its own. + +Form Templates +-------------- + +To guarantee a consistent look and feel for input forms, i.e. in the settings sections, there are templates for the basic form fields. They are initialized with an array of data, depending on the tyle of the field. + +All of these take an array for holding the values, i.e. for an one line text input field, which is required and should be used to type email addesses use something along + + '$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', '', 'email'), + +To evaluate the input value, you can then use the $_POST array, more precisely the $_POST['adminemail'] variable. + +Listed below are the template file names, the general purpose of the template and their field parameters. + +### field_checkbox.tpl + +A checkbox. If the checkbox is checked its value is **1**. Field parameter: + +0. Name of the checkbox, +1. Label for the checkbox, +2. State checked? if true then the checkbox will be marked as checked, +3. Help text for the checkbox. + +### field_combobox.tpl + +A combobox, combining a pull down selection and a textual input field. Field parameter: + +0. Name of the combobox, +1. Label for the combobox, +2. Current value of the variable, +3. Help text for the combobox, +4. Array holding the possible values for the textual input, +5. Array holding the possible values for the pull down selection. + +### field_custom.tpl + +A customizeable template to include a custom element in the form with the usual surroundings, Field parameter: + +0. Name of the field, +1. Label for the field, +2. the field, +3. Help text for the field. + +### field_input.tpl + +A single line input field for textual input. Field parameter: + +0. Name of the field, +1. Label for the input box, +2. Current value of the variable, +3. Help text for the input box, +4. if set to "required" modern browser will check that this input box is filled when submitting the form, +5. if set to "autofocus" modern browser will put the cursur into this box once the page is loaded, +6. if set to "email" or "url" modern browser will check that the filled in value corresponds to an email address or URL. + +### field_intcheckbox.tpl + +A checkbox (see above) but you can define the value of it. Field parameter: + +0. Name of the checkbox, +1. Label for the checkbox, +2. State checked? if true then the checkbox will be marked as checked, +3. Value of the checkbox, +4. Help text for the checkbox. + +### field_openid.tpl + +An input box (see above) but prepared for special CSS styling for openID input. Field parameter: + +0. Name of the field, +1. Label for the input box, +2. Current value of the variable, +3. Help text for the input field. + +### field_password.tpl + +A single line input field (see above) for texttual input. The characters typed in will not be shown by the browser. Field parameter: + +0. Name of the field, +1. Label for the field, +2. Value for the field, e.g. the old password, +3. Help text for the input field, +4. if set to "required" modern browser will check that this field is filled out, +5. if set to "autofocus" modern browser will put the cursor automatically into this input field. + +### field_radio.tpl + +A radio button. Field parameter: + +0. Name of the radio button, +1. Label for the radio button, +2. Current value of the variable, +3. Help text for the button, +4. if set, the radio button will be checked. + +### field_richtext.tpl + +A multi-line input field for *rich* textual content. Field parameter: + +0. Name of the input field, +1. Label for the input box, +2. Current text for the box, +3. Help text for the input box. + +### field_select.tpl + +A drop down selection box. Field parameter: + +0. Name of the field, +1. Label of the selection box, +2. Current selected value, +3. Help text for the selection box, +4. Array holding the possible values of the selection drop down. + +### field_select_raw.tpl + +A drop down selection box (see above) but you have to prepare the values yourself. Field parameter: + +0. Name of the field, +1. Label of the selection box, +2. Current selected value, +3. Help text for the selection box, +4. Possible values of the selection drop down. + +### field_textarea.tpl + +A multi-line input field for (plain) textual content. Field parameter: + +0. Name of the input field, +1. Label for the input box, +2. Current text for the box, +3. Help text for the input box. + +### field_yesno.tpl + +A button that has two states *yes* or *no*. Field parameter: + +0. Name of the input field, +1. Label for the button, +2. Current value, +3. Help text for the button +4. if set to an array of two values, these two will be used, otherwise "off" and "on". From c5200f9327852117a951524c5657b65180b86ad8 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 19 Jan 2015 08:15:20 +0100 Subject: [PATCH 12/16] profile edit homepage field type URL --- view/templates/profile_edit.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/templates/profile_edit.tpl b/view/templates/profile_edit.tpl index 8a00bd6e06..b68ec5081d 100644 --- a/view/templates/profile_edit.tpl +++ b/view/templates/profile_edit.tpl @@ -131,7 +131,7 @@
- +
From b2527039b7b7c4ee3ac88e788c34c2a6ff1b671e Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Tue, 20 Jan 2015 19:19:58 +0100 Subject: [PATCH 13/16] add text-only email option add a checkbok to notification settings. if checked, html body is not added to email. --- include/Emailer.php | 21 +++++++++++++----- mod/settings.php | 22 ++++++++++++------- view/templates/settings.tpl | 4 +++- .../theme/decaf-mobile/templates/settings.tpl | 4 +++- .../theme/frost-mobile/templates/settings.tpl | 4 +++- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/include/Emailer.php b/include/Emailer.php index 9679dc952c..e11954200c 100644 --- a/include/Emailer.php +++ b/include/Emailer.php @@ -20,6 +20,11 @@ class Emailer { call_hooks('emailer_send_prepare', $params); + $email_textonly = False; + if (x($params,"uid")) { + $email_textonly = get_pconfig($params['uid'], "system", "email_textonly"); + } + $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8'); @@ -44,11 +49,16 @@ class Emailer { "--" . $mimeBoundary . "\n" . // plain text section "Content-Type: text/plain; charset=UTF-8\n" . "Content-Transfer-Encoding: base64\n\n" . - $textBody . "\n" . - "--" . $mimeBoundary . "\n" . // text/html section - "Content-Type: text/html; charset=UTF-8\n" . - "Content-Transfer-Encoding: base64\n\n" . - $htmlBody . "\n" . + $textBody . "\n"; + + if (!$email_textonly && !is_null($htmlBody)){ + $multipartMessageBody .= + "--" . $mimeBoundary . "\n" . // text/html section + "Content-Type: text/html; charset=UTF-8\n" . + "Content-Transfer-Encoding: base64\n\n" . + $htmlBody . "\n"; + } + $multipartMessageBody .= "--" . $mimeBoundary . "--\n"; // message ending // send the message @@ -58,6 +68,7 @@ class Emailer { 'body' => $multipartMessageBody, 'headers' => $messageHeader ); + echo "
"; var_dump($hookdata); killme();
 		call_hooks("emailer_send", $hookdata);
 		$res = mail(
 			$hookdata['to'],							// send to address
diff --git a/mod/settings.php b/mod/settings.php
index 8fa0d86a90..799a5faa17 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -395,6 +395,8 @@ function settings_post(&$a) {
 	$post_joingroup   = (($_POST['post_joingroup'] == 1) ? 1: 0);
 	$post_profilechange   = (($_POST['post_profilechange'] == 1) ? 1: 0);
 
+	$email_textonly   = (($_POST['email_textonly'] == 1) ? 1 : 0);
+
 	$notify = 0;
 
 	if(x($_POST,'notify1'))
@@ -495,6 +497,7 @@ function settings_post(&$a) {
 	set_pconfig(local_user(),'system','post_joingroup', $post_joingroup);
 	set_pconfig(local_user(),'system','post_profilechange', $post_profilechange);
 
+	set_pconfig(local_user(),'system','email_textonly', $email_textonly);
 
 	if($page_flags == PAGE_PRVGROUP) {
 		$hidewall = 1;
@@ -505,7 +508,7 @@ function settings_post(&$a) {
 			}
 			else {
 				notice( t('Private forum has no privacy permissions and no default privacy group.') . EOL);
-			} 
+			}
 		}
 	}
 
@@ -656,7 +659,7 @@ function settings_content(&$a) {
 		}
 
 
-		$r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my 
+		$r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
 				FROM clients
 				LEFT JOIN tokens ON clients.client_id=tokens.client_id
 				WHERE clients.uid IN (%d,0)",
@@ -830,7 +833,7 @@ function settings_content(&$a) {
 				$is_experimental = file_exists('view/theme/' . $th . '/experimental');
 				$unsupported = file_exists('view/theme/' . $th . '/unsupported');
 				$is_mobile = file_exists('view/theme/' . $th . '/mobile');
-				if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ 
+				if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
 					$theme_name = (($is_experimental) ?  sprintf("%s - \x28Experimental\x29", $f) : $f);
 					if($is_mobile) {
 						$mobile_themes[$f]=$theme_name;
@@ -1078,8 +1081,8 @@ function settings_content(&$a) {
 		'items' => array('expire_items',  t("Expire posts:"), $expire_items, '', array(t('No'),t('Yes'))),
 		'notes' => array('expire_notes',  t("Expire personal notes:"), $expire_notes, '', array(t('No'),t('Yes'))),
 		'starred' => array('expire_starred',  t("Expire starred posts:"), $expire_starred, '', array(t('No'),t('Yes'))),
-		'photos' => array('expire_photos',  t("Expire photos:"), $expire_photos, '', array(t('No'),t('Yes'))),		
-		'network_only' => array('expire_network_only',  t("Only expire posts by others:"), $expire_network_only, '', array(t('No'),t('Yes'))),		
+		'photos' => array('expire_photos',  t("Expire photos:"), $expire_photos, '', array(t('No'),t('Yes'))),
+		'network_only' => array('expire_network_only',  t("Only expire posts by others:"), $expire_network_only, '', array(t('No'),t('Yes'))),
 	);
 
 	require_once('include/group.php');
@@ -1175,10 +1178,13 @@ function settings_content(&$a) {
 		'$notify3'	=> array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''),
 		'$notify4'	=> array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''),
 		'$notify5'	=> array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''),
-		'$notify6'  => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),		
-		'$notify7'  => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),		
-		'$notify8'  => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''),		
+		'$notify6'  => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),
+		'$notify7'  => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
+		'$notify8'  => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''),
 
+		'$email_textonly' => array('email_textonly', t('Text-only notification emails'),
+									get_pconfig(local_user(),'system','email_textonly'),
+									t('Send only text notification emails body, without the html part')),
 
 		'$h_advn' => t('Advanced Account/Page Type Settings'),
 		'$h_descadvn' => t('Change the behaviour of this account for special situations'),
diff --git a/view/templates/settings.tpl b/view/templates/settings.tpl
index 8f913aac61..a3d4bf72db 100644
--- a/view/templates/settings.tpl
+++ b/view/templates/settings.tpl
@@ -86,7 +86,7 @@