コード例 #1
0
 public function getFieldValueForDisplay($field, $userId)
 {
     // Check to see if we have that field user combination
     $row = UserCustomFieldData::model()->find('field_id=:field AND user_id=:user', array(':field' => $field->id, ':user' => $userId));
     if ($row) {
         // Return the value
         $value = $row->value;
     } else {
         // Return default
         $value = $field->default_value;
     }
     if ($field->type == 'yesno') {
         $text = $value ? at('Yes') : at('No');
     } elseif ($field->type == 'checkbox') {
         $text = $value ? at('Checked') : at('Not Checked');
     } elseif ($field->type == 'dropdown') {
         $valueArray = UserCustomField::model()->convertExtraToArray($field->extra);
         $text = is_array($valueArray) && isset($valueArray[$value]) ? $valueArray[$value] : $value;
     } elseif ($field->type == 'multi') {
         $valueArray = UserCustomField::model()->convertExtraToArray($field->extra);
         $selectedValue = explode(',', $value);
         if (count($selectedValue)) {
             $arr = array();
             foreach ($selectedValue as $selectedVal) {
                 $arr[] = is_array($valueArray) && isset($valueArray[$selectedVal]) ? $valueArray[$selectedVal] : $selectedVal;
             }
             $text = implode(', ', $arr);
         } else {
             $text = is_array($valueArray) && isset($valueArray[$selectedValue]) ? $valueArray[$selectedValue] : $selectedValue;
         }
     } else {
         $text = $value;
     }
     return $text;
 }
コード例 #2
0
ファイル: form.php プロジェクト: YiiCoded/yii-ecommerce
			<div class="grid-9-12">
				<?php 
$this->widget('CMaskedTextField', array('mask' => '999 999 9999', 'model' => $model, 'attribute' => 'fax'));
?>
				<?php 
echo CHtml::error($model, 'fax');
?>
			</div>
			<div class="clear"></div>
			<hr />
			
		</div>
		
		<div id="tabs-3">
			<?php 
$customFields = UserCustomField::model()->getFieldsForAdmin();
?>
			<?php 
if (count($customFields)) {
    ?>
				<?php 
    foreach ($customFields as $customField) {
        ?>
					<div class="grid-3-12"><?php 
        echo CHtml::label($customField->getTitle(), $customField->getKey());
        ?>
</div>
					<div class="grid-9-12">
						<?php 
        echo $customField->getFormField($model->id);
        ?>
コード例 #3
0
ファイル: index.php プロジェクト: qhyabdoel/hris_mujigae
<!-- PAGE TITLE -->
<div class="page-title">                    
	<h2><span class="fa fa-arrow-circle-o-left"></span> Users - Custom Fields</h2>
</div>
<!-- END PAGE TITLE -->

<div class="row">
    <div class="col-md-12">

		<!-- START DEFAULT DATATABLE -->
		<div class="panel panel-default">
			<div class="panel-heading">                                
				<h3 class="panel-title"><?php 
echo CHtml::link(at('Create User`s Custom Field'), array('usercustomfields/create'), array('class' => 'btn btn-primary'));
?>
</h3>
				<ul class="panel-controls">
					<li><a href="#" class="panel-refresh"><span class="fa fa-refresh"></span></a></li>
				</ul>                                
			</div>
			<div class="panel-body">
				<?php 
$this->widget('CGridView', array('id' => 'user-custom-field-grid', 'itemsCssClass' => 'table datatable', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'header' => '#', 'htmlOptions' => array('style' => 'width:50px;')), array('name' => 'title', 'header' => 'Title'), array('name' => 'type', 'filter' => UserCustomField::model()->fieldType, 'header' => 'Type'), array('name' => 'status', 'filter' => array(0 => at('Public'), 1 => at('Hidden')), 'header' => 'Status', 'value' => '$data->status ? at("Public") : at("Hidden")'), array('name' => 'is_public', 'filter' => array(0 => at('Yes'), 1 => at('No')), 'header' => 'On Site', 'value' => '$data->is_public ? at("Yes") : at("No")'), array('name' => 'is_editable', 'filter' => array(0 => at('Yes'), 1 => at('No')), 'header' => 'Editable', 'value' => '$data->is_editable ? at("Yes") : at("No")'), array('name' => 'created_at', 'filter' => false, 'header' => 'Created Date', 'value' => 'timeSince($data->created_at)'), array('name' => 'author_id', 'filter' => false, 'header' => 'Author', 'type' => 'raw', 'htmlOptions' => array('style' => 'width: 100px'), 'value' => '$data->getAuthorLink("author")'), array('name' => 'updated_at', 'filter' => false, 'header' => 'Updated Date', 'value' => 'timeSince($data->updated_at)'), array('name' => 'updated_author_id', 'filter' => false, 'header' => 'Last Author', 'type' => 'raw', 'htmlOptions' => array('style' => 'width: 150px'), 'value' => '$data->getAuthorLink("last_author")'), array('class' => 'CButtonColumn', 'htmlOptions' => array('style' => 'width: 50px'), 'template' => '{update}{delete}'))));
?>
			</div>
		</div>
		<!-- END DEFAULT DATATABLE -->
	</div>
