[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / svp / svp_pipelines.php
index 50a76f8..476ff2c 100644 (file)
@@ -1,47 +1,49 @@
 <?php
 /**
  * Déclarations d'autorisations et utilisations de pipelines
- * 
+ *
  * @plugin SVP pour SPIP
  * @license GPL
  * @package SPIP\SVP\Pipelines
-**/
+ **/
 
 /**
  * Fonction du pipeline autoriser. N'a rien à faire
+ *
  * @pipeline autoriser
  */
-function svp_autoriser(){}
+function svp_autoriser() { }
 
 /**
  * Autoriser l'iconification (mettre un logo) d'un dépot
  *
  * @param  string $faire Action demandée
- * @param  string $type  Type d'objet sur lequel appliquer l'action
- * @param  int    $id    Identifiant de l'objet
- * @param  array  $qui   Description de l'auteur demandant l'autorisation
- * @param  array  $opt   Options de cette autorisation
+ * @param  string $type Type d'objet sur lequel appliquer l'action
+ * @param  int $id Identifiant de l'objet
+ * @param  array $qui Description de l'auteur demandant l'autorisation
+ * @param  array $opt Options de cette autorisation
  * @return bool          true s'il a le droit, false sinon
  */
-function autoriser_depot_iconifier_dist($faire, $type, $id, $qui, $opt){
+function autoriser_depot_iconifier_dist($faire, $type, $id, $qui, $opt) {
        return true;
 }
 
-
 /**
  * Autoriser l'ajout d'un plugin ou d'un dépôt
  *
  * @param  string $faire Action demandée
- * @param  string $type  Type d'objet sur lequel appliquer l'action
- * @param  int    $id    Identifiant de l'objet
- * @param  array  $qui   Description de l'auteur demandant l'autorisation
- * @param  array  $opt   Options de cette autorisation
+ * @param  string $type Type d'objet sur lequel appliquer l'action
+ * @param  int $id Identifiant de l'objet
+ * @param  array $qui Description de l'auteur demandant l'autorisation
+ * @param  array $opt Options de cette autorisation
  * @return bool          true s'il a le droit, false sinon
  */
-function autoriser_plugins_ajouter_dist($faire, $type, $id, $qui, $opt){
-       if (!defined('_AUTORISER_TELECHARGER_PLUGINS'))
+function autoriser_plugins_ajouter_dist($faire, $type, $id, $qui, $opt) {
+       if (!defined('_AUTORISER_TELECHARGER_PLUGINS')) {
                define('_AUTORISER_TELECHARGER_PLUGINS', true);
-       return _AUTORISER_TELECHARGER_PLUGINS AND autoriser('webmestre');
+       }
+
+       return _AUTORISER_TELECHARGER_PLUGINS and autoriser('webmestre');
 }
 
 
@@ -55,9 +57,10 @@ function autoriser_plugins_ajouter_dist($faire, $type, $id, $qui, $opt){
  * @param array $flux Données du pipeline
  * @return array      Données du pipeline
  */
-function svp_ajouter_onglets($flux){
-       if (($flux['args']=='plugins')
-       AND (autoriser('ajouter', '_plugins'))){
+function svp_ajouter_onglets($flux) {
+       if (($flux['args'] == 'plugins')
+               and (autoriser('ajouter', '_plugins'))
+       ) {
                $compteurs = svp_compter('depot');
                $page = ($compteurs['depot'] == 0) ? 'depots' : 'charger_plugin';
                $flux['data']['charger_plugin'] =
@@ -66,23 +69,24 @@ function svp_ajouter_onglets($flux){
                                'plugin_titre_automatique_ajouter',
                                generer_url_ecrire($page));
        }
+
        return $flux;
 }
 
 
 /**
  * Ne pas afficher par défaut les paquets,dépots,plugins locaux dans les boucles
- * 
+ *
  * On n'affiche dans les boucles (PLUGINS) (DEPOTS) et (PAQUETS)
  * que les éléments distants par défaut (on cache les locaux).
- * 
+ *
  * Utiliser {tout} pour tout avoir.
  * Utiliser {tout}{id_depot=0} pour avoir les plugins ou paquets locaux.
  *
  * @pipeline pre_boucle
  * @param Boucle $boucle Description de la boucle
  * @return Boucle        Description de la boucle
-**/
+ **/
 function svp_pre_boucle($boucle) {
 
        // DEPOTS, PAQUETS
@@ -92,15 +96,15 @@ function svp_pre_boucle($boucle) {
                # OR $boucle->type_requete == 'depots'
        ) {
                $id_table = $boucle->id_table;
-               $m_id_depot = $id_table .'.id_depot';
+               $m_id_depot = $id_table . '.id_depot';
                // Restreindre aux depots distants
                if (
                        #!isset($boucle->modificateur['criteres']['id_depot']) && 
-                       !isset($boucle->modificateur['tout'])) {
-                               $boucle->where[] = array("'>'", "'$m_id_depot'", "'\"0\"'");
+               !isset($boucle->modificateur['tout'])
+               ) {
+                       $boucle->where[] = array("'>'", "'$m_id_depot'", "'\"0\"'");
                }
-       }
-       // PLUGINS
+       } // PLUGINS
        elseif ($boucle->type_requete == 'plugins') {
                $id_table = $boucle->id_table;
                /*
@@ -119,16 +123,16 @@ function svp_pre_boucle($boucle) {
                }
                */
                if (
-               #       !$id_depot && 
-                       !isset($boucle->modificateur['tout'])) {
-                               // Restreindre aux plugins distant (id_depot > 0)
-                               $boucle->from["depots_plugins"] =  "spip_depots_plugins";
-                               $boucle->where[] = array("'='", "'depots_plugins.id_plugin'", "'$id_table.id_plugin'");
-                               $boucle->where[] = array("'>'", "'depots_plugins.id_depot'", "'\"0\"'");
+                       #       !$id_depot &&
+               !isset($boucle->modificateur['tout'])
+               ) {
+                       // Restreindre aux plugins distant (id_depot > 0)
+                       $boucle->from["depots_plugins"] = "spip_depots_plugins";
+                       $boucle->where[] = array("'='", "'depots_plugins.id_plugin'", "'$id_table.id_plugin'");
+                       $boucle->where[] = array("'>'", "'depots_plugins.id_depot'", "'\"0\"'");
                }
        }
 
        return $boucle;
 
 }
-?>