} 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,
$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.
$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();
}
}
/**
- * getRoles - Get the roles of the group.
+ * getRolesId - Get Ids of the roles of the group.
*
* @return array Role ids of this group.
*/