예제 #1
0
 /**
  * Rules for validation
  * @return array
  */
 public function rules()
 {
     $rules = [['sex', 'required'], [['city', 'hobby', 'phone', 'url', 'nick', 'birthday'], 'used'], ['nick', 'length_max', '50'], ['city', 'length_max', '50'], ['sex', 'in', [0, 1, 2]], ['hobby', 'length_max', '50'], ['phone', 'phone'], ['url', 'url']];
     // custom profile fields
     foreach (ProfileField::all() as $custom) {
         $rules[] = ['custom_data.' . $custom->id, 'used'];
         $rules[] = ['custom_data.' . $custom->id, (int) $custom->reg_cond === 1 ? 'direct_match' : 'reverse_match', $custom->reg_exp];
     }
     return $rules;
 }
예제 #2
0
파일: show.php 프로젝트: phpffcms/ffcms
if ($custom_fields !== null && Obj::isArray($custom_fields) && count($custom_fields) > 0) {
    ?>
                    <?php 
    foreach ($custom_fields as $cid => $value) {
        ?>
                        <?php 
        if (!Str::likeEmpty($value)) {
            ?>
                            <tr>
                                <td><?php 
            echo ProfileField::getNameById($cid);
            ?>
</td>
                                <td>
                                    <?php 
            if (ProfileField::getTypeById($cid) === 'link') {
                echo Url::link($value, Str::sub($value, 30));
            } else {
                echo \App::$Security->strip_tags($value);
            }
            ?>
                                </td>
                            </tr>
                        <?php 
        }
        ?>
                    <?php 
    }
    ?>
                <?php 
}
예제 #3
0
파일: settings.php 프로젝트: phpffcms/ffcms
<h1><?php 
echo __('Profile settings');
?>
</h1>
<hr />
<?php 
$form = new Form($model, ['class' => 'form-horizontal', 'action' => '', 'method' => 'post']);
echo $form->start();
?>

<?php 
echo $form->field('nick', 'text', ['class' => 'form-control'], __('Enter your nickname or real name'));
echo $form->field('sex', 'select', ['class' => 'form-control', 'options' => ['0' => __('Unknown'), '1' => __('Male'), '2' => __('Female')], 'optionsKey' => true], __('Choose your gender'));
echo $form->field('birthday', 'text', ['class' => 'form-control'], __('Enter your birthday date in d.m.Y format'));
echo $form->field('city', 'text', ['class' => 'form-control'], __('Enter the name of the city where you live'));
echo $form->field('hobby', 'text', ['class' => 'form-control'], __('Enter your hobbies in comma-separated format'));
echo $form->field('phone', 'text', ['class' => 'form-control'], __('Enter your phone number without spaces, if you want to make it public for other users'));
echo $form->field('url', 'text', ['class' => 'form-control'], __('If you have your own homepage - enter url there'));
foreach (ProfileField::all() as $custom) {
    echo $form->field('custom_data.' . $custom->id, 'text', ['class' => 'form-control']);
}
?>

<div class="col-md-9 col-md-offset-3"><?php 
echo $form->submitButton(__('Save'), ['class' => 'btn btn-primary']);
?>
</div>

<?php 
echo $form->finish();
예제 #4
0
파일: Profile.php 프로젝트: phpffcms/ffcms
 /**
  * Delete custom field action
  * @param int $id
  * @return string
  * @throws \Ffcms\Core\Exception\SyntaxException
  * @throws \Ffcms\Core\Exception\NativeException
  * @throws ForbiddenException
  */
 public function actionFielddelete($id)
 {
     if (!Obj::isLikeInt($id) || $id < 1) {
         throw new ForbiddenException();
     }
     // check if record with $id is exist
     $record = ProfileField::find($id);
     if ($record === null || $record === false) {
         throw new ForbiddenException();
     }
     $model = new FormFieldUpdate($record);
     // if delete is submited - lets remove this record
     if ($model->send()) {
         $model->delete();
         $this->response->redirect('profile/fieldlist');
     }
     return $this->view->render('field_delete', ['model' => $model]);
 }