Ejemplo n.º 1
0
 /**
  * Checks whether a #<number> string should be taken as a workitem link or not.
  * This function is used as a callback with preg_replace_callback (see below lines)
  */
 function workitemLinkPregReplaceCallback($matches)
 {
     $job_id = (int) $matches[1];
     if ($job_id < 99999 && WorkItem::idExists($job_id)) {
         return DELIMITER . '<a href="' . WORKLIST_URL . $job_id . '"' . ' class="worklist-item" id="worklist-' . $job_id . '" >#' . $job_id . '</a>' . DELIMITER . $matches[2];
     } else {
         return $matches[0];
     }
 }
Ejemplo n.º 2
0
 public static function isJobId($id)
 {
     if (WorkItem::idExists($id)) {
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 private function getRelated($input)
 {
     $related = "";
     $twoIds = false;
     if (preg_match_all('/(\\#[1-9][0-9]{4})(\\s|[^0-9a-z]|$)/i', $input, $matches)) {
         $distinctMatches = array_unique($matches[1]);
         foreach ($distinctMatches as $match) {
             $job_id = (int) substr($match, 1);
             if ($job_id != $worklist_id && WorkItem::idExists($job_id)) {
                 if ($related != "") {
                     $twoIds = true;
                     $related .= ", #" . $job_id;
                 } else {
                     $related = " #" . $job_id;
                 }
             }
         }
     }
     if ($related != "") {
         $related .= ")";
         if ($twoIds == true) {
             $related = " (related jobs: " . $related;
         } else {
             $related = " (related job: " . $related;
         }
     }
     return $related;
 }