From 9143cd121e0d255bdbdb3e31d8013458da23095b Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Thu, 12 Dec 2019 17:30:10 +0100 Subject: [PATCH] FEAT #11855 TIME 2:30 new link in notification --- apps/maarch_entreprise/index.php | 6 ++ .../batch/load_process_email_stack.php | 2 + .../batch/load_process_event_stack.php | 2 + .../diffusion_types/dest_user.php | 20 +++---- .../datasources/letterbox_events.php | 59 +++++++++++-------- .../datasources/mlb_notes_content.php | 21 +++++-- 6 files changed, 68 insertions(+), 42 deletions(-) diff --git a/apps/maarch_entreprise/index.php b/apps/maarch_entreprise/index.php index ff96d2a4b1c..673246109be 100755 --- a/apps/maarch_entreprise/index.php +++ b/apps/maarch_entreprise/index.php @@ -373,6 +373,12 @@ if (!empty($_REQUEST['page']) && empty($_REQUEST['triggerAngular'])) { ?><script>triggerAngular('#/administration')</script><?php } elseif (!empty($_REQUEST['scanGroupId']) && !empty($_REQUEST['tmpfilename'])) { ?><script>triggerAngular('#/indexing/<?php echo $_REQUEST['scanGroupId']?>?tmpfilename=<?php echo $_REQUEST['tmpfilename']?>')</script><?php + } elseif (!empty($_REQUEST['linkToDoc'])) { + ?><script>location.href="../../rest/resources/<?php echo $_REQUEST['linkToDoc']?>/content"</script><?php + } elseif (!empty($_REQUEST['linkToDetail'])) { + ?><script>triggerAngular('#/resources/<?php echo $_REQUEST['linkToDetail']?>')</script><?php + } elseif (!empty($_REQUEST['linkToProcess']) && !empty($_REQUEST['userId']) && !empty($_REQUEST['groupId']) && !empty($_REQUEST['basketId'])) { + ?><script>triggerAngular('#/process/users/<?php echo $_REQUEST['userId']?>/groups/<?php echo $_REQUEST['groupId']?>/baskets/<?php echo $_REQUEST['basketId']?>/resId/<?php echo $_REQUEST['linkToProcess']?>')</script><?php } elseif (empty($_REQUEST['page'])) { ?> <script> diff --git a/modules/notifications/batch/load_process_email_stack.php b/modules/notifications/batch/load_process_email_stack.php index c2be77c310a..59c2e17f934 100755 --- a/modules/notifications/batch/load_process_email_stack.php +++ b/modules/notifications/batch/load_process_email_stack.php @@ -177,6 +177,8 @@ $mailerParams = $xmlconfig->MAILER; $path_to_mailer = (string)$mailerParams->path_to_mailer; try { + Bt_myInclude($GLOBALS['maarchDirectory'] . 'vendor/autoload.php'); + Bt_myInclude( $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_functions.php' diff --git a/modules/notifications/batch/load_process_event_stack.php b/modules/notifications/batch/load_process_event_stack.php index 8b0894c3900..6a746962c14 100755 --- a/modules/notifications/batch/load_process_event_stack.php +++ b/modules/notifications/batch/load_process_event_stack.php @@ -199,6 +199,8 @@ $mailerParams = $xmlconfig->MAILER; // INCLUDES try { + Bt_myInclude('vendor/autoload.php'); + Bt_myInclude( 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_functions.php' diff --git a/modules/notifications/diffusion_types/dest_user.php b/modules/notifications/diffusion_types/dest_user.php index 2dbda285f7a..a13ac9c26f2 100755 --- a/modules/notifications/diffusion_types/dest_user.php +++ b/modules/notifications/diffusion_types/dest_user.php @@ -17,21 +17,20 @@ switch ($request) { $select = 'SELECT distinct us.*'; $from = ' FROM listinstance li JOIN users us ON li.item_id = us.user_id'; - $where = " WHERE li.coll_id = 'letterbox_coll' AND li.item_mode = 'dest'"; + $where = " WHERE li.item_mode = 'dest'"; $arrayPDO = array(':recordid' => $event->record_id); switch ($event->table_name) { case 'notes': $from .= ' JOIN notes ON notes.identifier = li.res_id'; $from .= ' JOIN res_letterbox lb ON lb.res_id = notes.identifier'; - $where .= ' AND notes.id = :recordid AND li.item_id != notes.user_id' + $where .= ' AND notes.id = :recordid AND us.id != notes.user_id' .' AND (' .' notes.id not in (SELECT DISTINCT note_id FROM note_entities) ' .' OR us.user_id IN (SELECT ue.user_id FROM note_entities ne JOIN users_entities ue ON ne.item_id = ue.entity_id WHERE ne.note_id = :recordid)' .')'; if ($notification->diffusion_properties != '') { $status_tab = explode(',', $notification->diffusion_properties); - // $status_str=implode("','",$status_tab); $where .= ' AND lb.status in (:statustab)'; $arrayPDO = array_merge($arrayPDO, array(':statustab' => $status_tab)); } @@ -44,7 +43,6 @@ switch ($request) { $where .= ' AND lb.res_id = :recordid'; if ($notification->diffusion_properties != '') { $status_tab = explode(',', $notification->diffusion_properties); - // $status_str=implode("','",$status_tab); $where .= ' AND lb.status in (:statustab)'; $arrayPDO = array_merge($arrayPDO, array(':statustab' => $status_tab)); } @@ -56,7 +54,6 @@ switch ($request) { $where .= ' AND listinstance_id = :recordid'; if ($notification->diffusion_properties != '') { $status_tab = explode(',', $notification->diffusion_properties); - // $status_str=implode("','",$status_tab); $where .= ' AND lb.status in (:statustab)'; $arrayPDO = array_merge($arrayPDO, array(':statustab' => $status_tab)); } @@ -80,18 +77,17 @@ switch ($request) { case 'res_id': $select = 'SELECT li.res_id'; - $from = ' FROM listinstance li'; - $where = " WHERE li.coll_id = 'letterbox_coll' "; + $from = ' FROM listinstance li JOIN users us ON li.item_id = us.user_id'; + $where = " WHERE "; $arrayPDO = array(':recordid' => $event->record_id); switch ($event->table_name) { case 'notes': $from .= ' JOIN notes ON notes.identifier = li.res_id'; $from .= ' JOIN res_letterbox lb ON lb.res_id = notes.identifier'; - $where .= ' AND notes.id = :recordid AND li.item_id != notes.user_id'; + $where .= ' notes.id = :recordid AND us.id != notes.user_id'; if ($notification->diffusion_properties != '') { $status_tab = explode(',', $notification->diffusion_properties); - // $status_str=implode("','",$status_tab); $where .= ' AND lb.status in (:statustab)'; $arrayPDO = array_merge($arrayPDO, array(':statustab' => $status_tab)); } @@ -100,10 +96,9 @@ switch ($request) { case 'res_letterbox': case 'res_view_letterbox': $from .= ' JOIN res_letterbox lb ON lb.res_id = li.res_id'; - $where .= ' AND lb.res_id = :recordid'; + $where .= ' lb.res_id = :recordid'; if ($notification->diffusion_properties != '') { $status_tab = explode(',', $notification->diffusion_properties); - // $status_str=implode("','",$status_tab); $where .= ' AND lb.status in (:statustab)'; $arrayPDO = array_merge($arrayPDO, array(':statustab' => $status_tab)); } @@ -112,10 +107,9 @@ switch ($request) { case 'listinstance': default: $from .= ' JOIN res_letterbox lb ON lb.res_id = li.res_id'; - $where .= ' AND listinstance_id = :recordid'; + $where .= ' listinstance_id = :recordid'; if ($notification->diffusion_properties != '') { $status_tab = explode(',', $notification->diffusion_properties); - // $status_str=implode("','",$status_tab); $where .= ' AND lb.status in (:statustab)'; $arrayPDO = array_merge($arrayPDO, array(':statustab' => $status_tab)); } diff --git a/modules/templates/datasources/letterbox_events.php b/modules/templates/datasources/letterbox_events.php index 187ed50aad1..9ebc5c66551 100755 --- a/modules/templates/datasources/letterbox_events.php +++ b/modules/templates/datasources/letterbox_events.php @@ -56,7 +56,7 @@ foreach ($events as $event) { case 'listinstance': $from .= ' JOIN listinstance li ON lb.res_id = li.res_id'; - $where .= ' li.coll_id = ? AND listinstance_id = ? '; + $where .= ' listinstance_id = ? '; $arrayPDO = array_merge($arrayPDO, array($coll_id, $event->record_id)); break; @@ -79,9 +79,20 @@ foreach ($events as $event) { // Lien vers la page detail $urlToApp = trim($maarchUrl, '/').'/apps/'.trim($maarchApps, '/').'/index.php?'; - $res['linktodoc'] = $urlToApp.'display=true&page=view_resource_controler&dir=indexing_searching&id='.$res['res_id']; - $res['linktodetail'] = $urlToApp.'page=details&dir=indexing_searching&id='.$res['res_id']; - $res['linktoprocess'] = $urlToApp.'page=view_baskets&module=basket&baskets=MyBasket&directLinkToAction&resid='.$res['res_id']; + + $user = \User\models\UserModel::getByLogin(['login' => $datasources['recipient'][0]['user_id'], 'select' => ['id']]); + $basket = \Basket\models\BasketModel::getByBasketId(['select' => ['id'], 'basketId' => 'MyBasket']); + $preferenceBasket = \User\models\UserBasketPreferenceModel::get([ + 'select' => ['group_serial_id'], + 'where' => ['user_serial_id = ?', 'basket_id = ?'], + 'data' => [$user['id'], 'MyBasket'] + ]); + + $res['linktodoc'] = $urlToApp . 'linkToDoc='.$res['res_id']; + $res['linktodetail'] = $urlToApp . 'linkToDetail='.$res['res_id']; + if (!empty($res['res_id']) && !empty($preferenceBasket[0]['group_serial_id']) && !empty($basket['id']) && !empty($user['id'])) { + $res['linktoprocess'] = $urlToApp . 'linkToProcess='.$res['res_id'].'&groupId='.$preferenceBasket[0]['group_serial_id'].'&basketId='.$basket['id'].'&userId='.$user['id']; + } $stmt2 = $dbDatasource->query('SELECT * FROM entities WHERE entity_id = ? ', array($res['initiator'])); $initiator = $stmt2->fetch(PDO::FETCH_ASSOC); @@ -95,26 +106,26 @@ foreach ($events as $event) { $datasources['res_letterbox'][] = $res; //multicontact - $stmt = $dbDatasource->query('SELECT * FROM contacts_res WHERE res_id = ? AND contact_id = ? ', array($res['res_id'], $res['contact_id'])); - $datasources['res_letterbox_contact'][] = $stmt->fetch(PDO::FETCH_ASSOC); - if ($datasources['res_letterbox_contact'][0]['contact_id'] != '') { - // $datasources['contact'] = array(); - $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = ? and ca_id = ? ', array($datasources['res_letterbox_contact'][0]['contact_id'], $datasources['res_letterbox_contact'][0]['address_id'])); - $myContact = $stmt->fetch(PDO::FETCH_ASSOC); - $myContact['contact_title'] = $contacts->get_civility_contact($myContact['contact_title']); - $datasources['contact'][] = $myContact; - - // single Contact - } elseif (isset($res['contact_id']) && isset($res['address_id'])) { - $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = ? and ca_id = ? ', array($res['contact_id'], $res['address_id'])); - $myContact = $stmt->fetch(PDO::FETCH_ASSOC); - $myContact['contact_title'] = $contacts->get_civility_contact($myContact['contact_title']); - $datasources['contact'][] = $myContact; - } else { - $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = 0'); - $myContact = $stmt->fetch(PDO::FETCH_ASSOC); - $datasources['contact'][] = $myContact; - } + // $stmt = $dbDatasource->query('SELECT * FROM contacts_res WHERE res_id = ? AND contact_id = ? ', array($res['res_id'], $res['contact_id'])); + // $datasources['res_letterbox_contact'][] = $stmt->fetch(PDO::FETCH_ASSOC); + // if ($datasources['res_letterbox_contact'][0]['contact_id'] != '') { + // // $datasources['contact'] = array(); + // $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = ? and ca_id = ? ', array($datasources['res_letterbox_contact'][0]['contact_id'], $datasources['res_letterbox_contact'][0]['address_id'])); + // $myContact = $stmt->fetch(PDO::FETCH_ASSOC); + // $myContact['contact_title'] = $contacts->get_civility_contact($myContact['contact_title']); + // $datasources['contact'][] = $myContact; + + // // single Contact + // } elseif (isset($res['contact_id']) && isset($res['address_id'])) { + // $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = ? and ca_id = ? ', array($res['contact_id'], $res['address_id'])); + // $myContact = $stmt->fetch(PDO::FETCH_ASSOC); + // $myContact['contact_title'] = $contacts->get_civility_contact($myContact['contact_title']); + // $datasources['contact'][] = $myContact; + // } else { + // $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = 0'); + // $myContact = $stmt->fetch(PDO::FETCH_ASSOC); + // $datasources['contact'][] = $myContact; + // } } $datasources['images'][0]['imgdetail'] = $maarchUrl.'/apps/'.$maarchApps.'/img/object.gif'; diff --git a/modules/templates/datasources/mlb_notes_content.php b/modules/templates/datasources/mlb_notes_content.php index afcdaa7163d..41bee8ed829 100755 --- a/modules/templates/datasources/mlb_notes_content.php +++ b/modules/templates/datasources/mlb_notes_content.php @@ -26,7 +26,7 @@ foreach($events as $event) { $query = "SELECT mlb.*, notes.*, users.* " . "FROM " . $res_view . " mlb " . "JOIN notes on notes.identifier = mlb.res_id " - . "JOIN users on users.user_id = notes.user_id " + . "JOIN users on users.id = notes.user_id " . "WHERE notes.id = ? "; $arrayPDO = array($event->record_id); break; @@ -38,7 +38,7 @@ foreach($events as $event) { . "users.* " . "FROM listinstance li JOIN " . $res_view . " mlb ON mlb.res_id = li.res_id " . "JOIN notes on notes.identifier = li.res_id " - . "JOIN users on users.user_id = notes.user_id " + . "JOIN users on users.id = notes.user_id " . "WHERE li.item_id = ? " . "AND li.item_mode = 'dest' " . "AND li.item_type = 'user_id' " @@ -56,9 +56,20 @@ foreach($events as $event) { // Lien vers la page détail $urlToApp = trim($maarchUrl, '/').'/apps/'.trim($maarchApps, '/').'/index.php?'; - $note['linktodoc'] = $urlToApp . 'display=true&page=view_resource_controler&dir=indexing_searching&id=' . $note['res_id']; - $note['linktodetail'] = $urlToApp . 'page=details&dir=indexing_searching&id=' . $note['res_id']; - $note['linktoprocess'] = $urlToApp . 'page=view_baskets&module=basket&baskets=MyBasket&directLinkToAction&resid=' . $note['res_id']; + + $user = \User\models\UserModel::getByLogin(['login' => $datasources['recipient'][0]['user_id'], 'select' => ['id']]); + $basket = \Basket\models\BasketModel::getByBasketId(['select' => ['id'], 'basketId' => 'MyBasket']); + $preferenceBasket = \User\models\UserBasketPreferenceModel::get([ + 'select' => ['group_serial_id'], + 'where' => ['user_serial_id = ?', 'basket_id = ?'], + 'data' => [$user['id'], 'MyBasket'] + ]); + + $note['linktodoc'] = $urlToApp . 'linkToDoc='.$note['res_id']; + $note['linktodetail'] = $urlToApp . 'linkToDetail='.$note['res_id']; + if (!empty($note['res_id']) && !empty($preferenceBasket[0]['group_serial_id']) && !empty($basket['id']) && !empty($user['id'])) { + $note['linktoprocess'] = $urlToApp . 'linkToProcess='.$note['res_id'].'&groupId='.$preferenceBasket[0]['group_serial_id'].'&basketId='.$basket['id'].'&userId='.$user['id']; + } // Insertion $datasources['notes'][] = $note; -- GitLab