Ajout d'un bouton pour "upgrader" les quotas des membres
lorsqu'on a modifié les quotas du profil. Fix #1317
This commit is contained in:
		
							parent
							
								
									886068bd03
								
							
						
					
					
						commit
						fb514b928c
					
				|  | @ -35,6 +35,10 @@ if (!$admin->enabled) { | |||
| 	__("This page is restricted to authorized staff"); | ||||
| 	exit(); | ||||
| } | ||||
| $fields = array ( | ||||
|   "synchronise"        => array ("get", "integer", "0"), | ||||
| ); | ||||
| getFields($fields); | ||||
| 
 | ||||
| include_once ("head.php"); | ||||
| 
 | ||||
|  | @ -43,10 +47,14 @@ include_once ("head.php"); | |||
| <hr id="topbar"/> | ||||
| <br /> | ||||
| <?php | ||||
| 	if (isset($error) && $error) { | ||||
| 	  echo "<p class=\"error\">$error</p>"; | ||||
| 	} | ||||
| if ($synchronise==true) { | ||||
|   $quota->synchronise_user_profile(); | ||||
|   echo "<p class=\"error\">";__("User's quotas synchronised");echo "</p>"; | ||||
| } | ||||
| 
 | ||||
| if (isset($error) && $error) { | ||||
|   echo "<p class=\"error\">$error</p>"; | ||||
| } | ||||
| ?>
 | ||||
| <form method="post" action="adm_dodefquotas.php"> | ||||
| <p> | ||||
|  | @ -78,6 +86,7 @@ foreach($quota->listtype() as $type) { | |||
| <p> | ||||
| <?php __("Here is the list of the quotas on the server for the new accounts. If you want to change them, enter new values"); ?>
 | ||||
| </p> | ||||
| <span class="inb"><a href="adm_defquotas.php?synchronise=1"><?php __("Synchronise user's quota"); ?></a></span>  
 | ||||
| 
 | ||||
| <form method="post" action="adm_dodefquotas.php"> | ||||
| <div> | ||||
|  |  | |||
|  | @ -83,6 +83,22 @@ class m_quota { | |||
|     return $qlist; | ||||
|   } | ||||
|    | ||||
| 
 | ||||
|   /** | ||||
|     * Synchronise the quotas of the users with the quota of the | ||||
|     * user's profile. | ||||
|     * If the user have a greater quota than the profile, no change. | ||||
|     * If the quota entry doesn't exist for the user, create it with | ||||
|     * the defaults value. | ||||
|     */ | ||||
|   function synchronise_user_profile() { | ||||
|     global $db,$err; | ||||
|     $err->log("quota","apply_greater_quota"); | ||||
|     $q="insert into quotas select m.uid as uid, d.quota as name, d.value as total from membres m, defquotas d left join quotas q on q.name=d.quota  where m.type=d.type  ON DUPLICATE KEY UPDATE total = greatest(d.value, quotas.total);"; | ||||
|     $db->query($q); | ||||
|     return true; | ||||
|   } | ||||
| 
 | ||||
|   /* ----------------------------------------------------------------- */ | ||||
|   /** Return a ressource usage (u) and total quota (t) | ||||
|    * @param string $ressource ressource to get quota of | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Alan Garcia
						Alan Garcia