* 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
// 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;
+ $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;
+ }
}
}
//