示例#1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $fileId = $app->input->getInt("id");
     $userId = JFactory::getUser()->get("id");
     jimport("identityproof.validator.file.owner");
     $validator = new IdentityProofValidatorFileOwner(JFactory::getDbo(), $fileId, $userId);
     if (!$userId or !$validator->isValid()) {
         echo JText::_("COM_IDENTITYPROOF_ERROR_INVALID_REQUEST");
         JFactory::getApplication()->close(500);
         return;
     }
     // Load the form.
     JForm::addFormPath(IDENTITYPROOF_PATH_COMPONENT_SITE . '/models/forms');
     $this->form = JForm::getInstance('com_identityproof.download', 'download', array('control' => "jform", 'load_data' => false));
     // Set item id to the form.
     $this->form->setValue("file_id", null, $fileId);
     parent::display($tpl);
 }
示例#2
0
 /**
  * Return a not about resource.
  */
 public function note()
 {
     $app = JFactory::getApplication();
     // Create response object
     jimport("itprism.response.json");
     $response = new ITPrismResponseJson();
     $fileId = $this->input->get->get("id");
     $userId = JFactory::getUser()->get("id");
     // Create validator object.
     jimport("identityproof.validator.file.owner");
     $validator = new IdentityProofValidatorFileOwner(JFactory::getDbo(), $fileId, $userId);
     if (!$userId) {
         $response->setTitle(JText::_('COM_IDENTITYPROOF_FAIL'))->setText(JText::_('COM_IDENTITYPROOF_ERROR_NOT_LOG_IN'))->failure();
         echo $response;
         $app->close();
     }
     if (!$validator->isValid()) {
         $response->setTitle(JText::_('COM_IDENTITYPROOF_FAIL'))->setText(JText::_('COM_IDENTITYPROOF_ERROR_INVALID_ITEM'))->failure();
         echo $response;
         $app->close();
     }
     try {
         // Get the model
         $model = $this->getModel();
         /** @var $model IdentityProofModelFile */
         $note = $model->getNote($fileId, $userId);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception($e->getMessage());
     }
     $response->setTitle(JText::_('COM_IDENTITYPROOF_SUCCESS'))->setData(array("note" => $note))->success();
     echo $response;
     $app->close();
 }