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

Changeset 8770


Ignore:
Timestamp:
Oct 23, 2008, 2:34:48 PM (11 years ago)
Author:
ebihara
Message:

#2888:changed SnsConfig? to enable configuring for multiple authentication

Location:
OpenPNE3/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/data/sns_config.yml

    r8757 r8770  
    1515pc_frontend_auth_mode:
    1616  caption:      "PC版認証方法"
    17   type:         "select"
     17  type:         "selectMany"
    1818  choices_type: "AuthMode"
    1919  default:      ["PCAddress"]
     
    2323mobile_frontend_auth_mode:
    2424  caption:      "携帯版版認証方法"
    25   type:         "select"
     25  type:         "selectMany"
    2626  choices_type: "AuthMode"
    2727  default:      ["MobileUID", "MobileAddress"]
  • OpenPNE3/trunk/lib/form/SnsConfigForm.class.php

    r8768 r8770  
    4444        $obj = new sfWidgetFormSelect(array('choices' => $this->generateChoices($config['choices_type'])));
    4545        break;
     46      case 'selectMany':
     47        $obj = new sfWidgetFormSelectMany(array('choices' => $this->generateChoices($config['choices_type'])));
     48        break;
    4649      case 'input':
    4750      default:
     
    5659    switch ($config['type']) {
    5760      case 'select':
    58         $obj = new sfValidatorChoice(array('choices' => $this->generateChoices($config['choices_type'])));
     61      case 'selectMany':
     62        $obj = new sfValidatorChoiceMany(array('choices' => $this->generateChoices($config['choices_type'])));
    5963        break;
    6064      case 'input':
     
    6872  public function save()
    6973  {
     74    $config = OpenPNEConfig::loadConfigYaml();
    7075    foreach ($this->getValues() as $key => $value) {
    7176      $snsConfig = SnsConfigPeer::retrieveByName($key);
     
    7479        $snsConfig->setName($key);
    7580      }
     81
    7682      $snsConfig->setValue($value);
    7783      $snsConfig->save();
  • OpenPNE3/trunk/lib/model/SnsConfig.php

    r7906 r8770  
    1010class SnsConfig extends BaseSnsConfig
    1111{
     12  var $snsConfigSettings = array();
     13
     14  public function __construct()
     15  {
     16    $this->snsConfigSettings = OpenPNEConfig::loadConfigYaml('sns');
     17  }
     18
     19  public function getValue()
     20  {
     21    $value = parent::getValue();
     22
     23    $config = $this->getConfig();
     24    if ($config && 'selectMany' === $config['type'])
     25    {
     26      $value = unserialize($value);
     27    }
     28
     29    return $value;
     30  }
     31
     32  public function setValue($v)
     33  {
     34    $config = $this->getConfig();
     35
     36    if ($config && 'selectMany' === $config['type'])
     37    {
     38      $v = serialize($v);
     39    }
     40
     41    parent::setValue($v);
     42  }
     43
     44  public function getConfig()
     45  {
     46    $name = $this->getName();
     47    if ($name) {
     48      return $this->snsConfigSettings[$name];
     49    }
     50
     51    return false;
     52  }
     53
    1254}
Note: See TracChangeset for help on using the changeset viewer.