Index: www/controllers/userwidget.php
===================================================================
--- www/controllers/userwidget.php	(revision 0)
+++ www/controllers/userwidget.php	(revision 0)
@@ -0,0 +1,44 @@
+<?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'],true,false);
+    $task_data_failed = user_submitted_tasks($dbuser['id'],false,true);
+    // get name
+    $name = $dbuser['full_name'];
+    // get rating
+    $rating = $dbuser['rating_cache'];
+    $rating =  ($rating / 3.000971648);
+    $rating = sprintf("%01.0f", $rating);
+    $afis = "Rating: " . $rating;
+    // get solved tasks
+    $n1 = sizeof($task_data_succes);
+    $pbr = "Probleme rezolvate: " . $n1;
+    // get failed tasks
+    $n2 = sizeof($task_data_failed);
+    $pbi = "Probleme incercate: " . $n2;
+    // calculate the succes
+    $suc = "Succes: ";
+    if ($n1 + $n2 != 0) {
+        $rez = $n1 / ($n1 + $n2) * 100;
+        round($rez, 2);
+        $rez = sprintf("%01.2f", $rez);
+        $suc .= $rez;
+        $suc .= "%";
+    } else {
+        $suc .= "-";
+    }
+    $data=array();
+    $data['name']=$name;
+    $data['afis']=$afis;
+    $data['rating']=$rating;
+    $data['pbr']=$pbr;
+    $data['pbi']=$pbi;
+    $data['succes']=$suc;
+    execute_view_die('views/userwidget.php',$data);
+}
+?>
Index: www/index.php
===================================================================
--- www/index.php	(revision 1148)
+++ 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/static/images/widget.jpg
===================================================================

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

Index: www/url.php
===================================================================
--- www/url.php	(revision 1148)
+++ 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) {
Index: www/views/userwidget.php
===================================================================
--- www/views/userwidget.php	(revision 0)
+++ www/views/userwidget.php	(revision 0)
@@ -0,0 +1,31 @@
+<?php
+    // the image
+    
+    $my_img = imagecreate(200, 80);
+    $my_img = imagecreatefromjpeg (IA_ROOT_DIR . "www/static/images/widget.jpg");
+    $background = imagecolorallocate($my_img, 154, 205, 50);
+    $text_colour = imagecolorallocate($my_img, 255, 255, 255);
+    $numr = (int)$view['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, $view['name'], $text_colour);
+    imagestring($my_img, 3, 115, 5, $view['afis'], $text_colour);
+    imagestring($my_img, 3, 95, 19, $view['succes'], $text_colour);
+    imagestring($my_img, 3, 15, 54, $view['pbr'], $text_colour);
+    imagestring($my_img, 3, 15, 65, $view['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);
+ ?>
