* Copyright 2009-2010, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
} else if (strlen($description)<10) {
$this->setError(_('Describe in a more comprehensive manner your project.'));
return false;
- } else if (strlen($description)>255) {
- $this->setError(_('Your project description is too long. Please make it smaller than 256 bytes.'));
- return false;
} else {
+
+ // Check if sys_use_project_vhost for homepage
+ if (forge_get_config('use_project_vhost')) {
+ $homepage = $unix_name.".".forge_get_config('web_host');
+ } else {
+ $homepage = forge_get_config('web_host')."/www/".$unix_name."/";
+ }
+
db_begin();
$res = db_query_params('
$unix_name,
htmlspecialchars($description),
$unix_name.".".forge_get_config('web_host'),
- $unix_name.".".forge_get_config('web_host'),
+ $homepage,
'P',
$unix_box,
$scm_box,
// Check that status transition is valid
if ($this->getStatus() != $status
- && !$allowed_status_changes[$this->getStatus().$status]) {
+ && !in_array($this->getStatus(). $status,$allowed_status_changes)) {
$this->setError(_('Invalid Status Change'));
return false;
}
$plugin_id));
return $res;
}
+ $this->normalizeAllRoles () ;
}
/**
$sql = 'INSERT INTO project_tags (group_id,name) VALUES ($1, $2)';
$res = db_query_params($sql, array($this->getID(), $tag));
if (!$res) {
- $this->setError(_('Setting tags: ').db_error());
+ $this->setError(_('Setting tags:') . ' ' .
+ db_error());
db_rollback();
return false;
}
$this->setError(_('Cannot Delete System Group'));
return false;
}
- $perm =& $this->getPermission();
+ $perm = $this->getPermission();
if (!$perm || !is_object($perm)) {
$this->setPermissionDeniedError();
return false;
return false;
}
- //db_begin();
+ db_begin();
//
// Remove all the members
//
- $members =& $this->getMembers();
+ $members = $this->getMembers();
foreach ($members as $i) {
if(!$this->removeUser($i->getID())) {
$this->setError(_('Could not properly remove member:').' '.$i->getID());
// Delete Trackers
//
$atf = new ArtifactTypeFactory($this);
- $at_arr =& $atf->getArtifactTypes();
+ $at_arr = $atf->getArtifactTypes();
foreach ($at_arr as $i) {
if (!is_object($i)) {
continue;
// Delete Forums
//
$ff = new ForumFactory($this);
- $f_arr =& $ff->getForums();
+ $f_arr = $ff->getForums();
foreach ($f_arr as $i) {
if (!is_object($i)) {
continue;
// Delete Subprojects
//
$pgf = new ProjectGroupFactory($this);
- $pg_arr =& $pgf->getProjectGroups();
+ $pg_arr = $pgf->getProjectGroups();
foreach ($pg_arr as $i) {
if (!is_object($i)) {
continue;
//
$res = db_query_params('SELECT * FROM frs_package WHERE group_id=$1',
array($this->getID()));
+ if (!$res) {
+ $this->setError(_('Error FRS Packages: ').db_error());
+ db_rollback();
+ return false;
+ }
+
while ($arr = db_fetch_array($res)) {
$frsp=new FRSPackage($this, $arr['package_id'], $arr);
if (!$frsp->delete(1, 1)) {
return false;
}
+ // Delete entry in groups.
$res = db_query_params('DELETE FROM groups WHERE group_id=$1',
array($this->getID()));
if (!$res) {
/*
Basic functions to add/remove users to/from a group
and update their permissions
- */
+ */
/**
* addUser - controls adding a user to a group.
* @return boolean success.
*/
function updateUser($user_id,$role_id) {
- global $SYS;
if (!forge_check_perm ('project_admin', $this->getID())) {
$this->setPermissionDeniedError();
$template = $this->getTemplateProject();
$id_mappings = array();
- $seen_local_roles = false;
+ $seen_admin_role = false;
if ($template) {
// Copy roles from template project
foreach($template->getRoles() as $oldrole) {
// Need to use a different role name so that the permissions aren't set from the hardcoded defaults
$role->create('TEMPORARY ROLE NAME', $data, true);
$role->setName($oldrole->getName());
- $seen_local_roles = true;
+ if ($oldrole->getSetting ('project_admin', $template->getID())) {
+ $seen_admin_role = true;
+ }
} else {
$role = $oldrole;
$role->linkProject($this);
}
}
- if (!$seen_local_roles) {
+ if (!$seen_admin_role) {
$role = new Role($this);
$adminperms = array ('project_admin' => array ($this->getID() => 1)) ;
$role_id = $role->create ('Admin', $adminperms, true) ;
$roles = $this->getRoles() ;
foreach ($roles as $r) {
+ if ($r->getHomeProject() == NULL) {
+ continue;
+ }
if ($r->getSetting ('project_admin', $this->getID())) {
$r->addUser(user_get_object ($idadmin_group));
}
}
-
+
// Temporarily switch to the submitter's identity
$saved_session = session_get_user();
session_set_internal($idadmin_group);
$oldff = new ForumFactory($template) ;
foreach ($oldff->getForums() as $o) {
$f = new Forum($this);
- $f->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->isPublic(),$o->getSendAllPostsTo(),1,$o->allowAnonymous(),$o->getModerationLevel());
+ $f->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),0,$o->getSendAllPostsTo(),1,0,0);
$id_mappings['forum'][$o->getID()] = $f->getID();
}
}
}
}
- $this->setUseSCM ($template->usesSCM()) ;
+ // Disabled to keep user choice from registration page.
+// $this->setUseSCM ($template->usesSCM()) ;
foreach ($template->getPlugins() as $plugin_id => $plugin_name) {
- $this->setPluginUse ($plugin_name) ;
+ if (preg_match('/^scm/', $plugin_name) && ($plugin_name != 'scmhook')) {
+ $this->setPluginUse($plugin_name);
+ }
}
foreach ($template->getRoles() as $oldrole) {
plugin_hook_by_reference ('clone_project_from_template', $params) ;
} else {
// Disable everything
- $res = db_query_params ('UPDATE groups SET use_mail=0, use_survey=0, use_forum=0, use_pm=0, use_pm_depend_box=0, use_scm=0, use_news=0, use_docman=0, use_ftp=0, use_tracker=0, use_frs=0, use_stats=0 WHERE group_id=$1',
-
- array ($this->getID())) ;
+ db_query_params ('UPDATE groups SET use_mail=0, use_survey=0, use_forum=0, use_pm=0, use_pm_depend_box=0, use_scm=0, use_news=0, use_docman=0, use_ftp=0, use_tracker=0, use_frs=0, use_stats=0 WHERE group_id=$1',
+ array ($this->getID())) ;
}
$this->normalizeAllRoles();
$admin_email = $admin->getEmail () ;
setup_gettext_for_user ($admin) ;
- foreach ($submitters as $u) {
- $submitter_names[] = $u->getRealName() ;
- }
-
$message = sprintf(_('New %1$s Project Submitted
Project Full Name: %2$s
} else if (strlen(htmlspecialchars($group_name))>50) {
$this->setError(_('Group name is too long'));
return false;
- } else if ($group=group_get_object_by_publicname($group_name)) {
+ } else if (group_get_object_by_publicname($group_name)) {
$this->setError(_('Group name already taken'));
return false;
}
/**
- * getRoles - Get the roles of the group.
+ * getRolesId - Get Ids of the roles of the group.
*
* @return array Role ids of this group.
*/