Browse Source

Fixing who is online list in order to view bigger images using a crop feature of CSS

Julio Montoya 14 years ago
parent
commit
577e2be787

BIN
main/img/unknown_180_100.jpg


+ 1 - 1
main/inc/lib/display.lib.php

@@ -241,7 +241,7 @@ class Display {
         if (is_array($query_vars)) {
             $table->set_additional_parameters($query_vars);
         }
-        return $table->display_simple_grid($visibility_options, $paging_options['hide_navigation'], $paging_options['per_page'], $sort_data);
+        return $table->display_simple_grid($visibility_options, $paging_options['hide_navigation'], $default_items_per_page, $sort_data);
     }
 
     /**

+ 4 - 5
main/inc/lib/online.inc.php

@@ -157,12 +157,11 @@ function who_is_online($valid, $friends = false) {
 			}
 		}
 	}
-	/*
+	
+	
 	//This query will show all registered users. Only for dev purposes.
-	$query = "SELECT DISTINCT u.user_id as login_user_id, login_date
-	FROM ".$track_online_table ."  e , $table_user u
-	GROUP by u.user_id  ORDER BY picture_uri DESC";
-	*/
+	//$query = "SELECT DISTINCT u.user_id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u GROUP by u.user_id  ORDER BY picture_uri DESC";
+	
 	$result = @Database::query($query);
 	//@todo why we dont believe in db query results?
 	if (count($result)>0) {

+ 13 - 12
main/inc/lib/social.lib.php

@@ -792,28 +792,29 @@ class SocialManager extends UserManager {
 					$url = '#';
 				}
 				$image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
-
-				$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_MEDIUM );
+                
+                if ($image_array['file'] == 'unknown.jpg') {
+                    $friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg'; 
+                } else {
+                    $friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL );    
+                }                
+				
 				// reduce image
 				$name = api_get_person_name($user_info['firstName'], $user_info['lastName']);
 
 				$table_row[] = '<a href="'.$url.'"><img title = "'.$name.'" class="social-home-users-online" alt="'.$name.'" src="'.$friends_profile['file'].'"></a>';
-				$table_row[] = '<a href="'.$url.'" style="font-size:10px;">'.api_get_person_name(cut($user_info['firstName'],15), cut($user_info['lastName'],15)).'</a>';
-/*
-				if (api_get_setting('show_email_addresses') == 'true') {
-					$table_row[] = Display::encrypted_mailto_link($user_info['mail']);
-				}*/
+				$table_row[] = '<a href="'.$url.'" style="font-size:10px;">'.(cut($user_info['firstName'],16)).'<br />'.cut($user_info['lastName'],18).'</a>';
+
 				$user_anonymous = api_get_anonymous_id();
 				$table_data[] = $table_row;
 			}
 			$table_header[] = array(get_lang('UserPicture'), false, 'width="90"');
-			///$table_header[] = array(get_lang('Name'), true);
-			//$table_header[] = array(get_lang('LastName'), true);
-
+			
 			if (api_get_setting('show_email_addresses') == 'true') {
-				$table_header[] = array(get_lang('Email'), true);
+				//$table_header[] = array(get_lang('Email'), true);
 			}
-			Display::display_sortable_table($table_header, $table_data, array(), array('per_page' => 10), $extra_params, array(),'grid');
+			echo Display::return_sortable_grid('online', $table_header, $table_data, array('per_page' => 20));
+			//Display::display_sortable_table($table_header, $table_data, array(), array('per_page' => 10), $extra_params, array(),'grid');
 		}
 	}
 	/**

+ 51 - 49
main/inc/lib/sortabletable.class.php

@@ -103,7 +103,7 @@ class SortableTable extends HTML_Table {
 	 * @param string $default_order_direction The default order direction;
 	 * either the constant 'ASC' or 'DESC'
 	 */
-	public function __construct ($table_name = 'table', $get_total_number_function = null, $get_data_function = null, $default_column = 1, $default_items_per_page = 20, $default_order_direction = 'ASC') {
+	public function __construct($table_name = 'table', $get_total_number_function = null, $get_data_function = null, $default_column = 1, $default_items_per_page = 20, $default_order_direction = 'ASC') {
 		parent :: __construct (array ('class' => 'data_table'));
 		$this->table_name = $table_name;
 		$this->additional_parameters = array ();
@@ -149,18 +149,18 @@ class SortableTable extends HTML_Table {
 		$this->per_page = isset ($_SESSION[$this->param_prefix.'per_page']) ? intval($_SESSION[$this->param_prefix.'per_page']) : $default_items_per_page;
 		$this->per_page = isset ($_GET[$this->param_prefix.'per_page'])		? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page;
 
-		$_SESSION[$this->param_prefix.'per_page'] = $this->per_page;
+		$_SESSION[$this->param_prefix.'per_page']  = $this->per_page;
 		$_SESSION[$this->param_prefix.'direction'] = $this->direction ;
-		$_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr;
-		$_SESSION[$this->param_prefix.'column'] = $this->column;
-		$this->pager = null;
-		$this->default_items_per_page = $default_items_per_page;
-		$this->total_number_of_items = -1;
-		$this->get_total_number_function = $get_total_number_function;
-		$this->get_data_function = $get_data_function;
-		$this->column_filters = array ();
-		$this->form_actions = array ();
-		$this->checkbox_name = null;
+		$_SESSION[$this->param_prefix.'page_nr']   = $this->page_nr;
+		$_SESSION[$this->param_prefix.'column']    = $this->column;
+		$this->pager                               = null;
+		$this->default_items_per_page              = $default_items_per_page;
+		$this->total_number_of_items               = -1;
+		$this->get_total_number_function           = $get_total_number_function;
+		$this->get_data_function                   = $get_data_function;
+		$this->column_filters                      = array ();
+		$this->form_actions                        = array ();
+		$this->checkbox_name                         = null;
 		$this->td_attributes = array ();
 		$this->th_attributes = array ();
 		$this->other_tables = array();
@@ -169,25 +169,25 @@ class SortableTable extends HTML_Table {
 	/**
 	 * Get the Pager object to split the showed data in several pages
 	 */
-	public function get_pager () {
+	public function get_pager() {
 		if (is_null($this->pager)) {
-			$total_number_of_items = $this->get_total_number_of_items();
-			$params['mode'] = 'Sliding';
-			$params['perPage'] = $this->per_page;
-			$params['totalItems'] = $total_number_of_items;
-			$params['urlVar'] = $this->param_prefix.'page_nr';
-			$params['currentPage'] = $this->page_nr;
-			$icon_attributes = array('style' => 'vertical-align: middle;');
-			$params['prevImg'] = Display :: return_icon('action_prev.png', get_lang('PreviousPage'), $icon_attributes);
-			$params['nextImg'] = Display :: return_icon('action_next.png', get_lang('NextPage'), $icon_attributes);
+			$total_number_of_items   = $this->get_total_number_of_items();
+			$params['mode']          = 'Sliding';
+			$params['perPage']       = $this->per_page;
+			$params['totalItems']    = $total_number_of_items;
+			$params['urlVar']        = $this->param_prefix.'page_nr';
+			$params['currentPage']   = $this->page_nr;
+			$icon_attributes         = array('style' => 'vertical-align: middle;');
+			$params['prevImg']       = Display :: return_icon('action_prev.png', get_lang('PreviousPage'), $icon_attributes);
+			$params['nextImg']       = Display :: return_icon('action_next.png', get_lang('NextPage'), $icon_attributes);
 			$params['firstPageText'] = Display :: return_icon('action_first.png', get_lang('FirstPage'), $icon_attributes);
-			$params['lastPageText'] =  Display :: return_icon('action_last.png', get_lang('LastPage'), $icon_attributes);
-			$params['firstPagePre'] = '';
-			$params['lastPagePre'] = '';
+			$params['lastPageText']  =  Display :: return_icon('action_last.png', get_lang('LastPage'), $icon_attributes);
+			$params['firstPagePre']  = '';
+			$params['lastPagePre']   = '';
 			$params['firstPagePost'] = '';
-			$params['lastPagePost'] = '';
+			$params['lastPagePost']  = '';
 			$params['spacesBeforeSeparator'] = '';
-			$params['spacesAfterSeparator'] = '';
+			$params['spacesAfterSeparator']  = '';
 			$query_vars = array_keys($_GET);
 			$query_vars_needed = array ($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page');
 			if (count($this->additional_parameters) > 0) {
@@ -195,7 +195,7 @@ class SortableTable extends HTML_Table {
 			}
 			$query_vars_exclude = array_diff($query_vars, $query_vars_needed);
 			$params['excludeVars'] = $query_vars_exclude;
-			$this->pager = & Pager :: factory($params);
+			$this->pager = & Pager::factory($params);
 		}
 		return $this->pager;
 	}
@@ -282,7 +282,7 @@ class SortableTable extends HTML_Table {
 	 * This function shows the content of a table in a grid.
 	 * Should not be use to edit information (edit/delete rows) only.
 	 * */
-	public function display_grid () {
+	public function display_grid() {
 
 		$empty_table = false;
 		if ($this->get_total_number_of_items() == 0) {
@@ -295,7 +295,7 @@ class SortableTable extends HTML_Table {
 		$html = '';
 		if (!$empty_table) {
 			$form = $this->get_page_select_form();
-			$nav = $this->get_navigation_html();
+			$nav  = $this->get_navigation_html();
 
 			// @todo This style css must be moved to default.css only for dev
 			echo '<style>
@@ -411,7 +411,7 @@ class SortableTable extends HTML_Table {
 	 * @param bool	 	sort data optionally
 	 * @return string	grid html
 	 */
-	public function display_simple_grid($visibility_options, $hide_navigation = true, $per_page = 0, $sort_data = true) {
+	public function display_simple_grid($visibility_options, $hide_navigation = true, $per_page = 20, $sort_data = true) {
 
 		$empty_table = false;
 		if ($this->get_total_number_of_items() == 0) {
@@ -420,23 +420,24 @@ class SortableTable extends HTML_Table {
 			$message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty'));
 			$this->setCellContents(1, 0, $message_empty);
 			$empty_table = true;
-		}
+		}		
 		$html = '';
-
 		if (!$empty_table) {
 			// If we show the pagination
 			if (!$hide_navigation) {
 				$form = '&nbsp;';
-				if ($per_page > 10) {
-					$form = $this->get_page_select_form();
+				if ($this->get_total_number_of_items() > $per_page) {
+    				if ($per_page > 10) {
+    					$form = $this->get_page_select_form();
+    				}
+    				$nav = $this->get_navigation_html();
+    				// This also must be moved
+    				$html = '<div class="sub-header" >';
+    				$html .= '<div class="grid_selectbox">'.$form.'</div>';
+    				$html .= '<div class="grid_title">'.$this->get_table_title().'</div>';
+    				$html .= '<div class="grid_nav">'.$nav.'</div>';
+				    $html .= '</div>';
 				}
-				$nav = $this->get_navigation_html();
-				// This also must be moved
-				$html = '<div class="sub-header" >';
-				$html .= '<div class="grid_selectbox">'.$form.'</div>';
-				$html .= '<div class="grid_title">'.$this->get_table_title().'</div>';
-				$html .= '<div class="grid_nav">'.$nav.'</div>';
-				$html .= '</div>';
 			}
 
 			$html .= '<div class="clear"></div>';
@@ -463,6 +464,7 @@ class SortableTable extends HTML_Table {
 		} else {
 			// The normal way
 			$items = $this->get_clean_html($sort_data); // Getting the items of the table
+			
 		}
 
 
@@ -477,7 +479,7 @@ class SortableTable extends HTML_Table {
 		}
 
 		$html .= '<div class="'.$this->table_name.'_grid_container">';
-		if (is_array($items) && count($items) >0) {
+		if (is_array($items) && count($items) > 0) {
 			foreach ($items as & $row) {
 				$html .= '<div class="'.$this->table_name.'_grid_item">';
 				$i = 0;
@@ -539,13 +541,13 @@ class SortableTable extends HTML_Table {
 	 * @param bool true for sorting table data or false otherwise
 	 * @return array table row items
 	 */
-	public function get_clean_html ($sort = true) {
-		$pager = $this->get_pager();
-		$val = $pager->getOffsetByPageId();
-		$offset = $pager->getOffsetByPageId();
-		$from = $offset[0] - 1; 
+	public function get_clean_html($sort = true) {
+		$pager    = $this->get_pager();
+		$val      = $pager->getOffsetByPageId();
+		$offset   = $pager->getOffsetByPageId();
+		$from     = $offset[0] - 1; 
 		
-		$table_data = $this->get_table_data($from, $sort);
+		$table_data = $this->get_table_data($from, $sort);	
 		
 		$new_table_data = array();
 		if (is_array($table_data)) {

+ 1 - 2
main/social/groups.php

@@ -513,8 +513,7 @@ if ($group_id != 0 ) {
         	   		if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
     	        	    $create_group_item =  '<a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('group_add.png',get_lang('CreateASocialGroup'),array('hspace'=>'6','style'=>'float:left')).get_lang('CreateASocialGroup').'</a>';
     	        	    $my_group_content = $create_group_item. $my_group_content;
-        	        } else {
-        	           
+        	        } else {        	           
     	            	if (api_is_allowed_to_edit(null,true)) {
     	            	    $create_group_item =  '<a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('group_add.png',get_lang('CreateASocialGroup'),array('hspace'=>'6','style'=>'float:left')).get_lang('CreateASocialGroup').'</a>';
     	        	        $my_group_content = $create_group_item. $my_group_content;

+ 28 - 13
whoisonline.php

@@ -117,7 +117,7 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
 	if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
 		$user_list = who_is_online_in_this_course($_user['user_id'], api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
 	} else {
-		$user_list = who_is_online(api_get_setting('time_limit_whosonline'));
+		$user_list = who_is_online(api_get_setting('time_limit_whosonline'));		
 	}
 
 	$total = count($user_list);
@@ -133,8 +133,7 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
 			/*
 			if ($_GET['id'] == '') {
 				echo '<p><a class="refresh" href="javascript:window.location.reload()">'.get_lang('Refresh').'</a></p>';
-			}*/
-			
+			}*/			
 		} else {
 			echo '<div class="actions-title">';
 			echo get_lang('UsersOnLineList');
@@ -145,21 +144,42 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
 	if ($user_list) {
 		if (!isset($_GET['id'])) {
 			if (api_get_setting('allow_social_tool') == 'true') {
-				echo '<div id="social-content-right">';
-				
+				echo '<div id="social-content-right">';				
 				echo '<div class="social-box-container2">';
 				//this include the social menu div
 				if (!api_is_anonymous()) {
 					echo UserManager::get_search_form($_GET['q']);
 				}
 			}			
+			
+            //@todo move these style tag in the main/css
+            echo '
+            <style> 
+            .online_grid_item {
+                float:left;
+                margin:10px;
+                text-align:center;    
+            }
+            .online_grid_element_0 {    
+                width: 100px; 
+                height: 100px; 
+                overflow: hidden; 
+                
+            }
+            /* input values to crop the image: top, right, bottom, left */
+            .online_grid_element_0 img{
+                 width: 200px;
+                 margin: -10px 0 0 -50px;
+                  /* height: 150px; */ 
+            }
+            </style>';
+            
 			SocialManager::display_user_list($user_list);
 			
 			if (api_get_setting('allow_social_tool') == 'true') {
 				echo '</div>';
 				echo '</div>';
-			}
-			
+			}			
 		} else {
 			//individual user information - also displays header info
 			SocialManager::display_individual_user(Security::remove_XSS($_GET['id']));
@@ -170,16 +190,11 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
 		echo get_lang('UsersOnLineList');
 		echo '</div>';
 	}
-
-
 } else {
 	Display::display_header(get_lang('UsersOnLineList'));
 	Display::display_error_message(get_lang('AccessNotAllowed'));
 }
-
 $referer = empty($_GET['referer']) ? 'index.php' : api_htmlentities(strip_tags($_GET['referer']), ENT_QUOTES);
 
-/*
-		FOOTER
-*/
+/*	FOOTER  */
 Display::display_footer();