To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Changeset 1084

Show
Ignore:
Timestamp:
04/28/10 11:48:44 (22 months ago)
Author:
dordille
Message:

Added methods to retrieve data from forms.

Location:
plugins/apostropheFormBuilderPlugin/trunk/lib
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostropheFormBuilderPlugin/trunk/lib/form/aFormBuilder.class.php

    r628 r1084  
    1414                $this->setDefault('form_id', $this->getOption('a_form')->getId()); 
    1515                $this->setWidget('form_id' , new sfWidgetFormInputHidden()); 
    16                  
     16 
    1717    $fieldsetWrapperForm = new sfForm(); 
    1818     
    19     foreach ($this->getOption('a_form')->aFormFieldsets as $aFormFieldset) 
     19    foreach ($this->getOption('a_form_fieldsets', $this->getOption('a_form')->aFormFieldsets) as $aFormFieldset) 
    2020    { 
    21       $fieldsetWrapperForm->embedForm($aFormFieldset->getId(), $aFormFieldset->getForm( 
    22         $this->getObject()->getFieldSubmissionsForFieldset($aFormFieldset['id']),  
    23         array('a_form_fieldset' => $aFormFieldset) 
     21      $fieldsetWrapperForm->embedForm( 
     22        $aFormFieldset->getId(), 
     23        $aFormFieldset->getForm( 
     24          $this->getObject()->getFieldSubmissionsForFieldset($aFormFieldset['id']), 
     25          array('a_form_fieldset' => $aFormFieldset) 
    2426      )); 
    2527                        $fieldsetWrapperForm[$aFormFieldset->getId()]->getWidget()->setLabel($aFormFieldset->getLabel()); 
     
    2931                $this->useFields(array('form_id', 'fields')); 
    3032  } 
    31            
     33         
     34 
    3235  public function updateObjectEmbeddedForms($values, $forms = null) 
    3336  { 
     
    5053  { 
    5154    $this->getObject()->setFormId($this->getOption('a_form')->getId()); 
    52     $this->getObject()->setIpAddress($_SERVER['REMOTE_ADDR']);   
     55    $this->getObject()->setIpAddress($_SERVER['REMOTE_ADDR']); 
     56    $this->getObject()->setUserId($this->getOption('user_id', null)); 
    5357  } 
    5458   
  • plugins/apostropheFormBuilderPlugin/trunk/lib/model/doctrine/PluginaForm.class.php

    r936 r1084  
    4646  } 
    4747 
    48   public function getSubform($rank = 0, $aFormSubmission = null) 
     48  public function getSubform($rank = 0, $aFormSubmission = null, $options = array()) 
    4949  { 
    5050    $i = 0; 
     
    6464    $form = new aFormBuilder( 
    6565      $aFormSubmission, 
    66       array('a_form' => $this, 'a_form_fieldsets' => $subFieldset)); 
     66      array_merge( 
     67        $options, 
     68        array('a_form' => $this, 'a_form_fieldsets' => $subFieldset) 
     69    )); 
    6770     
    6871    return $form; 
     
    8285  } 
    8386 
     87  public function getUserSubmissions($user_id, $q = null, $hydrationMode = null) 
     88  { 
     89    return Doctrine::getTable('aFormSubmission') 
     90      ->getUserSubmissionsQuery($this['id'], $user_id, $q) 
     91      ->execute(array(), $hydrationMode); 
     92  } 
     93 
    8494} 
  • plugins/apostropheFormBuilderPlugin/trunk/lib/model/doctrine/PluginaFormSubmission.class.php

    r628 r1084  
    1919                return $aFieldSubmissions; 
    2020        } 
     21 
    2122} 
  • plugins/apostropheFormBuilderPlugin/trunk/lib/model/doctrine/PluginaFormSubmissionTable.class.php

    r20 r1084  
    55class PluginaFormSubmissionTable extends Doctrine_Table 
    66{ 
     7  public function getUserSubmissionsQuery($form_id, $user_id, $q = null) 
     8  { 
     9    if(is_null($q)) 
     10      $q = Doctrine::getTable('aFormSubmission')->createQuery('fs'); 
    711 
     12    $q->innerJoin('fs.aFormFieldSubmissions ffs INDEXBY ffs.field_id') 
     13      ->addWhere('fs.user_id = ?', $user_id) 
     14      ->addWhere('fs.form_id = ?', $form_id); 
     15 
     16    return $q; 
     17  } 
    818}