示例#1
0
文件: api.json.php 项目: viru48/imc
 public function userexists()
 {
     $result = null;
     $usernameExists = false;
     $emailExists = false;
     $app = JFactory::getApplication();
     try {
         self::validateRequest();
         if ($app->input->getMethod() != 'GET') {
             throw new Exception('You cannot use other method than GET to check userexists');
         }
         //get necessary arguments
         $args = array('username' => $app->input->getString('username'), 'email' => $app->input->getString('email'));
         ImcFrontendHelper::checkNullArguments($args);
         $userid = JUserHelper::getUserId($args['username']);
         if ($userid > 0) {
             $app->enqueueMessage(JText::_('COM_IMC_API_USERNAME_EXISTS'), 'info');
             $usernameExists = true;
         }
         if (ImcFrontendHelper::emailExists($args['email'])) {
             $app->enqueueMessage(JText::_('COM_IMC_API_EMAIL_EXISTS'), 'info');
             $emailExists = true;
         }
         $result = array($usernameExists || $emailExists);
         echo new JResponseJson($result, 'Check user action completed successfully');
     } catch (Exception $e) {
         header("HTTP/1.0 202 Accepted");
         echo new JResponseJson($e);
     }
 }