Пример #1
0
function myVerifyFunction($params)
{
    $verified = "false";
    $role = $params['role'];
    $user = $params['user'];
    $projectId = array_key_exists('project', $params) ? $params['project'] : '';
    // Get the list of roles (so we can compare)
    $roles = Role::getRoles();
    // Target role value
    $targetValue = $roles[$role];
    // Split on colon
    $roleParts = explode(':', $role);
    if ($roleParts[0] == "user") {
        // If it's a user-level role, get user role field and get value
        if (array_key_exists($user->role, $roles)) {
            $userValue = $roles[$user->role];
        }
    } else {
        if ($roleParts[0] == "project") {
            // It's a project-level role
            if (array_key_exists($projectId, $user->projectRoles) && array_key_exists($user->projectRoles[$projectId], $roles)) {
                $userValue = $roles[$user->projectRoles[$projectId]];
            }
        }
    }
    echo "Verifying ({$userValue} >= {$targetValue})...";
    if ($userValue >= $targetValue) {
        $verified = "true";
    }
    echo "{$verified}.\n";
}
Пример #2
0
 public function testNormalRole()
 {
     $role = Role::get($this->normalRole->getId());
     $this->player_b->addRole($role->getId());
     $this->assertFalse($role->displayAsLeader());
     $this->assertFalse($role->isProtected());
     $this->assertEquals("Sample Normal Role", $role->getName());
     $this->assertArrayContainsModel($role, Role::getRoles($this->player_b->getId()));
     $this->wipe($role);
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 protected function build($builder)
 {
     $emailConstraints = array(new Length(array('max' => 255)));
     if (!\Service::isDebug()) {
         // Don't validate e-mails when developing, for example to allow
         // messaging anyone@localhost
         $emailConstraints[] = new Email();
     }
     $builder->add('description', 'textarea', array('constraints' => new Length(array('max' => 8000)), 'data' => $this->editing->getDescription(), 'required' => false))->add('avatar', 'file', array('constraints' => new Image(array('minWidth' => 50, 'minHeight' => 50, 'maxSize' => '4M')), 'required' => false))->add('delete_avatar', 'submit')->add('country', 'choice', array('choices' => \Country::getCountriesWithISO(), 'data' => $this->editing->getCountry()->getISO(), 'required' => false))->add('email', 'email', array('constraints' => $emailConstraints, 'data' => $this->editing->getEmailAddress(), 'label' => 'E-Mail Address', 'required' => false))->add('receive', 'choice', array('choices' => array('nothing' => 'Nothing', 'messages' => 'Messages only', 'everything' => 'Everything'), 'data' => $this->editing->getReceives(), 'label' => 'Receive notifications about', 'expanded' => true, 'placeholder' => false, 'required' => false))->add('timezone', new TimezoneType($this->editing->getTimezone()), array('constraints' => new NotBlank(), 'data' => $this->editing->getTimezone()));
     if (!$this->editingSelf) {
         $builder->add('roles', new ModelType('Role', false), array('constraints' => new NotBlank(), 'data' => \Role::getRoles($this->editing->getId()), 'multiple' => true));
     }
     $builder->add('enter', 'submit');
     $address = $this->editing->getEmailAddress();
     if (!$this->editingSelf && !empty($address) && !$this->editing->isVerified()) {
         // Show a button to verify an unverified user's e-mail address to
         // admins
         $builder->add('verify_email', 'submit', array('attr' => array('class' => 'c-button--grey'), 'label' => 'Verify E-Mail address'));
     }
     return $builder;
 }
Пример #4
0
                  <?php 
            }
            ?>
              </div>
              <br />
              <div class="row">
                <div class="col-sm-8">
                  <select class="selectpicker" name="role_select_<?php 
            echo $item->id;
            ?>
" id="role_select_<?php 
            echo $item->id;
            ?>
">
                    <?php 
            $roles = Role::getRoles($db);
            foreach ($roles as $role) {
                echo "<option value=\"" . $role['role_id'] . "\">" . $role['role_name'] . "</option>";
            }
            ?>
                  </select>
                </div>
                <div class="col-sm-4">
                  <button type="button" class="btn btn-default add_user_role" id="<?php 
            echo $item->id;
            ?>
">Add Role</button>
                </div>
              </div>
            </div>
          </div>
Пример #5
0
 /**
  * Rebuild the list of permissions a user has been granted
  */
 private function updateUserPermissions()
 {
     $this->roles = Role::getRoles($this->id);
     $this->permissions = array();
     foreach ($this->roles as $role) {
         $this->permissions = array_merge($this->permissions, $role->getPerms());
     }
 }