Example #1
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     $str_url = "";
     $str_name = "";
     $str_addon = "";
     switch ($obj->type) {
         case ITEM_PROJECT:
             if ($project = Project::getVisibleById($obj->id)) {
                 $str_name = asHtml($project->name);
                 $str_url = $PH->getUrl('projView', array('prj' => $project->id));
             }
             break;
         case ITEM_TASK:
             if ($task = Task::getVisibleById($obj->id)) {
                 $str_name = asHtml($task->name);
                 $str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
                 if ($project = Project::GetVisibleById($task->project)) {
                     $str_addon = "(" . $project->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_COMMENT:
             if ($comment = Comment::getVisibleById($obj->id)) {
                 if ($comment->name == '') {
                     $str_name = "-";
                 } else {
                     $str_name = asHtml($comment->name);
                 }
                 $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                 $str_addon .= "(";
                 if ($task = Task::getVisibleById($comment->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= $project->getLink(false) . " > ";
                     }
                     $str_addon .= $task->getLink(false);
                     if ($comment->comment) {
                         if ($comm = Comment::getVisibleById($comment->comment)) {
                             $str_addon .= " > " . $comm->name;
                         }
                     }
                 }
                 $str_addon .= ")";
             }
             break;
         case ITEM_COMPANY:
             if ($c = Company::getVisibleById($obj->id)) {
                 $str_name = asHtml($c->name);
                 $str_url = $PH->getUrl('companyView', array('company' => $c->id));
             }
             break;
         case ITEM_PERSON:
             if ($person = Person::getVisibleById($obj->id)) {
                 $str_name = asHtml($person->name);
                 $str_url = $PH->getUrl('personView', array('person' => $person->id));
             }
             break;
         case ITEM_PROJECTPERSON:
             if ($pp = ProjectPerson::getVisibleById($obj->id)) {
                 if (!($person = new Person($pp->person))) {
                     $PH->abortWarning("ProjectPerson has invalid person-pointer!", ERROR_BUG);
                 }
                 $str_name = asHtml($person->name);
                 $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 if ($project = Project::getVisibleById($pp->project)) {
                     $str_addon = "(" . $project->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_EMPLOYMENT:
             if ($emp = Employment::getById($obj->id)) {
                 if ($person = Person::getVisibleById($emp->person)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 if ($company = Company::getVisibleById($emp->company)) {
                     $str_addon = "(" . $company->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_EFFORT:
             if ($e = Effort::getVisibleById($obj->id)) {
                 $str_name = asHtml($e->name);
                 $str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
                 if ($task = Task::getVisibleById($e->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= "(" . $project->getLink(false);
                         $str_addon .= " > " . $task->getLink(false) . ")";
                     }
                 }
             }
             break;
         case ITEM_FILE:
             if ($f = File::getVisibleById($obj->id)) {
                 $str_name = asHtml($f->org_filename);
                 $str_url = $PH->getUrl('fileView', array('file' => $f->id));
                 $str_addon .= "(";
                 if ($p = Project::getVisibleById($f->project)) {
                     $str_addon .= $p->getLink(false);
                 }
                 if ($t = Task::getVisibleById($f->parent_item)) {
                     $str_addon .= " > " . $t->getLink(false);
                 }
                 $str_addon .= ")";
             }
             break;
         case ITEM_ISSUE:
             if ($i = Issue::getVisibleById($obj->id)) {
                 if ($t = Task::getVisibleById($i->task)) {
                     $str_name = asHtml($t->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $t->id));
                     if ($p = Project::getVisibleById($t->project)) {
                         $str_addon .= "(" . $p->getLink(false) . ")";
                     }
                 }
             }
             break;
         case ITEM_TASKPERSON:
             if ($tp = TaskPerson::getVisibleById($obj->id)) {
                 if ($person = Person::getVisibleById($tp->person)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 if ($task = Task::getVisibleById($tp->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= "(" . $project->getLink(false);
                         $str_addon .= " > " . $task->getLink(false) . ")";
                     }
                 }
             }
             break;
         default:
             break;
     }
     print "<td><a href='{$str_url}'>{$str_name}</a><span class='sub who'> {$str_addon}</span></td>";
 }