]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/smssettings.php
Merge branch '0.8.x' of git://gitorious.org/~brion/statusnet/brion-fixes into 0.8.x
[quix0rs-gnu-social.git] / actions / smssettings.php
index 489fd1f587f21028789c143b4bc82d3715c5ef10..672abcef8c15587e0eda8e089578e4bbea496c0a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Settings for SMS
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Settings
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2008-2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@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);
 }
 
@@ -37,10 +37,10 @@ require_once INSTALLDIR.'/lib/connectsettingsaction.php';
  * Settings for SMS
  *
  * @category Settings
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@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      SettingsAction
  */
@@ -69,6 +69,12 @@ class SmssettingsAction extends ConnectSettingsAction
         return _('You can receive SMS messages through email from %%site.name%%.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('sms');
+    }
+
     /**
      * Content area of the page
      *
@@ -80,6 +86,12 @@ class SmssettingsAction extends ConnectSettingsAction
 
     function showContent()
     {
+        if (!common_config('sms', 'enabled')) {
+            $this->element('div', array('class' => 'error'),
+                           _('SMS is not available.'));
+            return;
+        }
+
         $user = common_current_user();
 
         $this->elementStart('form', array('method' => 'post',
@@ -113,7 +125,7 @@ class SmssettingsAction extends ConnectSettingsAction
                 $this->hidden('carrier', $confirm->address_extra);
                 $this->submit('cancel', _('Cancel'));
 
-                $this->elementStart('ul', 'form_datas');
+                $this->elementStart('ul', 'form_data');
                 $this->elementStart('li');
                 $this->input('code', _('Confirmation code'), null,
                              _('Enter the code you received on your phone.'));
@@ -121,7 +133,7 @@ class SmssettingsAction extends ConnectSettingsAction
                 $this->elementEnd('ul');
                 $this->submit('confirm', _('Confirm'));
             } else {
-                $this->elementStart('ul', 'form_datas');
+                $this->elementStart('ul', 'form_data');
                 $this->elementStart('li');
                 $this->input('sms', _('SMS Phone number'),
                              ($this->arg('sms')) ? $this->arg('sms') : null,
@@ -156,7 +168,7 @@ class SmssettingsAction extends ConnectSettingsAction
         $this->elementStart('fieldset', array('id' => 'settings_sms_preferences'));
         $this->element('legend', null, _('Preferences'));
 
-        $this->elementStart('ul', 'form_datas');
+        $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
         $this->checkbox('smsnotify',
                         _('Send me notices through SMS; '.
@@ -448,7 +460,7 @@ class SmssettingsAction extends ConnectSettingsAction
 
         $cnt = $carrier->find();
 
-        $this->elementStart('ul', 'form_datas');
+        $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
         $this->element('label', array('for' => 'carrier'), _('Mobile carrier'));
         $this->elementStart('select', array('name' => 'carrier',
@@ -488,6 +500,58 @@ class SmssettingsAction extends ConnectSettingsAction
         }
 
         common_redirect(common_local_url('confirmaddress',
-                                         array('code' => $code)));
+                                         array('code' => $code)),
+                        303);
+    }
+
+    /**
+     * Handle a request to remove an incoming email address
+     *
+     * @return void
+     */
+
+    function removeIncoming()
+    {
+        $user = common_current_user();
+
+        if (!$user->incomingemail) {
+            $this->showForm(_('No incoming email address.'));
+            return;
+        }
+
+        $orig = clone($user);
+
+        $user->incomingemail = null;
+
+        if (!$user->updateKeys($orig)) {
+            common_log_db_error($user, 'UPDATE', __FILE__);
+            $this->serverError(_("Couldn't update user record."));
+        }
+
+        $this->showForm(_('Incoming email address removed.'), true);
+    }
+
+    /**
+     * Generate a new incoming email address
+     *
+     * @return void
+     *
+     * @see Emailsettings::newIncoming
+     */
+
+    function newIncoming()
+    {
+        $user = common_current_user();
+
+        $orig = clone($user);
+
+        $user->incomingemail = mail_new_incoming_address();
+
+        if (!$user->updateKeys($orig)) {
+            common_log_db_error($user, 'UPDATE', __FILE__);
+            $this->serverError(_("Couldn't update user record."));
+        }
+
+        $this->showForm(_('New incoming email address added.'), true);
     }
 }