Project

General

Profile

t-3588.patch

Shinichi Urabe, 2015-06-09 04:18

Download (3.47 KB)

View differences:

apps/mobile_frontend/modules/community/actions/actions.class.php
140 140
      $this->redirect('community/configImage?id='.$this->id);
141 141
    }
142 142
  }
143
  /**
144
   * Executes edit action
145
   *
146
   * @param sfRequest $request A request object
147
   */
148
  public function executeEdit(opWebRequest $request)
149
  {
150
    $this->unusedFileForm = true;
151

  
152
    return parent::executeEdit($request);
153
  }
154 143
}
lib/action/opCommunityAction.class.php
91 91

  
92 92
    $this->communityForm       = new CommunityForm($this->community);
93 93
    $this->communityConfigForm = new CommunityConfigForm(array(), array('community' => $this->community));
94
    if (!$this->unusedFileForm){$this->communityFileForm = new CommunityFileForm(array(), array('community' => $this->community));}
95
    
96
    if ($request->isMethod('post'))
94
    $this->communityFileForm   = null;
95
    if (!sfConfig::get('app_is_mobile', false))
97 96
    {
98
      $params = $request->getParameter('community');
99
      $params['id'] = $this->id;
100
      $this->communityForm->bind($params);
101
      $this->communityConfigForm->bind($request->getParameter('community_config'));
102
      if($this->communityFileForm)
103
      {
104
        $this->communityFileForm->bind($request->getParameter('community_file'), $request->getFiles('community_file'));
105
        if ($this->communityForm->isValid() && $this->communityConfigForm->isValid() && $this->communityFileForm->isValid())
106
        {
107
          $this->communityForm->save();
108
          $this->communityConfigForm->save();
109
          $this->communityFileForm->save();
97
      $this->communityFileForm = new CommunityFileForm(array(), array('community' => $this->community));
98
    }
110 99

  
111
          $this->redirect('@community_home?id='.$this->community->getId());
112
        }
113
      }
114
      elseif ($this->communityForm->isValid() && $this->communityConfigForm->isValid())
115
      {
116
        $this->communityForm->save();
117
        $this->communityConfigForm->save();
100
    if ($request->isMethod(sfRequest::POST) && $this->processForms($this->communityForm, $this->communityConfigForm, $this->communityFileForm))
101
    {
102
      $this->redirect('@community_home?id='.$this->community->getId());
103
    }
104
  }
118 105

  
119
        $this->redirect('@community_home?id='.$this->community->getId());
106
  protected function processForms(CommunityForm $communityForm, CommunityConfigForm $communityConfigForm, CommunityFileForm $communityFileForm = null)
107
  {
108
    $request = $this->getRequest();
109
    $forms = array($communityForm, $communityConfigForm);
110
    if ($communityFileForm)
111
    {
112
      $forms[] = $communityFileForm;
113
    }
114

  
115
    $okCount = 0;
116
    foreach ($forms as $form)
117
    {
118
      $name = $form->getName();
119
      $form->bind($request->getParameter($name), $request->getFiles($name));
120
      if ($form->isValid())
121
      {
122
        $okCount++;
120 123
      }
121 124
    }
125

  
126
    if ($okCount !== count($forms))
127
    {
128
      return false;
129
    }
130

  
131
    foreach ($forms as $form)
132
    {
133
      $form->save();
134
    }
135

  
136
    return true;
122 137
  }
123 138

  
124 139
 /**