示例#1
0
文件: api.php 项目: uzura8/flockbird
 private function check_id_and_get_profile($profile_id)
 {
     if (!$profile_id || !($profile = \Model_Profile::check_authority($profile_id))) {
         throw new \HttpNotFoundException();
     }
     if (!in_array($profile->form_type, \Site_Profile::get_form_types_having_profile_options())) {
         throw new \HttpInvalidInputException();
     }
     return $profile;
 }
示例#2
0
文件: list.php 项目: uzura8/flockbird
        ?>
</td>
	<td><?php 
        echo symbol_bool($profile->is_disp_regist);
        ?>
</td>
	<td><?php 
        echo symbol_bool($profile->is_disp_config);
        ?>
</td>
	<td><?php 
        echo symbol_bool($profile->is_disp_search);
        ?>
</td>
	<td><?php 
        if (in_array($profile->form_type, Site_Profile::get_form_types_having_profile_options())) {
            echo Html::anchor('admin/profile/options/' . $profile->id, term('site.list'));
        } else {
            echo symbol('noValue');
        }
        ?>
</td>
</tr>
<?php 
    }
    ?>
</table>
<?php 
} else {
    echo term('profile', 'site.item');
    ?>
示例#3
0
 /**
  * The edit_options action.
  * 
  * @access  public
  * @return  void
  */
 public function action_edit_options($id = null)
 {
     if (!$id || !($profile = \Model_Profile::find($id))) {
         throw new \HttpNotFoundException();
     }
     if (!in_array($profile->form_type, \Site_Profile::get_form_types_having_profile_options())) {
         throw new \HttpInvalidInputException();
     }
     $profile_options = \Model_ProfileOption::get4profile_id($id);
     $posted_vals = array();
     if (\Input::method() == 'POST') {
         try {
             \Util_security::check_csrf();
             $posted_vals = \Input::post('labels');
             if (count($posted_vals) != count($profile_options)) {
                 throw new \httpinvalidinputexception();
             }
             \DB::start_transaction();
             foreach ($profile_options as $profile_option) {
                 $value = $posted_vals[$profile_option->id];
                 if (!strlen($value)) {
                     throw new \httpinvalidinputexception('未入力の項目があります。');
                 }
                 if ($value !== $profile_option->label) {
                     $profile_option->label = $value;
                     $profile_option->save();
                 }
             }
             \DB::commit_transaction();
             \Session::set_flash('message', term('profile', 'form.choices') . 'を編集しました。');
             \Response::redirect('admin/profile/options/' . $profile->id);
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $vals = array();
     foreach ($profile_options as $profile_option) {
         $vals[$profile_option->id] = isset($posted_vals[$profile_option->id]) ? $posted_vals[$profile_option->id] : $profile_option->label;
     }
     $this->set_title_and_breadcrumbs(sprintf('%s %s: %s', term('profile'), term('form.edit'), $profile->caption));
     $this->template->content = \View::forge('profile/edit_options', array('profile' => $profile, 'vals' => $vals, 'profile_options' => $profile_options));
 }