$postFunction($_POST); } } } function defaultAction() { UI::layout([ $this, 'defaultView' ]); } function defaultView() { $usrLogin = User::getLogin(); //$this->menu(); $this->userMsgs($usrLogin); } function menu() { $usrLogin = User::getLogin(); echo UI::h('ul', [], [ UI::h('li', [], "TODO: ..."), ]); } function userMsgs($usrLogin) { $msgsList = $this->getMsgs('inbox', $usrLogin); $totalReadMsgs = 0; $totalUnreadMsgs = 0; foreach ($msgsList as $ind => $msg) { if ($msg['_read']) { $totalReadMsgs++; } else { $totalUnreadMsgs++; } } $sentMsgsList = $this->getMsgs('sent', $usrLogin); $removedMsgsList = $this->getMsgs('removed', $usrLogin); ?>

Wiadomości

_printUserMsgsList('inbox', $msgsList, $usrLogin); ?>
_printUserMsgsList('sent', $sentMsgsList, $usrLogin); ?>
_printUserMsgsList('removed', $removedMsgsList, $usrLogin); ?>
msgs = $this->getMsgs($listType, $usrLogin, $lastMsgId); $resultData->keysOrder = array_keys($resultData->msgs); echo json_encode($resultData); } function _printUserMsgsList($listType, $msgsList, $usrLogin) { $msgsTotal = count($msgsList); $listLimit = $this->_listLimit; $lastMsgId = 0; $viewMsgList = array_slice($msgsList, 0, $this->_listLimit, $preserve_keys = true); if ($msgsTotal > $listLimit) { $msgIds = array_slice(array_keys($msgsList), 0, $listLimit); $lastMsgId = array_pop($msgIds); } $actionTask = ($listType == 'inbox')? 'read' : 'view'; echo UI::h('table', [ 'class' => "tblMsgsList table table-hovered", 'style' => "margin-bottom:0; table-layout:fixed" ], [ UI::h('thead', [], [ UI::h('tr', [], [ UI::h('th', [ 'style' => "width:60px" ], "#"), UI::h('th', [], "wiadomość"), UI::h('th', [ 'style' => "width:130px" ], "data"), ]), ]), ($msgsTotal > $listLimit) ? UI::h('tfoot', [], [ UI::h('tr', [ 'class' => "active" ], [ UI::h('td', [ 'colspan' => "3", 'style' => "text-align:center" ], [ UI::h('button', [ 'class' => "btn btn-link", 'data-last_msg_id' => $lastMsgId, 'data-list_type' => $listType, 'onclick' => "return tblMsgsLoadMoreRows(this);", ], "pobierz starsze wiadomości ..."), ]), ]), ]) : '' , UI::h('tbody', [], ($msgsTotal <= 0) ? UI::h('tr', [], [ UI::h('td', [ 'colspan' => "3" ], [ UI::h('em', [ 'class' => "text-muted", 'style' => "padding-left:60px;" ], "Brak wiadomości"), ]), ]) : array_map(function ($msg) use ($actionTask, $usrLogin) { $msgLink = ('read' == $actionTask || 'view' == $actionTask) ? $this->getLink($actionTask, [ 'id' => $msg['_raw']->ID, 'usrLogin' => $usrLogin ]) : null ; $jsOnClick = ($msgLink) ? "window.location.href='{$msgLink}'" : '' ; return UI::h('tr', [ 'onclick' => $jsOnClick, 'class' => "tblMsgsListItem " . ($msg['_read'] ? 'active' : '') ], [ UI::h('td', [], $msg['_raw']->ID), UI::h('td', [], [ UI::h('div', [ 'style' => "overflow:hidden; white-space:nowrap; text-overflow:ellipsis" ], htmlspecialchars($msg['message'])), UI::h('div', [ 'class' => "text-muted", 'style' => "font-style:italic"], [ "od {$msg['_raw']->A_RECORD_CREATE_AUTHOR} do " . $this->getOutMsgTarget($msg['_raw']), ]), ]), UI::h('td', [ 'style' => "white-space:nowrap" ], [ $msg['_raw']->A_RECORD_CREATE_DATE, ($msg['_readDate']) ? UI::h('div', [ 'class' => "text-muted", 'style' => "font-style:italic", 'title' => "Przeczytano {$msg['_readDate']}" ], $msg['_readDate']) : UI::h('div', [ 'class' => "text-muted", 'style' => "font-style:italic", 'title' => "Wiadomość nie została jeszcze odczytana" ], "nieodczytana") , ]), ]); }, $viewMsgList) ), ]); } function getOutMsgTarget($msg) { switch ($msg->userTargetType) { case 'everyone': return "wszystkich"; case 'user': return $msg->userTargetName; case 'group': return "grupy {$msg->userTargetName}"; default: return '???'; } } function getMsgs($filterType, $usrLogin, $lastMsgId = null, $fromTime = null) { $lastMsgId = (int)$lastMsgId; $msgsRoute = Router::getRoute('Msgs'); $msgsList = array(); if (empty($usrLogin)) throw new Exception("No user login!"); $sqlWhereAddFilter = ""; if ($usrLogin == User::getLogin()) { $userGroupIds = User::getGroupsIds(); } else { $userGroup = UsersHelper::getGroupByUserName($usrLogin); $userGroupIds = array_keys($userGroup); } $sqlFilerMsgsForUser = " m.`userTargetType` in('everyone') or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}') or (m.`userTargetType`='group' and m.`userTargetName` in(" . implode(",", $userGroupIds) . ")) "; switch ($filterType) { case 'inbox': $sqlWhereAddFilter = " and ({$sqlFilerMsgsForUser}) and m.`A_STATUS` in('WAITING', 'NORMAL') "; break; case 'unread': $sqlWhereAddFilter = " and ({$sqlFilerMsgsForUser}) and m.`A_STATUS` in('WAITING') "; break; case 'sent': $sqlWhereAddFilter = " and m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}' and (m.`A_STATUS` in('WAITING', 'NORMAL') or (m.`A_STATUS`='OFF_HARD' and m.`A_RECORD_DELETE_AUTHOR`!='{$usrLogin}') ) "; break; case 'removed': $sqlWhereAddFilter = " and (m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}' or ({$sqlFilerMsgsForUser}) ) and m.`A_STATUS` in('OFF_HARD', 'DELETED') "; break; default: throw new Exception("Unknown filter type"); } if ($lastMsgId > 0) { $sqlWhereAddFilter .= "\n and m.`ID`<{$lastMsgId}"; } if (!empty($fromTime)) { $sqlWhereAddFilter .= "\n and m.`A_RECORD_CREATE_DATE`>='{$fromTime}'"; } $sqlLimit = $this->_listLimit + 1; $sql = " select m.* from `CRM_UI_MSGS` m where m.`uiTargetType` = 'default_db_table_record' {$sqlWhereAddFilter} order by m.`ID` DESC limit {$sqlLimit} "; return array_map(function ($row) { return [ 'message' => $row['msg'], 'type' => $row['msgType'], '_raw' => (object)$row, '_read' => ('WAITING' != $row['A_STATUS']), '_readDate' => $row['actionExecutedTime'], ]; }, DB::getPDO()->fetchAllByKey($sql, 'ID')); } function _validate($args) { $toType = V::get('to_type', '', $args); $to = V::get('to', '', $args); $msg = V::get('msg', '', $args); if (!in_array($toType, array('everyone', 'user', 'group'))) { throw new Exception("Niedozwolony typ odbiorcy"); } if (empty($to) && 'everyone' != $toType) { throw new Exception("Proszę podać odbiorcę wiadomości"); } if (empty($msg)) { throw new Exception("Proszę podać treść wiadomości"); } } function _create($args, $tableName, $idRow) { $toType = V::get('to_type', '', $args); $to = V::get('to', '', $args); $msg = V::get('msg', '', $args); $usrLogin = User::getLogin(); try { $createdId = DB::getPDO()->insert('CRM_UI_MSGS', [ 'uiTargetType' => "default_db_table_record", 'uiTargetName' => "{$tableName}.{$idRow}", 'userTargetType' => $toType, 'userTargetName' => $to, 'msg' => $msg, 'A_RECORD_CREATE_DATE' => "NOW()", 'A_RECORD_CREATE_AUTHOR' => $usrLogin, 'A_STATUS' => "WAITING", 'app_className' => "TableMsgs", ]); } catch (Exception $e) { DBG::log($e); throw new Exception("Nie udało się zapisać wiadomości."); } return $createdId; } function _printMsgForm($args) { $toType = V::get('to_type', '', $args); $to = V::get('to', '', $args); $msg = V::get('msg', '', $args); $listTo = array(); $listTo['everyone'] = 'Wszyscy'; $listTo['user'] = 'Użytkownik'; $listTo['group'] = 'Grupa'; $toType = (array_key_exists($toType, $listTo))? $toType : 'everyone'; $typeSpecialGroupId = TypespecialVariable::getInstance(-1, '__ZASOB'); $typeSpecialUserLogin = TypespecialVariable::getInstance(-1, '__USER_LOGIN'); $selectedLogin = ('user' == $toType)? $to : ''; $selectedGroupId = ('group' == $toType)? $to : ''; ?>
showFormItem($tblID = -1, $fldName, $selectedGroupId, $fldParams); ?>
showFormItem($tblID = -1, $fldName, $selectedLogin, $fldParams); ?>
message = "TypeSpecial '__USER_LOGIN' not exists"; echo json_encode($jsonData); exit; } $query = V::get('q', '', $_REQUEST); $rawRows = null; $jsonData = array(); $queryParams = array(); $rows = $typeSpecialUserId->getValuesWithExports($query, $queryParams); foreach ($rows as $kID => $vItem) { $itemJson = new stdClass(); $itemJson->id = $vItem->id; $itemJson->name = $vItem->param_out; if (!empty($vItem->exports)) { $itemJson->exports = $vItem->exports; } $jsonData[] = $itemJson; } echo json_encode($jsonData); } function typeSpecialGroupIdAction() { header("Content-type: application/json"); Lib::loadClass('TypespecialVariable'); $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB'); if (!$typeSpecialZasob) { $jsonData = new stdClass(); $jsonData->message = "TypeSpecial '__ZASOB' not exists"; echo json_encode($jsonData); exit; } $query = V::get('q', '', $_REQUEST); $rawRows = null; $jsonData = array(); $queryParams = array(); $queryParams['zasob_type_in'] = array('STANOWISKO', 'PODMIOT', 'DZIAL'); $rows = $typeSpecialZasob->getValuesWithExports($query, $queryParams); DBG::_('DBG_TS', '>1', "rows({$query})", $rows, __CLASS__, __FUNCTION__, __LINE__); foreach ($rows as $kID => $vItem) { $itemJson = new stdClass(); $itemJson->id = $vItem->id; $itemJson->name = $vItem->param_out; if (!empty($vItem->exports)) { $itemJson->exports = $vItem->exports; } $jsonData[] = $itemJson; } echo json_encode($jsonData); } function readAction() { $idMsg = V::get('id', 0, $_GET, 'int'); $usrLogin = V::get('usrLogin', '', $_REQUEST, 'word'); if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404); if (empty($usrLogin)) throw new HttpException("Błęny user login!", 404); SE_Layout::gora(); SE_Layout::menu(); try { $msg = $this->_getMsg($idMsg, $usrLogin); $this->_markAsRead($msg); $this->viewMsg($msg); } catch (Exception $e) { SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine()); } SE_Layout::dol(); } function viewAction() { $idMsg = V::get('id', 0, $_GET, 'int'); $usrLogin = V::get('usrLogin', 0, $_REQUEST, 'word'); if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404); if (empty($usrLogin)) throw new HttpException("Błęny user login", 404); SE_Layout::gora(); SE_Layout::menu(); try { $msg = $this->_getMsg($idMsg, $usrLogin); $this->viewMsg($msg); } catch (Exception $e) { SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine()); } SE_Layout::dol(); } function _getMsg($idMsg, $usrLogin) { $msgsRoute = Router::getRoute('Msgs'); $msg['_raw'] = $msgsRoute->getMessage($idMsg); if (!$msg['_raw']) throw new HttpException("Wiadomość nie istnieje!", 404); $msg['usrLogin'] = $usrLogin; $msg['message'] = $msg['_raw']->msg; $msg['type'] = $msg['_raw']->msgType; $msg['_read'] = ('WAITING' != $msg['_raw']->A_STATUS); // `uiTargetType` enum('default_db_table','default_db_table_record','after_login','everywhere') NOT NULL, // TODO: add namespace, featureID // $msg['_raw']->uiTargetType => default_db_table_record // $msg['_raw']->uiTargetName => TEST_PERMS.31 if ('default_db_table_record' !== $msg['_raw']->uiTargetType) { throw new Exception("Parse message target type error!"); } $parts = explode('.', $msg['_raw']->uiTargetName); if (2 !== count($parts)) throw new Exception("Parse message target type error!"); $msg['tblName'] = $parts[0]; $msg['idRow'] = $parts[1]; if (!is_numeric($msg['idRow'])) throw new Exception("Parse message target type - id row type error!"); return $msg; } function _markAsRead($msg) { if ($msg['_read']) return; $usrLogin = User::getLogin(); $sql = " update `CRM_UI_MSGS` set `A_STATUS` = 'NORMAL' , `A_RECORD_UPDATE_AUTHOR` = '{$usrLogin}' , `A_RECORD_UPDATE_DATE` = NOW() , `actionExecutedTime` = NOW() where `ID`='{$msg['_raw']->ID}' and `A_STATUS` = 'WAITING' and `A_RECORD_UPDATE_AUTHOR` = '' and `A_RECORD_UPDATE_DATE` is null and ( ('{$usrLogin}' != `A_RECORD_CREATE_AUTHOR`) or ('{$usrLogin}' = `A_RECORD_CREATE_AUTHOR` and 'user' = `userTargetType` and '{$usrLogin}' = `userTargetName` ) ) "; try { DB::getPDO()->execSql($sql); } catch (Exception $e) { DBG::log($e); throw new Exception("Wystąpiły błędy podczas próby zapisu wiadomości: " . $e->getMessage()); } } function viewMsg($msg) { $usrLogin = User::getLogin(); $idTable = 0; //$rmMsgLink = "{$linkBase}&_task=removeMsg&id={$msg['_raw']->ID}"; $targetNamespace = (!empty($msg['tblName'])) ? "default_db/{$msg['tblName']}" : ""; // default_db/CRM_LISTA_ZASOBOW $idRow = (!empty($msg['idRow'])) ? $msg['idRow'] : ""; $targetLabel = ($targetNamespace) ? $this->getOutTargetLabel($targetNamespace) : ""; // $tblAcl->getRawLabel() echo UI::h('div', [ 'class' => "container" ], [ UI::h('h3', [], [ UI::h('i', [ 'class' => "glyphicon glyphicon-envelope" ]), " ", UI::h('a', [ 'href' => $this->getLink('', [ 'usrLogin' => $usrLogin ]) ], "Wiadomości {$usrLogin}"), " » ", " Wiadomość nr {$msg['_raw']->ID}", ($targetNamespace && $idRow) ? UI::h('small', [ 'style' => "display:block; text-align:right" ], [ UI::h('a', [ 'style' => "font-size:12px; line-height:15px; vertical-align:text-bottom", 'title' => "Edytuj rekord", 'href' => "index.php?_route=ViewTableAjax&namespace={$targetNamespace}#EDIT/{$idRow}", ], [ UI::h('i', [ 'class' => "glyphicon glyphicon-pencil" ]), " Edytuj rekord {$idRow}", ]), UI::h('span', [ 'style' => "font-size:12px; line-height:15px; vertical-align:text-bottom" ], " z tabeli "), UI::h('a', [ 'style' => "font-size:12px; line-height:15px; vertical-align:text-bottom", 'href' => "index.php?_route=ViewTableAjax&namespace={$targetNamespace}", ], $targetLabel), " ", $this->printMsgDropdownMenu($msg['_raw']), ]) : '' , ]), ]); $this->printWidgetViewMsg($msg); } function getOutTargetLabel($ns) { try { $acl = ACL::getAclByNamespace($ns); return $acl->getRawLabel(); } catch (Exception $e) { DBG::log($e); } return $ns; } function printMsgDropdownMenu($rawMsg) { $isRemoved = ('DELETED' === $rawMsg->A_STATUS || 'OFF_HARD' == $rawMsg->A_STATUS); return UI::h('div', [ 'class' => "dropdown", 'style' => "display:inline" ], [ UI::h('button', [ 'class' => "btn btn-xs btn-default dropdown-toggle", 'title' => "Message Menu", 'data-toggle' => "dropdown" ], [ UI::h('i', [ 'class' => "glyphicon glyphicon-menu-hamburger" ]), " Menu", ]), UI::h('ul', [ 'class' => "dropdown-menu dropdown-menu-right" ], [ UI::h('li', [], [ ($isRemoved) ? UI::h('form', [ 'method' => "POST" ], [ UI::h('input', [ 'type' => 'hidden', 'name' => "_postTask", 'value' => "restoreMsg" ]), UI::h('input', [ 'type' => 'hidden', 'name' => "id", 'value' => $rawMsg->ID ]), UI::h('button', [ 'type' => "submit", 'class' => "btn btn-link" ], [ UI::h('i', [ 'class' => "glyphicon glyphicon-inbox" ]), " Przywróć", ]), ]) : UI::h('form', [ 'method' => "POST" ], [ UI::h('input', [ 'type' => 'hidden', 'name' => "_postTask", 'value' => "removeMsg" ]), UI::h('input', [ 'type' => 'hidden', 'name' => "id", 'value' => $rawMsg->ID ]), UI::h('button', [ 'type' => "submit", 'class' => "btn btn-link", 'style' => "color:red" ], [ UI::h('i', [ 'class' => "glyphicon glyphicon-remove" ]), " Usuń" ]), ]) , ]), ]), ]); } function printWidgetViewMsg($msg) { $messageList = array(); $uiTargetName = $msg['_raw']->uiTargetName; $uiTargetType = $msg['_raw']->uiTargetType; $replyLink = "index.php?_route=UserMsgs&_task=reply&uiTargetName={$uiTargetName}&uiTargetType={$uiTargetType}"; $markAsReadLink = "index.php?_route=UserMsgs&_task=markAsRead"; $message = $this->_convertMessageToJson($msg['_raw']); {//if ($message->idThread > 0) { $sqlLimit = 100; $ds = DB::getDataSource(); $sqlIdThread = ($message->idThread > 0)? $message->idThread : $message->id; $sql = " select m.* from `CRM_UI_MSGS` m where (m.`idThread` = {$sqlIdThread} or m.`ID` = {$sqlIdThread}) -- and m.`ID` < {$message->id} order by m.`ID` asc limit {$sqlLimit} "; $moreMsgs = $ds->getListByQuery($sql); foreach ($moreMsgs as $msg) $messageList[] = $this->_convertMessageToJson($msg); } //$messageList[] = $message; ?>
id = $rawMsg->ID; $message->idThread = $rawMsg->idThread;// TODO: ID_THREAD $message->idReplyTo = $rawMsg->idReplyTo;// TODO: ID_REPLY_TO $message->message = $rawMsg->msg; $message->type = $rawMsg->msgType; $message->to = $rawMsg->userTargetName; $message->toType = $rawMsg->userTargetType; $message->author = $rawMsg->A_RECORD_CREATE_AUTHOR; $message->created = $rawMsg->A_RECORD_CREATE_DATE; $message->_read = ('WAITING' != $rawMsg->A_STATUS); $message->_readByUser = ('WAITING' != $rawMsg->A_STATUS); if ('WAITING' == $rawMsg->A_STATUS && $usrLogin == $rawMsg->A_RECORD_CREATE_AUTHOR) { if ('user' == $rawMsg->userTargetType && $usrLogin == $rawMsg->userTargetName) { $message->_readByUser = false; } else { $message->_readByUser = true; } } if ($message->_read) { if (!empty($rawMsg->A_RECORD_UPDATE_DATE)) $message->_readDate = $rawMsg->A_RECORD_UPDATE_DATE; if (!empty($rawMsg->A_RECORD_UPDATE_AUTHOR)) $message->_readBy = $rawMsg->A_RECORD_UPDATE_AUTHOR; } return $message; } function getMessagesByIdAction() { try { $idThread = V::get('idThread', '', $_GET, 'int'); $idLastMsg = V::get('idLastMsg', '', $_GET, 'int'); if ($idThread <= 0) throw new Exception("Wrong param id!"); $sqlLimit = 10;// TODO: 100? $ds = DB::getDataSource(); $sql = " select m.* from `CRM_UI_MSGS` m where m.`idThread` = {$idThread} and m.`ID` > {$idLastMsg} order by m.`ID` asc limit {$sqlLimit} "; $moreMsgs = $ds->getListByQuery($sql); $response = new stdClass(); $response->msg = "Nowe wiadomości"; $response->type = 'success'; $response->msgs = array(); foreach ($moreMsgs as $msg) { $response->msgs[] = $this->_convertMessageToJson($msg); } } catch (Exception $e) { $response = new stdClass(); $response->msg = "Wystąpiły błędy: " . $e->getMessage(); $response->type = 'danger'; } echo json_encode($response); } function replyAction() { try { $uiTargetType = V::get('uiTargetType', '', $_GET); $uiTargetName = V::get('uiTargetName', '', $_GET); $response = $this->_reply($uiTargetType, $uiTargetName, $_POST); } catch (Exception $e) { $response = new stdClass(); $response->msg = "Wystąpiły błędy: " . $e->getMessage(); $response->type = 'danger'; } echo json_encode($response); } function markAsReadAction() { $usrLogin = User::getLogin(); try { $idMsg = V::get('idMsg', '', $_GET, 'int'); $msg = $this->_getMsg($idMsg, $usrLogin); $this->_markAsRead($msg); $response = new stdClass(); //$response->msg = ""; $response->type = "success"; $msg = $this->_getMsg($idMsg, $usrLogin); $response->record = $this->_convertMessageToJson($msg['_raw']); } catch (Exception $e) { $response = new stdClass(); $response->msg = "Wystąpiły błędy: " . $e->getMessage(); $response->type = 'danger'; } echo json_encode($response); } function _reply($uiTargetType, $uiTargetName, $args) { $ds = DB::getDataSource(); $newMsg = array(); $newMsg['idReplyTo'] = V::get('idReplyTo', '', $args, 'int'); $newMsg['msg'] = V::get('message', '', $args); $newMsg['msgType'] = V::get('msgType', 'info', $args); $newMsg['userTargetType'] = V::get('toType', '', $args); $newMsg['userTargetName'] = V::get('to', '', $args); $newMsg['A_RECORD_CREATE_DATE'] = 'NOW()'; $newMsg['A_RECORD_CREATE_AUTHOR'] = User::getLogin(); $newMsg['app_className'] = 'TableMsgs'; //DBG::_(true, true, "newMsg", $newMsg, __CLASS__, __FUNCTION__, __LINE__); if ($newMsg['idReplyTo'] <= 0) throw new Exception("Wrong id reply to msg"); $parentMsg = $ds->getById('CRM_UI_MSGS', $newMsg['idReplyTo']); if (!$parentMsg) throw new Exception("Nie znaleziono wiadomości"); $newMsg['idThread'] = ($parentMsg->idThread > 0)? $parentMsg->idThread : $parentMsg->ID; $newMsg['uiTargetType'] = $uiTargetType;// TODO:? $parentMsg->uiTargetType $newMsg['uiTargetName'] = $uiTargetName;// TODO:? $parentMsg->uiTargetName $insertedId = $ds->insert('CRM_UI_MSGS', $newMsg); if (!$insertedId) throw new Exception("Nie udało się utworzyć rekordu"); $msgAdded = $ds->getById('CRM_UI_MSGS', $insertedId); $response = new stdClass(); $response->msg = "Wysłano wiadomość"; $response->type = 'success'; $response->record = $this->_convertMessageToJson($msgAdded); return $response; } function removeMsgAction() { $idMsg = V::get('id', 0, $_GET, 'int'); $usrLogin = V::get('usrLogin', 0, $_REQUEST, 'word'); if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404); if (empty($usrLogin)) throw new HttpException("Błęny user login", 404); SE_Layout::gora(); SE_Layout::menu(); try { $msg = $this->_getMsg($idMsg, $usrLogin); $msgsRoute = Router::getRoute('Msgs'); $msgsRoute->removeTableRecordMsg($idMsg); } catch (Exception $e) { SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine()); SE_Layout::dol(); exit; } ?>
Wiadomość została usunięta wróć
_getMsg($id, $usrLogin); $isRemoved = ('DELETED' === $msg['_raw']->A_STATUS || 'OFF_HARD' == $msg['_raw']->A_STATUS); if ($isRemoved) throw new AlertInfoException("Wiadomość nr {$id} została usunięta wcześniej"); Router::getRoute('Msgs')->removeTableRecordMsg($id); throw new AlertInfoException("Usunięto wiadomość nr {$id}"); // TODO: przywróć btn require global post task class } catch (Exception $e) { DBG::log($e); S::saveUserMessage(get_class($e), $e->getMessage()); } } function restoreMsgPostTask($args) { try { $id = V::get('id', 0, $args, 'int'); if ($id <= 0) throw new AlertDangerException("Missing message id!"); $usrLogin = V::get('usrLogin', User::getLogin(), $_REQUEST, 'word'); $msg = $this->_getMsg($id, $usrLogin); $isRemoved = ('DELETED' === $msg['_raw']->A_STATUS || 'OFF_HARD' == $msg['_raw']->A_STATUS); if (!$isRemoved) throw new AlertInfoException("Wiadomość nr {$id} nie jest usunięta"); Router::getRoute('Msgs')->restoreTableRecordMsg($id); throw new AlertInfoException("Przywrócono wiadomość nr {$id}"); // TODO: przywróć btn require global post task class } catch (Exception $e) { DBG::log($e); S::saveUserMessage(get_class($e), $e->getMessage()); } } }