+2004-11-08 Tim Perdue <tim@gforge.org>
+
+ * enhancing task mgr with more fields and properties. Much more will be
+ rolled in the future.
+
+2004-11-07 Tim Perdue <tim@gforge.org>
+
+ * gforge 4.0.1 released
+
2004-11-04 Guillaume Smet <guillaume-gforge@smet.org>
* fixed bug when updating forum due to RBAC refactoring
$hook_params['passwd'] = $passwd ;
plugin_hook ("session_before_login", $hook_params) ;
- return session_login_valid_dbonly ($loginname, $passwd, $allowpending) ;}
+ return session_login_valid_dbonly ($loginname, $passwd, $allowpending) ;
+}
function session_login_valid_dbonly ($loginname, $passwd, $allowpending) {
global $feedback,$userstatus,$Language;
themes t
WHERE u.language=sl.language_id
AND u.theme_id=t.theme_id
- AND u.user_id='$user_id'
- ");
+ AND u.user_id='$user_id'");
return $res;
}
}
}
+//TODO - this should be generalized and used for pre.php, squal_pre.php,
+//SOAP, forum_gateway.php, tracker_gateway.php, etc to
+//setup languages
+function session_continue($sessionKey) {
+ global $session_ser, $Language, $sys_strftimefmt, $sys_datefmt;
+ $session_ser = $sessionKey;
+ session_set();
+ $Language=new BaseLanguage();
+ $Language->loadLanguage("English"); // TODO use the user's default language
+ setlocale (LC_TIME, $Language->getText('system','locale'));
+ $sys_strftimefmt = $Language->getText('system','strftimefmt');
+ $sys_datefmt = $Language->getText('system','datefmt');
+}
+
/**
* session_get_user() - Wrapper function to return the User object for the logged in user.
*
return $PROJECTTASK_OBJ["_".$project_task_id."_"];
}
+/*
+ Types of task dependencies
+*/
+define('PM_LINK_DEFAULT','SS');
+define('PM_LINK_START_START','SS');
+define('PM_LINK_START_FINISH','SF');
+define('PM_LINK_FINISH_START','FS');
+define('PM_LINK_FINISH_FINISH','FF');
class ProjectTask extends Error {
* @param int The percentage of completion in integer format of this task.
* @param array An array of user_id's that are assigned this task.
* @param array An array of project_task_id's that this task depends on.
+ * @param int The duration of the task in days.
+ * @param int The id of the parent task, if any.
* @return boolean success.
*/
function create($summary,$details,$priority,$hours,$start_date,$end_date,
- $category_id,$percent_complete,&$assigned_arr,&$depend_arr) {
+ $category_id,$percent_complete,&$assigned_arr,&$depend_arr,$duration=0,$parent_id=0) {
$v = new Validator();
$v->check($summary, "summary");
$v->check($details, "details");
return false;
} else {
$sql="INSERT INTO project_task (project_task_id,group_project_id,created_by,summary,
- details,start_date,end_date,status_id,category_id,priority,percent_complete,hours)
+ details,start_date,end_date,status_id,category_id,priority,percent_complete,hours,duration,parent_id)
VALUES ('$project_task_id','". $this->ProjectGroup->getID() ."', '".user_getid()."', '". htmlspecialchars($summary) ."',
- '". htmlspecialchars($details) ."','$start_date','$end_date','1','$category_id','$priority','$percent_complete','$hours')";
+ '". htmlspecialchars($details) ."','$start_date','$end_date','1','$category_id','$priority','$percent_complete','$hours','$duration','$parent_id')";
$result=db_query($sql);
if (!$result || db_affected_rows($result) < 1) {
return $this->data_array['realname'];
}
+ /**
+ * getDuration - the duration of the task.
+ *
+ * @return int The number of days of duration.
+ */
+ function getDuration() {
+ return $this->data_array['duration'];
+ }
+
+ /**
+ * getParentID - the task_id of the parent task, if any.
+ *
+ * @return string The real name person who created this task.
+ */
+ function getParentID() {
+ return $this->data_array['parent_id'];
+ }
+
/**
* getSubmittedUnixName - get the unix name of the person who created this task.
*
* @param array The array of project_task_id's.
* @returns boolean success.
*/
- function setDependentOn(&$arr) {
+ function setDependentOn(&$arr_) {
//
// IMPORTANT - MUST VERIFY NO CIRCULAR DEPENDENCY!!
//
+ $arr =& array_keys($arr_);
//get existing dependencies to diff against
- $arr2 =& $this->getDependentOn();
+ $arr2 =& array_keys($this->getDependentOn());
$this->dependon =& $arr2;
if (count($arr) || count($arr2)) {
if (!$this->checkCircular($add_arr[$i],$this->getID())) {
return false;
}
- db_query("INSERT INTO project_dependencies (project_task_id,is_dependent_on_task_id)
- VALUES ('".$this->getID()."','". $add_arr[$i] ."')");
+ $lnk = $arr_[$add_arr[$i]];
+ if (!$lnk) {
+ $lnk=PM_LINK_DEFAULT;
+ }
+ db_query("INSERT INTO project_dependencies (project_task_id,is_dependent_on_task_id,link_type)
+ VALUES ('".$this->getID()."','". $add_arr[$i] ."','$lnk')");
if (db_error()) {
$this->setError('setDependentOn()-2:: '.db_error());
return false;
}
}
+ /**
+ * convertDependentOn - converts a regular array of dependencies, such
+ * as from a multiple-select-box to an associative array with default
+ * link types. Should be called from web code as part of the create/update calls.
+ * Here we are converting an array like array(1,5,9,77) to array(1=>SS,5=>SF,9=>FS,77=>SS)
+ */
+ function &convertDependentOn($arr) {
+ $deps =& $this->getDependentOn();
+ for ($i=0; $i<count($arr); $i++) {
+ if ($deps[$arr[$i]]) {
+ //use existing link_type if it exists
+ $new[$arr[$i]]=$deps[$arr[$i]];
+ } else {
+ //else create with default link type
+ $new[$arr[$i]]=PM_LINK_DEFAULT;
+ }
+ }
+ return $new;
+ }
+
/**
* getDependentOn - get an array of project_task_id's that you are dependent on.
*
- * @return array The array of project_task_id's.
+ * @return array The array of project_task_id's in this format:
+ * array($id=>$link_type,id2=>link_type2).
*/
function &getDependentOn() {
if (!$this->getID()) {
return array();
}
if (!$this->dependon) {
- $this->dependon =& util_result_column_to_array(db_query("SELECT is_dependent_on_task_id
- FROM project_dependencies
- WHERE project_task_id='".$this->getID()."'"));
+ $res=db_query("SELECT is_dependent_on_task_id,link_type
+ FROM project_dependencies
+ WHERE project_task_id='".$this->getID()."'");
+ for ($i=0; $i<db_numrows($res); $i++) {
+ $this->dependon[db_result($res,$i,'is_dependent_on_task_id')] = db_result($res,$i,'link_type');
+ }
}
/* fix bug 319: if dependentlist is emtpy, set it to 100 (none) */
if (!$this->dependon) {
- $this->dependon[]=100;
+ $this->dependon[100]=PM_LINK_DEFAULT;
}
return $this->dependon;
}
* @param array An array of user_id's that are assigned this task.
* @param array An array of project_task_id's that this task depends on.
* @param int The GroupProjectID of a new subproject that you want to move this Task to.
+ * @param int The duration of the task in days.
+ * @param int The id of the parent task, if any.
* @return boolean success.
*/
function update($summary,$details,$priority,$hours,$start_date,$end_date,
- $status_id,$category_id,$percent_complete,&$assigned_arr,&$depend_arr,$new_group_project_id) {
+ $status_id,$category_id,$percent_complete,&$assigned_arr,&$depend_arr,
+ $new_group_project_id,$duration=0,$parent_id=0) {
$v = new Validator();
$v->check($summary, "summary");
$v->check($priority, "priority");
$this->addHistory('assigned_to_id',$old_assigned[$tmp]);
}
}
- $old_array = &$this->getDependentOn();
+ $old_array =& array_keys($this->getDependentOn());
$diff_array=array_diff($old_array,$depend_arr);
if (count($diff_array)>0) {
for ($tmp=0;$tmp<count($old_array);$tmp++) {
status_id='$status_id',
percent_complete='$percent_complete',
category_id='$category_id',
- group_project_id='$new_group_project_id'
+ group_project_id='$new_group_project_id',
+ duration='$duration',
+ parent_id='$parent_id'
WHERE group_project_id='$group_project_id'
AND project_task_id='".$this->getID()."'";
--- /dev/null
+ALTER TABLE project_task ADD COLUMN duration int;
+ALTER TABLE project_task ALTER COLUMN duration SET DEFAULT 0;
+UPDATE project_task SET duration=0;
+ALTER TABLE project_task ADD COLUMN parent_id int;
+ALTER TABLE project_task ALTER COLUMN parent_id SET DEFAULT 0;
+UPDATE project_task SET parent_id=0;
+
+DROP VIEW project_task_vw;
+
+CREATE VIEW project_task_vw AS
+SELECT project_task.*,project_category.category_name,project_status.status_name,users.user_name,users.realname
+FROM project_task
+FULL JOIN project_category ON (project_category.category_id=project_task.category_id)
+FULL JOIN users ON (users.user_id=project_task.created_by)
+NATURAL JOIN project_status;
+
+ALTER TABLE project_dependencies ADD COLUMN link_type char(2);
+ALTER TABLE project_dependencies ALTER COLUMN link_type SET DEFAULT 'SS';
+UPDATE project_dependencies SET link_type='SS';
+
+DROP VIEW project_dependon_vw;
+DROP VIeW project_depend_vw;
+
+CREATE VIEW project_depend_vw AS
+ SELECT pt.project_task_id,pd.is_dependent_on_task_id,pd.link_type,pt.end_date,pt.start_date
+ FROM project_task pt NATURAL JOIN project_dependencies pd;
+
+CREATE VIEW project_dependon_vw AS
+ SELECT pd.project_task_id,pd.is_dependent_on_task_id,pd.link_type,pt.end_date,pt.start_date
+ FROM project_task pt FULL JOIN project_dependencies pd ON
+ (pd.is_dependent_on_task_id=pt.project_task_id);
+
<input type="submit" value="<?php echo $Language->getText('general','submit') ?>" name="submit" />
</td>
</tr>
+ <input type="hidden" name="duration" value="0">
+ <input type="hidden" name="parent_id" value="0">
+<!--
+will add duration and parent_id choices at some point
+ <tr>
+ <td>
+ <strong><?php echo $Language->getText('pm','hours') ?>:</strong><?php echo utils_requiredField(); ?><br />
+ <input type="text" name="hours" size="5" />
+ </td>
+ <td>
+ <input type="submit" value="<?php echo $Language->getText('general','submit') ?>" name="submit" />
+ </td>
+ </tr>
+-->
</table>
</form>
<?php
to pass into multiple select box
*/
- $result2=db_query("SELECT users.user_name AS User_Name FROM users,project_assigned_to ".
- "WHERE users.user_id=project_assigned_to.assigned_to_id AND project_task_id='$project_task_id'");
+ $result2=db_query("SELECT users.user_name AS User_Name FROM users,project_assigned_to
+ WHERE users.user_id=project_assigned_to.assigned_to_id AND project_task_id='$project_task_id'");
ShowResultSet($result2,$Language->getText('pm_detailtask','assigned_to'), false, false);
?>
</td>
Get the list of ids this is dependent on and convert to array
to pass into multiple select box
*/
- $result2=db_query("SELECT project_task.summary FROM project_dependencies,project_task ".
- "WHERE is_dependent_on_task_id=project_task.project_task_id AND project_dependencies.project_task_id='$project_task_id'");
+ $result2=db_query("SELECT project_task.summary FROM project_dependencies,project_task
+ WHERE is_dependent_on_task_id=project_task.project_task_id
+ AND project_dependencies.project_task_id='$project_task_id'");
ShowResultSet($result2,$Language->getText('pm_detailtask','dependend_on_task'), false, false);
?>
</td>
function multipleDependBox ($name='dependent_on[]') {
$result=$this->getOtherTasks();
//get the data so we can mark items as SELECTED
- $arr2 =& $this->getDependentOn();
- /* fix bug 319: if array is empty, preselect 100 (none) */
- if (!$arr2){
- $arr2[]=100;
- }
return html_build_multiple_select_box ($result,$name,$arr2);
}
?>
</td>
</tr>
+ <input type="hidden" name="duration" value="<?php echo $pt->getDuration(); ?>">
+ <input type="hidden" name="parent_id" value="<?php echo $pt->getParentID(); ?>">
+<!--
+//will add duration and parent selection boxes
+ <tr>
+ <td>
+ <strong><?php echo $Language->getText('pm','hours') ?>:</strong><br />
+ <input type="text" name="hours" size="5" value="<?php echo $pt->getHours(); ?>" />
+ </td>
+ <td>
+ <strong><?php echo $Language->getText('pm','status') ?>:</strong><br />
+ <?php
+// echo $pg->statusBox('status_id', $pt->getStatusID(), false );
+ ?>
+ </td>
+ </tr>
+-->
<tr>
<td colspan="2">
<?php echo $pt->showDependentTasks(); ?>
$start_date=mktime($start_hour,$start_minute,0,$start_month,$start_day,$start_year);
$end_date=mktime($end_hour,$end_minute,0,$end_month,$end_day,$end_year);
- if (!$pt->create($summary,$details,$priority,$hours,$start_date,$end_date,$category_id,$percent_complete,$assigned_to,$dependent_on)) {
+ if (!$pt->create($summary,$details,$priority,$hours,$start_date,$end_date,$category_id,$percent_complete,$assigned_to,$pt->convertDependentOn($dependent_on),$duration,$parent_id)) {
exit_error('ERROR',$pt->getErrorMessage());
} else {
if (count($add_artifact_id) > 0) {
$start_date=mktime($start_hour,$start_minute,0,$start_month,$start_day,$start_year);
$end_date=mktime($end_hour,$end_minute,0,$end_month,$end_day,$end_year);
if (!$pt->update($summary,$details,$priority,$hours,$start_date,$end_date,
- $status_id,$category_id,$percent_complete,$assigned_to,$dependent_on,$new_group_project_id)) {
+ $status_id,$category_id,$percent_complete,$assigned_to,$pt->convertDependentOn($dependent_on),$new_group_project_id,$duration,$parent_id)) {
exit_error('ERROR','update():: '.$pt->getErrorMessage());
} else {
if (count($rem_artifact_id) > 0) {
//yikes, we want the ability to mass-update to "un-assigned", which is the ID=100, which
//conflicts with the "no change" ID! Sorry for messy use of 100.1
$_assigned_to=(($assigned_to != '100.1') ? $pt->getAssignedTo() : array('100'));
- $_dependent_on=$pt->getDependentOn();
+ $_dependent_on=array_keys($pt->getDependentOn());
$_new_group_project_id=(($new_group_project_id != 100) ? $new_group_project_id : $pt->ProjectGroup->getID() );
+ $_duration=$pt->getDuration();
+ $_parent_id=$pt->getParentID();
if (!$pt->update($_summary,$_details,$_priority,$_hours,$_start_date,$_end_date,
- $_status_id,$_category_id,$_percent_complete,$_assigned_to,$_dependent_on,$_new_group_project_id)) {
+ $_status_id,$_category_id,$_percent_complete,$_assigned_to,$_dependent_on,$_new_group_project_id,$_duration,$parent_id)) {
$was_error=true;
$feedback .= ' ID: '.$project_task_id_list[$i].'::'.$pt->getErrorMessage();