Example #1
0
 public function joinGroupInvitationExist($userId, $groupId)
 {
     return Censor::find(['typeId', $this->getTypeId(self::TYPE_JOIN_GROUP_INVITE), 'firstId', $userId, "secondId", $groupId, "status", self::UNPROCESS])->first();
 }
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);
 }