</div>

<div class="clear"></div>
コード例 #4
0
ファイル: form.php プロジェクト: YiiCoded/yii-ecommerce
echo CHtml::activeTextField($model, 'description');
?>
						<?php 
echo CHtml::error($model, 'description');
?>
					</div>
					<div class="clear"></div>
					<hr />
					
					<div class="grid-3-12"><?php 
echo CHtml::activeLabelEx($model, 'type');
?>
</div>
					<div class="grid-9-12">
						<?php 
echo CHtml::activeDropDownList($model, 'type', UserCustomField::model()->getTypes(), array('prompt' => at('-- Choose Value --'), 'class' => 'chzn-select validate[required]'));
?>
						<?php 
echo CHtml::error($model, 'type');
?>
					</div>
					<div class="clear"></div>
					<hr />
					
					<div class="grid-3-12"><?php 
echo CHtml::activeLabelEx($model, 'status');
?>
</div>
					<div class="grid-9-12">
						<?php 
echo CHtml::activeDropDownList($model, 'status', array(0 => at('Hidden'), 1 => at('Active')), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'class' => 'chzn-select'));
コード例 #5
0
 public function getFieldsForAdmin()
 {
     return UserCustomField::model()->isActive()->findAll();
 }
コード例 #6
0
 /**
  * Delete field action
  */
 public function actionDelete()
 {
     // Check Access
     checkAccessThrowException('op_usercustomfields_deleteposts');
     if (isset($_GET['id']) && ($model = UserCustomField::model()->findByPk($_GET['id']))) {
         alog(at("Deleted Custom Field '{name}'.", array('{name}' => $model->title)));
         $model->delete();
         fok(at('Field Deleted.'));
         $this->redirect(array('usercustomfields/index'));
     } else {
         $this->redirect(array('usercustomfields/index'));
     }
 }
コード例 #7
0
ファイル: User.php プロジェクト: YiiCoded/yii-ecommerce
 public function getFieldsAttributes()
 {
     $fields = UserCustomField::model()->getFieldsForAdmin();
     $arr = array();
     foreach ($fields as $field) {
         $arr[] = array('name' => $field->getKey(), 'label' => $field->getTitle());
     }
     return $arr;
 }
コード例 #8
0
 /**
  * Update user
  */
 public function actionUpdate($id)
 {
     // Check Access
     checkAccessThrowException('op_users_update');
     $model = User::model()->findByPk($id);
     if ($model) {
         if (isset($_POST['User'])) {
             $model->setAttributes($_POST['User']);
             if ($model->save()) {
                 if (isset($_POST['UserCustomField'])) {
                     UserCustomField::model()->processCustomFields($_POST['UserCustomField'], $model->id);
                 }
                 // Loop through the roles and assign them
                 $types = array('roles', 'tasks', 'operations');
                 $lastID = $model->id;
                 $allitems = Yii::app()->authManager->getAuthItems(null, $lastID);
                 if (count($allitems)) {
                     foreach ($allitems as $allitem) {
                         Yii::app()->authManager->revoke($allitem->name, $lastID);
                     }
                 }
                 foreach ($types as $type) {
                     if (isset($_POST[$type]) && count($_POST[$type])) {
                         foreach ($_POST[$type] as $others) {
                             // assign if not assigned yet
                             if (!Yii::app()->authManager->isAssigned($others, $lastID)) {
                                 $authItem = Yii::app()->authManager->getAuthItem($others);
                                 Yii::app()->authManager->assign($others, $lastID, $authItem->bizrule, $authItem->data);
                             }
                         }
                     }
                 }
                 fok(at('User Updated!'));
                 // Log Message
                 alog(at("Updated user: '******'.", array('{name}' => $model->name)));
                 $this->redirect(array('index'));
             }
         }
         $temp = Yii::app()->authManager->getAuthItems();
         $items = array(CAuthItem::TYPE_ROLE => array(), CAuthItem::TYPE_TASK => array(), CAuthItem::TYPE_OPERATION => array());
         if (count($temp)) {
             foreach ($temp as $item) {
                 $items[$item->type][$item->name] = $item->name;
             }
         }
         // Selected
         $temp_selected = Yii::app()->authManager->getAuthItems(null, $model->id);
         $items_selected = array();
         if (count($temp)) {
             foreach ($temp_selected as $item_selected) {
                 $items_selected[$item_selected->type][$item_selected->name] = $item_selected->name;
             }
         }
         // Add Breadcrumb
         $this->addBreadCrumb(at('Update User'));
         $this->title[] = at('Update User');
         $this->render('form', array('model' => $model, 'items_selected' => $items_selected, 'items' => $items));
     } else {
         throw new CHttpException(404, at('Sorry, That record was not found.'));
     }
 }