123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
- {
- protected $needPost = true;
-
- function prepare(array $args = array())
- {
- parent::prepare($args);
- $this->user = $this->auth_user;
- $this->device = $this->trimmed('device');
- return true;
- }
-
- function handle()
- {
- parent::handle();
- if (!in_array($this->format, array('xml', 'json'))) {
- $this->clientError(
-
- _('API method not found.'),
- 404,
- $this->format
- );
- }
-
- if (!in_array(strtolower($this->device), array('sms', 'im', 'none'))) {
-
- $this->clientError(_( 'You must specify a parameter named ' .
- '\'device\' with a value of one of: sms, im, none.' ));
- }
- if (empty($this->user)) {
-
- $this->clientError(_('No such user.'), 404);
- }
- $original = clone($this->user);
- if (strtolower($this->device) == 'sms') {
- $this->user->smsnotify = true;
- } elseif (strtolower($this->device) == 'im') {
-
-
-
-
- } elseif (strtolower($this->device == 'none')) {
- $this->user->smsnotify = false;
-
-
-
-
- }
- $result = $this->user->update($original);
- if ($result === false) {
- common_log_db_error($this->user, 'UPDATE', __FILE__);
-
- $this->serverError(_('Could not update user.'));
- }
- $profile = $this->user->getProfile();
- $twitter_user = $this->twitterUserArray($profile, true);
-
-
-
-
-
- if ($this->format == 'xml') {
- $this->initDocument('xml');
- $this->showTwitterXmlUser($twitter_user, 'user', true);
- $this->endDocument('xml');
- } elseif ($this->format == 'json') {
- $this->initDocument('json');
- $this->showJsonObjects($twitter_user);
- $this->endDocument('json');
- }
- }
- }
|