]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/emailsettings.php
Merge branch '0.9.x' into finish-account-api
[quix0rs-gnu-social.git] / actions / emailsettings.php
index 4cd63a9d3bc0e482034289a25838f58d86029054..67b991cdc8b3d09afffe2349c3f9d925d2719898 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Settings for email
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Settings
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @author    Zach Copley <zach@controlyourself.ca>
- * @copyright 2008-2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Zach Copley <zach@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/settingsaction.php';
+require_once INSTALLDIR.'/lib/accountsettingsaction.php';
 
 /**
  * Settings for email
  *
  * @category Settings
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
- * @author   Zach Copley <zach@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Zach Copley <zach@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  *
  * @see      Widget
  */
 
-class EmailsettingsAction extends SettingsAction
+class EmailsettingsAction extends AccountSettingsAction
 {
     /**
      * Title of the page
@@ -71,6 +71,12 @@ class EmailsettingsAction extends SettingsAction
         return _('Manage how you get email from %%site.name%%.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('email');
+    }
+
     /**
      * Content area of the page
      *
@@ -85,45 +91,46 @@ class EmailsettingsAction extends SettingsAction
         $user = common_current_user();
 
         $this->elementStart('form', array('method' => 'post',
-                                          'id' => 'emailsettings',
+                                          'id' => 'form_settings_email',
+                                          'class' => 'form_settings',
                                           'action' =>
                                           common_local_url('emailsettings')));
 
+        $this->elementStart('fieldset', array('id' => 'settings_email_address'));
+        $this->element('legend', null, _('Address'));
         $this->hidden('token', common_session_token());
 
-        $this->element('h2', null, _('Address'));
-
         if ($user->email) {
-            $this->elementStart('p');
-            $this->element('span', 'address confirmed', $user->email);
-            $this->element('span', 'input_instructions',
-                           _('Current confirmed email address.'));
+            $this->element('p', array('id' => 'form_confirmed'), $user->email);
+            $this->element('p', array('class' => 'form_note'), _('Current confirmed email address.'));
             $this->hidden('email', $user->email);
-            $this->elementEnd('p');
             $this->submit('remove', _('Remove'));
         } else {
             $confirm = $this->getConfirmation();
             if ($confirm) {
-                $this->elementStart('p');
-                $this->element('span', 'address unconfirmed', $confirm->address);
-                $this->element('span', 'input_instructions',
-                               _('Awaiting confirmation on this address. '.
-                                 'Check your inbox (and spam box!) for a message '.
-                                 'with further instructions.'));
+                $this->element('p', array('id' => 'form_unconfirmed'), $confirm->address);
+                $this->element('p', array('class' => 'form_note'),
+                                        _('Awaiting confirmation on this address. '.
+                                        'Check your inbox (and spam box!) for a message '.
+                                        'with further instructions.'));
                 $this->hidden('email', $confirm->address);
-                $this->elementEnd('p');
                 $this->submit('cancel', _('Cancel'));
             } else {
+                $this->elementStart('ul', 'form_data');
+                $this->elementStart('li');
                 $this->input('email', _('Email Address'),
                              ($this->arg('email')) ? $this->arg('email') : null,
                              _('Email address, like "UserName@example.org"'));
+                $this->elementEnd('li');
+                $this->elementEnd('ul');
                 $this->submit('add', _('Add'));
             }
         }
+        $this->elementEnd('fieldset');
 
-        if ($user->email) {
-            $this->element('h2', null, _('Incoming email'));
-
+       if (common_config('emailpost', 'enabled') && $user->email) {
+            $this->elementStart('fieldset', array('id' => 'settings_email_incoming'));
+            $this->element('legend',_('Incoming email'));
             if ($user->incomingemail) {
                 $this->elementStart('p');
                 $this->element('span', 'address', $user->incomingemail);
@@ -139,32 +146,54 @@ class EmailsettingsAction extends SettingsAction
                              'cancels the old one.'));
             $this->elementEnd('p');
             $this->submit('newincoming', _('New'));
+            $this->elementEnd('fieldset');
         }
 
-        $this->element('h2', null, _('Preferences'));
+        $this->elementStart('fieldset', array('id' => 'settings_email_preferences'));
+        $this->element('legend', null, _('Preferences'));
 
+        $this->elementStart('ul', 'form_data');
+        $this->elementStart('li');
         $this->checkbox('emailnotifysub',
                         _('Send me notices of new subscriptions through email.'),
                         $user->emailnotifysub);
+        $this->elementEnd('li');
+        $this->elementStart('li');
         $this->checkbox('emailnotifyfav',
                         _('Send me email when someone '.
                           'adds my notice as a favorite.'),
                         $user->emailnotifyfav);
+        $this->elementEnd('li');
+        $this->elementStart('li');
         $this->checkbox('emailnotifymsg',
                         _('Send me email when someone sends me a private message.'),
                         $user->emailnotifymsg);
+        $this->elementEnd('li');
+        $this->elementStart('li');
+        $this->checkbox('emailnotifyattn',
+                        _('Send me email when someone sends me an "@-reply".'),
+                        $user->emailnotifyattn);
+        $this->elementEnd('li');
+        $this->elementStart('li');
         $this->checkbox('emailnotifynudge',
                         _('Allow friends to nudge me and send me an email.'),
                         $user->emailnotifynudge);
-        $this->checkbox('emailpost',
-                        _('I want to post notices by email.'),
-                        $user->emailpost);
+        $this->elementEnd('li');
+        if (common_config('emailpost', 'enabled')) {
+            $this->elementStart('li');
+            $this->checkbox('emailpost',
+                            _('I want to post notices by email.'),
+                            $user->emailpost);
+            $this->elementEnd('li');
+        }
+        $this->elementStart('li');
         $this->checkbox('emailmicroid',
                         _('Publish a MicroID for my email address.'),
                         $user->emailmicroid);
-
+        $this->elementEnd('li');
+        $this->elementEnd('ul');
         $this->submit('save', _('Save'));
-
+        $this->elementEnd('fieldset');
         $this->elementEnd('form');
     }
 
@@ -239,6 +268,7 @@ class EmailsettingsAction extends SettingsAction
         $emailnotifyfav   = $this->boolean('emailnotifyfav');
         $emailnotifymsg   = $this->boolean('emailnotifymsg');
         $emailnotifynudge = $this->boolean('emailnotifynudge');
+        $emailnotifyattn  = $this->boolean('emailnotifyattn');
         $emailmicroid     = $this->boolean('emailmicroid');
         $emailpost        = $this->boolean('emailpost');
 
@@ -254,6 +284,7 @@ class EmailsettingsAction extends SettingsAction
         $user->emailnotifyfav   = $emailnotifyfav;
         $user->emailnotifymsg   = $emailnotifymsg;
         $user->emailnotifynudge = $emailnotifynudge;
+        $user->emailnotifyattn  = $emailnotifyattn;
         $user->emailmicroid     = $emailmicroid;
         $user->emailpost        = $emailpost;
 
@@ -295,7 +326,7 @@ class EmailsettingsAction extends SettingsAction
             $this->showForm(_('Cannot normalize that email address'));
             return;
         }
-        if (!Validate::email($email, true)) {
+        if (!Validate::email($email, common_config('email', 'check_domain'))) {
             $this->showForm(_('Not a valid email address'));
             return;
         } else if ($user->email == $email) {