// Create a linked list based on the msproj_id
//
for ($i=0; $i<$count; $i++) {
- $msprojid[$tasks[$i]['msproj_id']] =& $tasks[$i];
- $resrc = $tasks[$i]['resources'];
- for ($j=0; $j<count($resrc); $j++) {
- //validate user - see if they really exist as techs in this subproject
- if (!util_ifsetor($tarr[strtolower($resrc[$j]['user_name'])])) {
- //create list of bogus names to send back
- if (array_search(strtolower($resrc[$j]['user_name']),$invalid_names) === false) {
- $invalid_names[]=$resrc[$j]['user_name'];
+ if (isset($tasks[$i]['msproj_id'])) {
+ $msprojid[$tasks[$i]['msproj_id']] =& $tasks[$i];
+ }
+ if (isset($tasks[$i]['resources'])) {
+ $resrc = $tasks[$i]['resources'];
+ for ($j=0; $j<count($resrc); $j++) {
+ //validate user - see if they really exist as techs in this subproject
+ if (!util_ifsetor($tarr[strtolower($resrc[$j]['user_name'])])) {
+ //create list of bogus names to send back
+ if (array_search(strtolower($resrc[$j]['user_name']),$invalid_names) === false) {
+ $invalid_names[]=$resrc[$j]['user_name'];
+ }
}
}
}
}
//map users
$assignees=array();
- $resrc = $tasks[$i]['resources'];
- for ($ucount=0; $ucount< count($resrc); $ucount++) {
- //get their user_id from the $tarr we created earlier
- $assignees[]=$tarr[strtolower($resrc[$ucount]['user_name'])];
+ if (isset($tasks[$i]['resources'])) {
+ $resrc = $tasks[$i]['resources'];
+ for ($ucount=0; $ucount< count($resrc); $ucount++) {
+ //get their user_id from the $tarr we created earlier
+ $assignees[]=$tarr[strtolower($resrc[$ucount]['user_name'])];
+ }
}
//don't do anything with dependencies yet - we may only have
//the MSprojid from dependent items
} else {
$category_id = $pt->getCategoryID();
}
-
+ $deps = array();
if (!$pt->create(
$tasks[$i]['name'],
$tasks[$i]['notes'],
$category_id,
$percent_complete,
$assignees,
- $deps = array(),
+ $deps,
$tasks[$i]['duration'],
$tasks[$i]['parent_id'])) {
$array['success']=false;
//successful
$tasks[$i]['id'] = $pt->getID();
$tasks[$i]['obj'] = $pt;
- $pt->setExternalID($tasks[$i]['msproj_id']);
+ if (isset($tasks[$i]['msproj_id'])) {
+ $pt->setExternalID($tasks[$i]['msproj_id']);
+ }
$pt = null;
}
}
//map users
$assignees=array();
- $resrc = $tasks[$i]['resources'];
- for ($ucount=0; $ucount<count($resrc); $ucount++) {
- //get their user_id from the $tarr we created earlier
- $assignees[]=$tarr[strtolower($resrc[$ucount]['user_name'])];
+ if (isset($tasks[$i]['resources'])) {
+ $resrc = $tasks[$i]['resources'];
+ for ($ucount=0; $ucount<count($resrc); $ucount++) {
+ //get their user_id from the $tarr we created earlier
+ $assignees[]=$tarr[strtolower($resrc[$ucount]['user_name'])];
+ }
}
//don't do anything with dependencies yet - we may only have the
$category_id = $pt->getCategoryID();
}
+ $depends_on = $pt->getDependentOn();
+
if (!$pt->update(
$tasks[$i]['name'],
$tasks[$i]['notes'],
$category_id,
$percent_complete,
$assignees,
- $pt->getDependentOn(),
+ $depends_on,
$pg->getID(),
$tasks[$i]['duration'],
$tasks[$i]['parent_id'])) {
//successful
$tasks[$i]['id'] = $pt->getID();
$tasks[$i]['obj'] = $pt;
- $pt->setExternalID($tasks[$i]['msproj_id']);
+ if (isset($tasks[$i]['msproj_id'])) {
+ $pt->setExternalID($tasks[$i]['msproj_id']);
+ }
$pt = null;
}
if (!$was_error) {
//iterate the tasks
for ($i=0; $i<$count; $i++) {
- $darr=$tasks[$i]['dependenton'];
+ if (isset($tasks[$i]['dependenton'])) {
+ $darr=$tasks[$i]['dependenton'];
- $deps=array();
- //iterate each dependency in a task
- for ($dcount=0; $dcount<count($darr); $dcount++) {
- //get the id of the task we're dependent on -
- // may have to get it from msprojid linked list
- $id=$darr[$dcount]['task_id'];
- if ($id < 1) {
- $id=$msprojid[$darr[$dcount]['msproj_id']]['id'];
- }
- //prevent task from being dependent on itself
- if ($id == $tasks[$i]['id']) {
- continue;
+ $deps=array();
+ //iterate each dependency in a task
+ for ($dcount=0; $dcount<count($darr); $dcount++) {
+ //get the id of the task we're dependent on -
+ // may have to get it from msprojid linked list
+ $id=$darr[$dcount]['task_id'];
+ if ($id < 1) {
+ $id=$msprojid[$darr[$dcount]['msproj_id']]['id'];
+ }
+ //prevent task from being dependent on itself
+ if ($id == $tasks[$i]['id']) {
+ continue;
+ }
+ $deps[$id]=$darr[$dcount]['link_type'];
}
- $deps[$id]=$darr[$dcount]['link_type'];
- }
- if (isset($tasks[$i]['obj']) && is_object($tasks[$i]['obj'])) {
- if (!$tasks[$i]['obj']->setDependentOn($deps)) {
- $was_error=true;
- $array['success']=false;
+ if (isset($tasks[$i]['obj']) && is_object($tasks[$i]['obj'])) {
+ if (!$tasks[$i]['obj']->setDependentOn($deps)) {
+ $was_error=true;
+ $array['success']=false;
+ }
}
- } else {
- // $was_error=true;
- // $array['success']=false;
+ unset($deps);
}
- unset($deps);
} //iterates tasks to do dependencies
}