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

source: OpenPNE3/trunk/apps/pc_backend/modules/community/lib/DefaultCommunityForm.class.php @ 11200

Last change on this file since 11200 was 11200, checked in by ShogoKawahara, 13 years ago

#3317,#3761:added ability to manage communities and added ability to configure default communities

File size: 1.2 KB
Line 
1<?php 
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11/**
12 * default community form
13 *
14 * @package    OpenPNE
15 * @subpackage form
16 * @author     Shogo Kawahara <kawahara@tejimaya.com>
17 */
18class DefaultCommunityForm extends sfForm
19{
20  public function configure()
21  {
22    $this->setWidgets(array(
23      'id'  => new sfWidgetFormInput(),
24    ));
25
26    $this->setValidators(array(
27      'id' => new sfValidatorInteger(),
28    ));
29
30    $this->widgetSchema->setNameFormat('community[%s]');
31  }
32
33  public function save()
34  {
35    $community = CommunityPeer::retrieveByPk($this->getValue('id'));
36
37    if (!$community)
38    {
39      return false;
40    }
41
42    $communityConfig = CommunityConfigPeer::retrieveByNameAndCommunityId('is_default', $community->getId());
43
44    if (!$communityConfig)
45    {
46      $communityConfig = new CommunityConfig();
47    }
48    $communityConfig->setCommunity($community);
49    $communityConfig->setName('is_default');
50    $communityConfig->setValue(true);
51    $communityConfig->save();
52    return true;
53  }
54}
Note: See TracBrowser for help on using the repository browser.