예제 #1
0
 public function validate($form, $data, $group = null)
 {
     $app = JFactory::getApplication();
     $values = JRequest::getVar('joomdoc_option_value', array(), 'default', 'array');
     $labels = JRequest::getVar('joomdoc_option_label', array(), 'default', 'array');
     if (!empty($values) && !empty($labels)) {
         // check if field options values and labels are unique
         if (count(array_unique($values)) < count($values) || count(array_unique($labels)) < count($labels)) {
             $this->setError(JText::_('JOOMDOC_FIELD_OPTIONS_NONUNIQUE'));
             $options = array();
             foreach ($values as $id => $value) {
                 $option = new stdClass();
                 $option->id = $id;
                 $option->value = $value;
                 $option->label = $labels[$id];
                 $options[] = $option;
             }
             // save current option list into session
             $app->setUserState('com_joomdoc.field.options', $options);
             return false;
         }
     }
     // options are unique - cleanup session
     $app->setUserState('com_joomdoc.field.options', null);
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // check if field title is unique
     $query->select('COUNT(*)')->from('#__joomdoc_field')->where('LOWER(TRIM(title)) = ' . $db->q(JString::strtolower(JString::trim($data['title']))))->where('id <> ' . (int) $data['id']);
     if ($db->setQuery($query)->loadResult()) {
         $this->setError(JText::_('JOOMDOC_FIELD_NONUNIQUE'));
         return false;
     }
     return parent::validate($form, $data, $group);
 }
예제 #2
0
 public function validate($form, $data, $group = null)
 {
     // Prepare the data.
     $data["level"] = implode(",", $data["level"]);
     return parent::validate($form, $data, $group);
     // TODO: Change the autogenerated stub
 }
예제 #3
0
 public function validate($form, $data, $group = null) {
     // Adicionando a data de criação do export
     if (empty($data['created_when'])) {
         $date = new DateTime();
         $data['created_when'] = $date->format('Y-m-d h:i:s');
     }
     // Dedo-duro
     if (empty($data['created_by'])) {
         $user = JFactory::getUser();
         $data['created_by'] = $user->get('id');
     }
     
     return parent::validate($form, $data, $group);
 }
예제 #4
0
파일: form.php 프로젝트: pguilford/vcomcc
 public function validate($form, $data, $group = null)
 {
     $data = parent::validate($form, $data, $group);
     // fix for magic quotes
     if (get_magic_quotes_gpc()) {
         $props = json_decode($data['props']);
         if ($props == null) {
             foreach ($data as $key => $value) {
                 $data[$key] = stripslashes($value);
             }
         }
     }
     return $data;
 }
예제 #5
0
 /**
  * Method to validate the form data.
  *
  * @param   object  $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  * @since   11.1
  */
 public function validate($form, $data, $group = null)
 {
     if ($result = parent::validate($form, $data, $group)) {
         // for Fields group
         // Convert jform[fields_group][field] to jform[field] or JTable cannot bind data.
         // ==========================================================================================
         $result = AKHelper::_('array.pivotFromTwoDimension', $result);
     }
     return $result;
 }
예제 #6
0
파일: cron.php 프로젝트: romuland/khparts
 /**
  * Method to validate the form data.
  *
  * @param	object		$form		The form to validate against.
  * @param	array		$data		The data to validate.
  * @return	mixed		Array of filtered data if valid, false otherwise.
  * @since	1.1
  */
 function validate($form, $data)
 {
     $params = $data['params'];
     $ok = parent::validate($form, $data);
     //standard jform validation failed so we shouldn't test further as we can't
     //be sure of the data
     if (!$ok) {
         return false;
     }
     //hack - must be able to add the plugin xml fields file to $form to include in validation
     // but cant see how at the moment
     $data['params'] = $params;
     return $data;
 }
