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

Changeset 11045


Ignore:
Timestamp:
Mar 17, 2009, 11:15:34 PM (11 years ago)
Author:
ebihara
Message:

#3219:added limitation for creating community by the "is_allow_user_community" flag of community categories

Location:
OpenPNE3/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/pc_backend/modules/community/templates/_categoryListForm.php

    r11043 r11045  
    22<tr>
    33<th><?php echo $form['name']->renderLabel() ?></th>
     4<?php if (empty($forceAllowUserCommunity)) : ?>
    45<th><?php echo $form['is_allow_user_community']->renderLabel() ?></th>
     6<?php endif; ?>
    57<th colspan="2"><?php echo __('操作') ?></th>
    68</tr>
     
    1012<?php echo $category->getForm()->renderGlobalErrors() ?>
    1113<tr>
    12 <?php foreach ($category->getForm() as $row) : ?>
     14<?php foreach ($category->getForm() as $key => $row) : ?>
    1315<?php if (!$row->isHidden()) : ?>
     16<?php if (empty($forceAllowUserCommunity) || $key != 'is_allow_user_community') : ?>
    1417<td><?php echo $row->renderError() ?><?php echo $row ?></td>
     18<?php endif; ?>
    1519<?php endif; ?>
    1620<?php endforeach; ?>
     
    3539<?php echo $form->renderGlobalErrors() ?>
    3640<tr>
    37 <?php foreach ($form as $row) : ?>
     41<?php foreach ($form as $key => $row) : ?>
    3842<?php if (!$row->isHidden()) : ?>
     43<?php if (empty($forceAllowUserCommunity) || $key != 'is_allow_user_community') : ?>
    3944<td><?php echo $row->renderError() ?><?php echo $row ?></td>
     45<?php endif; ?>
    4046<?php endif; ?>
    4147<?php endforeach; ?>
  • OpenPNE3/trunk/apps/pc_backend/modules/community/templates/categoryListSuccess.php

    r11043 r11045  
    77<h3>大カテゴリ</h3>
    88<?php include_partial('categoryListForm', array(
    9   'form'       => $rootForm,
    10   'categories' => $categories,
    11   'deleteForm' => $deleteForm,
     9  'form'                    => $rootForm,
     10  'forceAllowUserCommunity' => true,
     11  'categories'              => $categories,
     12  'deleteForm'              => $deleteForm,
    1213)) ?>
    1314
  • OpenPNE3/trunk/lib/action/sfOpenPNECommunityAction.class.php

    r11019 r11045  
    6666    {
    6767      $this->community = new Community();
    68      
    6968    }
    7069
  • OpenPNE3/trunk/lib/form/CommunityForm.class.php

    r11044 r11045  
    2727    $this->setValidator('name', new sfValidatorString(array('max_length' => 64, 'trim' => true)));
    2828
    29     $this->setWidget('community_category_id', new opWidgetFormPropelChoiceTree(array(
     29    $c = new Criteria();
     30    if (1 != sfContext::getInstance()->getUser()->getMemberId())
     31    {
     32      $c->add(CommunityCategoryPeer::IS_ALLOW_USER_COMMUNITY, 1);
     33    }
     34    $this->setWidget('community_category_id', new sfWidgetFormPropelChoice(array(
    3035      'model'       => 'CommunityCategory',
    3136      'add_empty'   => false,
    32       'peer_method' => 'retrieveAllRoots',
     37      'peer_method' => 'retrieveAllChildren',
     38      'criteria'    => $c,
    3339    )));
    3440    $this->widgetSchema->setLabel('community_category_id', 'Community Category');
    3541    $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('form_community');
     42
     43    $this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkCreatable'))));
    3644  }
    3745
     
    5563    }
    5664  }
     65
     66  public function checkCreatable($validator, $value)
     67  {
     68    $category = CommunityCategoryPeer::retrieveByPk($value['community_category_id']);
     69    if ($category->getIsAllowUserCommunity())
     70    {
     71      return $value;
     72    }
     73
     74    if (1 == sfContext::getInstance()->getUser()->getMemberId())
     75    {
     76      return $value;
     77    }
     78
     79    throw new sfValidatorError($validator, 'invalid');
     80  }
    5781}
  • OpenPNE3/trunk/lib/model/CommunityCategoryPeer.php

    r11043 r11045  
    99  }
    1010
    11   static public function retrieveAllRoots()
     11  static public function retrieveAllRoots(Criteria $c = null)
    1212  {
    13     $c = new Criteria();
     13    if (!$c)
     14    {
     15      $c = new Criteria();
     16    }
     17
    1418    $c->add(self::LEFT_COL, 1, Criteria::EQUAL);
    1519    return parent::doSelect($c);
    1620  }
     21
     22  static public function retrieveAllChildren(Criteria $c = null)
     23  {
     24    if (!$c)
     25    {
     26      $c = new Criteria();
     27    }
     28
     29    $c->add(self::LEFT_COL, 1, Criteria::GREATER_THAN);
     30    return parent::doSelect($c);
     31  }
    1732}
Note: See TracChangeset for help on using the changeset viewer.