|
|
@@ -324,13 +324,15 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
case 'inbox':
|
|
|
$sqlWhereAddFilter = "
|
|
|
and ({$sqlFilerMsgsForUser})
|
|
|
- and m.`A_STATUS` not in('DELETED')
|
|
|
+ and m.`A_STATUS` in('WAITING', 'NORMAL')
|
|
|
";
|
|
|
break;
|
|
|
case 'sent':
|
|
|
$sqlWhereAddFilter = "
|
|
|
and m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
|
|
|
- and m.`A_STATUS` not in('DELETED')
|
|
|
+ and (m.`A_STATUS` in('WAITING', 'NORMAL')
|
|
|
+ or (m.`A_STATUS`='OFF_HARD' and m.`A_RECORD_DELETE_AUTHOR`!='{$usrLogin}')
|
|
|
+ )
|
|
|
";
|
|
|
break;
|
|
|
case 'removed':
|
|
|
@@ -338,7 +340,7 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
and (m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
|
|
|
or ({$sqlFilerMsgsForUser})
|
|
|
)
|
|
|
- and m.`A_STATUS` in('DELETED')
|
|
|
+ and m.`A_STATUS` in('OFF_HARD', 'DELETED')
|
|
|
";
|
|
|
break;
|
|
|
default: throw new Exception("Unknown filter type");
|
|
|
@@ -653,6 +655,10 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
$usrAcl = User::getAcl();
|
|
|
$tblAcl = $usrAcl->getTableAcl($idTable);
|
|
|
|
|
|
+ $showRemoveBtn = true;
|
|
|
+ if ('DELETED' == $msg['_raw']->A_STATUS) $showRemoveBtn = false;
|
|
|
+ if ('OFF_HARD' == $msg['_raw']->A_STATUS && $usrLogin != $msg['_raw']->A_RECORD_CREATE_AUTHOR) $showRemoveBtn = false;
|
|
|
+
|
|
|
$linkBase = "index.php?_route=UserMsgs";
|
|
|
$linkBase .= "&usrLogin={$usrLogin}";
|
|
|
$rmMsgLink = "{$linkBase}&_task=removeMsg&id={$msg['_raw']->ID}";
|
|
|
@@ -665,6 +671,22 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
z tabeli <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idTable; ?>"><?php echo $tblAcl->getLabel(); ?></a>
|
|
|
</small>
|
|
|
</h3>
|
|
|
+<!--
|
|
|
+<ul class="media-list">
|
|
|
+ <li class="media">
|
|
|
+ <div class="media-left">
|
|
|
+ <a href="#">
|
|
|
+ <img class="media-object" src="..." alt="...">
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div class="media-body">
|
|
|
+ <h4 class="media-heading">Media heading</h4>
|
|
|
+ ...
|
|
|
+ <ul class="media-list">...</ul>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+</ul>
|
|
|
+-->
|
|
|
<div class="panel panel-<?php echo $msg['type']; ?>">
|
|
|
<div class="panel-heading">
|
|
|
<h3 class="panel-title">Wiadomość wysłana przez <?php echo $msg['_raw']->A_RECORD_CREATE_AUTHOR; ?>
|
|
|
@@ -680,7 +702,7 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
<?php if (!empty($msg['_raw']->A_RECORD_DELETE_DATE) && !empty($msg['_raw']->A_RECORD_DELETE_AUTHOR)) : ?>
|
|
|
<em style="margin-left:20px" class="text-muted">usunięta <?php echo $msg['_raw']->A_RECORD_DELETE_DATE; ?> przez <?php echo $msg['_raw']->A_RECORD_DELETE_AUTHOR; ?></em>
|
|
|
<?php endif; ?>
|
|
|
- <?php if ('DELETED' != $msg['_raw']->A_STATUS) : ?>
|
|
|
+ <?php if ($showRemoveBtn) : ?>
|
|
|
<a href="<?php echo $rmMsgLink; ?>" class="btn btn-xs btn-default pull-right" title="usuń wiadomość" onclick="return confirm('Czy jesteś pewien że chcesz usunąć wiadomość?');"><i class="glyphicon glyphicon-remove"></i> Usuń</a>
|
|
|
<?php endif; ?>
|
|
|
</div>
|
|
|
@@ -691,7 +713,6 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
}
|
|
|
|
|
|
public function removeMsgAction() {
|
|
|
- $idMsg = V::get('id', 0, $_GET, 'int');
|
|
|
$idMsg = V::get('id', 0, $_GET, 'int');
|
|
|
$usrLogin = V::get('usrLogin', 0, $_REQUEST, 'word');
|
|
|
if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
|
|
|
@@ -702,7 +723,8 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
|
|
|
try {
|
|
|
$msg = $this->_getMsg($idMsg, $usrLogin);
|
|
|
- $this->_removeRowMsg($msg);
|
|
|
+ $msgsRoute = Router::getRoute('Msgs');
|
|
|
+ $msgsRoute->removeTableRecordMsg($idMsg);
|
|
|
} catch (Exception $e) {
|
|
|
SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
|
|
|
SE_Layout::dol();
|
|
|
@@ -718,22 +740,4 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
SE_Layout::dol();
|
|
|
}
|
|
|
|
|
|
- public function _removeRowMsg($msg) {
|
|
|
- // IDEA: do kosza - add trigger to insert into `CRM_UI_MSGS__TRASH` after DELETE on `CRM_UI_MSGS`
|
|
|
- if (empty($msg['_raw']) || empty($msg['_raw']->ID)) throw new Exception("Brak wiadomości!");
|
|
|
- $usrLogin = User::getLogin();
|
|
|
- $db = DB::getDB();
|
|
|
- if (!$db) throw new Exception("Brak dazy danych!");
|
|
|
- if ($db->has_errors()) throw new Exception("DB Errors: " . implode("\n<br>", $db->get_errors()));
|
|
|
- $sqlTODO = "delete `CRM_UI_MSGS` where `ID`='{$msg['_raw']->ID}' ";
|
|
|
- $sql = "update `CRM_UI_MSGS`
|
|
|
- set `A_STATUS`='DELETED'
|
|
|
- , `A_RECORD_DELETE_AUTHOR`='{$usrLogin}'
|
|
|
- , `A_RECORD_DELETE_DATE`=NOW()
|
|
|
- where `ID`='{$msg['_raw']->ID}'
|
|
|
- ";
|
|
|
- $res = $db->query($sql);
|
|
|
- if (!$res || $db->has_errors()) throw new Exception("Wystąpiły błędy podczas próby zapisu wiadomości: " . implode("\n<br>", $db->get_errors()));
|
|
|
- }
|
|
|
-
|
|
|
}
|