예제 #7
0
 /**
  * Method to validate the form data.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @see     JFormRule
  * @see     JFilterInput
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     $ok = parent::validate($form, $data);
     // Standard jform validation failed so we shouldn't test further as we can't be sure of the data
     if (!$ok) {
         return false;
     }
     $db = FabrikWorker::getDbo(true);
     if (FabrikWorker::isReserved($data['name'])) {
         $this->setError(JText::_('COM_FABRIK_RESEVED_NAME_USED'));
     }
     $elementModel = $this->getElementPluginModel($data);
     $nameChanged = $data['name'] !== $elementModel->getElement()->name;
     $elementModel->getElement()->bind($data);
     $listModel = $elementModel->getListModel();
     if ($data['id'] === 0) {
         // Have to forcefully set group id otherwise listmodel id is blank
         $elementModel->getElement()->group_id = $data['group_id'];
         if ($listModel->canAddFields() === false && $listModel->noTable() === false) {
             $this->setError(JText::_('COM_FABRIK_ERR_CANT_ADD_FIELDS'));
         }
     } else {
         if ($listModel->canAlterFields() === false && $nameChanged && $listModel->noTable() === false) {
             $this->setError(JText::_('COM_FABRIK_ERR_CANT_ALTER_EXISTING_FIELDS'));
         }
     }
     $listModel = $elementModel->getListModel();
     /**
      * Test for duplicate names
      * unlinking produces this error
      */
     if (!JRequest::getVar('unlink', false) && (int) $data['id'] === 0) {
         $row->group_id = (int) $data['group_id'];
         $query = $db->getQuery(true);
         $query->select('t.id')->from('#__{package}_joins AS j');
         $query->join('INNER', '#__{package}_lists AS t ON j.table_join = t.db_table_name');
         $query->where("group_id = {$row->group_id} AND element_id = 0");
         $db->setQuery($query);
         $joinTblId = (int) $db->loadResult();
         $ignore = array($data['id']);
         if ($joinTblId === 0) {
             if ($listModel->fieldExists($data['name'], $ignore)) {
                 $this->setError(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         } else {
             $joinListModel = JModel::getInstance('list', 'FabrikFEModel');
             $joinListModel->setId($joinTblId);
             $joinEls = $joinListModel->getElements();
             foreach ($joinEls as $joinEl) {
                 if ($joinEl->getElement()->name == $data['name']) {
                     $ignore[] = $joinEl->getElement()->id;
                 }
             }
             if ($joinListModel->fieldExists($data['name'], $ignore)) {
                 $this->setError(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         }
     }
     // Strip <p> tag from label
     $data['label'] = JString::str_ireplace(array('<p>', '</p>'), '', $data['label']);
     return count($this->getErrors()) == 0 ? $data : false;
 }
예제 #8
0
 /**
  * Method to validate the form data.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     // Fire HUBzero registration check here so that we don't have to duplicate validation code
     require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'registration.php';
     $registration = new \Components\Members\Models\Registration();
     $registration->set('name', $data['name']);
     $registration->set('login', $data['username']);
     $registration->set('email', $data['email']);
     $registration->set('confirmEmail', $data['email']);
     if (!$registration->check('create', $data['id'], array('name', 'login', 'email'))) {
         $this->setError(implode("<br/>", $registration->_invalid));
         return false;
     }
     return parent::validate($form, $data, $group);
 }
예제 #9
0
 /**
  * Loads ContentHelper for filters before validating data.
  *
  * @param   object  $form  The form to validate against.
  * @param   array   $data  The data to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @since   1.1
  */
 function validate($form, $data, $group = null)
 {
     require_once PATH_CORE . '/components/com_content/admin/helpers/content.php';
     return parent::validate($form, $data, $group);
 }
예제 #10
0
파일: table.php 프로젝트: BillVGN/PortalPRP
    public function validate($form, $data, $group = null) {
        $date = new DateTime();
        $user = JFactory::getUser();

        if (empty($data['created_when'])) {
            // Adicionando a data de criação da table
            $data['created_when'] = $date->format('Y-m-d H:i:s');
        } else {
            // Ou a data de modificação
            $data['modified_when'] = $date->format('Y-m-d H:i:s');
        }
        
        if (empty($data['created_by'])) {
            // Quem criou
            $data['created_by'] = $user->get('id');
        } else {
            // Ou quem modificou
            $data['modified_by'] = $user->get('id');
        }
        
        return parent::validate($form, $data, $group);
    }
예제 #11
0
 /**
  * Method to validate the form data.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  * @since   12.2
  */
 public function validate($form, $data, $group = null)
 {
     // check if the not_required field is set
     if (DemoHelper::checkString($data['not_required'])) {
         $requiredFields = (array) explode(',', (string) $data['not_required']);
         $requiredFields = array_unique($requiredFields);
         // now change the required field attributes value
         foreach ($requiredFields as $requiredField) {
             // make sure there is a string value
             if (DemoHelper::checkString($requiredField)) {
                 // change to false
                 $form->setFieldAttribute($requiredField, 'required', 'false');
                 // also clear the data set
                 $data[$requiredField] = '';
             }
         }
     }
     return parent::validate($form, $data, $group);
 }
예제 #12
0
 /**
  * needed for saving params- not sure y!
  * @param unknown_type $form
  * @param unknown_type $data
  */
 function validate($form, $data)
 {
     parent::validate($form, $data);
     return $data;
 }
예제 #13
0
 /**
  * Method to validate the form data.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  */
 public function validate($form, $data, $group = null)
 {
     parent::validate($form, $data);
     return $data;
 }
예제 #14
0
파일: user.php 프로젝트: fracting/cmc
 /**
  * Since we now have a dynamic form we have to go around the validation somehow
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     // The data that we are receiving should have a cmc_groups
     if (isset($data['cmc_groups']['EMAIL'])) {
         $data['email'] = $data['cmc_groups']['EMAIL'];
         $data['firstname'] = $data['cmc_groups']['FNAME'];
         $data['lastname'] = $data['cmc_groups']['LNAME'];
     } else {
         JFactory::getApplication()->enqueueMessage('Your list doesn\'t have a EMAIL field or you are using a different field name for email(the field name should be EMAIL)');
         return false;
     }
     return parent::validate($form, $data);
 }
예제 #15
0
파일: event.php 프로젝트: sansandeep143/av
 public function validate($form, $data, $group = null)
 {
     // clean up the folder name if it is no picasa album
     if (empty($data['id'])) {
         // make the foldername for local folders safe
         if ($data['foldertype'] == 0) {
             $data['folder'] = JFolder::makeSafe($data['folder']);
         }
     }
     $validData = parent::validate($form, $data, $group);
     if (is_bool($validData) && $validDate == false) {
         return false;
     }
     if (!isset($data['usergroups']) || count($data['usergroups']) == 0) {
         $validData['usergroupids'] = '';
     } else {
         $validData['usergroupids'] = implode(',', $data['usergroups']);
     }
     return $validData;
 }
예제 #16
0
파일: element.php 프로젝트: rhotog/fabrik
 /**
  * Method to validate the form data.
  *
  * @param	object		$form		The form to validate against.
  * @param	array		$data		The data to validate.
  * @return	mixed		Array of filtered data if valid, false otherwise.
  * @since	1.1
  */
 function validate($form, $data)
 {
     $ok = parent::validate($form, $data);
     //standard jform validation failed so we shouldn't test further as we can't
     //be sure of the data
     if (!$ok) {
         return false;
     }
     $db = FabrikWorker::getDbo(true);
     // validate name
     //$data['name'] = str_replace('-', '_', $data['name']);
     if (FabrikWorker::isReserved($data['name'])) {
         $this->setError(JText::_('COM_FABRIK_RESEVED_NAME_USED'));
     }
     $elementModel = $this->getElementPluginModel($data);
     $elementModel->getElement()->bind($data);
     if ($data['id'] === 0) {
         //have to forcefully set group id otherwise listmodel id is blank
         $elementModel->getElement()->group_id = $data['group_id'];
     }
     $listModel =& $elementModel->getListModel();
     //test for duplicate names
     //unlinking produces this error
     if (!JRequest::getVar('unlink', false) && (int) $data['id'] === 0) {
         $row->group_id = (int) $data['group_id'];
         $query = $db->getQuery(true);
         $query->select('t.id')->from('#__{package}_joins AS j');
         $query->join('INNER', "#__{package}_lists AS t ON j.table_join = t.db_table_name");
         $query->where("group_id = {$row->group_id} AND element_id = 0");
         $db->setQuery($query);
         $joinTblId = (int) $db->loadResult();
         $ignore = array($data['id']);
         if ($joinTblId === 0) {
             if ($listModel->fieldExists($data['name'], $ignore)) {
                 $this->setError(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         } else {
             $joinListModel = JModel::getInstance('list', 'FabrikFEModel');
             $joinListModel->setId($joinTblId);
             $joinEls = $joinListModel->getElements();
             foreach ($joinEls as $joinEl) {
                 if ($joinEl->getElement()->name == $data['name']) {
                     $ignore[] = $joinEl->getElement()->id;
                 }
             }
             if ($joinListModel->fieldExists($data['name'], $ignore)) {
                 $this->setError(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         }
     }
     //end  duplicate name test
     // $$$ rob commented out as on new elemetns db join was creating
     // join records pointing to an el id of 0
     // should consider makeing an $element->onValidate() or similar
     /*if (!$elementModel->onSave()) {
     		 $this->setError(JText::_('COM_FABRIK_ERROR_SAVING_ELEMENT_PLUGIN_OPTIONS'));
     	 }*/
     return count($this->getErrors()) == 0 ? $data : false;
 }
예제 #17
0
 /**
  * Loads ContentHelper for filters before validating data.
  *
  * @param   object  $form  The form to validate against.
  * @param   array   $data  The data to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @since   1.1
  */
 function validate($form, $data, $group = null)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php';
     return parent::validate($form, $data, $group);
 }
예제 #18
0
 /**
  * Method to validate the form data.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @see     JFormRule
  * @see     JFilterInput
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     if ($data['password'] !== $data['passwordConf']) {
         $this->setError(JText::_('COM_FABRIK_PASSWORD_MISMATCH'));
         return false;
     }
     return parent::validate($form, $data);
 }
예제 #19
0
 /**
  * Loads ContentHelper for filters before validating data.
  *
  * @param   object  $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the group(defaults to null).
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @since   1.1
  */
 public function validate($form, $data, $group = null)
 {
     JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php');
     return parent::validate($form, $data, $group);
 }
예제 #20
0
 /**
  * Method to validate the form data. 
  *  This override handle the inputs of files types, (Joomla issue when they
  * are required)
  *
  * @access	public
  * @param	object	$form	The form to validate against.
  * @param	array	$data	The data to validate.
  * @param	string	$group	The name of the field group to validate.
  *
  * @return	mixed	Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     //Get the posted files if this model is concerned by files submission
     // JOOMLA FIX : if missing fields in $_POST -> issue in partial update when required
     $currentData = $this->getItem();
     foreach ($currentData as $fieldName => $value) {
         $field = $form->getField($fieldName, $group, $value);
         //Skip the ID data (and other fields not in the form)
         if (!$field) {
             continue;
         }
         //Missing in $_POST and required
         if (!in_array($fieldName, array_keys($data)) && $field->required) {
             //Insert the current object value. (UPDATE)
             $data[$fieldName] = $currentData->{$fieldName};
         }
     }
     //JOOMLA FIX : Reformate some field types not handled properly
     foreach ($form->getFieldset($group) as $field) {
         $value = null;
         if (isset($data[$field->fieldname])) {
             $value = $data[$field->fieldname];
         }
         switch ($field->type) {
             //JOOMLA FIX : Reformate the date/time format comming from the post
             case 'ckcalendar':
                 //cimport('helpers.dates');
                 if ($value && (string) $field->format && !RtiprintHelperDates::isNull((string) $value)) {
                     $time = RtiprintHelperDates::getSqlDate($value, array($field->format));
                     if ($time === null) {
                         JError::raiseWarning(1203, JText::sprintf('RTIPRINT_VALIDATOR_WRONG_DATETIME_FORMAT_FOR_PLEASE_RETRY', $field->label));
                         $valid = false;
                     } else {
                         $data[$field->fieldname] = RtiprintHelperDates::toSql($time);
                     }
                 }
                 break;
                 //JOOMLA FIX : Apply a null value if the field is in the form
             //JOOMLA FIX : Apply a null value if the field is in the form
             case 'ckcheckbox':
                 if (!$value) {
                     $data[$field->fieldname] = 0;
                 }
                 break;
         }
     }
     // JOOMLA FIX : always missing file names in $_POST -> issue when required
     //Get the posted files if this model is concerned by files submission
     if (count($this->fileFields)) {
         $fileInput = new JInput($_FILES);
         $files = $fileInput->get('jform', null, 'array');
         if (count($files['name'])) {
             foreach ($files['name'] as $fieldName => $value) {
                 //For required files, temporary insert the value comming from $_FILES
                 if (!empty($value)) {
                     $field = $form->getField($fieldName, $group);
                     if ($field->required) {
                         $data[$fieldName] = $value;
                     }
                 }
             }
         }
     }
     //Exec the native PHP validation (rules)
     $result = parent::validate($form, $data, $group);
     //check the result before to go further
     if ($result === false) {
         return false;
     }
     //ID key follower (in some case, ex : save2copy task)
     if (isset($data['id'])) {
         $result['id'] = $data['id'];
     }
     return $result;
 }