ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 9826


Ignore:
Timestamp:
Jan 1, 2009, 12:06:33 AM (14 years ago)
Author:
ebihara
Message:

#3265,#3264:changed MemberConfigAccessBlock? to display errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/form/MemberConfigForm/MemberConfigAccessBlock.class.php

    r9505 r9826  
    3333    }
    3434
    35     $memberIds = array_merge($this->blockedId, $value);
    36     foreach ($memberIds as $memberId)
     35    foreach ($value as $memberId)
    3736    {
    3837      $relation = MemberRelationshipPeer::retrieveByFromAndTo($this->member->getId(), $memberId);
    3938      if (!$relation)
    4039      {
    41         if (!MemberPeer::retrieveByPK($memberId))
    42         {
    43           continue;
    44         }
    45 
    4640        $relation = new MemberRelationship();
    4741        $relation->setMemberIdFrom($this->member->getId());
     
    6155    {
    6256      $this->setDefault($name, $this->blockedId);
     57
     58      $this->mergePostValidator(new sfValidatorCallback(array(
     59        'callback'  => array('MemberConfigAccessBlockForm', 'validate'),
     60        'arguments' => array('ids' => $this->blockedId),
     61      )));
    6362    }
    6463
    6564    return $result;
    6665  }
     66
     67  public static function validate($validator, $values, $arguments = array())
     68  {
     69    $result = array();
     70
     71    $memberIds = array_merge($arguments['ids'], $values['access_block']);
     72
     73    if (in_array(sfContext::getInstance()->getUser()->getMemberId(), $memberIds))
     74    {
     75      throw new sfValidatorError($validator, 'invalid');
     76    }
     77
     78    foreach ($memberIds as $memberId)
     79    {
     80      if (!$memberId)
     81      {
     82        continue;
     83      }
     84
     85      if (!MemberPeer::retrieveByPK($memberId))
     86      {
     87        throw new sfValidatorError($validator, 'invalid');
     88      }
     89
     90      $result[] = $memberId;
     91    }
     92
     93    $values['access_block'] = $result;
     94    return $values;
     95  }
    6796}
Note: See TracChangeset for help on using the changeset viewer.