Esempio n. 1
0
     break;
 case "add_comment_entry":
     $bReturnRes = true;
     $ID = intval($_REQUEST["entry_id"]);
     $dbEntry = CTimeManEntry::GetByID($ID);
     $entry = $dbEntry->Fetch();
     if ($entry && CModule::IncludeModule("forum")) {
         $OWNER = intval($entry["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 ($bCanAddComment) {
             $arFields = array("ENTRY_ID" => $ID, "COMMENT_TEXT" => $_REQUEST["comment_text"], "USER_ID" => $USER->GetID());
             $comment_id = CTimeManNotify::AddCommentToLog($arFields);
             ob_start();
             $APPLICATION->IncludeComponent('bitrix:timeman.topic.reviews', '', array('ENTRY_ID' => $ID), null, array('HIDE_ICONS' => 'Y'));
             $res['COMMENTS'] = trim(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 'save':
     $arSettings = $obUser->GetSettings(array('UF_TM_REPORT_REQ'));
 public static function AddComment_Report($arFields)
 {
     $dbResult = CSocNetLog::GetList(array("ID" => "DESC"), array("TMP_ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "PARAMS", "SITE_ID"));
     $FORUM_ID = 0;
     if (($arLog = $dbResult->Fetch()) && $arLog["SOURCE_ID"] > 0) {
         $FORUM_ID = CTimeManNotify::GetForum($arLog);
     }
     if ($FORUM_ID > 0) {
         $arReturn = CReportNotifications::AddComment_Report_Forum($arFields, $FORUM_ID, $arLog);
         if (intval($arReturn["SOURCE_ID"]) > 0) {
             $arReportFields = array("REPORT_ID" => $arLog["SOURCE_ID"], "USER_ID" => $arFields["USER_ID"], "LOG_ID" => $arLog["ID"], "MESSAGE" => $arFields["TEXT_MESSAGE"]);
             CReportNotifications::AddCommentToIM($arReportFields);
         }
     } else {
         $arReturn = array("SOURCE_ID" => false, "ERROR" => GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR"), "NOTES" => "");
     }
     return $arReturn;
 }
Esempio n. 3
0
 public static function Approve($ID, $check_rights = true)
 {
     if ($check_rights) {
         $hasAccess = false;
         $arAccessUsers = CTimeMan::GetAccess();
         if (count($arAccessUsers['WRITE']) > 0) {
             $bCanEditAll = in_array('*', $arAccessUsers['WRITE']);
             $dbRes = CTimeManEntry::GetList(array(), array('ID' => $ID), false, false, array('*'));
             $arRes = $dbRes->Fetch();
             if ($arRes) {
                 $hasAccess = $bCanEditAll || in_array($arRes['USER_ID'], $arAccessUsers['WRITE']);
             }
         }
         if (!$hasAccess) {
             $GLOBALS['APPLICATION']->ThrowException('Access denied');
             return false;
         }
     }
     if (CTimeManEntry::Update($ID, array('ACTIVE' => 'Y'))) {
         CTimeManReport::Approve($ID);
         CTimeManReportDaily::SetActive($ID);
         CTimeManNotify::SendMessage($ID, 'U');
         return true;
     }
     return false;
 }
Esempio n. 4
0
 function AddCommentToLog($arFields)
 {
     global $DB, $USER;
     CModule::IncludeModule("socialnetwork");
     $result = false;
     $LOG_ID = CTimeManNotify::SendMessage($arFields["ENTRY_ID"], 'A');
     $arMessFields = array("EVENT_ID" => "timeman_entry_comment", "ENTITY_ID" => $arFields["USER_ID"], "TEXT_MESSAGE" => $arFields["COMMENT_TEXT"], "MESSAGE" => $arFields["COMMENT_TEXT"], "USER_ID" => $arFields["USER_ID"], "ENTITY_TYPE" => SONET_TIMEMAN_ENTRY_ENTITY, "LOG_ID" => $LOG_ID, "=LOG_DATE" => $DB->CurrentTimeFunction());
     $result = CSocNetLogComments::Add($arMessFields, true, false);
     CSocNetLog::CounterIncrement($result, false, false, "LC");
     $curUser = $USER->GetID();
     $dbLogRights = CSocNetLogRights::GetList(array(), array("LOG_ID" => $LOG_ID));
     while ($arRight = $dbLogRights->Fetch()) {
         $arRights[] = $arRight["GROUP_CODE"];
     }
     if (!in_array("U" . $curUser, $arRights)) {
         CSocNetLogRights::Add($LOG_ID, "U" . $curUser);
     }
     return $result;
 }
Esempio n. 5
0
 public function CloseDay($timestamp = false, $report = '', $bFieldsOnly = false)
 {
     global $APPLICATION;
     if (($last_entry = $this->_GetLastData(true)) && (!$last_entry['DATE_FINISH'] || $last_entry['PAUSED'] == 'Y')) {
         if ($this->OpenAction($bSkipCheck) === 'REOPEN') {
             $last_entry = $this->ReopenDay();
         }
         if ($timestamp <= 0) {
             $timestamp = false;
         } else {
             $timestamp = CTimeMan::ConvertShortTS($timestamp - CTimeZone::GetOffset(), ConvertTimeStamp(MakeTimeStamp($last_entry['DATE_START'], FORMAT_DATETIME), 'SHORT'));
         }
         if ($this->State() == 'EXPIRED' && !$timestamp) {
             $GLOBALS['APPLICATION']->ThrowException('Workday is expired', 'WD_EXPIRED');
             return false;
         }
         $arFields = array('USER_ID' => $this->USER_ID, 'DATE_START' => $last_entry['DATE_START'], 'DATE_FINISH' => ConvertTimeStamp(($timestamp ? $timestamp : time()) + CTimeZone::GetOffset(), 'FULL'), 'PAUSED' => 'N');
         if (!$this->isEntryValid('CLOSE', $timestamp)) {
             $arFields['ACTIVE'] = 'N';
             if (strlen($report) > 0) {
                 $arFields['REPORTS'] = array();
                 if ($ex = $APPLICATION->GetException()) {
                     $arFields['REPORTS'][] = array('REPORT_TYPE' => 'ERR_CLOSE', 'REPORT' => $ex->GetId() . ';' . date('c') . ';' . $ex->GetString());
                 }
                 $arFields['REPORTS'][] = array('REPORT_TYPE' => 'REPORT_CLOSE', 'REPORT' => $report);
             } else {
                 if ($ex = $APPLICATION->GetException()) {
                     $APPLICATION->ThrowException($ex->GetString(), 'REPORT_NEEDED');
                 }
                 return false;
             }
         }
         if ($timestamp === false) {
             $timestamp = time();
         }
         if ($timestamp + CTimeZone::GetOffset() < MakeTimeStamp($last_entry['DATE_START'])) {
             return false;
         }
         $arFields['IP_CLOSE'] = $_SERVER['REMOTE_ADDR'];
         if ($bFieldsOnly) {
             return $arFields;
         } else {
             if (CTimeManEntry::Update($last_entry['ID'], $arFields)) {
                 if (isset($arFields['ACTIVE']) && $arFields['ACTIVE'] == 'N') {
                     CTimeManNotify::SendMessage($last_entry['ID']);
                 }
                 return $this->_GetLastData(true);
             }
         }
     } else {
         $GLOBALS['APPLICATION']->ThrowException('WD_NOT_OPEN');
     }
     return false;
 }