Переглянути джерело

Fix perm id and sort of modules by id.

Laurent Destailleur 4 роки тому
батько
коміт
6c521073ea

+ 30 - 37
htdocs/admin/system/modules.php

@@ -228,26 +228,26 @@ print '<tr class="liste_titre_filter">';
 
 if ($arrayfields['name']['checked']) {
 	print '<td class="liste_titre left">';
-	print '<input class="flat" type="text" name="search_name" size="8" value="'.$search_name.'">';
+	print '<input class="flat" type="text" name="search_name" size="8" value="'.dol_escape_htmltag($search_name).'">';
 	print '</td>';
 }
 if ($arrayfields['version']['checked']) {
 	print '<td class="liste_titre left">';
-	print '<input class="flat" type="text" name="search_version" size="8" value="'.$search_version.'">';
+	print '<input class="flat" type="text" name="search_version" size="6" value="'.dol_escape_htmltag($search_version).'">';
 	print '</td>';
 }
 if ($arrayfields['id']['checked']) {
 	print '<td class="liste_titre left">';
-	print '<input class="flat" type="text" name="search_id" size="8" value="'.$search_id.'">';
+	print '<input class="flat" type="text" name="search_id" size="6 value="'.dol_escape_htmltag($search_id).'">';
 	print '</td>';
 }
-if ($arrayfields['module_position']['checked']) {
+if ($arrayfields['permission']['checked']) {
 	print '<td class="liste_titre left">';
+	print '<input class="flat" type="text" name="search_permission" size="8" value="'.dol_escape_htmltag($search_permission).'">';
 	print '</td>';
 }
-if ($arrayfields['permission']['checked']) {
+if ($arrayfields['module_position']['checked']) {
 	print '<td class="liste_titre left">';
-	print '<input class="flat" type="text" name="search_permission" size="8" value="'.$search_permission.'">';
 	print '</td>';
 }
 
@@ -267,14 +267,14 @@ if ($arrayfields['version']['checked']) {
 	print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder);
 }
 if ($arrayfields['id']['checked']) {
-	print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder);
-}
-if ($arrayfields['module_position']['checked']) {
-	print_liste_field_titre($arrayfields['module_position']['label'], $_SERVER["PHP_SELF"], "module_position", "", "", "", $sortfield, $sortorder);
+	print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder, 'nowraponall ');
 }
 if ($arrayfields['permission']['checked']) {
 	print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder);
 }
+if ($arrayfields['module_position']['checked']) {
+	print_liste_field_titre($arrayfields['module_position']['label'], $_SERVER["PHP_SELF"], "module_position", "", "", "", $sortfield, $sortorder);
+}
 
 // Fields from hook
 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
@@ -289,37 +289,30 @@ if ($sortfield == "name" && $sortorder == "asc") {
 	usort($moduleList, function (stdClass $a, stdClass $b) {
 		return strcasecmp($a->name, $b->name);
 	});
-}
-if ($sortfield == "name" && $sortorder == "desc") {
+} elseif ($sortfield == "name" && $sortorder == "desc") {
 	usort($moduleList, function (stdClass $a, stdClass $b) {
 		return strcasecmp($b->name, $a->name);
 	});
-}
-if ($sortfield == "version" && $sortorder == "asc") {
+} elseif ($sortfield == "version" && $sortorder == "asc") {
 	usort($moduleList, function (stdClass $a, stdClass $b) {
 		return strcasecmp($a->version, $b->version);
 	});
-}
-if ($sortfield == "version" && $sortorder == "desc") {
+} elseif ($sortfield == "version" && $sortorder == "desc") {
 	usort($moduleList, function (stdClass $a, stdClass $b) {
 		return strcasecmp($b->version, $a->version);
 	});
-}
-if ($sortfield == "id" && $sortorder == "asc") {
+} elseif ($sortfield == "id" && $sortorder == "asc") {
 	usort($moduleList, "compareIdAsc");
-}
-if ($sortfield == "id" && $sortorder == "desc") {
+} elseif ($sortfield == "id" && $sortorder == "desc") {
 	usort($moduleList, "compareIdDesc");
-}
-if ($sortfield == "permission" && $sortorder == "asc") {
+} elseif ($sortfield == "permission" && $sortorder == "asc") {
 	usort($moduleList, "comparePermissionIdsAsc");
-}
-if ($sortfield == "permission" && $sortorder == "desc") {
+} elseif ($sortfield == "permission" && $sortorder == "desc") {
 	usort($moduleList, "comparePermissionIdsDesc");
+} else {
+	$moduleList = dol_sort_array($moduleList, 'module_position');
 }
 
