thanks for the reply.
before continuing, it’s better if i tell you the schema of the tables user and community_user.
CREATE TABLE user(
id INT NOT NULL AUTO_INCREMENT,
clip_id INT,
username VARCHAR(45) NOT NULL,
password CHAR(40) NOT NULL, -- sha1 ?
name VARCHAR(100),
photo VARCHAR(100),
location POINT,
birthday DATE,
sex ENUM('F','M'),
INDEX (id),
PRIMARY KEY (id)
) ENGINE = InnoDB;
CREATE TABLE community_user(
user_id INT NOT NULL,
community_id INT NOT NULL,
is_suspended BOOLEAN DEFAULT FALSE,
can_invite_users BOOLEAN DEFAULT TRUE,
can_manage_objects BOOLEAN DEFAULT TRUE,
can_manage_templates BOOLEAN DEFAULT FALSE,
can_deactivate_community BOOLEAN DEFAULT FALSE,
can_manage_members BOOLEAN DEFAULT FALSE,
can_close_community BOOLEAN DEFAULT FALSE,
can_manage_requests BOOLEAN DEFAULT FALSE,
PRIMARY KEY (user_id, community_id)
) ENGINE = InnoDB;
this is the action in the controller:
public function actionMainIndex(){
if(isset($_GET['community_id'])){
$community = Community::model()->findByPk($_GET['community_id']);
if($community == null){
$message = 'Comunidade inexistente';
$actions = null;
$this->render('/site/errorpage',array('message'=>$message,'actions'=>$actions));
return;
}
$this->layout='application.views.layouts.main';
$dataProvider = new CommunityUser('search');
$dataProvider->setDefaultsToNull();
if(isset($_GET['CommunityUser'])){
$dataProvider->attributes = $_GET['CommunityUser'];
}
$failureMessage = null;
$successMessage = null;
if(isset($_GET['failuremessage']))
$failureMessage = $_GET['failuremessage'];
if(isset($_GET['successmessage']))
$successMessage = $_GET['successmessage'];
$isMember = CommunityController::isCurrentUserMember($community->id);
$this->render('/community/mainindex', array('dataProvider'=>$dataProvider,'community'=>$community, 'isMember'=>$isMember, 'successMessage'=>$successMessage, 'failureMessage'=>$failureMessage));
return;
}else{
$message = 'Parâmetros incorrectos';
$actions = null;
$this->render('/site/errorpage',array('message'=>$message,'actions'=>$actions));
return;
}
}
and now, the view:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'grid',
'dataProvider'=>$dataProvider->search(),
'filter'=>$dataProvider,
'columns'=>array(
'user_id',
array(
'header'=>'Username',
'name'=>'user.username',
'filter'=>CHtml::listData(User::model()->findAll(), 'id', 'username'),
'value'=>'$data->user->username',
),
array(
'name'=>'is_suspended',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("is_suspended")',
),
array(
'name'=>'can_manage_objects',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("can_manage_objects")',
),
array(
'name'=>'can_manage_templates',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("can_manage_templates")',
),
array(
'name'=>'can_deactivate_community',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("can_deactivate_community")',
),
array(
'name'=>'can_manage_members',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("can_manage_members")',
),
array(
'name'=>'can_close_community',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("can_close_community")',
),
array(
'name'=>'can_manage_requests',
'filter'=>array(0=>'Não', 1=> 'Sim'),
'value'=>'$data->getYesNo("can_manage_requests")',
),
array( 'class'=>'CButtonColumn',
'template'=>'{modifyPermissions} {removeUser} {activateUser} {suspendUser}',
'buttons'=>array(
'modifyPermissions' => array(
'label'=>'Modificar permissões do membro', // text label of the button
'url'=>'Yii::app()->createUrl("/community/userrights",array("user_id"=>$data->user_id, "community_id"=>$data->community_id))', // a PHP expression for generating the URL of the button
'imageUrl'=>'images/buttons/16x16/gif/69.gif', // image URL of the button. If not set or false, a text link is used
'htmlOptions'=>array('title'=>'modificar permissões'), // HTML options for the button tag
'visible'=>'1', // a PHP expression for determining whether the button is visible
),
'removeUser' => array(
'label'=>'Remover membro', // text label of the button
'url'=>'Yii::app()->createUrl("/community/removeuser",array("user_id"=>$data->user_id, "community_id"=>$data->community_id))', // a PHP expression for generating the URL of the button
'imageUrl'=>'images/buttons/16x16/gif/33.gif', // image URL of the button. If not set or false, a text link is used
'htmlOptions'=>array('title'=>'remover membro'), // HTML options for the button tag
'visible'=> '!$data->can_manage_members', // a PHP expression for determining whether the button is visible
),
'activateUser' => array(
'label'=>'Activar membro', // text label of the button
'url'=>'Yii::app()->createUrl("/community/activateuser",array("user_id"=>$data->user_id, "community_id"=>$data->community_id))', // a PHP expression for generating the URL of the button
'imageUrl'=>'images/buttons/16x16/gif/3.gif', // image URL of the button. If not set or false, a text link is used
'htmlOptions'=>array('title'=>'activar membro'), // HTML options for the button tag
'visible'=>'$data->is_suspended', // a PHP expression for determining whether the button is visible
),
'suspendUser' => array(
'label'=>'Suspender membro', // text label of the button
'url'=>'Yii::app()->createUrl("/community/suspenduser",array("user_id"=>$data->user_id, "community_id"=>$data->community_id))', // a PHP expression for generating the URL of the button
'imageUrl'=>'images/buttons/16x16/gif/4.gif', // image URL of the button. If not set or false, a text link is used
'visible'=>'!$data->is_suspended', // a PHP expression for determining whether the button is visible
),
)
),
),
)
);?>
The problem is that this solution still leaves any chance of filter out of question…i tried and no success. The only way to put a filter there is by using a field of the model CommunityUser…and that isn’t my objective
Help needed…