Implémentation module 'subject/getFriends' qui renvoie tout les contacts renseignés par un sujet
This commit is contained in:
parent
40f156bedf
commit
ad8db73e1b
|
@ -211,6 +211,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"getFriends": {
|
||||||
|
"description": "Retourne les informations de tous les contacts renseignés par un sujet d'enquête.",
|
||||||
|
"permissions": ["admin"],
|
||||||
|
"parameters": {
|
||||||
|
"subject_id": { "description": "Identifiant du sujet duquel on veut les amis.", "type": "id" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"getAll": {
|
"getAll": {
|
||||||
"description": "Retourne les informations de tous les sujets.",
|
"description": "Retourne les informations de tous les sujets.",
|
||||||
"permissions": ["admin"],
|
"permissions": ["admin"],
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* RETOURNE LA LISTE DES INDEX
|
/* RETOURNE LA LISTE DES INDEX
|
||||||
*
|
*
|
||||||
* @i<String> Index pour lequel on veut la ligne et le hash
|
* @i<String> Index pour lequel on veut la ligne et le hash
|
||||||
|
|
|
@ -32,10 +32,11 @@
|
||||||
/* (2) On récupère tous les sujets */
|
/* (2) On récupère tous les sujets */
|
||||||
foreach($ids as $id){
|
foreach($ids as $id){
|
||||||
$sub = $db->fetch($id)['subject'];
|
$sub = $db->fetch($id)['subject'];
|
||||||
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
|
||||||
|
|
||||||
|
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
||||||
$subjects[$id] = $sub;
|
$subjects[$id] = $sub;
|
||||||
}
|
}
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
/* [2] On récupére la liste des sujets pour PHONE
|
/* [2] On récupére la liste des sujets pour PHONE
|
||||||
|
@ -43,11 +44,9 @@
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||||
$ids = array_keys( $db->index() );
|
$ids = array_keys( $db->index() );
|
||||||
|
|
||||||
/* (2) On ferme la bd */
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
/* (3) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
/* (2) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
||||||
foreach($subjects as $id=>$data)
|
foreach($subjects as $id=>$data)
|
||||||
if( in_array($id, $ids) ) // Si dans phone
|
if( in_array($id, $ids) ) // Si dans phone
|
||||||
$subjects[$id]['phone'] = true;
|
$subjects[$id]['phone'] = true;
|
||||||
|
@ -60,11 +59,9 @@
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||||
$ids = array_keys( $db->index() );
|
$ids = array_keys( $db->index() );
|
||||||
|
|
||||||
/* (2) On ferme la bd */
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
/* (3) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
/* (2) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
||||||
foreach($subjects as $id=>$data)
|
foreach($subjects as $id=>$data)
|
||||||
if( in_array($id, $ids) ) // Si dans facebook
|
if( in_array($id, $ids) ) // Si dans facebook
|
||||||
$subjects[$id]['facebook'] = true;
|
$subjects[$id]['facebook'] = true;
|
||||||
|
@ -81,6 +78,73 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE LA LISTE DE TOUS LES AMIS D'UN SUJET
|
||||||
|
*
|
||||||
|
* @subject_id<int> Identifiant du sujet d'enquête
|
||||||
|
*
|
||||||
|
* @return subjects<Array> Tableau contenant les informations de tous les utilisateurs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getFriends($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
|
|
||||||
|
// Contiendra les sujets
|
||||||
|
$subjects = array();
|
||||||
|
|
||||||
|
/* [1] On récupére la liste des sujets
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On initialise et ouvre la bd */
|
||||||
|
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||||
|
$fetch = $db->fetch($subject_id);
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
/* (2) Si on trouve personne, on renvoie une erreur */
|
||||||
|
if( $fetch === false )
|
||||||
|
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||||
|
|
||||||
|
/* (3) On enregistre ses contacts s'il en a */
|
||||||
|
if( isset($fetch['contacts']) )
|
||||||
|
$subjects = array_merge($subjects, $fetch['contacts']);
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] On récupére la liste des contacts saisis dans PHONE
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On initialise et ouvre la bd */
|
||||||
|
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||||
|
$fetch = $db->fetch($subject_id);
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
/* (2) Si on trouve des contacts, on les ajoute */
|
||||||
|
if( $fetch !== false && isset($fetch['contacts']) )
|
||||||
|
$subjects = array_merge($subjects, $fetch['contacts']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] On récupére la liste des sujets pour FACEBOOK
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On initialise et ouvre la bd */
|
||||||
|
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||||
|
$fetch = $db->fetch($subject_id);
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
/* (2) Si on trouve des contacts, on les ajoute */
|
||||||
|
if( $fetch !== false && isset($fetch['contacts']) )
|
||||||
|
$subjects = array_merge($subjects, $fetch['contacts']);
|
||||||
|
|
||||||
|
|
||||||
|
/* [4] Gestion du retour
|
||||||
|
=========================================================*/
|
||||||
|
return array(
|
||||||
|
'ModuleError' => ManagerError::Success,
|
||||||
|
'subjects' => $subjects
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* CREATION D'UN SUJET
|
/* CREATION D'UN SUJET
|
||||||
*
|
*
|
||||||
|
@ -105,19 +169,18 @@
|
||||||
// Décalage à appliquer à tous les ids
|
// Décalage à appliquer à tous les ids
|
||||||
$newId = intval($uniqid) + 1;
|
$newId = intval($uniqid) + 1;
|
||||||
|
|
||||||
/* [2] On crée le sujet dans SURVEYS
|
// On crée notre sujet
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
|
||||||
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
|
||||||
|
|
||||||
$data = array( 'subject' => array(
|
$data = array( 'subject' => array(
|
||||||
'id' => $newId,
|
'id' => $newId,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'creation' => time()
|
'creation' => time()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/* [2] On crée le sujet dans SURVEYS
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On initialise et ouvre la bd */
|
||||||
|
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||||
$db->insert( $newId, $data );
|
$db->insert( $newId, $data );
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +193,6 @@
|
||||||
fclose($funiq);
|
fclose($funiq);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] Gestion du retour
|
/* [2] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return array(
|
return array(
|
||||||
|
@ -231,6 +293,7 @@
|
||||||
$subjects[$id] = $sub;
|
$subjects[$id] = $sub;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
/* [2] On récupére la liste des sujets pour PHONE
|
/* [2] On récupére la liste des sujets pour PHONE
|
||||||
|
@ -238,11 +301,9 @@
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||||
$ids = array_keys( $db->index() );
|
$ids = array_keys( $db->index() );
|
||||||
|
|
||||||
/* (2) On ferme la bd */
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
/* (3) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
/* (2) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
||||||
foreach($subjects as $id=>$data)
|
foreach($subjects as $id=>$data)
|
||||||
if( in_array($id, $ids) ) // Si dans phone
|
if( in_array($id, $ids) ) // Si dans phone
|
||||||
$subjects[$id]['phone'] = true;
|
$subjects[$id]['phone'] = true;
|
||||||
|
@ -255,11 +316,9 @@
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||||
$ids = array_keys( $db->index() );
|
$ids = array_keys( $db->index() );
|
||||||
|
|
||||||
/* (2) On ferme la bd */
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
/* (3) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
/* (2) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
||||||
foreach($subjects as $id=>$data)
|
foreach($subjects as $id=>$data)
|
||||||
if( in_array($id, $ids) ) // Si dans facebook
|
if( in_array($id, $ids) ) // Si dans facebook
|
||||||
$subjects[$id]['facebook'] = true;
|
$subjects[$id]['facebook'] = true;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \manager\ResourceDispatcher;
|
use \manager\ResourceDispatcher;
|
||||||
use \manager\Repo;
|
use \manager\Repo;
|
||||||
|
debug();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,9 +85,10 @@ if( $getAllR->error == ManagerError::Success )
|
||||||
<span class='select-container nobold'><select data-name='subject_id'>
|
<span class='select-container nobold'><select data-name='subject_id'>
|
||||||
<option value='.' disabled selected>Identifiant</option>
|
<option value='.' disabled selected>Identifiant</option>
|
||||||
<?php foreach($allSub as $id=>$data)
|
<?php foreach($allSub as $id=>$data)
|
||||||
echo "<option value='$id'>".$data['name']."</option>";
|
if( !isset($data['phone']) ) // Si aucune donnée pour phone
|
||||||
|
echo "<option value='$id'>".$data['name']." [$id]</option>";
|
||||||
?>
|
?>
|
||||||
</select></span>
|
</select></span>
|
||||||
|
|
||||||
<input type='text' data-name='number' id='p_subject_phone_number' placeholder='Numéro de téléphone'>
|
<input type='text' data-name='number' id='p_subject_phone_number' placeholder='Numéro de téléphone'>
|
||||||
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
|
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
|
||||||
|
@ -209,10 +211,11 @@ if( $getAllR->error == ManagerError::Success )
|
||||||
<span class='select-container nobold'><select data-name='subject_id'>
|
<span class='select-container nobold'><select data-name='subject_id'>
|
||||||
<option value='.' disabled selected>Identifiant</option>
|
<option value='.' disabled selected>Identifiant</option>
|
||||||
<?php foreach($allSub as $id=>$data)
|
<?php foreach($allSub as $id=>$data)
|
||||||
echo "<option value='$id'>".$data['name']."</option>";
|
if( !isset($data['facebook']) ) // Si aucune donnée pour fb
|
||||||
|
echo "<option value='$id'>".$data['name']." [$id]</option>";
|
||||||
?>
|
?>
|
||||||
</select></span>
|
</select></span>
|
||||||
|
|
||||||
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
|
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
|
||||||
</h4>
|
</h4>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -6,7 +6,7 @@ function pDynamicUpdate(c){var b=c instanceof Element,a=b&&"INPUT"==c.tagName&&"
|
||||||
pFicheManager.storageToFields();pMatriceManager.storageToFields();(a||b)&&pContactManager.storageToFields()}var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
|
pFicheManager.storageToFields();pMatriceManager.storageToFields();(a||b)&&pContactManager.storageToFields()}var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
|
||||||
function fDynamicUpdate(c){var b=c instanceof Element,a=b&&"INPUT"==c.tagName&&"submit"==c.type,e=b&&"SPAN"==c.tagName&&("f_nav-mini"==c.parentNode.id||"f_nav-fiche"==c.parentNode.id),b=b&&"SPAN"==c.tagName&&"f_nav-contact"==c.parentNode.id;if(!a&&!e&&!b&&!0!==c)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
|
function fDynamicUpdate(c){var b=c instanceof Element,a=b&&"INPUT"==c.tagName&&"submit"==c.type,e=b&&"SPAN"==c.tagName&&("f_nav-mini"==c.parentNode.id||"f_nav-fiche"==c.parentNode.id),b=b&&"SPAN"==c.tagName&&"f_nav-contact"==c.parentNode.id;if(!a&&!e&&!b&&!0!==c)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
|
||||||
fFicheManager.storageToFields();fMatriceManager.storageToFields();(a||b)&&fContactManager.storageToFields()}
|
fFicheManager.storageToFields();fMatriceManager.storageToFields();(a||b)&&fContactManager.storageToFields()}
|
||||||
api.send({path:"subject/getAll"},function(c){if(0!=c.ModuleError)return Notification.error("Erreur",c.ModuleError),!1;lsi.createDataset("all-subjects");lsi["import"]("all-subjects",c.subjects);include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=
|
api.send({path:"subject/getFriends",subject_id:1},function(c){if(0!=c.ModuleError)return Notification.error("Erreur",c.ModuleError),!1;lsi.createDataset("all-subjects");lsi["import"]("all-subjects",c.subjects);include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=
|
||||||
new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach();pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);
|
new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach();pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);
|
||||||
pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var b=new ShortcutManager;b.append("s+n+a+k+e",
|
pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var b=new ShortcutManager;b.append("s+n+a+k+e",
|
||||||
function(){pMatriceManager.snake()});b.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur",
|
function(){pMatriceManager.snake()});b.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur",
|
||||||
|
|
|
@ -193,9 +193,9 @@ function fDynamicUpdate(target){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] On récupère la liste des sujets
|
/* [3] On récupère la liste des "amis"
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
api.send({ path: 'subject/getAll' }, function(allSubjectsResponse){
|
api.send({ path: 'subject/getFriends', subject_id: 1 }, function(allSubjectsResponse){
|
||||||
|
|
||||||
// Si erreur
|
// Si erreur
|
||||||
if( allSubjectsResponse.ModuleError != 0){
|
if( allSubjectsResponse.ModuleError != 0){
|
||||||
|
@ -203,7 +203,7 @@ api.send({ path: 'subject/getAll' }, function(allSubjectsResponse){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On enregistre la liste des sujets existants
|
// On enregistre la liste des amis existants
|
||||||
lsi.createDataset('all-subjects');
|
lsi.createDataset('all-subjects');
|
||||||
lsi.import('all-subjects', allSubjectsResponse.subjects);
|
lsi.import('all-subjects', allSubjectsResponse.subjects);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue