The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings MonLabo
Summary Activity Tracker Tasks Docs SCM Files Dokuwiki Continious Integration Listes Sympa

SCM Repository

1 <?php
3 defined( 'ABSPATH' ) or die( 'No direct script access allowed' );
5 /**
6  * Crée le code HTML d'un tableau complet crée à partir des Informations
7  * d'un groupe de personnes et destiné à être affiché dans l'inteface d'administration.
8  *
9  * @param array $status statut des personnes à extraire
10  *
11  * @return string code HTML
12  */
13 function generate_table_admin_for_persons( $status ) {
14         $generate_HTML = New MonLabo_generate_HTML();
15         $MonLabo_access_data = New MonLabo_access_data();
16         $persons_information = $MonLabo_access_data->get_persons_information( $status );
17         $teams_information = $MonLabo_access_data->get_teams_information();
18         $options0 = get_option( 'MonLabo_settings_group0' );
19         $options2 = get_option( 'MonLabo_settings_group2' );
20         $nb_custom_fields = 0;
21         if ( isset( $options0['MonLabo_uses_custom_fields_for_staff'] ) && ( intval( $options0['MonLabo_uses_custom_fields_for_staff'] ) === 1 ) ) {
22                 $options3 = get_option( 'MonLabo_settings_group3' );
23                 if ( $options3['MonLabo_custom_fields_number']<'1' ) { $nb_custom_fields = 0; }
24                 elseif ( $options3['MonLabo_custom_fields_number']>'10' ) { $nb_custom_fields = 10; }
25                 else { $nb_custom_fields = intval( $options3['MonLabo_custom_fields_number'] ); }
26         }
27         $colums_titles = Array( '', _x( 'Nom', 'personne', 'mon-laboratoire' ), _x( 'Prénom', 'personne', 'mon-laboratoire' ), __( 'id', 'mon-laboratoire' ), _x( 'Titre', 'personne', 'mon-laboratoire' ), __( 'Page', 'mon-laboratoire' )
28                                         , __( 'Logo', 'mon-laboratoire' ), _x( 'Catégorie', 'personne', 'mon-laboratoire' ), _x( 'Fonction (fr)', 'personne', 'mon-laboratoire' ), _x( 'Fonction (en)', 'personne', 'mon-laboratoire' )
29                                         , __( 'Mail', 'mon-laboratoire' ), __( 'Téléphone', 'mon-laboratoire' ), __( 'Bureau', 'mon-laboratoire' ), __( 'Adr. alt.', 'mon-laboratoire' ), __( 'URL ext.', 'mon-laboratoire' ), __( 'id HAL', 'mon-laboratoire' )
30                                         , __( 'id Descartes', 'mon-laboratoire' ), __( 'login Descates', 'mon-laboratoire' )
31                                         , _x( 'Statut', 'personne', 'mon-laboratoire' ), _x( 'Départ', 'personne', 'mon-laboratoire' ), __( 'Visible', 'mon-laboratoire' ), __( 'Équipes', 'mon-laboratoire' ), __( 'Tuteurs', 'mon-laboratoire' )
32                                 );
33         for ( $i = 1; $i <= $nb_custom_fields; $i++ ) {
34                 $colums_titles[] = 'custom'.$i;
35         }
36         $list_array = array();
37         $number_of_persons = count( $persons_information );
38         $a_afficher = '';
39         if ( '0' != $number_of_persons ) {
40                 foreach ( $persons_information as $person_information ) {
41                         $person_array = array();
42                         $person_array['modifier'] = '<form method="post" action="admin.php?page=MonLabo_edit_members_and_groups&tab=tab_one&submit_item='.$person_information->id.'">'
43                                                                         .'<button type="submit">'.__( 'Modifier', 'mon-laboratoire' ).'</button></form>';
44                         $person_array['last_name'] = $person_information->last_name;
45                         $person_array['first_name'] = $person_information->first_name;
46                         $person_array['id'] = $person_information->id;
47                         $person_array['title'] = $person_information->title;
48                         $person_array['wp_post_id'] = '<a href="'.get_edit_post_link( $person_information->wp_post_id ).'&action=edit">'.$person_information->wp_post_id.'</a>';
50                         $wp_post_id = $person_information->wp_post_id;
51                         $person_array['logo'] = '<a class="hover-zoom-square30">';
52                         if ( has_post_thumbnail( $wp_post_id ) ) {
53                                   $person_array['logo'].= get_the_post_thumbnail( $wp_post_id, 'thumbnail', array( 'class' => 'img-arrondi',  'id'=>"image-preview-'.$person_information->id.'" ) );
54                         } elseif  ( ( !is_numeric( $wp_post_id ) ) and ( !empty( $person_information->alternate_image ) ) ) {
55                                 $person_array['logo'].= '<img id="image-preview-'.$person_information->id.'" src="'.$person_information->alternate_image.'" class="wp-image-6 alignright img-arrondi wp-post-image" alt="'.$person_information->alternate_image.'" />';
56                         } else {
57                                 //Display default image
58                                 $person_array['logo'].= '<img id="image-preview-'.$person_information->id.'" src="'.$options2['MonLabo_img_par_defaut'].'" class="wp-image-6 alignright img-arrondi wp-post-image" alt="'.$options2['MonLabo_img_par_defaut'].'" />';
59                         }
60                         $person_array['logo'] .= '</a>';
62                         $person_array['category'] = $person_information->category;
63                         $person_array['function_fr'] = '<small>'.$person_information->function_fr.'</small>';
64                         $person_array['function_en'] = '<small>'.$person_information->function_en.'</small>';
65                         $person_array['mail'] = '<small>'.$person_information->mail.'</small>';
66                         $person_array['phone'] = $person_information->phone;
67                         $person_array['room'] = $person_information->room;
68                         $person_array['address_alt'] = ( empty( $person_information->address_alt ) ? '' : '<small>'.$person_information->address_alt.'</small>' );
69                         $person_array['external_url'] = ( empty( $person_information->external_url ) ? '' : '<a href="'.$person_information->external_url.'">'.__( 'lien', 'mon-laboratoire' ).'</a>' );
70                         $person_array['hal_publi_author_id'] = $person_information->hal_publi_author_id;
71                         $person_array['descartes_publi_author_id'] = $person_information->descartes_publi_author_id;
72                         $person_array['uid_ENT_parisdescartes'] = $person_information->uid_ENT_parisdescartes;
73                         $person_array['status'] = $person_information->status;
74                         $person_array['date_departure'] = $person_information->date_departure;
75                         $person_array['visible'] = $person_information->visible;
76                         $teams_id = $MonLabo_access_data->get_teams_id_for_a_person( $person_information->id );
77                         if ( !empty( $teams_id ) ) {
78                                 $teams_links = Array();
79                                 foreach ( $teams_id as $id ) {
80                                         $teams_links[] = "<a href='#' title='".$teams_information[$id]->name_fr."'>$id</a>";
81                                 }
82                                 $person_array['equipes'] = MonLaboLib::secured_implode( ', ', $teams_links );
83                         } else {
84                                 $person_array['equipes'] = '';
85                         }
86                         $mentors_name = $MonLabo_access_data->get_mentors_name_for_a_person( $person_information->id );
87                         if ( !empty( $mentors_name ) ) {
88                                 $person_array['mentors'] = '<small>' . MonLaboLib::secured_implode( ', ', $mentors_name ) . '</small>';
89                         } else {
90                                 $person_array['mentors'] = '';
91                         }
92                         for ( $i = 1; $i <= $nb_custom_fields; $i++ ) {
93                                 $nom_variable = 'custom'.$i;
94                                 $person_array[$nom_variable] = $person_information->$nom_variable;
95                         }
96                         $list_array[] = $person_array;
97                 }
98                 $a_afficher .= '<div class="MonLabo MonLabo-persons-table-normal">'
99                                                 .$generate_HTML->generic_table( '', $colums_titles, $list_array )
100                                                 .'</div>';
101         }
102         return $a_afficher;
105 /**
106  * Crée le code HTML d'un tableau complet crée à partir des Informations
107  * d'un groupe d'équipes et destiné à être affiché dans l'inteface d'administration.
108  *
109  * @return string code HTML
110  */
111 function generate_table_admin_for_teams() {
113         $generate_HTML = New MonLabo_generate_HTML();
114         $MonLabo_access_data = New MonLabo_access_data();
115         $teams_information = $MonLabo_access_data->get_teams_information();
116         $options0 = get_option( 'MonLabo_settings_group0' );
117         $options4 = get_option( 'MonLabo_settings_group4' );
119         $colums_titles = Array( '', __( 'id', 'mon-laboratoire' ), _x( 'Nom (fr)', 'mon-laboratoire' ), __( 'Nom (en)', 'mon-laboratoire' ), __( 'Logo', 'mon-laboratoire' ), __( 'Pages', 'mon-laboratoire' ), __( 'URL ext.', 'mon-laboratoire' )
120                                         , __( 'id HAL', 'mon-laboratoire' ), __( 'id Descartes', 'mon-laboratoire' )
121                                         , __( 'Couleur', 'mon-laboratoire' ), __( 'Responsables', 'mon-laboratoire' ), __( 'Unité', 'mon-laboratoire' )
122                                 );
123         if ( isset( $options0['MonLabo_uses_thematiques'] ) && ( intval( $options0['MonLabo_uses_thematiques'] ) === 1 ) ) {
124                 $colums_titles[]= 'Thématiques';
125         }
126         $list_array = array();
127         $number_of_teams = count( $teams_information );
128         $a_afficher = '';
130         if ( '0' != $number_of_teams ) {
131                 foreach ( $teams_information as $team_information ) {
132                         $team_array = array();
133                         $team_array['modifier'] = '<form method="post" action="admin.php?page=MonLabo_edit_members_and_groups&tab=tab_two&submit_item='.$team_information->id.'">'
134                                                                         .'<button type="submit">'.__( 'Modifier', 'mon-laboratoire' ).'</button></form>';
135                         $team_array['id'] = $team_information->id;
136                         $team_array['name_fr'] = '<small>'.$team_information->name_fr.'</small>';
137                         $team_array['name_en'] = '<small>'.$team_information->name_en.'</small>';
138                         $team_array['logo'] = ( empty( $team_information->logo ) ? '' : '<a href="'.$team_information->logo.'" class="hover-zoom-square30"><img src="'.$team_information->logo.'" height="24" alt="'.$team_information->logo.'" /></a>' );
139                         if ( !empty( $team_information->wp_post_id ) ) {
140                                 $teams_links = Array();
141                                 foreach ( explode( ', ', $team_information->wp_post_id ) as $id ) {
142                                         $teams_links[] = '<a href="'.get_edit_post_link( $id ).'&action=edit">'.$id.'</a>';
143                                 }
144                                 $team_array['wp_post_id'] = MonLaboLib::secured_implode( ', ', $teams_links );
145                         } else {
146                                 $team_array['wp_post_id'] = '';
147                         }
148                         $team_array['external_url'] = ( empty( $team_information->external_url ) ? '' : '<a href="'.$team_information->external_url.'">'.__( 'lien', 'mon-laboratoire' ).'</a>' );
149                         $team_array['hal_publi_team_id'] = $team_information->hal_publi_team_id;
150                         if ( !empty( $team_information->descartes_publi_team_id ) ) {
151                                 $team_array['descartes_publi_team_id'] = "<a href='".$options4['MonLabo_DescartesPubmed_api_url'].'?equipe='.$team_information->descartes_publi_team_id."'>"
152                                                                                                                 .$team_information->descartes_publi_team_id.'</a>';
153                         } else {
154                                 $team_array['descartes_publi_team_id'] = '';
155                         }
156                         $team_array['color'] = $team_information->color;
157                         $team_names = $MonLabo_access_data->get_leaders_name_for_a_team( $team_information->id );
158                         $team_array['leaders'] = MonLaboLib::secured_implode( ', ', $team_names );
160                         if ( MAIN_STRUCT_NO_UNIT === $team_information->id_unit ) {
161                                 $team_array['id_unit'] = __( 'Structure principale', 'mon-laboratoire' );
162                         } else {
163                                 $team_array['id_unit'] = $team_information->id_unit;
164                         }
166                         if ( isset( $options0['MonLabo_uses_thematiques'] ) && ( intval( $options0['MonLabo_uses_thematiques'] ) === 1 ) ) {
167                                 $thematics_information = $MonLabo_access_data->get_thematics_information_for_a_team( $team_information->id );
168                                 if ( !empty( $thematics_information ) ) {
169                                         $thematics_links = Array();
170                                         foreach ( $thematics_information as $thematic ) {
171                                                 $thematics_links[] = "<a href='#' title='".$thematic->name_fr."'>$thematic->id</a>";
172                                         }
173                                         $team_array['thematics'] = MonLaboLib::secured_implode( ', ', $thematics_links );
174                                 } else {
175                                         $team_array['thematics'] = '';
176                                 }
177                         }
178                         $list_array[] = $team_array;
179                 }
180                 $a_afficher .= '<div class="MonLabo MonLabo_teams_table_normal">'
181                                                 .$generate_HTML->generic_table( '', $colums_titles, $list_array )
182                                                 .'</div>';
183         }
184         return $a_afficher;
187 /**
188  * Crée le code HTML d'un tableau complet crée à partir des Informations
189  * d'un groupe de thématiques et destiné à être affiché dans l'inteface d'administration.
190  *
191  * @return string code HTML
192  */
193 function generate_table_admin_for_thematics() {
194         $generate_HTML = New MonLabo_generate_HTML();
195         $MonLabo_access_data = New MonLabo_access_data();
196         $thematics_information = $MonLabo_access_data->get_thematics_information();
197         $colums_titles = Array( '', __( 'id', 'mon-laboratoire' ), __( 'Nom (fr)', 'mon-laboratoire' ), __( 'Nom (en)', 'mon-laboratoire' ), __( 'Logo', 'mon-laboratoire' ), __( 'URL ext.', 'mon-laboratoire' )
198                                         , __( 'id HAL', 'mon-laboratoire' ), __( 'Équipes', 'mon-laboratoire' )
199                                 );
200         $list_array = array();
201         $number_of_thematics = count( $thematics_information );
202         $a_afficher = '';
203         if ( '0' != $number_of_thematics ) {
204                 foreach ( $thematics_information as $thematic_information ) {
205                         $thematic_array = array();
206                         $thematic_array['modifier'] = '<form method="post" action="admin.php?page=MonLabo_edit_members_and_groups&tab=tab_three&submit_item='.$thematic_information->id.'">'
207                                                                         .'<button type="submit">'.__( 'Modifier', 'mon-laboratoire' ).'</button></form>';
208                         $thematic_array['id'] = $thematic_information->id;
209                         $thematic_array['name_fr'] = '<small>'.$thematic_information->name_fr.'</small>';
210                         $thematic_array['name_en'] = '<small>'.$thematic_information->name_en.'</small>';
211                         $thematic_array['logo'] = ( empty( $thematic_information->logo ) ? '' : '<a href="'.$thematic_information->logo.'" class="hover-zoom-square30"><img src="'.$thematic_information->logo.'" height="24" alt="'.$thematic_information->logo.'" /></a>' );
212                         $thematic_array['external_url'] = ( empty( $thematic_information->external_url ) ? '' : '<a href="'.$thematic_information->external_url.'">'.__( 'lien', 'mon-laboratoire' ).'</a>' );
213                         $thematic_array['hal_publi_thematic_id'] = $thematic_information->hal_publi_thematic_id;
214                         $teams_information = $MonLabo_access_data->get_teams_information_for_a_thematic( $thematic_information->id );
215                         if ( !empty( $teams_information ) ) {
216                                 $thematics_links = Array();
217                                 foreach ( $teams_information as $team ) {
218                                         $teams_links[] = "<a href='#' title='".$team->name_fr."'>$team->id</a>";
219                                 }
220                                 $thematic_array['thematics'] = MonLaboLib::secured_implode( ', ', $teams_links );
221                         } else {
222                                 $thematic_array['thematics'] = '';
223                         }
224                         $list_array[] = $thematic_array;
225                 }
226                 $a_afficher .= '<div class="MonLabo MonLabo_thematics_table_normal">'
227                                                 .$generate_HTML->generic_table( "", $colums_titles, $list_array )
228                                                 .'</div>';
229         }
230         return $a_afficher;
234 /**
235  * Crée le code HTML d'un tableau complet crée à partir des Informations
236  * d'un groupe d'unités et destiné à être affiché dans l'inteface d'administration.
237  *
238  * @return string code HTML
239  */
240 function generate_table_admin_for_units() {
241         /*                        `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
242                                   `affiliations` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
243                                   `code` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
244                                   `name_fr` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
245                                   `name_en` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
246                                   `external_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
247                                   `hal_publi_unit_id` int(11) DEFAULT NULL,
248                                   */
249         $generate_HTML = New MonLabo_generate_HTML();
250         $MonLabo_access_data = New MonLabo_access_data();
251         $units_information = $MonLabo_access_data->get_units_information();
252         $options4 = get_option( 'MonLabo_settings_group4' );
253         $colums_titles = Array( '',  __( 'id', 'mon-laboratoire' ),
254                                                           __( 'Nom (fr)', 'mon-laboratoire' ),
255                                                           __( 'Nom (en)', 'mon-laboratoire' ),
256                                                           __( 'logo', 'mon-laboratoire' ),
257                                                           __( 'Code', 'mon-laboratoire' ),
258                                                           __( 'Affiliations', 'mon-laboratoire' ),
259                                                           __( 'URL ext.', 'mon-laboratoire' ),
260                                                           __( 'id Descartes', 'mon-laboratoire' ),
261                                                           __( 'id HAL', 'mon-laboratoire' ),
262                                                           __( 'Adresse alt.', 'mon-laboratoire' ),
263                                                           __( 'Contact alt.', 'mon-laboratoire' ),
264                                                           __( 'Directeurs', 'mon-laboratoire' ) );
265         $list_array = array();
266         if( !empty( $units_information ) ) {
267                 $number_of_units = count( $units_information );
268         } else {
269                 $number_of_units = 0;
270         }
271         $a_afficher = '';
272         if ( '0' != $number_of_units ) {
273                 foreach ( $units_information as $unit_information ) {
274                         $unit_array = array();
275                         $unit_array['modifier'] = '<form method="post" action="admin.php?page=MonLabo_edit_members_and_groups&tab=tab_four&submit_item='.$unit_information->id.'">'
276                                                                         .'<button type="submit">'.__( 'Modifier', 'mon-laboratoire' ).'</button></form>';
277                         $unit_array['id'] = $unit_information->id;
278                         $unit_array['name_fr'] = '<small>'.$unit_information->name_fr.'</small>';
279                         $unit_array['name_en'] = '<small>'.$unit_information->name_en.'</small>';
280                         $unit_array['logo'] = ( empty( $unit_information->logo ) ? '' : '<a href="'.$unit_information->logo.'" class="hover-zoom-square30"><img src="'.$unit_information->logo.'" height="24" alt="'.$unit_information->logo.'" /></a>' );
281                         $unit_array['code'] = $unit_information->code;
282                         $unit_array['affiliations'] = '<small>'.$unit_information->affiliations.'</small>';
283                         $unit_array['external_url'] = ( empty( $unit_information->external_url ) ? '' : '<a href="'.$unit_information->external_url.'">'.__( 'lien', 'mon-laboratoire' ).'</a>' );
284                         if ( !empty( $unit_information->descartes_publi_unit_id ) ) {
285                                 $unit_array['descartes_publi_unit_id'] = "<a href='".$options4['MonLabo_DescartesPubmed_api_url'].'?unite='.$unit_information->descartes_publi_unit_id."'>"
286                                                                                                                 .$unit_information->descartes_publi_unit_id.'</a>';
287                         } else {
288                                 $unit_array['descartes_publi_unit_id'] = '';
289                         }
291                         $unit_array['hal_publi_unit_id'] = $unit_information->hal_publi_unit_id;
292                         $unit_array['address_alt'] = $unit_information->address_alt;
293                         $unit_array['contact_alt'] = $unit_information->contact_alt;
294                         $directors = $MonLabo_access_data->get_directors_name_for_an_unit( $unit_information->id );
295                         if ( !empty( $directors ) ) {
296                                 $unit_array['directors'] = MonLaboLib::secured_implode( ', ', $directors );
297                         } else {
298                                 $unit_array['directors'] = '';
299                         }
300                         $list_array[] = $unit_array;
301                 }
302                 $a_afficher .= '<div class="MonLabo MonLabo_units_table_normal">'
303                                                 .$generate_HTML->generic_table( '', $colums_titles, $list_array )
304                                                 .'</div>';
305         }
306         return $a_afficher;