Пример #1
0
 /**
  * @brief Redirecciona a la vista de edicion, para editar la informacion y
  * almacenarla
  */
 function edit()
 {
     $cid = JRequest::getVar('cid', array());
     jimport('Amadeus.Util.Validation');
     if (!AmadeusUtilValidation::isArrayOf('integer', $cid)) {
         JError::raiseError(500, 'ERROR: El arreglo no contiene valores enteros.');
     }
     $_id = $cid[0];
     $model =& $this->getModel($this->_model);
     $model->setRegisterToPost($_id);
     $this->seeViewEdit();
 }
Пример #2
0
 /**
  * @brief Borra de la base de datos, los registros seleccionados, admás de sus archivos.
  * @return bool
  */
 function remove()
 {
     $link = JRoute::_($this->getURLBase(), false);
     $model =& $this->getModel($this->_model);
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     jimport('Amadeus.Util.Validation');
     if (!AmadeusUtilValidation::isArrayOf('integer', $cid)) {
         JError::raiseError(500, 'ERROR: El arreglo no contiene valores enteros.');
     }
     if ($this->beforeRemove($cid) === false) {
         return false;
     }
     if (!$this->__removeFile($cid, $model)) {
         return false;
     }
     $conditions = 'id IN ( \'' . join('\' , \'', $cid) . '\' )';
     $model->delete($conditions);
     if ($this->afterRemove() === false) {
         return false;
     }
     $this->setRedirect($link, JText::_('DELETE_SUCCESS'));
     return true;
 }
Пример #3
0
 /**
  * @brief Accion ecargada de manipular el archivo que se esta cargando.
  *
  * Las validaciones se hacen con respecto a las configuraciones provistas
  * por el Joomla en su seccion "Configuracion Multimedia". Si la variable
  * \a only_image se encuentra con un valor verdadero, solo se permitira subir
  * archivos de tipo imagen, en caso contraro, archivos validos.
  */
 function upload()
 {
     $media =& JComponentHelper::getParams('com_media');
     $only_image = JRequest::getVar('only_image', '');
     if ($only_image == true) {
         $allowedExtensions = explode(',', $media->get('image_extensions'));
     } else {
         $allowedExtensions = explode(',', $media->get('upload_extensions'));
     }
     /// Se selecciona el menor valor para subir archivos, ya sea el configurado por el
     /// servidor o el configurado en el Joomla
     $postSize = $this->toBytes(ini_get('post_max_size'));
     $uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
     $sizeLimit = (int) $media->get('upload_maxsize') * 1048576;
     $sizeLimit = min($postSize, $uploadSize, $sizeLimit);
     require_once JPATH_COMPONENT . DS . 'uploader.php';
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload(JPATH_SITE . '/tmp/', true);
     if (!isset($result['error'])) {
         jimport('Amadeus.Util.Validation');
         $file = $uploader->getName();
         $result = AmadeusUtilValidation::isValidFile($file, $only_image);
         if (isset($result['error'])) {
             jimport('joomla.filesystem.file');
             if (!JFile::delete($file)) {
                 $result = array('error' => JText::_('DELETEERROR'));
             }
         }
     }
     echo htmlspecialchars($this->encodeJSON($result), ENT_NOQUOTES);
 }