-$moduleList = dol_sort_array($moduleList, 'module_position');
-
 foreach ($moduleList as $module) {
 	print '<tr class="oddeven">';
 
@@ -338,10 +331,6 @@ foreach ($moduleList as $module) {
 		print '<td class="center">'.$module->id.'</td>';
 	}
 
-	if ($arrayfields['module_position']['checked']) {
-		print '<td class="center">'.$module->module_position.'</td>';
-	}
-
 	if ($arrayfields['permission']['checked']) {
 		$idperms = '';
 
@@ -357,7 +346,11 @@ foreach ($moduleList as $module) {
 			}
 		}
 
-		print '<td>'.($idperms ? $idperms : "&nbsp;").'</td>';
+		print '<td><span class="opacitymedium">'.($idperms ? $idperms : "&nbsp;").'</span></td>';
+	}
+
+	if ($arrayfields['module_position']['checked']) {
+		print '<td class="center">'.$module->module_position.'</td>';
 	}
 
 	print '<td></td>';
@@ -394,11 +387,11 @@ $db->close();
   */
 function compareIdAsc(stdClass $a, stdClass $b)
 {
-	if ($a->id == $b->id) {
+	if ((int) $a->id == (int) $b->id) {
 		return 0;
 	}
 
-	return $a->id > $b->id ? -1 : 1;
+	return ((int) $a->id < (int) $b->id) ? -1 : 1;
 }
 
  /**
@@ -410,11 +403,11 @@ function compareIdAsc(stdClass $a, stdClass $b)
   */
 function compareIdDesc(stdClass $a, stdClass $b)
 {
-	if ($a->id == $b->id) {
+	if ((int) $a->id == (int) $b->id) {
 		return 0;
 	}
 
-	return $b->id > $a->id ? -1 : 1;
+	return ((int) $b->id < (int) $a->id) ? -1 : 1;
 }
 
  /**
@@ -441,7 +434,7 @@ function comparePermissionIdsAsc(stdClass $a, stdClass $b)
 		return 0;
 	}
 
-	return $a->permission[0] > $b->permission[0] ? -1 : 1;
+	return $a->permission[0] < $b->permission[0] ? -1 : 1;
 }
 
  /**
@@ -468,5 +461,5 @@ function comparePermissionIdsDesc(stdClass $a, stdClass $b)
 		return 0;
 	}
 
-	return $a->permission[0] > $b->permission[0] ? 1 : -1;
+	return $b->permission[0] < $a->permission[0] ? -1 : 1;
 }

+ 1 - 1
htdocs/core/modules/modBlockedLog.class.php

@@ -113,7 +113,7 @@ class modBlockedLog extends DolibarrModules
 		// -----------------
 		$this->rights = array(); // Permission array used by this module
 
-		$r = 0;
+		$r = 1;
 		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
 		$this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label
 		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+ 1 - 1
htdocs/core/modules/modBom.class.php

@@ -205,7 +205,7 @@ class modBom extends DolibarrModules
 		// Permissions provided by this module
 		$this->rights = array(); // Permission array used by this module
 
-		$r = 0;
+		$r = 1;
 		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
 		$this->rights[$r][1] = 'Read bom of Bom'; // Permission label
 		$this->rights[$r][3] = 0; // Permission by default for new user (0/1)

+ 1 - 1
htdocs/core/modules/modDebugBar.class.php

@@ -79,7 +79,7 @@ class modDebugBar extends DolibarrModules
 		// Permissions
 		$this->rights = array();
 
-		$this->rights[1][0] = 430; // id de la permission
+		$this->rights[1][0] = 431; // id de la permission
 		$this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission
 		$this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour)
 		$this->rights[1][3] = 1; // La permission est-elle une permission par defaut

+ 2 - 1
htdocs/core/modules/modEventOrganization.class.php

@@ -224,7 +224,8 @@ class modEventOrganization extends DolibarrModules
 
 		// Permissions provided by this module
 		$this->rights = array();
-		$r = 0;
+		$r = 1;
+
 		// Add here entries to declare new permissions
 		/* BEGIN MODULEBUILDER PERMISSIONS */
 		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

+ 1 - 1
htdocs/core/modules/modLoan.class.php

@@ -97,7 +97,7 @@ class modLoan extends DolibarrModules
 		$r = 0;
 
 		$r++;
-		$this->rights[$r][0] = 520;
+		$this->rights[$r][0] = 521;
 		$this->rights[$r][1] = 'Read loans';
 		$this->rights[$r][2] = 'r';
 		$this->rights[$r][3] = 0;

+ 1 - 1
htdocs/core/modules/modMailing.class.php

@@ -48,7 +48,7 @@ class modMailing extends DolibarrModules
 		// It is used to group modules by family in module setup page
 		$this->family = "interface";
 		// Module position in the family on 2 digits ('01', '10', '20', ...)
-		$this->module_position = '22';
+		$this->module_position = '23';
 
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i', '', get_class($this));

+ 1 - 1
htdocs/core/modules/modMrp.class.php

@@ -236,7 +236,7 @@ class modMrp extends DolibarrModules
 
 		// Permissions provided by this module
 		$this->rights = array();
-		$r = 0;
+		$r = 1;
 		// Add here entries to declare new permissions
 		/* BEGIN MODULEBUILDER PERMISSIONS */
 		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)

+ 1 - 1
htdocs/core/modules/modNotification.class.php

@@ -45,7 +45,7 @@ class modNotification extends DolibarrModules
 		// It is used to group modules in module setup page
 		$this->family = "interface";
 		// Module position in the family on 2 digits ('01', '10', '20', ...)
-		$this->module_position = '01';
+		$this->module_position = '22';
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i', '', get_class($this));
 		$this->description = "EMail notifications (push) on business Dolibarr events";

+ 1 - 1
htdocs/core/modules/modReceiptPrinter.class.php

@@ -95,7 +95,7 @@ class modReceiptPrinter extends DolibarrModules
 		// $this->rights[$r][5]     Niveau 2 pour nommer permission dans code
 
 		$r++;
-		$this->rights[$r][0] = 67000;
+		$this->rights[$r][0] = 67001;
 		$this->rights[$r][1] = 'ReceiptPrinter';
 		$this->rights[$r][2] = 'r';
 		$this->rights[$r][3] = 0;

+ 3 - 2
htdocs/core/modules/modWorkstation.class.php

@@ -45,7 +45,7 @@ class modWorkstation extends DolibarrModules
 
 		// Id for module (must be unique).
 		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
-		$this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module
+		$this->numero = 690;
 		// Key text used to identify module (for permissions, menus, etc...)
 		$this->rights_class = 'workstation';
 		// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
@@ -239,7 +239,7 @@ class modWorkstation extends DolibarrModules
 
 		// Permissions provided by this module
 		$this->rights = array();
-		$r = 0;
+		$r = 1;
 		// Add here entries to declare new permissions
 		/* BEGIN MODULEBUILDER PERMISSIONS */
 		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
@@ -330,6 +330,7 @@ class modWorkstation extends DolibarrModules
 			// This is a Left menu entry
 			'type'=>'left',
 			'titre'=>$langs->trans('Workstations'),
+			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
 			'mainmenu'=>'mrp',
 			'leftmenu'=>'workstation_workstation',
 			'url'=>'',

+ 1 - 1
htdocs/core/modules/modZapier.class.php

@@ -242,7 +242,7 @@ class modZapier extends DolibarrModules
 		// Permission array used by this module
 		$this->rights = array();
 
-		$r = 0;
+		$r = 1;
 		// Permission id (must not be already used)
 		$this->rights[$r][0] = $this->numero + $r;
 		// Permission label

BIN
htdocs/theme/eldy/img/object_zapier.png


+ 2 - 3
htdocs/user/class/user.class.php

@@ -673,8 +673,7 @@ class User extends CommonObject
 		if (!empty($rid)) {
 			$module = $perms = $subperms = '';
 
-			// Si on a demande ajout d'un droit en particulier, on recupere
-			// les caracteristiques (module, perms et subperms) de ce droit.
+			// Si on a demande ajout d'un droit en particulier, on recupere les caracteristiques (module, perms et subperms) de ce droit.
 			$sql = "SELECT module, perms, subperms";
 			$sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
 			$sql .= " WHERE id = ".((int) $rid);
@@ -718,7 +717,7 @@ class User extends CommonObject
 			}
 		}
 
-		// Ajout des droits trouves grace au critere whereforadd
+		// Add automatically other permission using the criteria whereforadd
 		if (!empty($whereforadd)) {
 			//print "$module-$perms-$subperms";
 			$sql = "SELECT id";

+ 2 - 2
htdocs/user/perms.php

@@ -105,7 +105,7 @@ if (empty($reshook)) {
 			setEventMessages($edituser->error, $edituser->errors, 'errors');
 		}
 
-		// If we are changing our own permissions, we reload
+		// If we are changing our own permissions, we reload permissions and menu
 		if ($object->id == $user->id) {
 			$user->clearrights();
 			$user->getrights();
@@ -124,7 +124,7 @@ if (empty($reshook)) {
 			setEventMessages($edituser->error, $edituser->errors, 'errors');
 		}
 
-		// If we are changing our own permissions, we reload
+		// If we are changing our own permissions, we reload permissions and menu
 		if ($object->id == $user->id) {
 			$user->clearrights();
 			$user->getrights();