Completed
Push — master ( d66359...78c36e )
by cam
05:04
created
ecrire/inc/preselectionner_parent_nouvel_objet.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 if (!defined('_ECRIRE_INC_VERSION')) {
15
-	return;
15
+    return;
16 16
 }
17 17
 if (!defined('_AUTO_SELECTION_RUBRIQUE')) {
18
-	define('_AUTO_SELECTION_RUBRIQUE', false);
18
+    define('_AUTO_SELECTION_RUBRIQUE', false);
19 19
 }
20 20
 
21 21
 
@@ -29,39 +29,39 @@  discard block
 block discarded – undo
29 29
  * @return string
30 30
  */
31 31
 function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) {
32
-	if (!_AUTO_SELECTION_RUBRIQUE) {
33
-		return '';
34
-	}
32
+    if (!_AUTO_SELECTION_RUBRIQUE) {
33
+        return '';
34
+    }
35 35
 
36
-	if (!isset($row['id_rubrique'])) {
37
-		return '';
38
-	}
36
+    if (!isset($row['id_rubrique'])) {
37
+        return '';
38
+    }
39 39
 
40
-	$id_rubrique = '';
41
-	if ($GLOBALS['connect_id_rubrique']) {
42
-		// si admin restreint : sa rubrique
43
-		$id_rubrique = $GLOBALS['connect_id_rubrique'][0];
44
-	} elseif (is_int(_AUTO_SELECTION_RUBRIQUE)
45
-		and sql_fetsel("id_rubrique", "spip_rubriques", "id_rubrique=".intval(_AUTO_SELECTION_RUBRIQUE))
46
-	) {
47
-		$id_rubrique = _AUTO_SELECTION_RUBRIQUE;
48
-	} else {
49
-		// sinon la derniere rubrique cree
50
-		$row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", "0,1");
51
-		$id_rubrique = $row_rub['id_rubrique'];
52
-	}
53
-	// si le choix ne convient pas, on cherche dans un secteur
54
-	if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) {
55
-		$id_rubrique = '';
56
-		// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
57
-		$res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0");
58
-		while (!$id_rubrique and $row_rub = sql_fetch($res)) {
59
-			if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) {
60
-				$id_rubrique = $row_rub['id_rubrique'];
61
-			}
62
-		}
63
-	}
40
+    $id_rubrique = '';
41
+    if ($GLOBALS['connect_id_rubrique']) {
42
+        // si admin restreint : sa rubrique
43
+        $id_rubrique = $GLOBALS['connect_id_rubrique'][0];
44
+    } elseif (is_int(_AUTO_SELECTION_RUBRIQUE)
45
+        and sql_fetsel("id_rubrique", "spip_rubriques", "id_rubrique=".intval(_AUTO_SELECTION_RUBRIQUE))
46
+    ) {
47
+        $id_rubrique = _AUTO_SELECTION_RUBRIQUE;
48
+    } else {
49
+        // sinon la derniere rubrique cree
50
+        $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", "0,1");
51
+        $id_rubrique = $row_rub['id_rubrique'];
52
+    }
53
+    // si le choix ne convient pas, on cherche dans un secteur
54
+    if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) {
55
+        $id_rubrique = '';
56
+        // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
57
+        $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0");
58
+        while (!$id_rubrique and $row_rub = sql_fetch($res)) {
59
+            if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) {
60
+                $id_rubrique = $row_rub['id_rubrique'];
61
+            }
62
+        }
63
+    }
64 64
 
65
-	return $id_rubrique;
65
+    return $id_rubrique;
66 66
 
67 67
 }
Please login to merge, or discard this patch.