Changes between Version 2 and Version 3 of how-to/servers/support/gnusocial


Ignore:
Timestamp:
Aug 18, 2014, 1:17:58 PM (5 years ago)
Author:
Mats Sjöberg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • how-to/servers/support/gnusocial

    v2 v3  
    11== Adding MF/PL statement check box
    22
    3 In order to add a check box to have users agree to the MF/PL Statement of Unity I edited two files: `actions/register.php` and `plugins/OpenID/actions/finishopenidlogin.php`. To view the exact changes I did check the `mayfirst` git branch on howard, e.g. like this:
     3In order to add a check box to have users agree to the MF/PL Statement of Unity I edited two files: `actions/register.php` and `plugins/OpenID/actions/finishopenidlogin.php`. The exact changes are shown below from the output of `git diff`.
    44
    55{{{
    6 $ ssh root@howard.mayfirst.org
    7 # cd /home/gnusocial/social.mayfirst.org/web
    8 # git branch # this is just to check we are in the correct branch
    9   master
    10 * mayfirst
    11 # git diff master actions/register.php
     6diff --git a/actions/register.php b/actions/register.php
     7index 82fb9fc..8ae5c00 100644
     8--- a/actions/register.php
     9+++ b/actions/register.php
     10@@ -200,6 +200,10 @@ class RegisterAction extends Action
     11                 // TRANS: Form validation error displayed when trying to register without agreeing to the site license.
     12                 $this->showForm(_('You cannot register if you do not '.
     13                                   'agree to the license.'));
     14+            } else if (!$this->boolean('mfpl_statement')) {
     15+                // TRANS: Form validation error displayed when trying to register without agreeing to the statement.
     16+                $this->showForm(_('You cannot register if you do not '.
     17+                                  'agree to the MF/PL Statement of Unity.'));
     18             } else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
     19                 // TRANS: Form validation error displayed when trying to register without a valid e-mail address.
     20                 $this->showForm(_('Not a valid email address.'));
     21@@ -499,6 +503,21 @@ class RegisterAction extends Action
     22             $this->raw($this->licenseCheckbox());
     23             $this->elementEnd('label');
     24             $this->elementEnd('li');
     25+            // MFPL statement
     26+            $attrs = array('type' => 'checkbox',
     27+                           'id' => 'mfpl_statement',
     28+                           'class' => 'checkbox',
     29+                           'name' => 'mfpl_statement',
     30+                           'value' => 'true');
     31+            if ($this->boolean('mfpl_statement')) {
     32+                $attrs['checked'] = 'checked';
     33+            }
     34+            $this->elementStart('li');
     35+            $this->element('input', $attrs);
     36+            $this->elementStart('label', array('class' => 'checkbox', 'for' => 'mfpl_statement'));
     37+            $this->raw($this->statementCheckbox());
     38+            $this->elementEnd('label');
     39+            $this->elementEnd('li');
     40         }
     41         $this->elementEnd('ul');
     42         // TRANS: Button text to register a user on account registration page.
     43@@ -541,7 +560,7 @@ class RegisterAction extends Action
     44             $message = _('My text and files are available under %s ' .
     45                          'except this private data: password, ' .
     46                          'email address, IM address, and phone number.');
     47-            $link = '<a href="' .
     48+            $link = '<a target="_blank" href="' .
     49                     htmlspecialchars(common_config('license', 'url')) .
     50                     '">' .
     51                     htmlspecialchars(common_config('license', 'title')) .
     52@@ -551,6 +570,12 @@ class RegisterAction extends Action
     53         return $out;
     54     }
     55 
     56+    function statementCheckbox()
     57+    {
     58+        // TRANS: Statement checkbox label in registration dialog.
     59+        return _('I agree to the <a href="https://mayfirst.org/unity" target="_blank">May First/People Link Statement of Unity.</a>');
     60+    }
     61+
     62     /**
     63      * Show some information about registering for the site
     64      *
    1265}}}
     66
     67{{{
     68diff --git a/plugins/OpenID/actions/finishopenidlogin.php b/plugins/OpenID/actions/finishopenidlogin.php
     69index 3a99988..755516d 100644
     70--- a/plugins/OpenID/actions/finishopenidlogin.php
     71+++ b/plugins/OpenID/actions/finishopenidlogin.php
     72@@ -49,6 +49,12 @@ class FinishopenidloginAction extends Action
     73                                     $this->trimmed('newname'));
     74                     return;
     75                 }
     76+                if (!$this->boolean('mfpl_statement')) {
     77+                    // TRANS: Message given if user does not agree with the statement.
     78+                    $this->showForm(_m('You cannot register if you do not agree to the MF/PL Statement of Unity.'),
     79+                                    $this->trimmed('newname'));
     80+                    return;
     81+                }
     82                 $this->createNewUser();
     83             } else if ($this->arg('connect')) {
     84                 $this->connectUser();
     85@@ -155,7 +161,7 @@ class FinishopenidloginAction extends Action
     86         $message = _m('My text and files are available under %s ' .
     87                      'except this private data: password, ' .
     88                      'email address, IM address, and phone number.');
     89-        $link = '<a href="' .
     90+        $link = '<a target="_blank" href="' .
     91                 htmlspecialchars(common_config('license', 'url')) .
     92                 '">' .
     93                 htmlspecialchars(common_config('license', 'title')) .
     94@@ -163,6 +169,23 @@ class FinishopenidloginAction extends Action
     95         $this->raw(sprintf(htmlspecialchars($message), $link));
     96         $this->elementEnd('label');
     97         $this->elementEnd('li');
     98+
     99+        // MFPL statement
     100+        $this->elementStart('li');
     101+        $this->element('input', array('type' => 'checkbox',
     102+                                      'id' => 'mfpl_statement',
     103+                                      'class' => 'checkbox',
     104+                                      'name' => 'mfpl_statement',
     105+                                      'value' => 'true'));
     106+        $this->elementStart('label', array('for' => 'mfpl_statement',
     107+                                          'class' => 'checkbox'));
     108+        // TRANS: OpenID plugin link text.
     109+        // TRANS: %s is a link to a license with the license name as link text.
     110+        $message = _m('I agree to the <a href="https://mayfirst.org/unity" target="_blank">May First/People Link Statement of Unity.</a>');
     111+        $this->raw($message);
     112+        $this->elementEnd('label');
     113+        $this->elementEnd('li');
     114+
     115         $this->elementEnd('ul');
     116         // TRANS: Button label in form in which to create a new user on the site for an OpenID.
     117         $this->submit('create', _m('BUTTON', 'Create'));
     118}}}