Index: www/controllers/userwidget.php
===================================================================
--- www/controllers/userwidget.php	(revision 0)
+++ www/controllers/userwidget.php	(revision 0)
@@ -0,0 +1,63 @@
+<?php 
+
+require_once(IA_ROOT_DIR."common/db/user.php");
+
+//Displays an image with user statistics
+    function controller_userwidget($user_name) {
+//get data
+        $dbuser = user_get_by_username($user_name);
+        $task_data_succes = user_submitted_tasks($dbuser['id'],1,0);
+        $task_data_failed = user_submitted_tasks($dbuser['id'],0,1);
+//get Nume
+        $nume = $dbuser['full_name'];
+//get rating
+        $rating = $dbuser['rating_cache'];
+        $rating = (int) $rating;
+        $afis = "Rating: " . $rating;
+//get probleme rezolvate
+        $n1 = sizeof($task_data_succes);
+        $pbr = "Probleme rezolvate: " . $n1;
+//get probleme incercate
+        $n2 = sizeof($task_data_failed);
+        $pbi = "Probleme incercate: " . $n2;
+//calcul succes
+        $suc = "Succes: ";
+        if($n1+$n2!=0) {
+	    $rez = $n1/($n1+$n2)*100;
+	    $rez = round($rez,2);
+	    $rez = sprintf("%01.2f",$rez);
+	    $suc .= $rez;
+	    $suc .= "%";
+        } else {
+            $suc .= "-";
+        }
+//imaginea
+        $my_img = imagecreate(200, 80);
+        $my_img = imagecreatefromjpeg (IA_ROOT_DIR . "www/static/images/macro_userwidget/widg.jpg");
+        $background = imagecolorallocate( $my_img,154, 205,50 );
+        $text_colour = imagecolorallocate($my_img, 255, 255, 255);
+        $numr = (int)$rating;
+        if($numr>=600) {
+            $line_colour = imagecolorallocate($my_img, 178, 34, 34);
+        }
+        else if($numr>=520) {
+            $line_colour = imagecolorallocate($my_img, 255, 255, 0);
+        }
+        else {
+            $line_colour = imagecolorallocate($my_img, 50, 205, 50);
+        }
+        imagestring($my_img, 3, 15, 42, $nume, $text_colour);
+        imagestring($my_img, 3, 115, 5, $afis, $text_colour);
+        imagestring($my_img, 3, 95, 19, $suc, $text_colour);
+        imagestring($my_img, 3, 15, 54, $pbr, $text_colour);
+        imagestring($my_img, 3, 15, 65, $pbi, $text_colour);
+        imagesetthickness($my_img, 5);
+        imageline( $my_img, 0, 38, 200, 38, $line_colour);
+        header("Content-type: image/png");
+        imagepng($my_img);
+        imagecolordeallocate($line_color);
+        imagecolordeallocate($text_color);
+        imagecolordeallocate($background);
+        imagedestroy($my_img);
+    }
+?>
Index: www/index.php
===================================================================
--- www/index.php	(revision 1146)
+++ www/index.php	(working copy)
@@ -49,7 +49,7 @@
                                'login', 'logout', 'json', 'job_detail',
                                'monitor', 'projector', 'submit', 'userinfo',
                                'plot', 'search',
-                               'unsubscribe', 'resetpass', 'reeval'
+                               'unsubscribe', 'resetpass', 'reeval', 'userwidget'
 ));
 
 //
Index: www/macros/macro_userwidget.php
===================================================================
--- www/macros/macro_userwidget.php	(revision 0)
+++ www/macros/macro_userwidget.php	(revision 0)
@@ -0,0 +1,33 @@
+<?php
+
+require_once(IA_ROOT_DIR . 'www/format/format.php');
+require_once(IA_ROOT_DIR . 'common/db/user.php');
+
+// Display a widget to an user.
+//
+//
+// Args:
+//      user(required): user id.
+//
+function macro_userwidget($args) {
+    $user = getattr($args, 'user', '');
+    if ($user === '') {
+        return macro_error("User parameter required.");
+    }
+
+    $dbuser = user_get_by_username($user);
+    if (!$dbuser) {
+        return macro_error("User inexistent.");
+    }
+    $ret = '<img src="';
+    if(IA_DEVELOPMENT_MODE) {
+        $ret .= url_absolute("/infoarena2-dev/userwidget/" . $user);    
+    }    
+    else {
+        $ret .= url_absolute("/userwidget/" . $user);
+    }
+    $ret .= '" />';
+    return $ret;
+}
+
+?>
Index: www/static/images/macro_userwidget/widg.jpg
===================================================================

Property changes on: www/static/images/macro_userwidget/widg.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: www/url.php
===================================================================
--- www/url.php	(revision 1146)
+++ www/url.php	(working copy)
@@ -387,6 +387,10 @@
     return IA_SMF_URL;
 }
 
+function url_userwidget($user_id) {
+    return url_complex("userwidget/".$user_id, array());
+}
+
 // Newsletter
 
 function url_newsletter($page_name, $rev = null) {
