Ejemplo n.º 1
0
 /**
  * Reset an application's Consumer key and secret
  *
  * XXX: Should this be moved to its own page with a confirm?
  *
  */
 function resetKey()
 {
     $this->application->query('BEGIN');
     $oauser = new Oauth_application_user();
     $oauser->application_id = $this->application->id;
     $result = $oauser->delete();
     if ($result === false) {
         common_log_db_error($oauser, 'DELETE', __FILE__);
         $this->success = false;
         $this->msg = 'Unable to reset consumer key and secret.';
         $this->showPage();
         return;
     }
     $consumer = $this->application->getConsumer();
     $result = $consumer->delete();
     if ($result === false) {
         common_log_db_error($consumer, 'DELETE', __FILE__);
         $this->success = false;
         $this->msg = 'Unable to reset consumer key and secret.';
         $this->showPage();
         return;
     }
     $consumer = Consumer::generateNew();
     $result = $consumer->insert();
     if (empty($result)) {
         common_log_db_error($consumer, 'INSERT', __FILE__);
         $this->application->query('ROLLBACK');
         $this->success = false;
         $this->msg = 'Unable to reset consumer key and secret.';
         $this->showPage();
         return;
     }
     $orig = clone $this->application;
     $this->application->consumer_key = $consumer->consumer_key;
     $result = $this->application->update($orig);
     if ($result === false) {
         common_log_db_error($application, 'UPDATE', __FILE__);
         $this->application->query('ROLLBACK');
         $this->success = false;
         $this->msg = 'Unable to reset consumer key and secret.';
         $this->showPage();
         return;
     }
     $this->application->query('COMMIT');
     $this->success = true;
     $this->msg = 'Consumer key and secret reset.';
     $this->showPage();
 }
 function _deleteAppUsers()
 {
     $oauser = new Oauth_application_user();
     $oauser->application_id = $this->id;
     $oauser->delete();
 }