Пример #1
0
 public function addComment($authorId, array $data)
 {
     $fields = array();
     if (!empty($data['fileId'])) {
         $fields['UF_FORUM_MESSAGE_DOC'] = array($data['fileId']);
     } elseif (!empty($data['versionId'])) {
         $fields['UF_FORUM_MESSAGE_VER'] = $data['versionId'];
     }
     \CTaskComments::add($this->entityId, $authorId, $data['text'], $fields);
 }
Пример #2
0
 /**
  * @param CTaskItemInterface $oTaskItem
  * @param array $arFields with mandatory elements POST_MESSAGE
  * @throws TasksException
  * @return CTaskElapsedItem
  */
 public static function add(CTaskItemInterface $oTaskItem, $arFields)
 {
     CTaskAssert::assert(is_array($arFields) && !empty($arFields));
     // if you reached this point (e.g. created an instance of a task class, you have an access to the task and therefore can comment it)
     //if ( ! $this->isActionAllowed(CTaskItem::ACTION_COMMENT_ADD) )
     //	throw new TasksException('', TasksException::TE_ACTION_NOT_ALLOWED);
     $obComment = new CTaskComments();
     $messageId = $obComment->add($oTaskItem->getId(), $oTaskItem->getExecutiveUserId(), $arFields['POST_MESSAGE']);
     if ($messageId === false) {
         throw new TasksException('', TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED);
     }
     return new self($oTaskItem, (int) $messageId);
 }
Пример #3
0
$GLOBALS["USER"]->Authorize($arUser["ID"]);
$TASK_ID = false;
if (preg_match("/task([0-9]+)/i", $arData["repository"]["name"], $r)) {
    $TASK_ID = $r[1];
} elseif (preg_match("/task([0-9]+)/i", $arData["repository"]["description"], $r)) {
    $TASK_ID = $r[1];
} elseif (preg_match("/task([0-9]+)/i", $arData["ref"], $r)) {
    $TASK_ID = $r[1];
}
CModule::IncludeModule("tasks");
CModule::IncludeModule("forum");
$branch = $arData["ref"];
$branch = str_replace("refs/heads/", "", $branch);
foreach ($arData["commits"] as $arCommit) {
    $message = $arCommit["message"];
    $message = utf8win1251($message);
    if (preg_match("/task([0-9]+)/i", $message, $r)) {
        $TASK_ID = $r[1];
    }
    if (!$TASK_ID) {
        continue;
    }
    $message = str_replace($r[0], "", $message);
    $rsTask = CTasks::GetList(array(), array("ID" => $TASK_ID));
    $arTask = $rsTask->Fetch();
    if (!$arTask) {
        continue;
    }
    CTaskComments::add($arTask["ID"], $arUser["ID"], "<b>Commit:</b> <a href=" . $arCommit["url"] . ">" . substr($arCommit["id"], 0, 9) . "</a>\nBranch: " . $branch . "\n" . $message);
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";