Ejemplo n.º 1
0
     break;
 case "add_comment_full_report":
     $bReturnRes = true;
     $ID = intval($_POST["report_id"]);
     $dbReport = CTimeManReportFull::GetByID($ID);
     $report = $dbReport->Fetch();
     if ($report && CModule::IncludeModule("forum")) {
         $OWNER = intval($report["USER_ID"]);
         $CURRENT_USER = $USER->GetID();
         $arAccessUsers = CTimeMan::GetAccess();
         $bCanEditAll = in_array('*', $arAccessUsers['WRITE']);
         $bCanReadAll = in_array('*', $arAccessUsers['READ']);
         $bCanAddComment = in_array($OWNER, $arAccessUsers['WRITE']) || CTimeMan::IsAdmin() || $bCanEditAll || $OWNER == $CURRENT_USER;
         if ($_POST["add_comment"] == "Y" && $bCanAddComment) {
             $arFields = array("REPORT_ID" => $ID, "COMMENT_TEXT" => $_POST["comment_text"], "USER_ID" => $CURRENT_USER, "REPORT_OWNER" => $OWNER);
             $comment_id = CReportNotifications::AddCommentToLog($arFields);
             ob_start();
             $APPLICATION->IncludeComponent("bitrix:timeman.topic.reviews", "", array("REPORT_ID" => $ID), false);
             $res["COMMENTS"] = ob_get_contents();
             ob_end_clean();
             $count = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $report['FORUM_TOPIC_ID']), true);
             $res["COMMENTS_COUNT"] = $count;
         } else {
             $res = array("ERROR" => "ADD COMMENT ERROR");
         }
     } else {
         $res = array("ERROR" => "ADD COMMENT ERROR");
     }
     break;
 case "add_comment_entry":
     $bReturnRes = true;
Ejemplo n.º 2
0
 public static function OnAfterUserUpdate($arFields)
 {
     if (array_key_exists("UF_DEPARTMENT", $arFields)) {
         $arDept = $arFields["UF_DEPARTMENT"];
         if (!is_array($arDept)) {
             $arDept = array($arDept);
         }
         foreach ($arDept as $key => $val) {
             if (intval($val) <= 0) {
                 unset($arDept[$key]);
             }
         }
         if (!empty($arDept) && CModule::IncludeModule("socialnetwork")) {
             $arNewRights = CReportNotifications::GetRights($arFields["ID"]);
             $rsLog = CSocNetLog::GetList(array(), array('ENTITY_TYPE' => SONET_WORK_REPORT_ENTITY, 'ENTITY_ID' => $arFields["ID"], 'EVENT_ID' => "report"), false, false, array("ID"));
             while ($arLog = $rsLog->Fetch()) {
                 $arOldRights = array();
                 $rsLogRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arLog["ID"]));
                 while ($arLogRight = $rsLogRight->Fetch()) {
                     $arOldRights[] = $arLogRight["GROUP_CODE"];
                 }
                 $diff1 = array_diff($arNewRights, $arOldRights);
                 $diff2 = array_diff($arOldRights, $arNewRights);
                 if (!empty($diff1) || !empty($diff2)) {
                     CSocNetLogRights::DeleteByLogID($arLog["ID"]);
                     CSocNetLogRights::Add($arLog["ID"], $arNewRights);
                 }
             }
         }
     }
 }