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

Ignore:
Timestamp:
Dec 1, 2008, 5:20:13 AM (13 years ago)
Author:
ebihara
Message:

#3030:added some methods for opPluginChannelPackage* models and forms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/opPluginChannelPackage.php

    r9279 r9438  
    33class opPluginChannelPackage extends BaseopPluginChannelPackage
    44{
     5        public function save(PropelPDO $con = null)
     6  {
     7    $user = sfContext::getInstance()->getUser();
     8
     9    if ($this->isNew())
     10    {
     11      $maintainer = new opPluginChannelMaintainer();
     12      $maintainer->setMember($user->getMember());
     13      $maintainer->setIsActive(true);
     14      $this->addopPluginChannelMaintainer($maintainer);
     15    }
     16
     17    if (!$this->isBelong())
     18    {
     19      throw new opPrivilegeException('You don\'t have permission to access this data.');
     20    }
     21
     22    return parent::save($con);
     23  }
     24
     25        public function isBelong()
     26  {
     27    $user = sfContext::getInstance()->getUser();
     28    $c = new Criteria();
     29    $c->add(opPluginChannelMaintainerPeer::MEMBER_ID, $user->getMember()->getId());
     30    return (bool)$this->getopPluginChannelMaintainers($c);
     31  }
     32
     33  public function getReleaseByVersion($version)
     34  {
     35    $c = new Criteria();
     36    $c->add(opPluginChannelReleasePeer::NAME, $version);
     37    $releases = $this->getOpPluginChannelReleases($c);
     38
     39    return array_shift($releases);
     40  }
     41
     42  public function getVersionByStability($stability)
     43  {
     44    $c = new Criteria();
     45
     46    if ($stability !== 'latest')
     47    {
     48      $stableIndex = array_search($stability, opPluginChannelRelease::$stabilityList);
     49      $c->add(opPluginChannelReleasePeer::STABILITY, $stableIndex);
     50    }
     51
     52    $releases = $this->getOpPluginChannelReleases($c);
     53    if (!$releases)
     54    {
     55      return false;
     56    }
     57
     58    $versions = $this->createVersionList($releases);
     59    return array_pop($versions);
     60  }
     61
     62  public function createVersionList($releases)
     63  {
     64    $versions = array();
     65
     66    foreach ($releases as $release)
     67    {
     68      $versions[] = $release->getName();
     69    }
     70    usort($versions, 'version_compare');
     71
     72    return $versions;
     73  }
    574}
Note: See TracChangeset for help on using the changeset viewer.