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

Changeset 9589


Ignore:
Timestamp:
Dec 18, 2008, 6:47:56 PM (12 years ago)
Author:
masabon
Message:

#3028:added the defenition of community_config table

Location:
OpenPNE3/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/pc_frontend/templates/_partsBox.php

    r9544 r9589  
    3131<?php echo $option['form'] ?>
    3232<?php endif; ?>
     33<?php include_customizes($id, 'lastRaw') ?>
    3334</table>
    3435<div class="operation">
  • OpenPNE3/trunk/apps/pc_frontend/templates/_partsListBox.php

    r9470 r9589  
    1414<tr>
    1515<th><?php echo $key ?></th>
    16 <td><?php echo $list->getRaw($key) ?></th>
     16<td><?php echo $list->getRaw($key) ?></td>
    1717</tr>
    1818<?php endforeach; ?>
     19<?php include_customizes($id, 'lastRaw') ?>
    1920</table>
    2021
  • OpenPNE3/trunk/config/schema.yml

    r9584 r9589  
    7979    updated_at: ~
    8080    _behaviors:
    81       check_privilage_belong: { class_name: CommunityMember }
     81      check_privilege_belong: { class_name: CommunityMember }
    8282
    8383  community_member:
     
    103103    value: { type: longvarchar }
    104104
     105  community_config:
     106    id: ~
     107    community_id: { type: integer, required: true, foreignTable: community, foreignReference: id, OnDelete:     cascade }
     108    name: { type: varchar(64), required: true }
     109    value: { type: longvarchar }
     110
    105111  home_widget:
    106112    id: ~
  • OpenPNE3/trunk/lib/behavior/opCheckPrivilageBelongBehavior.class.php

    r9448 r9589  
    11<?php
    2 class opCheckPrivilageBelongBehavior
     2class opCheckPrivilegeBelongBehavior
    33{
    4   public function checkPrivilageBelong($object, $member_id)
     4  public function checkPrivilegeBelong($object, $member_id)
    55  {
    66    $this_class = get_class($object);
    7     $class_name = sfConfig::get('propel_behavior_check_privilage_belong_'.$this_class.'_class_name');
     7    $class_name = sfConfig::get('propel_behavior_check_privilege_belong_'.$this_class.'_class_name');
    88
    99    $class = new $class_name();
    1010    $peer = $class->getPeer();
    11     $column_name = get_class($peer).'::MEMBER_ID';
     11    $column_name_member_id = get_class($peer).'::MEMBER_ID';
     12    $column_name_object_id = get_class($peer).'::'.strtoupper($this_class).'_ID';
    1213
    1314    $c = new Criteria();
    14     $c->add(constant($column_name),  $member_id, Criteria::EQUAL);
     15    $c->add(constant($column_name_member_id), $member_id, Criteria::EQUAL);
     16    $c->add(constant($column_name_object_id), $object->getId(),Criteria::EQUAL);
    1517
    1618    $result = $peer->doSelectStmt($c);
     
    2224    }
    2325  }
     26
     27  public function isPrivilegeBelong($object, $member_id)
     28  {
     29    try {
     30      $this->checkPrivilegeBelong($object, $member_id);
     31      return true;
     32    } catch (opPrivilegeException $e) {
     33      return false;
     34    }
     35  }
    2436}
  • OpenPNE3/trunk/lib/config/sfOpenPNEApplicationConfiguration.class.php

    r9582 r9589  
    2525    ));
    2626
    27     sfPropelBehavior::registerMethods('check_privilage_belong', array (
    28       array ('opCheckPrivilageBelongBehavior', 'checkPrivilageBelong'),
     27    sfPropelBehavior::registerMethods('check_privilege_belong', array (
     28      array ('opCheckPrivilegeBelongBehavior', 'checkPrivilegeBelong'),
     29      array ('opCheckPrivilegeBelongBehavior', 'isPrivilegeBelong'),
    2930    ));
    3031  }
  • OpenPNE3/trunk/lib/form/CommunityForm.class.php

    r7861 r9589  
    1212  public function configure()
    1313  {
     14    unset($this['created_at'], $this['updated_at']);
     15
     16    $this->setValidator('config', new sfValidatorPass());
    1417  }
    1518
     
    1720  {
    1821    $community = parent::save($con);
     22    $tainted_values = $this->getTaintedValues();
     23    $community_config_array = $tainted_values['config'];
    1924
    2025    if ($this->isNew()) {
     
    2429      $communityMember->setCommunityId($community->getId());
    2530      $communityMember->save();
     31
     32      foreach ($community_config_array as $community_config_key => $community_config_value)
     33      {
     34        $community_config = new CommunityConfig();
     35        $community_config->setCommunityId($community->getId());
     36        $community_config->setName($community_config_key);
     37        $community_config->setValue($community_config_value);
     38        $community_config->save();
     39      }
     40    }
     41    else
     42    {
     43      foreach ($community_config_array as $community_config_key => $community_config_value)
     44      {
     45        $community_config = CommunityConfigPeer::retrieveByNameAndCommunityId($community_config_key, $community->getId());
     46        $community_config->setValue($community_config_value);
     47        $community_config->save();
     48      }
    2649    }
    2750
Note: See TracChangeset for help on using the changeset viewer.