Example #1
0
 /** @relation-command */
 public function addOwnerUser($userID)
 {
     $relation = new UserMemberGroup();
     $relation->user_id = $userID;
     $relation->group_id = $this->id;
     $relation->joinded_datetime = DateTimeHelper::now();
     $relation->is_leader = 1;
     // remember to use 1 for boolean, using true will not make this record saving
     $relation->is_approved = 1;
     $relation->save();
 }
Example #2
0
 public function actionDisapproveUser($id, $groupId)
 {
     $model = Group::model()->findByPk($groupId);
     $currentUesrId = Yii::App()->user->id;
     if (!$model->isGroupOwners($currentUesrId)) {
         throw new CHttpException(404, "You are not the owner");
     }
     $relation = UserMemberGroup::model()->findByPk(array('user_id' => $id, 'group_id' => $groupId));
     $relation->is_approved = 0;
     if ($relation->save()) {
         $this->redirect(Yii::app()->request->urlReferrer);
     }
 }