Example #1
0
 public function actionDecline($censorId = null)
 {
     $censor = Censor::get($censorId);
     if ($censor !== null) {
         $groupUser = new GroupUser();
         $groupUser->groupId = $censor->secondId;
         $groupUser->userId = $censor->firstId;
         $groupUser->joinTime = date('Y-m-d H:i:s');
         $groupUser->status = 1;
         if (!GroupUser::isUserInGroup($groupUser->userId, $groupUser->groupId)) {
             $this->flash("message", "The request is processed.");
             $group = Group::get($groupUser->groupId);
             $title = "Join group request declined";
             $content = 'Group creator have declined your request of joining in group ' . RHtml::linkAction('group', $group->name, 'detail', $group->id);
             $content = RHtml::encode($content);
             Message::sendMessage("group", $group->id, $groupUser->userId, $title, $content);
         } else {
             $this->flash("warning", "TA is already a member of this group.");
         }
         $censor->fail();
         $this->redirectAction('message', 'view');
     }
 }
Example #2
0
 /**
  * Process VIP
  * by songrenchu
  */
 public function actionProcessVIP()
 {
     $this->setHeaderTitle('Censor VIP');
     $this->layout = 'admin';
     $data = array();
     if (isset($_GET['censorId']) && isset($_GET['op'])) {
         $censor = Censor::get($_GET['censorId']);
         if ($censor !== null) {
             if ((int) $_GET['op'] === 0) {
                 $user = User::get($censor->firstId);
                 $user->roleId = Role::VIP_ID;
                 $user->save();
                 $censor->pass();
                 $content = "Congratulations, " . RHtml::linkAction('user', $user->name, 'view', $user->id) . "!<br/> Your VIP application is accepted by Administrator.";
                 Message::sendMessage("system", 0, $user->id, "VIP application accepted", RHtml::encode($content), '');
             } else {
                 $censor->fail();
                 $user = User::get($censor->firstId);
                 $content = "Sorry, " . RHtml::linkAction('user', $user->name, 'view', $user->id) . "!<br/> Your VIP application is declined by Administrator.";
                 Message::sendMessage("system", 0, $user->id, "VIP application declined", RHtml::encode($content), '');
             }
         }
         $this->redirectAction('user', 'processVIP');
     }
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 5);
     $query = Censor::find(['status', Censor::UNPROCESS, 'typeId', (new Censor())->getTypeId("apply_vip")]);
     $count = $data['count'] = $query->count();
     $applications = $query->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
     $data['applications'] = $applications;
     $users = [];
     foreach ($applications as $apply) {
         $user = User::get($apply->firstId);
         $users[] = $user;
     }
     $data['users'] = $users;
     $url = RHtml::siteUrl('user/processVIP');
     $pager = new RPager('page', $count, $pageSize, $url, $curPage);
     $pager = $pager->showPager();
     $data['pager'] = $pager;
     $this->render('process_vip', $data, false);
 }