public function actionCreate()
 {
     $this->layout = Yum::module()->adminLayout;
     $model = new YumProfileField();
     // add to group?
     if (isset($_GET['in_group'])) {
         $model->field_group_id = $_GET['in_group'];
     }
     if (isset($_POST['YumProfileField'])) {
         $model->attributes = $_POST['YumProfileField'];
         $field_type = $model->field_type;
         if ($field_type == 'DROPDOWNLIST') {
             $field_type = 'INTEGER';
         }
         if ($model->validate()) {
             $sql = 'ALTER TABLE ' . YumProfile::model()->tableName() . ' ADD `' . $model->varname . '` ';
             $sql .= $field_type;
             if ($field_type != 'TEXT' && $field_type != 'DATE') {
                 $sql .= '(' . $model->field_size . ')';
             }
             $sql .= ' NOT NULL ';
             if ($model->default) {
                 $sql .= " DEFAULT '" . $model->default . "'";
             } else {
                 $sql .= $field_type == 'TEXT' || $model->field_type == 'VARCHAR' ? " DEFAULT ''" : " DEFAULT 0";
             }
             $model->dbConnection->createCommand($sql)->execute();
             $model->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Yum::requiredFieldNote();
?>
</p>

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'privacysetting-form', 'enableAjaxValidation' => true));
echo $form->errorSummary($model);
?>

<div class="profile_field_selection">
<?php 
echo '<h3>' . Yum::t('Profile field public options') . '</h3>';
echo '<p>' . Yum::t('Select the fields that should be public') . ':</p>';
$i = 1;
$counter = 0;
foreach (YumProfileField::model()->findAll() as $field) {
    $counter++;
    if ($counter == 1) {
        echo '<div class="float-left" style="width: 175px;">';
    }
    printf('<div>%s<label class="profilefieldlabel" for="privacy_for_field_%d">%s</label></div>', CHtml::checkBox("privacy_for_field_{$i}", $model->public_profile_fields & $i), $i, Yum::t($field->title));
    $i *= 2;
    if ($counter % 4 == 0) {
        echo '</div><div class="float-left" style="width: 175px;">';
    }
}
if ($counter % 4 != 0) {
    echo '</div>';
}
echo '<div class="clear"></div>';
?>
 /**
  * Load profile fields.
  * Overwrite this method to get another set of fields
  * @since 0.6
  * @return array of YumProfileFields or empty array
  */
 public function loadProfileFields()
 {
     if (self::$fields === null) {
         self::$fields = YumProfileField::model()->cache(3600)->findAll();
         if (self::$fields == null) {
             self::$fields = array();
         }
     }
     return self::$fields;
 }
<?php 
if (!Yum::module()->loginType & UserModule::LOGIN_BY_EMAIL) {
    ?>
<tr>
	<th class="label"><?php 
    echo CHtml::encode($model->getAttributeLabel('username'));
    ?>
</th>
    <td><?php 
    echo CHtml::encode($model->username);
    ?>
</td>
</tr>
<?php 
}
$profileFields = YumProfileField::model()->forOwner()->sort()->with('group')->together()->findAll();
if ($profileFields && Yum::hasModule('profile')) {
    foreach ($profileFields as $field) {
        if ($field->field_type == 'DROPDOWNLIST') {
            ?>
			<tr>
				<th class="label"><?php 
            echo CHtml::encode(Yum::t($field->title));
            ?>
				</th>
				<td><?php 
            if (is_object($model->profile->{ucfirst($field->varname)})) {
                echo CHtml::encode($model->profile->{ucfirst($field->varname)}->{$field->related_field_name});
            }
            ?>
						</td>
?>
		<?php 
echo CHtml::error($model, 'position');
?>
		<p class="hint"><?php 
echo Yii::t("UserModule.user", 'Display order of fields.');
?>
</p>
	</div>

	<div class="row">
		<?php 
echo CHtml::activeLabelEx($model, 'visible');
?>
		<?php 
echo CHtml::activeDropDownList($model, 'visible', YumProfileField::itemAlias('visible'));
?>
		<?php 
echo CHtml::error($model, 'visible');
?>
	</div>

	<div class="row buttons">
	<?php 
echo CHtml::submitButton($model->isNewRecord ? Yum::t('Create') : Yum::t('Save'));
?>
	</div>

<?php 
echo CHtml::endForm();
?>
Exemplo n.º 6
0
			)
		);

	$this->widget('zii.widgets.CDetailView', array(
				'data'=>$model,
				'attributes'=>$attributes,
				));

} else {
	// For all users
	$attributes = array(
			'username',
			);

	if($profiles) {
		$profileFields = YumProfileField::model()->forAll()->findAll();
		if ($profileFields) {
			foreach($profileFields as $field) {
				array_push($attributes,array(
							'label' => Yii::t('UserModule.user', $field->title),
							'name' => $field->varname,
							'value' => $model->profile->getAttribute($field->varname),
							));
			}
		}
	}

	array_push($attributes,
			array(
				'name' => 'createtime',
				'value' => date(UserModule::$dateFormat,$model->createtime),
}
?>

<table class="dataGrid">
<tr>
	<th class="label"><?php 
echo CHtml::encode($model->getAttributeLabel('username'));
?>
</th>
    <td><?php 
echo CHtml::encode($model->username);
?>
</td>
</tr>
<?php 
$profileFields = YumProfileField::model()->forOwner()->sort()->findAll();
if ($profileFields) {
    foreach ($profileFields as $field) {
        ?>
<tr>
	<th class="label"><?php 
        echo CHtml::encode(Yii::t('UserModule.user', $field->title));
        ?>
</th>
    <td><?php 
        echo CHtml::encode($profile->getAttribute($field->varname));
        ?>
</td>
</tr>
			<?php 
    }