public function actionAdd($userId = null) { // the user whose id = $userId // loaded in beforeAction() method // $user = $this->filteredUser(); $uid = Rays::user()->id; if ($uid !== $userId) { $content = $this->renderPartial('_add_friend_msg', array('user' => Rays::user()), true); Message::sendMessage("system", $uid, $userId, "Friend request", $content); //add friend censor item $censor = new Censor(); $censor->addFriendApplication($uid, $userId); $this->flash('message', 'Adding friend request has been sent.'); $this->redirectAction('user', 'view', $userId); } }
/** * Check username for profanity. * * @param Validate Validate object * @param string field name * @return void */ public function censor(Validate $array, $field) { $censor = Censor::factory($array[$field]); if ($censor->is_offensive()) { $array->error($field, 'censor', array($array[$field])); return FALSE; } }
public function joinGroupInvitationExist($userId, $groupId) { return Censor::find(['typeId', $this->getTypeId(self::TYPE_JOIN_GROUP_INVITE), 'firstId', $userId, "secondId", $groupId, "status", self::UNPROCESS])->first(); }
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'); } }
/** * 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); }
public static function inviteFriends($groupId, $user, $invitees = array(), $invitationMsg) { $group = Group::get($groupId); foreach ($invitees as $friendId) { $censor = new Censor(); $censor->joinGroupApplication($friendId, $group->id); $content = RHtml::linkAction('user', $user->name, 'view', $user->id) . ' invited you to join group ' . RHtml::linkAction('group', $group->name, 'detail', $group->id) . ' ' . RHtml::linkAction('group', 'Accept invitation', 'acceptInvite', $censor->id, array('class' => 'btn btn-xs btn-info')) . '</br>' . $invitationMsg; $content = RHtml::encode($content); Message::sendMessage('user', $user->id, $friendId, 'new group invitation', $content); } }