* Copyright 1999-2001, VA Linux Systems, Inc.
* Copyright 2009-2010, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
+ * Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
* Copyright 2012, Franck Villaume - TrivialDev
* http://fusionforge.org
*
return group_get_object(db_result($res, 0, 'group_id'), $res);
}
+/**
+ * get_public_active_projects_asc() - Get a list of rows for public active projects (initially in trove/full_list)
+ *
+ * @param int Opional Maximum number of rows to limit query length
+ */
+function get_public_active_projects_asc($max_query_limit = -1) {
+
+ $res_grp = db_query_params ('
+ SELECT group_id, group_name, unix_group_name, short_description, register_time
+ FROM groups
+ WHERE status = $1 AND type_id=1 AND group_id>4 AND register_time > 0
+ ORDER BY group_name ASC
+ ',
+ array ('A'),
+ $max_query_limit);
+ $projects = array();
+ while ($row_grp = db_fetch_array($res_grp)) {
+ if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
+ continue ;
+ }
+ $projects[] = $row_grp;
+ }
+ return $projects;
+}
+
+
class Group extends Error {
/**
* Associative array of data from db.
scm_box,
register_purpose,
register_time,
- enable_anonscm,
rand_hash,
built_from_template
)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)',
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)',
array (htmlspecialchars ($group_name),
$unix_name,
htmlspecialchars($description),
- $unix_name.".".forge_get_config('web_host'),
+ $homepage,
$homepage,
'P',
$unix_box,
$scm_box,
htmlspecialchars($purpose),
time(),
- 0,
md5(util_randbytes()),
$built_from_template));
if (!$res || db_affected_rows($res) < 1) {
function update(&$user, $group_name, $homepage, $short_description, $use_mail, $use_survey, $use_forum,
$use_pm, $use_pm_depend_box, $use_scm, $use_news, $use_docman,
$new_doc_address, $send_all_docs, $logo_image_id,
- $use_ftp, $use_tracker, $use_frs, $use_stats, $tags, $is_public) {
+ $use_ftp, $use_tracker, $use_frs, $use_stats, $tags, $use_activity, $is_public) {
$perm =& $this->getPermission();
if (!$use_stats) {
$use_stats = 0;
}
+ if (!$use_activity) {
+ $use_activity = 0;
+ }
if (!$send_all_docs) {
$send_all_docs = 0;
}
use_ftp=$13,
use_tracker=$14,
use_frs=$15,
- use_stats=$16
- WHERE group_id=$17',
+ use_stats=$16,
+ use_activity=$17
+ WHERE group_id=$18',
array(htmlspecialchars($group_name),
$homepage,
htmlspecialchars($short_description),
$use_tracker,
$use_frs,
$use_stats,
+ $use_activity,
$this->getID()));
- if (!$res) {
+ if (!$res || db_affected_rows($res) < 1) {
$this->setError(sprintf(_('Error updating project information: %s'), db_error()));
db_rollback();
return false;
}
}
+ /**
+ * usesActivity - whether or not this group has opted to display Project Activities.
+ *
+ * @return boolean uses_activities.
+ */
+ function usesActivity() {
+ if (forge_get_config('use_activity')) {
+ return $this->data_array['use_activity'];
+ } else {
+ return false;
+ }
+ }
+
/**
* usesForum - whether or not this group has opted to use discussion forums.
*
* @return string homepage URL.
*/
function getHomePage() {
+ if (!preg_match("/^[a-zA-Z][a-zA-Z0-9+.-]*:/",
+ $this->data_array['homepage'])) {
+ $this->data_array['homepage'] = util_url_prefix() .
+ $this->data_array['homepage'];
+ }
return $this->data_array['homepage'];
}
return false;
}
}
- // Failsafe until user_group table is gone
- $res = db_query_params('DELETE FROM user_group WHERE group_id=$1',
- array($this->getID()));
// unlink roles from this project
$ra = RoleAnonymous::getInstance();
$oldatf = new ArtifactTypeFactory($template);
foreach ($oldatf->getArtifactTypes() as $o) {
$t = new ArtifactType ($this) ;
- $t->create ($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->isPublic(),$o->allowsAnon(),$o->emailAll(),$o->getEmailAddress(),$o->getDuePeriod()/86400,0,$o->getSubmitInstructions(),$o->getBrowseInstructions()) ;
+ $t->create ($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->emailAll(),$o->getEmailAddress(),$o->getDuePeriod()/86400,0,$o->getSubmitInstructions(),$o->getBrowseInstructions()) ;
$id_mappings['tracker'][$o->getID()] = $t->getID();
$t->cloneFieldsFrom ($o->getID());
}
$oldpgf = new ProjectGroupFactory($template);
foreach ($oldpgf->getProjectGroups() as $o) {
$pg = new ProjectGroup($this);
- $pg->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->isPublic(),$o->getSendAllPostsTo());
+ $pg->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->getSendAllPostsTo());
$id_mappings['pm'][$o->getID()] = $pg->getID();
}
}
$oldff = new ForumFactory($template) ;
foreach ($oldff->getForums() as $o) {
$f = new Forum($this);
- $f->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),0,$o->getSendAllPostsTo(),1,0,0);
+ $f->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->getSendAllPostsTo(),1);
$id_mappings['forum'][$o->getID()] = $f->getID();
}
}