* Copyright 2009-2010, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
- * Copyright 2012, Franck Villaume - TrivialDev
+ * Copyright 2012-2013, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
* IMPORTANT! That db result must contain all fields
* from groups table or you will have problems
*
- * @param int Required
- * @param int Result set handle ("SELECT * FROM groups WHERE group_id=xx")
- * @return object a group object or false on failure
+ * @param int $group_id Required
+ * @param int|bool $res Result set handle ("SELECT * FROM groups WHERE group_id=xx")
+ * @return Group|bool A group object or false on failure
*/
function &group_get_object($group_id, $res = false) {
//create a common set of group objects
/**
* Group - Group object constructor - use group_get_object() to instantiate.
*
- * @param int Required - group_id of the group you want to instantiate.
- * @param int Database result from select query OR associative array of all columns.
- * @return boolean success or not
+ * @param int|bool $id Required - Id of the group you want to instantiate.
+ * @param int|bool $res Database result from select query OR associative array of all columns.
+ * @return boolean Success or not
*/
- function Group($id = false, $res = false) {
+ function __construct($id = false, $res = false) {
$this->Error();
if (!$id) {
//setting up an empty object
/**
* fetchData - May need to refresh database fields if an update occurred.
*
- * @param int The group_id.
- * @return boolean success or not
+ * @param int $group_id The group_id.
+ * @return boolean success or not
*/
function fetchData($group_id) {
$res = db_query_params ('SELECT * FROM groups WHERE group_id=$1',
}
// in the database, these all default to '1',
- // so we have to explicity set 0
+ // so we have to explicitly set 0
if (!$use_mail) {
$use_mail = 0;
}
$homepage = util_make_url('/projects/' . $this->getUnixName() . '/');
}
- if (strlen(htmlspecialchars($short_description))>255) {
- $this->setError(_('Error updating project information: Maximum length for Project Description is 255 chars.'));
+ if (strlen(htmlspecialchars($short_description))<10) {
+ $this->setError(_('Describe in a more comprehensive manner your project.'));
return false;
}
/**
* usesPlugin - returns true if the group uses a particular plugin
*
- * @param string name of the plugin
+ * @param string $pluginname name of the plugin
* @return boolean whether plugin is being used or not
*/
function usesPlugin($pluginname) {
}
// unlink roles from this project
- $ra = RoleAnonymous::getInstance();
- $rl = RoleLoggedIn::getInstance();
- $ra->unlinkProject($this);
- $rl->unlinkProject($this);
- // @todo : unlink all the other roles created in the project...
+ foreach ($this->getRoles() as $r) {
+ if ($r->getHomeProject() == NULL
+ || $r->getHomeProject()->getID() != $this->getID()) {
+ $r->unlinkProject($this);
+ }
+ }
//
// Delete Trackers
//
- $atf = new ArtifactTypeFactory($this);
- $at_arr = $atf->getArtifactTypes();
- foreach ($at_arr as $i) {
- if (!is_object($i)) {
- continue;
- }
- if (!$i->delete(1,1)) {
- $this->setError(_('Could not properly delete the tracker:').' '.$i->getErrorMessage());
- return false;
+ if ($this->usesTracker()) {
+ $atf = new ArtifactTypeFactory($this);
+ $at_arr = $atf->getArtifactTypes();
+ foreach ($at_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if (!$i->delete(1,1)) {
+ $this->setError(_('Could not properly delete the tracker:').' '.$i->getErrorMessage());
+ return false;
+ }
}
}
//
// Delete Forums
//
- $ff = new ForumFactory($this);
- $f_arr = $ff->getForums();
- foreach ($f_arr as $i) {
- if (!is_object($i)) {
- continue;
- }
- if(!$i->delete(1,1)) {
- $this->setError(_('Could not properly delete the forum:').' '.$i->getErrorMessage());
- return false;
+
+ if ($this->usesForum()) {
+ $f_arr = $ff->getForums();
+ foreach ($f_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if(!$i->delete(1,1)) {
+ $this->setError(_('Could not properly delete the forum:').' '.$i->getErrorMessage());
+ return false;
+ }
}
}
//
// Delete Subprojects
//
- $pgf = new ProjectGroupFactory($this);
- $pg_arr = $pgf->getProjectGroups();
- foreach ($pg_arr as $i) {
- if (!is_object($i)) {
- continue;
- }
- if (!$i->delete(1,1)) {
- $this->setError(_('Could not properly delete the ProjectGroup:').' '.$i->getErrorMessage());
- return false;
+ if ($this->usesPM()) {
+ $pgf = new ProjectGroupFactory($this);
+ $pg_arr = $pgf->getProjectGroups();
+ foreach ($pg_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if (!$i->delete(1,1)) {
+ $this->setError(_('Could not properly delete the ProjectGroup:').' '.$i->getErrorMessage());
+ return false;
+ }
}
}
//
//
// Delete Surveys
//
- $sf = new SurveyFactory($this);
- $s_arr =& $sf->getSurveys();
- foreach ($s_arr as $i) {
- if (!is_object($i)) {
- continue;
- }
- if (!$i->delete()) {
- $this->setError(_('Could not properly delete the survey'));
- db_rollback();
- return false;
+ if ($this->usesSurvey()) {
+ $sf = new SurveyFactory($this);
+ $s_arr =& $sf->getSurveys();
+ foreach ($s_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if (!$i->delete()) {
+ $this->setError(_('Could not properly delete the survey'));
+ db_rollback();
+ return false;
+ }
}
- }
//
// Delete SurveyQuestions
//
- $sqf = new SurveyQuestionFactory($this);
- $sq_arr =& $sqf->getSurveyQuestions();
- foreach ($sq_arr as $i) {
- if (!is_object($i)) {
- continue;
- }
- if (!$i->delete()) {
- $this->setError(_('Could not properly delete the survey questions'));
- db_rollback();
- return false;
+ $sqf = new SurveyQuestionFactory($this);
+ $sq_arr = $sqf->getSurveyQuestions();
+ if (is_array($sq_arr)) {
+ foreach ($sq_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if (!$i->delete()) {
+ $this->setError(_('Could not properly delete the survey questions'));
+ db_rollback();
+ return false;
+ }
+ }
}
}
//
// Delete Mailing List Factory
//
- $mlf = new MailingListFactory($this);
- $ml_arr = $mlf->getMailingLists();
- foreach ($ml_arr as $i) {
- if (!is_object($i)) {
- continue;
- }
- if (!$i->delete(1,1)) {
- $this->setError(_('Could not properly delete the mailing list'));
- db_rollback();
- return false;
+ if ($this->usesMail()) {
+ $mlf = new MailingListFactory($this);
+ $ml_arr = $mlf->getMailingLists();
+ foreach ($ml_arr as $i) {
+ if (!is_object($i)) {
+ continue;
+ }
+ if (!$i->delete(1,1)) {
+ $this->setError(_('Could not properly delete the mailing list'));
+ db_rollback();
+ return false;
+ }
}
}
//