浏览代码

Add badge with nb of imported calendard on user tab

Laurent Destailleur 8 年之前
父节点
当前提交
44bdf91715

+ 23 - 6
htdocs/core/lib/usergroups.lib.php

@@ -59,6 +59,11 @@ function user_prepare_head($object)
 	    $h++;
 	}
 
+    $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id;
+    $head[$h][1] = $langs->trans("UserGUISetup");
+    $head[$h][2] = 'guisetup';
+    $h++;
+
 	if ($canreadperms)
 	{
 		$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id;
@@ -67,15 +72,27 @@ function user_prepare_head($object)
 		$h++;
 	}
 
-    $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id;
-    $head[$h][1] = $langs->trans("UserGUISetup");
-    $head[$h][2] = 'guisetup';
-    $h++;
-
     if (! empty($conf->agenda->enabled))
     {
+        if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
+        $MAXAGENDA=$conf->global->AGENDA_EXT_NB;
+        
+        $i=1;
+        $nbagenda = 0;
+        while ($i <= $MAXAGENDA)
+        {
+            $key=$i;
+            $name='AGENDA_EXT_NAME_'.$object->id.'_'.$key;
+            $src='AGENDA_EXT_SRC_'.$object->id.'_'.$key;
+            $offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
+            $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
+            $i++;
+        
+            if (! empty($object->conf->$name)) $nbagenda++;
+        }
+        
 	    $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
-	    $head[$h][1] = $langs->trans("ExtSites");
+	    $head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' <span class="badge">'.$nbagenda.'</span>' : '');
 	    $head[$h][2] = 'extsites';
 	    $h++;
     }

+ 1 - 1
htdocs/holiday/list.php

@@ -202,7 +202,7 @@ $user_id = $user->id;
 if ($id > 0)
 {
 	// Charge utilisateur edite
-	$fuser->fetch($id);
+	$fuser->fetch($id, '', '', 1);
 	$fuser->getrights();
 	$user_id = $fuser->id;
 }

+ 6 - 7
htdocs/user/agenda_extsites.php

@@ -42,7 +42,7 @@ $actiontest=GETPOST('test','alpha');
 $actionsave=GETPOST('save','alpha');
 
 if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
-$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
+$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
 
 // List of available colors
 $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
@@ -50,7 +50,8 @@ $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5')
 // Security check
 $id = GETPOST('id','int');
 $object = new User($db);
-$object->fetch($id);
+$object->fetch($id, '', '', 1);
+$object->getrights();
 
 // Security check
 $socid=0;
@@ -81,12 +82,12 @@ if (empty($reshook)) {
 	if ($actionsave) {
 		$db->begin();
 
-		$i = 1;
 		$errorsaved = 0;
 		$error = 0;
 		$tabparam = array();
 
 		// Save agendas
+		$i = 1;
 		while ($i <= $MAXAGENDA) {
 			$name = trim(GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$i, 'alpha'));
 			$src = trim(GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$i, 'alpha'));
@@ -110,7 +111,7 @@ if (empty($reshook)) {
 			$tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i]=$color;
 			$tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i]=$enabled;
 
