[76] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Abomailmans |
---|
| 5 | * MaZiaR - NetAktiv |
---|
| 6 | * tech@netaktiv.com |
---|
| 7 | * Printemps 2007 |
---|
| 8 | * Inspire de Spip-Listes |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | function _abomailmans_install(){ |
---|
| 13 | if ($GLOBALS['spip_version_code']<1.9204){ |
---|
| 14 | include_spip('base/abomailmans_upgrade'); |
---|
| 15 | abomailmans_install('install'); |
---|
| 16 | } |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | // Fonction utilitaires |
---|
| 20 | function abomailmans_abomailman_editable($id_abomailman = 0) { |
---|
| 21 | global $connect_statut; |
---|
| 22 | return $connect_statut == '0minirezo'; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | function abomailmans_abomailman_administrable($id_abomailman = 0) { |
---|
| 26 | global $connect_statut; |
---|
| 27 | return $connect_statut == '0minirezo'; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | // |
---|
| 32 | // Afficher une liste de mailmans |
---|
| 33 | // |
---|
| 34 | |
---|
| 35 | function abomailmans_afficher_abomailmans($titre_table, $requete, $icone = '') { |
---|
| 36 | global $couleur_claire, $couleur_foncee; |
---|
| 37 | global $connect_id_auteur; |
---|
| 38 | |
---|
| 39 | $tous_id = array(); |
---|
| 40 | |
---|
| 41 | $select = $requete['SELECT'] ? $requete['SELECT'] : '*'; |
---|
| 42 | $from = $requete['FROM'] ? $requete['FROM'] : 'spip_articles AS articles'; |
---|
| 43 | $join = $requete['JOIN'] ? (' LEFT JOIN ' . $requete['JOIN']) : ''; |
---|
| 44 | $where = $requete['WHERE'] ? (' WHERE ' . $requete['WHERE']) : ''; |
---|
| 45 | $order = $requete['ORDER BY'] ? (' ORDER BY ' . $requete['ORDER BY']) : ''; |
---|
| 46 | $group = $requete['GROUP BY'] ? (' GROUP BY ' . $requete['GROUP BY']) : ''; |
---|
| 47 | $limit = $requete['LIMIT'] ? (' LIMIT ' . $requete['LIMIT']) : ''; |
---|
| 48 | |
---|
| 49 | $cpt = "$from$join$where$group"; |
---|
| 50 | $tmp_var = substr(md5($cpt), 0, 4); |
---|
| 51 | |
---|
| 52 | if (!$group){ |
---|
| 53 | $cpt = spip_fetch_array(spip_query("SELECT COUNT(*) AS n FROM $cpt")); |
---|
| 54 | if (! ($cpt = $cpt['n'])) return $tous_id ; |
---|
| 55 | } |
---|
| 56 | else |
---|
| 57 | $cpt = spip_num_rows(spip_query("SELECT $select FROM $cpt")); |
---|
| 58 | if ($requete['LIMIT']) $cpt = min($requete['LIMIT'], $cpt); |
---|
| 59 | |
---|
| 60 | $nb_aff = 1.5 * _TRANCHES; |
---|
| 61 | $deb_aff = intval(_request('t_' .$tmp_var)); |
---|
| 62 | |
---|
| 63 | if ($cpt > $nb_aff) { |
---|
| 64 | $nb_aff = (_TRANCHES); |
---|
| 65 | $tranches = afficher_tranches_requete($cpt, 3, $tmp_var, '', $nb_aff); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | if (!$icone) $icone = "../"._DIR_PLUGIN_ABOMAILMANS."/img_pack/mailman.gif"; |
---|
| 69 | |
---|
| 70 | if ($cpt) { |
---|
| 71 | if ($titre_table) echo "<div style='height: 12px;'></div>"; |
---|
| 72 | echo "<div class='liste'>"; |
---|
| 73 | bandeau_titre_boite2($titre_table, $icone, $couleur_claire, "black"); |
---|
| 74 | echo "<table width='100%' cellpadding='4' cellspacing='0' border='0'>"; |
---|
| 75 | |
---|
| 76 | echo $tranches; |
---|
| 77 | |
---|
| 78 | $result = spip_query("SELECT $select FROM $from$join$where$group$order LIMIT $deb_aff, $nb_aff"); |
---|
| 79 | $num_rows = spip_num_rows($result); |
---|
| 80 | |
---|
| 81 | $ifond = 0; |
---|
| 82 | $premier = true; |
---|
| 83 | |
---|
| 84 | $compteur_liste = 0; |
---|
| 85 | while ($row = spip_fetch_array($result)) { |
---|
| 86 | $vals = ''; |
---|
| 87 | $id_abomailman = $row['id_abomailman']; |
---|
| 88 | $reponses = $row['reponses']; |
---|
| 89 | $titre = $row['titre']; |
---|
| 90 | |
---|
| 91 | $tous_id[] = $id_abomailman; |
---|
| 92 | |
---|
| 93 | $retour = parametre_url(self(),'duplique_chart',''); |
---|
| 94 | $link = generer_url_ecrire('abomailmans_edit',"id_abomailman=$id_abomailman&retour=".urlencode($retour)); |
---|
| 95 | if ($reponses) { |
---|
| 96 | $puce = 'puce-verte-breve.gif'; |
---|
| 97 | } |
---|
| 98 | else { |
---|
| 99 | $puce = 'puce-orange-breve.gif'; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | $s = "<img src='"._DIR_IMG_PACK."$puce' width='7' height='7' border='0'> "; |
---|
| 103 | $vals[] = $s; |
---|
| 104 | |
---|
| 105 | //$s .= typo($titre); |
---|
| 106 | $s = icone_horizontale(typo($titre), $link,"../"._DIR_PLUGIN_ABOMAILMANS."/img_pack/mailman.gif", "",false); |
---|
| 107 | $vals[] = $s; |
---|
| 108 | |
---|
| 109 | $s = ""; |
---|
| 110 | $vals[] = $s; |
---|
| 111 | |
---|
| 112 | $s = ""; |
---|
| 113 | |
---|
| 114 | $s = ""; |
---|
| 115 | if(abomailmans_abomailman_administrable($id_abomailman)){ |
---|
| 116 | $link = parametre_url('','exec=abomailmans_edit&supp_abomailman', $id_abomailman); |
---|
| 117 | $link = parametre_url($link,'id_abomailman', $id_abomailman); |
---|
| 118 | $vals[] = "<a href='$link'>"._T("abomailmans:supprimer")."</a>"; |
---|
| 119 | } |
---|
| 120 | $vals[] = $s; |
---|
| 121 | |
---|
| 122 | $table[] = $vals; |
---|
| 123 | } |
---|
| 124 | spip_free_result($result); |
---|
| 125 | |
---|
| 126 | $largeurs = array('','','','',''); |
---|
| 127 | $styles = array('arial11', 'arial11', 'arial1', 'arial1','arial1'); |
---|
| 128 | echo afficher_liste($largeurs, $table, $styles); |
---|
| 129 | echo "</table>"; |
---|
| 130 | echo "</div>\n"; |
---|
| 131 | } |
---|
| 132 | return $tous_id; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | //* Envoi de mail via Mailman |
---|
| 137 | function abomailman_mail ($from_nom, $from_email, $to_nom, $to_email, $subject="", $body="", $html="", $charset="") { |
---|
| 138 | include_spip ("class/phpmailer/class.phpmailer"); |
---|
| 139 | $mail = new PHPMailer(); |
---|
| 140 | $mail ->CharSet = $charset; |
---|
| 141 | if ($html==true) $mail->IsHTML(true); |
---|
| 142 | $mail->FromName = $from_nom; |
---|
| 143 | $mail->From = $from_email; |
---|
| 144 | $mail->AddAddress($to_email); |
---|
| 145 | $mail->Subject = $subject; |
---|
| 146 | $mail->Body = $body; |
---|
| 147 | |
---|
| 148 | if(!$mail->Send()) { |
---|
| 149 | return false; } |
---|
| 150 | else { |
---|
| 151 | return true; |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | // Afficher l'arbo |
---|
| 157 | function abomailman_arbo_rubriques($id_rubrique, $rslt_id_rubrique="") { |
---|
| 158 | global $ran; |
---|
| 159 | $ran ++; |
---|
| 160 | |
---|
| 161 | $marge=" |"; |
---|
| 162 | for ($g=0;$g<$ran;$g++) { |
---|
| 163 | if (($ran-1)==0) { |
---|
| 164 | $marge="•"; |
---|
| 165 | } |
---|
| 166 | else { |
---|
| 167 | $marge .="-"; |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | $marge .=" "; |
---|
| 171 | |
---|
| 172 | $rqt_rubriques = spip_query ("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE id_parent='".$id_rubrique."'"); |
---|
| 173 | while ($row = spip_fetch_array($rqt_rubriques)) { |
---|
| 174 | $id_rubrique = $row['id_rubrique']; |
---|
| 175 | $id_parent = $row['id_parent']; |
---|
| 176 | $titre = $row['titre']; |
---|
| 177 | $arbo .="<option value='".$id_rubrique."'>" . $marge . supprimer_numero (typo($titre)) . "</option>"; |
---|
| 178 | $arbo .= abomailman_arbo_rubriques($id_rubrique, $rslt_id_parent); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | return $arbo; |
---|
| 182 | |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | ?> |
---|