Compare commits
12 Commits
build/envo
...
2262bebcda
Author | SHA1 | Date | |
---|---|---|---|
2262bebcda | |||
7c50db02fd | |||
33f0d05fb6 | |||
f0ae7eb4f4 | |||
b29ce57c6e | |||
2e34d65cbf | |||
df29e2ca71 | |||
abd323163e | |||
e9b2f694fa | |||
210b669909 | |||
ef0d452bc2 | |||
1cd1174c79 |
@ -137,6 +137,7 @@ gos_web_socket:
|
||||
server:
|
||||
port: %websocket_port% #The port the socket server will listen on
|
||||
host: %websocket_host% #The host ip to bind to
|
||||
|
||||
router:
|
||||
resources:
|
||||
- "@CadolesWebsocketBundle/Resources/config/topic.yml"
|
||||
|
@ -105,7 +105,7 @@ class SecurityController extends Controller
|
||||
$em->flush();
|
||||
|
||||
// On calcule les groupes de l'utilisateur
|
||||
$user=$groups=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes);
|
||||
$groups=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -38,6 +38,7 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
|
||||
$em = $this->getContainer()->get('doctrine')->getEntityManager();
|
||||
$masteridentity=$this->getContainer()->getParameter('masteridentity');
|
||||
$ldap_template = $this->getContainer()->getParameter('ldap_template');
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->in('src/Cadoles/CoreBundle/Command/data');
|
||||
@ -138,7 +139,12 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
if(!$niveau01) {
|
||||
// Si ce n'est pas le cas on positionne un filtre ultra large sur le niveau01 de base
|
||||
$niveau01=$group=$em->getRepository('CadolesCoreBundle:Niveau01')->find(-100);
|
||||
$niveau01->setLdapfilter("(uid=*)");
|
||||
|
||||
if($ldap_template=="scribe")
|
||||
$niveau01->setLdapfilter("(&(uid=*)(objectclass=inetOrgPerson)(!(description=Computer)))");
|
||||
else
|
||||
$niveau01->setLdapfilter("(uid=*)");
|
||||
|
||||
$em->persist($niveau01);
|
||||
$em->flush();
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ class SynchroCommand extends Command
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
|
||||
|
||||
// Classes
|
||||
$this->writeln('');
|
||||
$this->writeln('== CLASSES ==========================================');
|
||||
$results = $this->ldap->search("type=Classe", ['cn','description','gidNumber'], $this->ldap_basedn);
|
||||
@ -143,6 +144,32 @@ class SynchroCommand extends Command
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
|
||||
}
|
||||
|
||||
// Options
|
||||
$this->writeln('');
|
||||
$this->writeln('== OPTIONS ==========================================');
|
||||
$results = $this->ldap->search("type=Option", ['cn','description','gidNumber'], $this->ldap_basedn);
|
||||
foreach($results as $result) {
|
||||
$cn=$result["cn"];
|
||||
$ldapfilter="(|(&(type=Option)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
|
||||
|
||||
$label="OPTION = ".$result["cn"];
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
|
||||
}
|
||||
|
||||
// Groupes
|
||||
$this->writeln('');
|
||||
$this->writeln('== GROUPES ==========================================');
|
||||
$results = $this->ldap->search("type=Groupe", ['cn','description','gidNumber'], $this->ldap_basedn);
|
||||
foreach($results as $result) {
|
||||
$cn=$result["cn"];
|
||||
$ldapfilter="(&(type=Groupe)(cn=$cn))";
|
||||
|
||||
$label="GROUPE = ".$result["cn"];
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeln('');
|
||||
@ -620,7 +647,7 @@ class SynchroCommand extends Command
|
||||
|
||||
$criteria = '(cn=*)';
|
||||
$subbranch=$baseGroup;
|
||||
$results = $this->search($criteria, array('cn'), $subbranch);
|
||||
$results = $this->ldap->search($criteria, array('cn'), $subbranch);
|
||||
foreach($results as $result) {
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $this->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
|
@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
|
||||
(-100, 'DRAAF', '130007107');
|
||||
|
||||
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
|
||||
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}kiCU5m1uSvZhdgI1Ga9gdq/8HUBjSIpX
|
||||
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}d+3hdhVA7sp4QIbp8DlYbcKNekrYbPkG
|
||||
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
|
||||
|
||||
|
||||
|
@ -54,6 +54,7 @@ class RestController extends Controller
|
||||
$output["bookmarks"] = [];
|
||||
$output["items"] = [];
|
||||
$output["itemcategorys"] = [];
|
||||
$output["groups"] = [];
|
||||
|
||||
$bookmarks=null;
|
||||
$items=null;
|
||||
@ -61,6 +62,7 @@ class RestController extends Controller
|
||||
$weburl="https://".$this->getParameter("weburl")."/".$this->getParameter("alias")."/";
|
||||
|
||||
$em->getRepository("CadolesPortalBundle:Item")->getUserItems($user,$bookmarks,$items,$itemcategorys,null,3);
|
||||
$this->getDoctrine()->getRepository("CadolesPortalBundle:Page")->getPagesUser($user,null,$entity,$pagesuser,$pagesadmin,$groupsshared);
|
||||
|
||||
// Construction de la réponse
|
||||
$output["user"]["firstname"] = $user->getFirstname();
|
||||
@ -69,6 +71,7 @@ class RestController extends Controller
|
||||
$output["user"]["avatar"] = $weburl."uploads/avatar/".$user->getAvatar();
|
||||
$output["user"]["niveau01"] = $user->getNiveau01()->getLabel();
|
||||
$output["user"]["niveau02"] = ($user->getNiveau02()?$user->getNiveau02()->getLabel():null);
|
||||
$output["user"]["role"] = $user->getRole();
|
||||
|
||||
if($bookmarks) {
|
||||
foreach($bookmarks as $bookmark) {
|
||||
@ -114,6 +117,16 @@ class RestController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if($groupsshared) {
|
||||
foreach($groupsshared as $groupshared) {
|
||||
$tmp=[];
|
||||
$tmp["id"] = $groupshared->getId();
|
||||
$tmp["title"] = $groupshared->getLabel();
|
||||
|
||||
array_push($output["groups"],$tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Retour
|
||||
|
@ -128,3 +128,6 @@ services:
|
||||
cadoles.saml_attribute_mapper:
|
||||
public: true
|
||||
class: Cadoles\CoreBundle\Service\samlAttributeMapperService
|
||||
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
@ -39,7 +39,7 @@ body.simple {
|
||||
|
||||
.widget-bordered {
|
||||
border: none !important;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
/* box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);*/
|
||||
background-color: transparent;
|
||||
border-radius: 10px;
|
||||
}
|
||||
@ -59,7 +59,7 @@ body.simple {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
.widget-notbordered .widgetheader {
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
@ -67,12 +67,12 @@ body.simple {
|
||||
.widget-notbordered .widgetbody .list-item, .widget-notbordered .widgetbody .grid-item-content {
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
.grid .grid-preview {
|
||||
width: 15%;
|
||||
min-width: 160px;
|
||||
min-width: 138px;
|
||||
}
|
||||
|
||||
.grid .grid-preview .grid-item-title {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
@ -133,7 +133,7 @@
|
||||
|
||||
|
||||
|
||||
<div id="page-wrapper" class="{% if maxwidth is defined and maxwidth %} page-maxed {% endif %}" style="min-height:1200px; {% if not usesidebar %} margin:0px; {% endif %}{% if not useheader %} background-color:transparent; padding: 5px 25px 10px 15px; {% endif %} ">
|
||||
<div id="page-wrapper" class="{% if maxwidth is defined and maxwidth %} page-maxed {% endif %}" style="min-height:1200px; {% if not usesidebar %} margin:0px; {% endif %}{% if not useheader %} background-color:transparent; {% endif %} ">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
{% block pagewrapper %}
|
||||
|
@ -48,8 +48,6 @@ class CronCommand extends ContainerAwareCommand
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.lock', "lock");
|
||||
|
||||
$crons = $entityManager->getRepository('CadolesCronBundle:Cron')->toexec();
|
||||
$i=0;
|
||||
|
||||
@ -65,9 +63,22 @@ class CronCommand extends ContainerAwareCommand
|
||||
$this->writeln ('Date = '.$now->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
// Cas particulier de la synchro
|
||||
// Dans la synchro il y a un clear du manager ce qui perturbe totalement le manager de Core:Exec
|
||||
// Il pert le lien avec la boucle sur crons
|
||||
// Alors si dans le cron il y a la synchro alors on n'execute que lui le reste sera executé lors du prochain passage
|
||||
$cronsynchro=$entityManager->getRepository('CadolesCronBundle:Cron')->find(100);
|
||||
if($cronsynchro&&in_array($cronsynchro,$crons)) {
|
||||
$crons=[$cronsynchro];
|
||||
|
||||
}
|
||||
|
||||
foreach($crons as $cron) {
|
||||
$i++;
|
||||
|
||||
// Id du cron
|
||||
$idcron = $cron->getId();
|
||||
|
||||
// Flag d'execution en cours
|
||||
$now=new \DateTime();
|
||||
$cron->setStartexecdate($now);
|
||||
@ -96,6 +107,10 @@ class CronCommand extends ContainerAwareCommand
|
||||
// Executer la commande
|
||||
try{
|
||||
$returnCode = $command->run($parameter, $output);
|
||||
|
||||
// Revenir sur le cron encours à cause du clear du manager présent dans la synchro
|
||||
// Sinon le manager se pomme et génère des nouveaux enregistrement plutot que mettre à jour celui en cours
|
||||
$cron=$entityManager->getRepository('CadolesCronBundle:Cron')->find($idcron);
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
$this->writelnred("JOB EN ERREUR");
|
||||
|
@ -42,6 +42,11 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
}
|
||||
|
||||
protected function insertCron() {
|
||||
|
||||
$metadata = $this->entityManager->getClassMetaData('CadolesCronBundle:Cron');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
// Job Mail
|
||||
// Toute les minutes
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(1);
|
||||
@ -60,11 +65,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
}
|
||||
|
||||
|
||||
// afin de forcer les ID sur certaines entités
|
||||
$metadata = $this->entityManager->getClassMetaData(get_class($entity));
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
// Job synchronisation des comptes utilisateur
|
||||
// Toute les 24h à 3h00
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(100);
|
||||
@ -83,7 +83,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
$entity->setJsonargument('{"simulate":"false"}');
|
||||
$this->entityManager->persist($entity);
|
||||
}
|
||||
|
||||
// Job purge des registrations obsolètes
|
||||
// Toute les 5mn
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(110);
|
||||
@ -99,7 +98,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
$entity->setNextexecdate($entity->getSubmitdate());
|
||||
$this->entityManager->persist($entity);
|
||||
}
|
||||
|
||||
// Job de purge des fichiers obsolète
|
||||
// Toute les 24h à 3h00
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(200);
|
||||
@ -117,7 +115,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
$entity->setNextexecdate($nextdate);
|
||||
$this->entityManager->persist($entity);
|
||||
}
|
||||
|
||||
// CRON PORTAIL
|
||||
// Job purge des registrations obsolètes
|
||||
// Toute les 5mn
|
||||
@ -139,7 +136,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
elseif($entity&&!($portal_activate||$calendar_activate)) {
|
||||
$this->entityManager->remove($entity);
|
||||
}
|
||||
|
||||
// Job de récupération des sondages Limesurvey
|
||||
// Toute les 6h
|
||||
$activate_widlimesurvey = $this->getContainer()->getParameter('activate_widlimesurvey');
|
||||
@ -161,7 +157,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
elseif($entity&&!$activate_widlimesurvey) {
|
||||
$this->entityManager->remove($entity);
|
||||
}
|
||||
|
||||
// Job de récupération des cours Moodle
|
||||
// Toute les 6h
|
||||
$activate_widmoodle = $this->getContainer()->getParameter('activate_widmoodle');
|
||||
@ -183,7 +178,6 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
elseif($entity&&!$activate_widmoodle) {
|
||||
$this->entityManager->remove($entity);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@
|
||||
<a href="{{ path('cadoles_portal_'~access~'_blogarticle_view',{'id':blogarticle.id}) }}">
|
||||
{% if blogarticle.image is not empty %}
|
||||
<div class="grid-item-logo">
|
||||
<img class="grid-item-img" src="/{{alias}}/{{blogarticle.image|replace({"/blogarticle/":"/blogarticle/thumb-"})}}" width="100%">
|
||||
<img class="grid-item-vignette" src="/{{alias}}/{{blogarticle.image|replace({"/blogarticle/":"/blogarticle/thumb-"})}}" width="100%">
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
@ -60,7 +60,7 @@
|
||||
<a href onClick="showFrameitem('blog','{{ path('cadoles_portal_'~access~'_blogarticle_view',{'id':blogarticle.id}) }}',true)">
|
||||
{% if blogarticle.image is not empty %}
|
||||
<div class="grid-item-logo">
|
||||
<img class="grid-item-img" src="/{{alias}}/{{blogarticle.image|replace({"/blogarticle/":"/blogarticle/thumb-"})}}" width="100%">
|
||||
<img class="grid-item-vignette" src="/{{alias}}/{{blogarticle.image|replace({"/blogarticle/":"/blogarticle/thumb-"})}}" width="100%">
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
@ -42,7 +42,7 @@
|
||||
<div class="widgetbody" style="{{ stylewidgetbody }}">
|
||||
|
||||
|
||||
<div style="text-align: center; margin-top:40px;">
|
||||
<div style="text-align: center; margin-top:50px;">
|
||||
{%if usage=="group" %}<small>Groupe<br></small>{% endif %}
|
||||
<span style="font-size:120%">{{ title }}</span><br><br>
|
||||
{{ description | raw }}
|
||||
@ -75,7 +75,7 @@
|
||||
{% endfor %}
|
||||
|
||||
{% if canadd==true %}
|
||||
<div class="grid-item grid-small" style="{{ stylewidgetbodyreverse }};">
|
||||
<div class="grid-item grid-small" style="{{ stylewidgetbodyreverse }}; height:150px">
|
||||
<a href="{{path('cadoles_core_user_group_users',{'id':id})}}" target="_top" style="{{ stylewidgetbodyreverse }};">
|
||||
<div class="grid-item-content">
|
||||
<div class="grid-item-logo">
|
||||
|
@ -105,4 +105,47 @@ class ChatController extends Controller
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function listAction(Request $request) {
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$id=$request->request->get('id');
|
||||
$output=array();
|
||||
|
||||
// On récupère le groupe
|
||||
$group=$em->getRepository("CadolesCoreBundle:Group")->find($id);
|
||||
if(!$group) die();
|
||||
|
||||
// On récupere le user
|
||||
$user=$this->getUser();
|
||||
if(!$user) die();
|
||||
|
||||
// On récupère le lien usergroup
|
||||
$usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["group"=>$group,"user"=>$user]);
|
||||
if(!$usergroup) die();
|
||||
|
||||
// On récupere les messages
|
||||
$messages=$em->getRepository("CadolesWebsocketBundle:Message")->findBy(["group"=>$group],["submitdate"=>"DESC"],10);
|
||||
|
||||
foreach($messages as $message) {
|
||||
$tmp=[];
|
||||
$tmp["id"]=$message->getId();
|
||||
$tmp["message"]=$message->getTopic();
|
||||
$tmp["submitdate"]=$message->getSubmitdate();
|
||||
$tmp["userid"]=$message->getUser()->getId();
|
||||
$tmp["userlastname"]=$message->getUser()->getLastname();
|
||||
$tmp["userfirstname"]=$message->getUser()->getFirstname();
|
||||
$tmp["useravatar"]=$message->getUser()->getAvatar();
|
||||
|
||||
array_push($output,$tmp);
|
||||
}
|
||||
|
||||
$response = new Response(json_encode($output));
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,7 @@ cadoles_websocket_chat:
|
||||
cadoles_websocket_message_see:
|
||||
path: /user/message/see
|
||||
defaults: { _controller: CadolesWebsocketBundle:Chat:see }
|
||||
|
||||
cadoles_websocket_message_list:
|
||||
path: /user/message/list
|
||||
defaults: { _controller: CadolesWebsocketBundle:Chat:list }
|
@ -9,7 +9,7 @@
|
||||
}
|
||||
{% else %}
|
||||
#page-wrapper {
|
||||
//padding: 5px 25px 0px 15px;
|
||||
padding: 5px 25px 0px 15px;
|
||||
//background: transparent;
|
||||
}
|
||||
{% endif %}
|
||||
@ -115,12 +115,90 @@
|
||||
|
||||
{% block localexternalscript %}
|
||||
<script src="/{{alias}}/bundles/goswebsocket/js/vendor/autobahn.min.js"></script>
|
||||
<script src="/{{alias}}/bundles/goswebsocket/js/gos_web_socket_client.js"></script>
|
||||
<script type="text/javascript" src="/{{alias}}/ckeditor/adapters/jquery.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
var webSocket;
|
||||
{% if websocket_activate and app.user %}
|
||||
var WS = (function()
|
||||
{
|
||||
var GosSocket = function(uri, sessionConfig){
|
||||
this._uri = uri;
|
||||
this._session = false;
|
||||
this._listeners = {};
|
||||
this.connect(sessionConfig);
|
||||
};
|
||||
|
||||
GosSocket.prototype.connect = function (sessionConfig) {
|
||||
var that = this;
|
||||
|
||||
ab.connect(this._uri,
|
||||
|
||||
//Function on connect
|
||||
function(session){
|
||||
that.fire({type: "socket/connect", data: session });
|
||||
},
|
||||
|
||||
//Function on disconnect / error
|
||||
function(code, reason){
|
||||
that._session = false;
|
||||
|
||||
that.fire({type: "socket/disconnect", data: {code: code, reason: reason}});
|
||||
},
|
||||
|
||||
sessionConfig
|
||||
);
|
||||
};
|
||||
|
||||
GosSocket.prototype.on = function(type, listener){
|
||||
if (typeof this._listeners[type] == "undefined"){
|
||||
this._listeners[type] = [];
|
||||
}
|
||||
|
||||
this._listeners[type].push(listener);
|
||||
};
|
||||
|
||||
GosSocket.prototype.fire = function(event){
|
||||
if (typeof event == "string"){
|
||||
event = { type: event };
|
||||
}
|
||||
if (!event.target){
|
||||
event.target = this;
|
||||
}
|
||||
|
||||
if (!event.type){ //falsy
|
||||
throw new Error("Event object missing 'type' property.");
|
||||
}
|
||||
|
||||
if (this._listeners[event.type] instanceof Array){
|
||||
var listeners = this._listeners[event.type];
|
||||
for (var i=0, len=listeners.length; i < len; i++){
|
||||
listeners[i].call(this, event.data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GosSocket.prototype.off = function(type, listener){
|
||||
if (this._listeners[type] instanceof Array){
|
||||
var listeners = this._listeners[type];
|
||||
for (var i=0, len=listeners.length; i < len; i++){
|
||||
if (listeners[i] === listener){
|
||||
listeners.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
connect: function(uri, sessionConfig)
|
||||
{
|
||||
return new GosSocket(uri, sessionConfig);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
{% endif %}
|
||||
|
||||
$(document).ready(function(){
|
||||
if (CKEDITOR.instances["chat_message"]) CKEDITOR.instances["chat_message"].destroy();
|
||||
@ -147,21 +225,49 @@
|
||||
},500);
|
||||
|
||||
$(".switch").bootstrapSwitch();
|
||||
var dateoptions = {weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" };
|
||||
$("#mymodal-sendmail").removeAttr("tabindex");
|
||||
|
||||
{% if websocket_activate and app.user %}
|
||||
var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}";
|
||||
webSocket = WS.connect(_WS_URI);
|
||||
var timer;
|
||||
websocket();
|
||||
|
||||
webSocket.on("socket/connect", function (session) {
|
||||
// Reinit du tps de tentative de reco
|
||||
$('#modalinfo').modal('hide');
|
||||
clearInterval(timer);
|
||||
});
|
||||
|
||||
{% if websocket_activate and app.user %}
|
||||
|
||||
var session;
|
||||
var dateoptions = {weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" };
|
||||
var timer;
|
||||
var delayRetry=500;
|
||||
var isdeco=false;
|
||||
var tosend=false;
|
||||
var tosendmail=false;
|
||||
var todelete=false;
|
||||
var idtodelete;
|
||||
|
||||
function websocket()
|
||||
{
|
||||
var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}";
|
||||
webSocket = WS.connect(_WS_URI,{retryDelay: delayRetry});
|
||||
|
||||
webSocket.on("socket/connect", function (sess) {
|
||||
console.log("=== CONNECT ===");
|
||||
|
||||
// Sauvegardce de la session
|
||||
session=sess;
|
||||
|
||||
//the callback function in "subscribe" is called everytime an event is published in that channel.
|
||||
session.subscribe("websocket/channel/{{groupid}}", function (uri, payload) {
|
||||
sess.subscribe("websocket/channel/{{groupid}}", function (uri, payload) {
|
||||
|
||||
// Récupération lastmessage
|
||||
if(isdeco) recuplastmsg();
|
||||
|
||||
// Si action en cours
|
||||
if(tosend) sendbtn();
|
||||
if(tosendmail) sendbtnmail();
|
||||
if(todelete) delmessage(idtodelete);
|
||||
|
||||
// Il est co
|
||||
isdeco=false;
|
||||
|
||||
if(payload.msg) {
|
||||
html ="<div id='message-"+payload.msg.id+"' class='message row'>";
|
||||
html+="<div class='msgavatar'>";
|
||||
@ -192,107 +298,169 @@
|
||||
alert(payload.alert);
|
||||
}
|
||||
});
|
||||
|
||||
$( "#sendbtn" ).click(function() {
|
||||
var data = CKEDITOR.instances["chat_message"].getData();
|
||||
if($("#sendbymail").bootstrapSwitch('state')) {
|
||||
CKEDITOR.instances["chat_messagemail"].setData(data);
|
||||
$("#mailsuject").val("{{app.session.get('appname')}} = Notification {{ group.label }}");
|
||||
$("#mailto").val("");
|
||||
$("#listtoavatar").html("");
|
||||
|
||||
{% for user in group.users %}
|
||||
{%if(user.user!=app.user)%}
|
||||
$("#mailto").val($("#mailto").val()+";{{user.user.email}}");
|
||||
$("#listtoavatar").append($("<img class='avatar' title='{{user.user.lastname}} {{user.user.firstname}}' data-mail='{{user.user.email}}' src='\\{{alias}}\\uploads\\avatar\\{{user.user.avatar}}'>"));
|
||||
{%endif%}
|
||||
{% endfor %}
|
||||
|
||||
$('#mymodal-sendmail').modal('show');
|
||||
}
|
||||
else {
|
||||
if(data) {
|
||||
event={mykey: "{{userkey}}", type: "add", message: data};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
CKEDITOR.instances["chat_message"].setData('');
|
||||
|
||||
/* Ne plus envoyer d'event compteur on passe par de l'ajax
|
||||
event={type: "add", group:{{groupid}}};
|
||||
parent.parent.counter(event);
|
||||
*/
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$( "#sendbtnmail" ).click(function() {
|
||||
var data = CKEDITOR.instances["chat_messagemail"].getData();
|
||||
var subject=$("#mailsuject").val();
|
||||
var mailto=$("#mailto").val();
|
||||
|
||||
if(data&&subject&&mailto) {
|
||||
event={mykey: "{{userkey}}", type: "add", message: data, mail: "true", to: mailto, subject: subject};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
CKEDITOR.instances["chat_message"].setData('');
|
||||
|
||||
/* Ne plus envoyer d'event compteur on passe par de l'ajax
|
||||
event={type: "add", group:{{groupid}}};
|
||||
parent.parent.counter(event);
|
||||
*/
|
||||
|
||||
$("#sendbymail").bootstrapSwitch('state',false);
|
||||
$('#mymodal-sendmail').modal('hide');
|
||||
}
|
||||
else alert("Sujet, corps et destinataire(s) obligatoire");
|
||||
});
|
||||
|
||||
$(document).on('click', '.delmessage', function(){
|
||||
id=$(this).data("id");
|
||||
event={mykey: "{{userkey}}", type: "del", id: id};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
});
|
||||
|
||||
$(document).on('click', '#listtoavatar img', function(){
|
||||
var mail = ";"+$(this).data("mail");
|
||||
$("#mailto").val($("#mailto").val().replace(mail, ""));
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
|
||||
webSocket.on("socket/disconnect", function(error){
|
||||
laberror="Disconnected for " + error.reason + " with code " + error.code;
|
||||
console.log("=== DISCONNECT ===");
|
||||
console.log(laberror);
|
||||
isdeco=true;
|
||||
});
|
||||
}
|
||||
|
||||
$('#modalinfo').modal('show');
|
||||
if(error.code==2) {
|
||||
$('#modalinfotext').html("<center>Impossible de se connecter au serveur.<br>Vous avez dépassé le nombre de reconnexion maximum<br><br>Veuillez retentez d'ici quelques secondes<br><br><code>"+laberror+"</code><br><br><div id='modalinfotimer'></div><br><a class='btn btn-primary' onclick='location.reload(true);'>Forcer la tentative de reconnexion</a></center>");
|
||||
$( "#sendbtn" ).click(function() {
|
||||
sendbtn();
|
||||
});
|
||||
|
||||
clearInterval(timer);
|
||||
var nbtentative=10;
|
||||
timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000);
|
||||
function sendbtn() {
|
||||
var data = CKEDITOR.instances["chat_message"].getData();
|
||||
if($("#sendbymail").bootstrapSwitch('state')) {
|
||||
CKEDITOR.instances["chat_messagemail"].setData(data);
|
||||
$("#mailsuject").val("{{app.session.get('appname')}} = Notification {{ group.label }}");
|
||||
$("#mailto").val("");
|
||||
$("#listtoavatar").html("");
|
||||
|
||||
setTimeout(function(){ location.reload(true); }, 10000);
|
||||
{% for user in group.users %}
|
||||
{%if(user.user!=app.user)%}
|
||||
$("#mailto").val($("#mailto").val()+";{{user.user.email}}");
|
||||
$("#listtoavatar").append($("<img class='avatar' title='{{user.user.lastname}} {{user.user.firstname}}' data-mail='{{user.user.email}}' src='\\{{alias}}\\uploads\\avatar\\{{user.user.avatar}}'>"));
|
||||
{%endif%}
|
||||
{% endfor %}
|
||||
|
||||
$('#mymodal-sendmail').modal('show');
|
||||
}
|
||||
else {
|
||||
if(data) {
|
||||
try {
|
||||
// Flager que l'envoit c'est fait
|
||||
tosend=false;
|
||||
$("#sendbtn").html("Envoyer");
|
||||
$("#sendbtn").removeClass("btn-danger");
|
||||
$("#sendbtn").css('cursor','auto');
|
||||
|
||||
// Push envent sur le websocket
|
||||
event={mykey: "{{userkey}}", type: "add", message: data};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
CKEDITOR.instances["chat_message"].setData('');
|
||||
}
|
||||
catch(error) {
|
||||
// L'envoi ne s'est pas fait
|
||||
console.log("Retry to send");
|
||||
|
||||
// On flag le fait de retenter l'envoit à la reconnexion
|
||||
tosend=true;
|
||||
|
||||
// On signal que l'envoi est en cours sur le bouton
|
||||
$("#sendbtn").html("Envoi en cours");
|
||||
$("#sendbtn").addClass("btn-danger");
|
||||
$("#sendbtn").css('cursor','progress');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$( "#sendbtnmail" ).click(function() {
|
||||
sendbtnmail();
|
||||
});
|
||||
|
||||
function sendbtnmail() {
|
||||
var data = CKEDITOR.instances["chat_messagemail"].getData();
|
||||
var subject=$("#mailsuject").val();
|
||||
var mailto=$("#mailto").val();
|
||||
|
||||
if(data&&subject&&mailto) {
|
||||
try {
|
||||
// Flager que l'envoit c'est fait
|
||||
tosendmail=false;
|
||||
$("#sendbtnmail").html("Envoyer");
|
||||
$("#sendbtnmail").removeClass("btn-danger");
|
||||
$("#sendbtnmail").css('cursor','auto');
|
||||
|
||||
// Push envent sur le websocket
|
||||
event={mykey: "{{userkey}}", type: "add", message: data, mail: "true", to: mailto, subject: subject};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
CKEDITOR.instances["chat_message"].setData('');
|
||||
|
||||
// Cacher la popup
|
||||
$("#sendbymail").bootstrapSwitch('state',false);
|
||||
$('#mymodal-sendmail').modal('hide');
|
||||
}
|
||||
catch(error) {
|
||||
// L'envoi ne s'est pas fait
|
||||
console.log("Retry to send");
|
||||
|
||||
// On flag le fait de retenter l'envoit à la reconnexion
|
||||
tosendmail=true;
|
||||
|
||||
// On signal que l'envoi est en cours sur le bouton
|
||||
$("#sendbtnmail").html("Envoi en cours");
|
||||
$("#sendbtnmail").addClass("btn-danger");
|
||||
$("#sendbtnmail").css('cursor','progress');
|
||||
}
|
||||
|
||||
if(error.code==3) {
|
||||
$('#modalinfotext').html("<center>Impossible de se connecter au serveur.<br>Veuillez retentez d'ici quelques secondes<br><br><code>"+laberror+"</code><br><br><div id='modalinfotimer'></div><br><a class='btn btn-primary' onclick='location.reload(true);'>Forcer la tentative de reconnexion</a></center>");
|
||||
}
|
||||
else alert("Sujet, corps et destinataire(s) obligatoire");
|
||||
}
|
||||
|
||||
clearInterval(timer);
|
||||
var nbtentative=10;
|
||||
timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000);
|
||||
$(document).on('click', '.delmessage', function(){
|
||||
delmessage($(this).data("id"));
|
||||
});
|
||||
|
||||
setTimeout(function(){ location.reload(true); }, 10000);
|
||||
}
|
||||
function delmessage(id) {
|
||||
try {
|
||||
// Flager que l'envoit c'est fait
|
||||
todelete=false;
|
||||
idtodelete=null;
|
||||
|
||||
if(error.code==6 || error.code==5) {
|
||||
$('#modalinfotext').html("<center>Impossible de se connecter au serveur.<br>Vous allez être reconnecté d'ici quelques secondes<br><br><code>"+laberror+"</code><br><br><div id='modalinfotimer'></div><br><a class='btn btn-primary' onclick='location.reload(true);'>Forcer la tentative de reconnexion</a></center>");
|
||||
// Push envent sur le websocket
|
||||
event={mykey: "{{userkey}}", type: "del", id: id};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
}
|
||||
catch(error){
|
||||
// Le delete ne s'est pas fait
|
||||
console.log("Retry to delete");
|
||||
|
||||
clearInterval(timer);
|
||||
var nbtentative=5;
|
||||
timer=setInterval(function(){ $('#modalinfotimer').html((nbtentative--)+"s") }, 1000);
|
||||
// On flag le fait de retenter l'envoit à la reconnexion
|
||||
todelete=true;
|
||||
idtodelete=id;
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('click', '#listtoavatar img', function(){
|
||||
var mail = ";"+$(this).data("mail");
|
||||
$("#mailto").val($("#mailto").val().replace(mail, ""));
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
function recuplastmsg() {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "{{ path('cadoles_websocket_message_list') }}",
|
||||
data: {
|
||||
"id": {{ groupid }},
|
||||
},
|
||||
success: function(datas) {
|
||||
$.each(datas, function(i,data) {
|
||||
// Le message a-t-il été déposé durant la déconnexion ?
|
||||
if(!$("#message-"+data.id).length) {
|
||||
html ="<div id='message-"+data.id+"' class='message row'>";
|
||||
html+="<div class='msgavatar'>";
|
||||
html+="<img id='user_avatar_img' src='/{{ alias }}/uploads/avatar/"+data.useravatar+"' class='avatar'><br>";
|
||||
if(data.userid=={{app.user.id}} || '{{ fgmanager }}'=='1') {
|
||||
html+="<i class='delmessage fa fa-trash fa-fw' data-id='"+data.id+"' style='cursor: pointer;'></i>";
|
||||
}
|
||||
html+="</div>";
|
||||
html+="<div class='msgdiv'>"
|
||||
html+="<div class='msgtitle'>"+data.userlastname+"<br><small>"+new Date(data.submitdate.date).toLocaleDateString("fr-FR", dateoptions)+"</small></div>";
|
||||
html+="<div class='msgtopic'>"+data.message+"</div>";
|
||||
html+="</div>";
|
||||
html+="</div>";
|
||||
$(".mychat").prepend(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
{% endif %}
|
||||
});
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
@ -8,7 +8,6 @@ parameters:
|
||||
masteridentity: %%ninegate_masteridentity
|
||||
|
||||
# Mode d'authentification soit SQL / LDAP / CAS / SAML
|
||||
# Pour l'instant SQL - CAS - SAML Reste à faire LDAP
|
||||
# Attention si le masteridentity est différent de SQL le mode d'authentification est forcement différent de SQL
|
||||
# Car aucune synchronisation des password n'est possible
|
||||
mode_auth: %%ninegate_mode_auth
|
||||
|
Reference in New Issue
Block a user