/** * User 가 권한이 있는 등급인지 판별 * * @param UserInterface $user user instance * @param string $criterion user rating keyword * @return bool */ protected function ratingInspect(UserInterface $user, $criterion) { if (Rating::compare($this->userRating($user), $criterion) == -1) { return false; } return true; }
/** * getGrant * * @param $user * * @return array */ protected function getGrant($user) { $logged = Auth::user(); $grant = ['modify' => false, 'manage' => false]; if ($logged->getId() === $user->getId()) { $grant['modify'] = true; } if (Rating::compare($logged->getRating(), Rating::MANAGER) >= 0) { $grant['manage'] = true; $grant['modify'] = true; return $grant; } return $grant; }
/** * @expectedException \Xpressengine\User\Exceptions\UnknownCriterionException */ public function testCampareThrowException() { Rating::compare(Rating::MEMBER, 'foo'); }
/** * Finds whether user has manager or super rating. * * @return boolean */ public function isManager() { return Rating::compare($this->getRating(), Rating::MANAGER) >= 0; }