This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, 6.0 has been updated
via 2c8b2d82123252365085e0fdb10cb01e57c99d97 (commit)
from e46d0fb4a0a19029664c08eb2f48fa002e520dcc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2c8b2d82123252365085e0fdb10cb01e57c99d97
Author: Roland Mas <[email protected]>
Date: Tue May 12 05:41:58 2015 +0200
More fixes to group deletion code (patch from Markus Köhl)
diff --git a/src/common/forum/Forum.class.php b/src/common/forum/Forum.class.php
index 9fb89f8..452221f 100644
--- a/src/common/forum/Forum.class.php
+++ b/src/common/forum/Forum.class.php
@@ -124,11 +124,8 @@ class Forum extends Error {
array($group_forum_id));
$is_news = $res && db_numrows($res) >= 1;
}
- if (!$is_news && !$Group->usesForum()) {
- $this->setError(sprintf(_('%s does not use the Forum
tool.'), $Group->getPublicName()));
- return;
- }
- $this->Group =& $Group;
+
+ $this->Group =& $Group;
if ($group_forum_id) {
if (!$arr || !is_array($arr)) {
diff --git a/src/common/include/Group.class.php
b/src/common/include/Group.class.php
index 03a133f..5e9fc17 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -28,6 +28,7 @@
require_once $gfcommon.'tracker/ArtifactTypes.class.php';
require_once $gfcommon.'tracker/ArtifactTypeFactory.class.php';
+require_once $gfcommon.'tracker/RoadmapFactory.class.php';
require_once $gfcommon.'forum/Forum.class.php';
require_once $gfcommon.'forum/ForumFactory.class.php';
require_once $gfcommon.'pm/ProjectGroup.class.php';
@@ -1665,7 +1666,7 @@ class Group extends Error {
//
// Remove all the members
//
- $members = $this->getMembers();
+ $members = $this->getMembers(false);
foreach ($members as $i) {
if(!$this->removeUser($i->getID())) {
$this->setError(_('Could not properly remove
member:').' '.$i->getID());
@@ -1695,6 +1696,20 @@ class Group extends Error {
return false;
}
}
+ //
+ // Delete Roadmaps
+ //
+ $rmf = new RoadmapFactory($this);
+ $rm_arr = $rmf->getRoadmaps();
+ foreach ($rm_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if (!$i->delete()) {
+ $this->setError(_('Could not properly delete the roadmap:') . ' '
. $i->getErrorMessage());
+ return false;
+ }
+ }
//
// Delete Forums
//
@@ -1754,7 +1769,7 @@ class Group extends Error {
db_rollback();
return false;
}
-
+
for ($i=0; $i<db_numrows($res); $i++) {
$Forum = new
Forum($news_group,db_result($res,$i,'forum_id'));
if (!$Forum->delete(1,1)) {
@@ -1762,7 +1777,17 @@ class Group extends Error {
return false;
}
}
- $res = db_query_params('DELETE FROM news_bytes WHERE
group_id=$1',
+
+ // Delete news forums in group itself
+ for ($i = 0; $i < db_numrows($res); $i++) {
+ $Forum = new Forum($this, db_result($res, $i, 'forum_id'));
+ if (!$Forum->delete(1, 1)) {
+ $this->setError(_("Could Not Delete News Forum: %d"),
$Forum->getID());
+ return false;
+ }
+ }
+
+ $res = db_query_params('DELETE FROM news_bytes WHERE group_id=$1',
array($this->getID()));
if (!$res) {
$this->setError(_('Error Deleting News: ').db_error());
@@ -2086,23 +2111,24 @@ class Group extends Error {
$user = user_get_object($user_id);
$roles =
RBACEngine::getInstance()->getAvailableRolesForUser($user);
- $found_role = NULL;
+ $found_roles = array();
foreach ($roles as $role) {
if ($role->getHomeProject() &&
$role->getHomeProject()->getID() == $this->getID()) {
- $found_role = $role;
- break;
+ $found_roles[] = $role;
}
}
- if ($found_role == NULL) {
+ if (count($found_roles) == 0) {
$this->setError(sprintf(_('Error: User not removed:
%s')));
db_rollback();
return false;
}
- $found_role->removeUser($user);
- if (!$SYS->sysGroupCheckUser($this->getID(), $user_id)) {
- $this->setError($SYS->getErrorMessage());
- db_rollback();
- return false;
+ foreach ($found_roles as $found_role) {
+ $found_role->removeUser($user);
+ if (!$SYS->sysGroupCheckUser($this->getID(), $user_id))
{
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
}
//
@@ -2285,10 +2311,11 @@ class Group extends Error {
/**
* getMembers - returns array of User objects for this project
*
+ * @param boolean $onlyactive Only users with state active,
or all users of group
* @return array of User objects for this group.
*/
- function getMembers() {
- return $this->getUsers (true);
+ function getMembers($onlyactive = true) {
+ return $this->getUsers (true, $onlyactive);
}
/**
@@ -2870,9 +2897,10 @@ if there is anything we can do to help you.
* getUsers - Get the users of a group
*
* @param bool $onlylocal
+ * @param boolean $onlyactive Only users with state active,
or all users of group
* @return array user's objects.
*/
- function getUsers($onlylocal = true) {
+ function getUsers($onlylocal = true, $onlyactive = true) {
if (!isset($this->membersArr)) {
$this->membersArr = array();
@@ -2889,7 +2917,7 @@ if there is anything we can do to help you.
$ids = array_unique ($ids);
foreach ($ids as $id) {
$u = user_get_object ($id);
- if ($u->isActive()) {
+ if (!$onlyactive || $u->isActive()) {
$this->membersArr[] = $u;
}
}
diff --git a/src/common/tracker/RoadmapFactory.class.php
b/src/common/tracker/RoadmapFactory.class.php
index 481908a..23e3ea0 100644
--- a/src/common/tracker/RoadmapFactory.class.php
+++ b/src/common/tracker/RoadmapFactory.class.php
@@ -57,16 +57,16 @@ class RoadmapFactory extends Error {
function __construct($group) {
$this->Error();
- if (is_object($group)) {
- if ($group->isError()) {
- $this->setError('in RoadmapFactory,
'.$group->getErrorMessage());
- return;
- }
- $this->group = $group;
- $this->group_id = $group->getID();
- } else {
- $this->setError(_('Invalid Group'));
+ if (!$group || !is_object($group)) {
+ $this->setError(_('No Valid Group Object'));
+ return;
+ }
+ if ($group->isError()) {
+ $this->setError('RoadmapFactory:
'.$group->getErrorMessage());
+ return;
}
+ $this->group =& $group;
+ $this->group_id = $group->getID();
}
public function getRoadmaps($enable_only=false) {
-----------------------------------------------------------------------
Summary of changes:
src/common/forum/Forum.class.php | 7 +---
src/common/include/Group.class.php | 60 ++++++++++++++++++++-------
src/common/tracker/RoadmapFactory.class.php | 18 ++++----
3 files changed, 55 insertions(+), 30 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits