/**
  * Clear the cache of the forms when a validation setting has changed.
  *
  * @param \DataContainer $dataContainer The data container.
  *
  * @return void
  */
 public function clearCache($dataContainer)
 {
     $collection = \FormModel::findBy(['fv_active=1', 'fv_setting=?'], $dataContainer->id);
     if ($collection) {
         foreach ($collection as $form) {
             $this->cache->remove($form->id);
         }
     }
 }
 public function validateVotingEmailFormField(\Widget $objWidget, $intId)
 {
     if (($objForm = \FormModel::findBy('alias', str_replace('auto_', '', $intId))) !== null && $objForm->maxVoteCount) {
         // check if a voting from the mail address already exists
         $db = \Database::getInstance();
         $objEmailCheck = $db->prepare('SELECT * FROM tl_formdata_details fdt INNER JOIN tl_formdata fd ON fdt.pid=fd.id INNER JOIN tl_form f ON fd.form=f.title WHERE fdt.ff_name=? AND fdt.value=? AND f.alias=?')->execute('email', $objWidget->value, $objForm->alias);
         if ($objEmailCheck->numRows > 0 && $objEmailCheck->numRows >= $objForm->maxVoteCount) {
             $objWidget->addError(sprintf($GLOBALS['TL_LANG']['email_voting']['maxVoteCount'], $objForm->maxVoteCount));
         }
     }
     return $objWidget;
 }
示例#3
0
 /**
  * Get all available forms.
  *
  * @param \DataContainer $dataContainer The data container driver.
  *
  * @return array
  */
 public function getSubformOptions($dataContainer)
 {
     $options = array();
     if ($dataContainer->activeRecord) {
         $collection = \FormModel::findBy(['tl_form.id !=?'], $dataContainer->activeRecord->pid, ['order' => 'title']);
         if ($collection) {
             foreach ($collection as $form) {
                 $options[$form->id] = sprintf('%s [%s]', $form->title, $form->id);
             }
         }
     }
     return $options;
 }