public function edit($id)
 {
     $member = $this->members->find($id, ['groups', 'mails', 'accounts']);
     if ($member === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('존재하지 않는 회원입니다.');
         throw $e;
     }
     $ratings = Rating::getUsableAll();
     $ratingNames = ['member' => '일반', 'manager' => '관리자', 'super' => '최고관리자'];
     foreach ($ratings as $key => $rating) {
         $ratings[$key] = ['value' => $rating, 'text' => $ratingNames[$rating]];
         if ($rating === $member->rating) {
             $ratings[$key]['selected'] = 'selected';
         }
     }
     $groupEntities = $this->groups->all();
     $groups = [];
     $joinedGroups = array_pluck($member->groups ?: [], 'id');
     foreach ($groupEntities as $key => $group) {
         $groups[$key] = ['value' => $group->id, 'text' => $group->name];
         if (in_array($group->id, $joinedGroups)) {
             $groups[$key]['checked'] = 'checked';
         }
     }
     $status = [Member::STATUS_ACTIVATED => ['value' => Member::STATUS_ACTIVATED, 'text' => '승인됨'], Member::STATUS_DENIED => ['value' => Member::STATUS_DENIED, 'text' => '거부됨']];
     $status[$member->status]['selected'] = 'selected';
     // profileImage config
     $profileImgSize = config('xe.member.profileImage.size');
     // dynamic field
     $dynamicField = app('xe.dynamicField');
     $fieldTypes = $dynamicField->gets('member');
     $defaultAccount = null;
     if (isset($member->accounts)) {
         foreach ($member->accounts as $account) {
             if ($account->provider === Member::PROVIDER_DEFAULT) {
                 $defaultAccount = $account;
             }
         }
     }
     return Presenter::make('member.settings.member.edit', compact('member', 'ratings', 'groups', 'status', 'defaultAccount', 'fieldTypes', 'profileImgSize'));
 }
 /**
  * getGrant
  *
  * @param $member
  *
  * @return array
  */
 protected function getGrant($member)
 {
     $logged = Auth::user();
     $grant = ['modify' => false, 'manage' => false];
     if ($logged->getId() === $member->getId()) {
         $grant['modify'] = true;
     }
     if (Rating::compare($logged->getRating(), Rating::MANAGER) >= 0) {
         $grant['manage'] = true;
         $grant['modify'] = true;
         return $grant;
     }
     return $grant;
 }
 /**
  * User 가 권한이 있는 등급인지 판별
  *
  * @param string $criterion user rating keyword
  * @return bool
  */
 protected function ratingInspect($criterion)
 {
     if (Rating::compare($this->userRating(), $criterion) == -1) {
         return false;
     }
     return true;
 }
Example #4
0
 /**
  * Finds whether member has manager or super rating.
  *
  * @return boolean
  */
 public function isManager()
 {
     return Rating::compare($this->getRating(), Rating::MANAGER) >= 0;
 }
 /**
  * @expectedException \Xpressengine\Member\Exceptions\UnknownCriterionException
  */
 public function testCampareThrowException()
 {
     Rating::compare(Rating::MEMBER, 'foo');
 }