5 * Copyright 2014, Franck Villaume - TrivialDev
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once $gfcommon.'include/FFError.class.php';
24 require_once $gfcommon.'frs/FRSRelease.class.php';
25 require_once $gfcommon.'frs/FRSPackage.class.php';
26 require_once $gfcommon.'frs/FRSPackageFactory.class.php';
28 class FRSReleaseFactory extends FFError {
54 * @param Group $Group The Group object to which these FRSRs are associated.
56 function __construct(& $Group) {
57 parent::__construct();
59 if (!$Group || !is_object($Group)) {
60 $this->setError(_('No Valid Group Object'));
63 if ($Group->isError()) {
64 $this->setError('FRSReleaseFactory'._(': ').$Group->getErrorMessage());
67 if (!$Group->usesFRS()) {
68 $this->setError(sprintf(_('%s does not use the FRS tool'), $Group->getPublicName()));
71 $this->Group =& $Group;
75 * getGroup - get the Group object this FRSReleaseFactory is associated with.
77 * @return object The Group object.
79 function &getGroup() {
84 * getFRSRs - get an array of FRSR objects for this Group.
86 * @param bool $status limite the search to active packages. Default is false.
87 * @return array The array of FRS objects.
89 function getFRSRs($status = false) {
90 if (isset($this->FRSRs) && is_array($this->FRSRs)) {
94 $this->FRSRs = array();
95 $frspf = new FRSPackageFactory($this->Group);
96 $ids = $frspf->getAllPackagesIds($status);
98 foreach ($ids as $id) {
99 if (forge_check_perm('frs', $id, 'read')) {
100 $frsp = frspackage_get_object($id);
101 $frspr = $frsp->getReleases();
102 $this->FRSRs = array_merge($frspr, $this->FRSRs);
109 * getFRSRNewReleases - get an array of FRS Newest Release objects for this Group.
111 * @param bool $status limite the search to active packages. Default is false.
112 * @return array The array of FRS objects.
114 function getFRSRNewReleases($status = false) {
115 if (isset($this->FRSNRs) && is_array($this->FRSNRs)) {
116 return $this->FRSNRs;
119 $this->FRSNRs = array();
120 $frspf = new FRSPackageFactory($this->Group);
121 $ids = $frspf->getAllPackagesIds($status);
123 foreach ($ids as $id) {
124 if (forge_check_perm('frs', $id, 'read')) {
126 $frsp = frspackage_get_object($id);
127 $frspnr_id = $frsp->getNewestReleaseID();
129 $frspnr = frsrelease_get_object($frspnr_id);
132 if (isset($frspnr) && $frspnr) {
133 $this->FRSNRs[] = $frspnr;
136 return $this->FRSNRs;