Example #1
0
 public function actionQuitGroup($groupid)
 {
     $session = Yii::$app->session;
     //群不存在
     if (empty(Groups_info::find()->where(['groupid' => $groupid])->one())) {
         $message = '该群不存在';
     } else {
         if (!in_array($groupid, $session['groupid'])) {
             echo "你不是该群成员";
         } else {
             //删除成员
             Group_mem::deleteAll(['groupid' => $groupid, 'userid' => $session['user']]);
             return $this->redirect('?r=forum/group');
         }
     }
 }
Example #2
0
<?php 
$form = ActiveForm::begin();
?>
	<?php 
echo $form->field($addgroupform, 'groupid', ['labelOptions' => ['label' => '群号']]);
?>
	<div>
		<?php 
echo Html::submitButton('加入群', ['class' => 'btn btn-primary']);
?>
	</div>
<?php 
ActiveForm::end();
?>

<?php 
if (empty($session['user'])) {
    echo '请';
    echo Html::tag('a', '登陆', ['href' => '?r=forum/lee-login']);
} else {
    if (empty($session['property'])) {
        echo '你还没有加入群';
    } else {
        echo '我的群:<br>';
        foreach ($groupid as $gid) {
            $x = Groups_info::findOne($gid);
            $x = $x['name'];
            echo '<li>' . Html::tag('a', $x, ['href' => '?r=forum/group-info&groupid=' . $gid]) . '<br>' . '</li>';
        }
    }
}