-			$i ++;
+			$i++;
 		}
 
 		if (!$error) {
@@ -167,7 +168,6 @@ print "<br>\n";
 $selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
 if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
 
-$var=true;
 print '<div class="div-table-responsive">';
 print "<table class=\"noborder\" width=\"100%\">";
 
@@ -180,7 +180,6 @@ print '<td align="right">'.$langs->trans("Color").'</td>';
 print "</tr>";
 
 $i=1;
-$var=true;
 while ($i <= $MAXAGENDA)
 {
 	$key=$i;
@@ -189,7 +188,7 @@ while ($i <= $MAXAGENDA)
 	$offsettz='AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key;
 	$color='AGENDA_EXT_COLOR_'.$id.'_'.$key;
 
-	
+
 	print '<tr class="oddeven">';
 	// Nb
 	print '<td class="maxwidth50onsmartphone">'.$langs->trans("AgendaExtNb",$key)."</td>";

+ 2 - 1
htdocs/user/bank.php

@@ -50,7 +50,8 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
 $object = new User($db);
 if ($id > 0 || ! empty($ref))
 {
-	$result = $object->fetch($id, $ref);
+	$result = $object->fetch($id, $ref, '', 1);
+	$object->getrights();
 }
 
 /*

+ 1 - 1
htdocs/user/card.php

@@ -1140,7 +1140,7 @@ else
 
     if ($id > 0)
     {
-        $object->fetch($id);
+        $object->fetch($id, '', '', 1);
         if ($res < 0) { dol_print_error($db,$object->error); exit; }
         $res=$object->fetch_optionals($object->id,$extralabels);
 		

+ 2 - 1
htdocs/user/clicktodial.php

@@ -83,7 +83,8 @@ llxHeader("","ClickToDial");
 if ($id > 0)
 {
     $object = new User($db);
-    $object->fetch($id);
+    $object->fetch($id, '', '', 1);
+    $object->getrights();
     $object->fetch_clicktodial();
 
 

+ 1 - 1
htdocs/user/document.php

@@ -86,7 +86,7 @@ if (! $sortfield) $sortfield="name";
 $object = new User($db);
 if ($id > 0 || ! empty($ref))
 {
-	$result = $object->fetch($id, $ref);
+	$result = $object->fetch($id, $ref, '', 1);
 	$object->getrights();
 	$entitytouseforuserdir = $object->entity;
 	if (empty($entitytouseforuserdir)) $entitytouseforuserdir=1;

+ 1 - 1
htdocs/user/info.php

@@ -34,7 +34,7 @@ $id = GETPOST('id','int');
 $object = new User($db);
 if ($id > 0 || ! empty($ref))
 {
-	$result = $object->fetch($id, $ref);
+	$result = $object->fetch($id, $ref, '', 1);
 	$object->getrights();
 }
 

+ 1 - 1
htdocs/user/ldap.php

@@ -42,7 +42,7 @@ if ($user->id == $id) $feature2=''; // A user can always read its own card
 $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
 
 $object = new User($db);
-$object->fetch($id);
+$object->fetch($id, '', '', 1);
 $object->getrights();
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array

+ 7 - 7
htdocs/user/note.php

@@ -36,7 +36,7 @@ $langs->load("bills");
 $langs->load("users");
 
 $object = new User($db);
-$object->fetch($id);
+$object->fetch($id, '', '', 1);
 $object->getrights();
 
 // If user is not user read and no permission to read other users, we stop
@@ -53,9 +53,9 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
 $hookmanager->initHooks(array('usercard','globalcard'));
 
 
-/******************************************************************************/
-/*                     Actions                                                */
-/******************************************************************************/
+/*
+ * Actions
+ */
 
 $parameters=array('id'=>$socid);
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
@@ -76,9 +76,9 @@ if (empty($reshook)) {
 }
 
 
-/******************************************************************************/
-/* Affichage fiche                                                            */
-/******************************************************************************/
+/*
+ * View
+ */
 
 llxHeader();
 

+ 2 - 1
htdocs/user/notify/card.php

@@ -122,7 +122,8 @@ if ($action == 'delete')
 $form = new Form($db);
 
 $object = new User($db);
-$result=$object->fetch($id);
+$result=$object->fetch($id, '', '', 1);
+$object->getrights();
 
 $title=$langs->trans("ThirdParty").' - '.$langs->trans("Notification");
 if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notification");

+ 1 - 1
htdocs/user/perms.php

@@ -68,7 +68,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
 if ($user->id <> $id && ! $canreaduser) accessforbidden();
 
 $object = new User($db);
-$object->fetch($id);
+$object->fetch($id, '', '', 1);
 $object->getrights();
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array