hi, Spyros
thanks for your hard working, the extension is so powerful!
Here is my suggestion to add a function for searching the user to the authitem/assignments
AuthitemController.php
public function actionSearchuser() {
$username = '';
if (!empty($_POST['username'])) {
$criteria = new CDbCriteria;
$criteria->condition = $this->module->username.' LIKE "%'.$_POST['username'].'%"';
$userclass = $this->module->userclass;
$users = $userclass::model()->findAll($criteria);
if (count($users)) {
if (count($users) > 1) {
$this->renderPartial('users', array('users'=>$users), false, true);
}
else {
$_GET['id'] = $users[0]->id;
$this->actionShowAssignments();
}
}
else {
throw new CHttpException('401', 'There is no such user.');
}
}
}
add these codes in the file views/authitem/assignments.php under the drop-down list
<?php echo CHtml::beginForm(Yii::app()->createUrl($this->module->id.'/authitem/searchuser'), 'POST', array('id'=>'searchuserForm'));?>
<?php echo CHtml::textField('username');?>
<?php echo CHtml::submitButton('submit');?>
<?php echo CHtml::endForm();?>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$('#searchuserForm').submit(function() {
$.ajax({
url: $('#searchuserForm').attr('action'),
type: 'POST',
data: $('#searchuserForm').serialize(),
beforeSend: function () {
$("#assignments").addClass("srbacLoading");
},
complete: function () {
$("#assignments").removeClass("srbacLoading");
},
success: function (html) {
$("#assignments").html(html);
}
});
return false;
});
});
//]]>
</script>
Create a new file srbac/views/authitem/users.php
<?php echo SHtml::beginForm(); ?>
<?php echo SHtml::activeDropDownList(
$this->module->getUserModel(),
$this->module->userid,
SHtml::listData($users, $this->module->userid, $this->module->username),
array(
'id'=>'users-list',
'size'=>1,
'class'=>'dropdown',
'ajax' => array(
'type'=>'POST',
'url'=>array('showAssignments'),
'update'=>'#assignments',
'beforeSend' => 'function(){
$("#assignments").addClass("srbacLoading");
}',
'complete' => 'function(){
$("#assignments").removeClass("srbacLoading");
}'
),
'prompt'=>Helper::translate('srbac','select user')
)
); ?>
<?php echo SHtml::endForm(); ?>