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 {
52 * @param Group $Group The Group object to which these FRSRs are associated.
54 function __construct(& $Group) {
55 parent::__construct();
57 if (!$Group || !is_object($Group)) {
58 $this->setError(_('No Valid Group Object'));
61 if ($Group->isError()) {
62 $this->setError('FRSReleaseFactory'._(': ').$Group->getErrorMessage());
65 if (!$Group->usesFRS()) {
66 $this->setError(sprintf(_('%s does not use the FRS tool'), $Group->getPublicName()));
69 $this->Group =& $Group;
73 * getGroup - get the Group object this FRSReleaseFactory is associated with.
75 * @return object The Group object.
77 function &getGroup() {
82 * getFRSRs - get an array of FRSR objects for this Group.
84 * @param bool $status limite the search to active packages. Default is false.
85 * @return array The array of FRS objects.
87 function getFRSRs($status = false) {
88 if (isset($this->FRSRs) && is_array($this->FRSRs)) {
92 $this->FRSRs = array();
93 $frspf = new FRSPackageFactory($this->Group);
94 $ids = $frspf->getAllPackagesIds($status);
96 foreach ($ids as $id) {
97 if (forge_check_perm('frs', $id, 'read')) {
98 $frsp = frspackage_get_object($id);
99 $frspr = $frsp->getReleases();
100 $this->FRSRs = array_merge($frspr, $this->FRSRs);
107 * getFRSRNewReleases - get an array of FRS Newest Release objects for this Group.
109 * @param bool $status limite the search to active packages. Default is false.
110 * @return array The array of FRS objects.
112 function getFRSRNewReleases($status = false) {
113 if (isset($this->FRSNRs) && is_array($this->FRSNRs)) {
114 return $this->FRSNRs;
117 $this->FRSNRs = array();
118 $frspf = new FRSPackageFactory($this->Group);
119 $ids = $frspf->getAllPackagesIds($status);
121 foreach ($ids as $id) {
122 if (forge_check_perm('frs', $id, 'read')) {
124 $frsp = frspackage_get_object($id);
125 $frspnr_id = $frsp->getNewestReleaseID();
127 $frspnr = frsrelease_get_object($frspnr_id);
130 if (isset($frspnr) && $frspnr) {
131 $this->FRSNRs[] = $frspnr;
134 return $this->FRSNRs;