Esempio n. 1
0
 public static function get_list($_FORM = array())
 {
     // Two modes, 1: get all comments for an entity, eg a task
     if ($_FORM["entity"] && in_array($_FORM["entity"], array("project", "client", "task", "timeSheet")) && $_FORM["entityID"]) {
         $e = new $_FORM["entity"]();
         $e->set_id($_FORM["entityID"]);
         if ($e->select()) {
             // this ensures that the user can read the entity
             return comment::util_get_comments_array($_FORM["entity"], $_FORM["entityID"], $_FORM);
         }
         // Or 2: get all starred comments
     } else {
         if ($_FORM["starred"]) {
             $filter = comment::get_list_filter($_FORM);
             if (is_array($filter) && count($filter)) {
                 $filter = " WHERE " . implode(" AND ", $filter);
             }
             $q = "SELECT comment.*, commentCreatedUser as personID, clientContact.clientContactName\n              FROM comment \n         LEFT JOIN clientContact on comment.commentCreatedUserClientContactID = clientContact.clientContactID\n                 " . $filter . " \n          ORDER BY commentCreatedTime";
             $db = new db_alloc();
             $db->query($q);
             $people =& get_cached_table("person");
             while ($row = $db->next_record()) {
                 $e = new $row["commentMaster"]();
                 $e->set_id($row["commentMasterID"]);
                 $e->select();
                 $row["entity_link"] = $e->get_link();
                 $row["personID"] and $row["person"] = $people[$row["personID"]]["name"];
                 $row["clientContactName"] and $row["person"] = $row["clientContactName"];
                 $rows[] = $row;
             }
             has("timeSheetItem") and $tsi_rows = timeSheetItem::get_timeSheetItemComments(null, true);
             foreach ((array) $tsi_rows as $row) {
                 $t = new task();
                 $t->set_id($row["taskID"]);
                 $t->select();
                 $row["entity_link"] = $t->get_link();
                 $row["commentMaster"] = "Task";
                 $row["commentMasterID"] = $row["taskID"];
                 $row["commentCreatedTime"] = $row["date"];
                 $row["personID"] and $row["person"] = $people[$row["personID"]]["name"];
                 $rows[] = $row;
             }
             return (array) $rows;
         }
     }
 }
Esempio n. 2
0
 function get_task_comments_array()
 {
     $rows = comment::util_get_comments_array("task", $this->get_id());
     $rows or $rows = array();
     return $rows;
 }