Browse Source

Merge remote-tracking branch 'upstream/1.9.x' into julio19x

Julio Montoya 12 years ago
parent
commit
b5efd63543

+ 14 - 1
main/css/base.css

@@ -3450,7 +3450,20 @@ a:active{
     display: inline-block;
     margin-right: 4px;
 }
-
+.send_msg_in_text {
+    background: url("send_msg.png") no-repeat scroll right center transparent;
+    height: 16px;
+    width: 17px;
+    display: inline-block;
+    margin-right: 4px;
+}
+.send_inv_in_text {
+    background: url("send_inv.png") no-repeat scroll right center transparent;
+    height: 16px;
+    width: 17px;
+    display: inline-block;
+    margin-right: 4px;
+}
 .teacher_online {
     background: url("teacher.png") no-repeat scroll right center transparent;
     height: 16px;

BIN
main/css/send_inv.png


BIN
main/css/send_msg.png


+ 4 - 3
main/dropbox/dropbox_class.inc.php

@@ -252,7 +252,7 @@ class Dropbox_SentWork extends Dropbox_Work
 	 * @param unknown_type $recipient_ids
 	 */
 	function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) {
-		global $dropbox_cnf;
+			global $dropbox_cnf;
 		// Call constructor of Dropbox_Work object
 		$this->Dropbox_Work($uploader_id, $title, $description, $author, $filename, $filesize);
 		
@@ -284,6 +284,7 @@ class Dropbox_SentWork extends Dropbox_Work
         $table_person = $dropbox_cnf['tbl_person'];
         $session_id = api_get_session_id();
         $uploader_id = $this->uploader_id;
+        $user  = api_get_user_id();
 		// Insert data in dropbox_post and dropbox_person table for each recipient
 		foreach ($this->recipients as $rec) {
             $file_id = (int)$this->id;
@@ -296,7 +297,7 @@ class Dropbox_SentWork extends Dropbox_Work
             /**
              * Poster is already added when work is created - not so good to split logic 
              */
-            //if ($user_id != $user_id) {
+            if ($user_id != $user) {
                 // Insert entries into person table
                 $sql = "INSERT INTO $table_person (c_id, file_id, user_id)
                         VALUES ($course_id, $file_id, $user_id)";
@@ -305,7 +306,7 @@ class Dropbox_SentWork extends Dropbox_Work
                 if (!$justSubmit) {
                     $result = Database::query($sql);	// If work already exists no error is generated
                 }
-            //}
+            }
 
 			// Update item_property table for each recipient
 			global $_course, $dropbox_cnf;

+ 6 - 3
main/exercice/exercise.class.php

@@ -3455,11 +3455,14 @@ class Exercise {
         if (!empty($user_data)) {
             $array[] = array('title' => get_lang("User"), 'content' => $user_data);
         }
-
+        // Description can be very long and is generally meant to explain
+        //   rules *before* the exam. Leaving here to make display easier if
+        //   necessary
+        /*
         if (!empty($this->description)) {
             $array[] = array('title' => get_lang("Description"), 'content' => $this->description);
         }
-
+        */
         if (!empty($start_date)) {
             $array[] = array('title' => get_lang("StartDate"), 'content' => $start_date);
         }
@@ -3900,4 +3903,4 @@ class Exercise {
         }
         return $list;
     }
-}
+}

+ 10 - 2
main/group/group_category.php

@@ -65,6 +65,14 @@ if (api_get_setting('allow_group_categories') == 'true') {
 	$nameTools = get_lang('PropModify');
 }
 
+$htmlHeadXtra[] = '<script>
+$(document).ready( function() {
+    $("#max_member").on("focus", function() {
+        $("#max_member_selected").attr("checked", true);
+    });
+});
+ </script>';
+  
 $interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
 
 $course_id = api_get_course_int_id();
@@ -123,8 +131,8 @@ $form->addElement('html', '</div>');
 // Members per group
 $form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT);
 $group = array ();
-$group[] = $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1);
-$group[] = $form->createElement('text', 'max_member', null, array ('size' => 2));
+$group[] = $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1, array('id' => 'max_member_selected'));
+$group[] = $form->createElement('text', 'max_member', null, array ('size' => 2, 'id' => 'max_member'));
 $group[] = $form->createElement('static', null, null, get_lang('GroupPlacesThis'));
 $form->addGroup($group, 'max_member_group', null, '', false);
 $form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members');

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

@@ -7,7 +7,7 @@
 /**
  * Init
  */
-require_once (api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php');
+require_once dirname(__FILE__).'/xajax/xajax.inc.php';
 //require_once (api_get_path(SYS_CODE_PATH).'admin/add_courses_to_session.php');
 
 /**

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

@@ -7,7 +7,7 @@
 /**
  * Init
  */
-require_once (api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php');
+require_once dirname(__FILE__).'/xajax/xajax.inc.php';
 /**
  * AddManySessionToCategoryFunctions class
  */

+ 41 - 47
main/inc/lib/login.lib.php

@@ -29,7 +29,6 @@ class Login
     public static function get_user_account_list($user, $reset = false, $by_username = false)
     {
         global $_configuration;
-        //$portal_url = $_configuration['root_web'];
         $portal_url = api_get_path(WEB_PATH);
 
         if ($_configuration['multiple_access_urls']) {
@@ -112,13 +111,13 @@ class Login
         if (api_mail_html('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
             return get_lang('your_password_has_been_reset');
         } else {
-            $admin_email = Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));            
-            return sprintf(get_lang('ThisPlatformWasUnableToSendTheEmailPleaseContactXForMoreInformation'), $admin_email);            
+            $admin_email = Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));
+            return sprintf(get_lang('ThisPlatformWasUnableToSendTheEmailPleaseContactXForMoreInformation'), $admin_email);
         }
     }
 
     /**
-     * Handle encrypted password, send an email to a user with his password 
+     * Handle encrypted password, send an email to a user with his password
      *
      * @param int	user id
      * @param bool	$by_username
@@ -126,7 +125,6 @@ class Login
      * @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
      */
     public static function handle_encrypted_password($user, $by_username = false) {
-        global $_configuration;
         $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT
 
         if ($by_username) { // Show only for lost password
@@ -136,8 +134,6 @@ class Login
             $user_account_list = self::get_user_account_list($user, true); // BODY
             $email_to = $user[0]['email'];
         }
-
-        $secret_word = self::get_secret_word($email_to);
         $email_body = get_lang('DearUser') . " :\n" . get_lang('password_request') . "\n";
         $email_body .= $user_account_list . "\n-----------------------------------------------\n\n";
         $email_body .= get_lang('PasswordEncryptedForSecurity');
@@ -148,16 +144,15 @@ class Login
         $email_admin = api_get_setting('emailAdministrator');
 
         if (@api_mail_html('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
-
             if (CustomPages::enabled()) {
                 return get_lang('YourPasswordHasBeenEmailed');
             } else {
                 Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
             }
         } else {
-            $admin_email = Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));            
+            $admin_email = Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));
             $message = sprintf(get_lang('ThisPlatformWasUnableToSendTheEmailPleaseContactXForMoreInformation'), $admin_email);
-            
+
             if (CustomPages::enabled()) {
                 return $message;
             } else {
@@ -172,8 +167,7 @@ class Login
      */
     public static function get_secret_word($add)
     {
-        global $_configuration;
-        return $secret_word = md5($_configuration['security_key'] . $add);
+        return $secret_word = sha1($add);
     }
 
     /**
@@ -194,12 +188,12 @@ class Login
             return get_lang('CouldNotResetPassword');
         }
 
-        if (self::get_secret_word($user['email']) == $secret) { // OK, secret word is good. Now change password and mail it.
+        if (self::get_secret_word($user['email']) == $secret) {
+            // OK, secret word is good. Now change password and mail it.
             $user['password'] = api_generate_password();
-            $crypted = $user['password'];
-            $crypted = api_get_encrypted_password($crypted);
+            $crypted = api_get_encrypted_password($user['password']);
             $sql = "UPDATE " . $tbl_user . " SET password='$crypted' WHERE user_id = $id";
-            $result = Database::query($sql);
+            Database::query($sql);
             return self::send_password_to_user($user, $by_username);
         } else {
             return get_lang('NotAllowed');
@@ -210,7 +204,7 @@ class Login
      *
      * @global bool   $is_platformAdmin
      * @global bool   $is_allowedCreateCourse
-     * @global object $_user 
+     * @global object $_user
      */
     public static function init_user($user_id, $reset)
     {
@@ -267,8 +261,8 @@ class Login
                     Session::write('is_platformAdmin', $is_platformAdmin);
                     Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
 
-//                  
-//                    
+//
+//
 //                    // If request_uri is setted we have to go further to have course permissions
 //                    if (empty($_SESSION['request_uri']) || !isset($_SESSION['request_uri'])) {
 //                        if (isset($_SESSION['noredirection'])) {
@@ -311,9 +305,9 @@ class Login
      * @global type $is_courseMember
      * @global type $is_sessionAdmin
      * @global type $is_allowed_in_course
-     * 
+     *
      * @param type $course_id
-     * @param type $reset 
+     * @param type $reset
      */
     static function init_course($course_id, $reset)
     {
@@ -335,7 +329,7 @@ class Login
         global $is_allowed_in_course;
 
         if ($reset) {
-            // Course session data refresh requested or empty data        
+            // Course session data refresh requested or empty data
             if ($course_id) {
                 $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
                 $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
@@ -383,7 +377,7 @@ class Login
                     Session::write('_real_cid', $_real_cid);
 
                     // if a session id has been given in url, we store the session
-                    
+
                     // Database Table Definitions
                     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
                     $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -425,14 +419,14 @@ class Login
                         }
                     }
                 }
-                //Deleting session info 
+                //Deleting session info
                 if (api_get_session_id()) {
                     Session::erase('id_session');
                     Session::erase('session_name');
                 }
             }
         } else {
-            // Continue with the previous values       
+            // Continue with the previous values
             if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values...
                 $_cid = -1;        //set default values that will be caracteristic of being unset
                 $_course = -1;
@@ -441,7 +435,7 @@ class Login
                 $_course = $_SESSION['_course'];
 
                 // these lines are usefull for tracking. Indeed we can have lost the id_session and not the cid.
-                // Moreover, if we want to track a course with another session it can be usefull        
+                // Moreover, if we want to track a course with another session it can be usefull
                 if (!empty($_GET['id_session'])) {
                     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
                     $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"';
@@ -464,9 +458,9 @@ class Login
 
                         /*
                          * When $_configuration['session_lifetime'] is too big 100 hours (in order to let users take exercises with no problems)
-                         * the function Tracking::get_time_spent_on_the_course() returns big values (200h) due the condition: 
+                         * the function Tracking::get_time_spent_on_the_course() returns big values (200h) due the condition:
                          * login_course_date > now() - INTERVAL $session_lifetime SECOND
-                         * 
+                         *
                          */
                         /*
                           if (isset($_configuration['session_lifetime'])) {
@@ -483,10 +477,10 @@ class Login
                         if (isset($_user['user_id']) && !empty($_user['user_id'])) {
 
                             //We select the last record for the current course in the course tracking table
-                            //But only if the login date is < than now + max_life_time            
+                            //But only if the login date is < than now + max_life_time
                             $sql = "SELECT course_access_id FROM $course_tracking_table
                             WHERE   user_id     = " . intval($_user ['user_id']) . " AND
-                                    course_code = '$course_code' AND 
+                                    course_code = '$course_code' AND
                                     session_id  = " . api_get_session_id() . " AND
                                     login_course_date > now() - INTERVAL $session_lifetime SECOND
                         ORDER BY login_course_date DESC LIMIT 0,1";
@@ -495,7 +489,7 @@ class Login
                             if (Database::num_rows($result) > 0) {
                                 $i_course_access_id = Database::result($result, 0, 0);
                                 //We update the course tracking table
-                                $sql = "UPDATE $course_tracking_table  SET logout_course_date = '$time', counter = counter+1  
+                                $sql = "UPDATE $course_tracking_table  SET logout_course_date = '$time', counter = counter+1
                                 WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id();
                                 //error_log($sql);
                                 Database::query($sql);
@@ -526,7 +520,7 @@ class Login
 
             if (isset($user_id) && $user_id && isset($_cid) && $_cid) {
 
-                //Check if user is subscribed in a course        
+                //Check if user is subscribed in a course
                 $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
                 $sql = "SELECT * FROM $course_user_table
                    WHERE user_id  = '" . $user_id . "' AND relation_type <> " . COURSE_RELATION_TYPE_RRHH . "
@@ -556,7 +550,7 @@ class Login
                 //We are in a session course? Check session permissions
                 if (!empty($session_id)) {
 
-                    //I'm not the teacher of the course 
+                    //I'm not the teacher of the course
                     if ($is_courseAdmin == false) {
                         // this user has no status related to this course
                         // The user is subscribed in a session? The user is a Session coach a Session admin ?
@@ -565,19 +559,19 @@ class Login
                         $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
                         $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
-                        //Session coach, session admin, course coach admin 
+                        //Session coach, session admin, course coach admin
                         $sql = "SELECT session.id_coach, session_admin_id, session_rcru.id_user
                 		FROM $tbl_session session, $tbl_session_course_user session_rcru
-					    WHERE  session_rcru.id_session  = session.id AND 
-					           session_rcru.course_code = '$_cid' AND 
-					           session_rcru.id_user     = '$user_id' AND 
+					    WHERE  session_rcru.id_session  = session.id AND
+					           session_rcru.course_code = '$_cid' AND
+					           session_rcru.id_user     = '$user_id' AND
                                session_rcru.id_session  = $session_id AND
 					           session_rcru.status      = 2";
 
                         $result = Database::query($sql);
                         $row = Database::store_result($result);
 
-                        //I'm a session admin?                
+                        //I'm a session admin?
                         if (isset($row) && isset($row[0]) && $row[0]['session_admin_id'] == $user_id) {
                             $_courseUser['role'] = 'Professor';
                             $is_courseMember = false;
@@ -588,9 +582,9 @@ class Login
                         } else {
                             //Im a coach or a student?
                             $sql = "SELECT id_user, status FROM " . $tbl_session_course_user . "
-                            WHERE   course_code = '$_cid' AND 
+                            WHERE   course_code = '$_cid' AND
                                     id_user     = '" . $user_id . "' AND
-                                    id_session  = '" . $session_id . "'                                    
+                                    id_session  = '" . $session_id . "'
                             LIMIT 1";
                             $result = Database::query($sql);
 
@@ -728,9 +722,9 @@ class Login
      * @global int $_cid
      * @global array $_course
      * @global int $_gid
-     * 
+     *
      * @param int $group_id
-     * @param bool $reset 
+     * @param bool $reset
      */
     static function init_group($group_id, $reset)
     {
@@ -785,14 +779,14 @@ class Login
             }
         }
     }
-    
+
     /**
      * Returns true if user exists in the platform when asking the password
-     * 
+     *
      * @param string $username (email or username)
      * @return boolean
      */
-    function get_user_accounts_by_username($username) {        
+    function get_user_accounts_by_username($username) {
         if (strpos($username,'@')){
             $username = api_strtolower($username);
             $email = true;
@@ -809,8 +803,8 @@ class Login
         }
 
 		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
-		$query = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email, 
-                         status AS status, official_code, phone, picture_uri, creator_id 
+		$query = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email,
+                         status AS status, official_code, phone, picture_uri, creator_id
 				 FROM  $tbl_user
 				 WHERE ( $condition AND active = 1) ";
 		$result 	= Database::query($query);

+ 18 - 6
main/inc/lib/message.lib.php

@@ -523,13 +523,14 @@ class MessageManager
         $result = Database::query($query);
     }
     
-    public static function update_message_status($user_id, $message_id)
+    public static function update_message_status($user_id, $message_id,$type)
     {
+        $type = intval($type);
         if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) {
             return false;
         }
         $table_message = Database::get_main_table(TABLE_MESSAGE);
-        $query = "UPDATE $table_message SET msg_status = 1 WHERE user_receiver_id=".intval($user_id)." AND id='".intval($message_id)."'";
+        $query = "UPDATE $table_message SET msg_status = '$type' WHERE user_receiver_id=".intval($user_id)." AND id='".intval($message_id)."'";
         $result = Database::query($query);
     }
 
@@ -1293,18 +1294,29 @@ class MessageManager
     static function inbox_display()
     {
         $success = get_lang('SelectedMessagesDeleted');
+        $success_read = get_lang('SelectedMessagesRead');
+        $success_unread = get_lang('SelectedMessagesUnRead');
         $html = '';
 
         if (isset($_REQUEST['action'])) {
             switch ($_REQUEST['action']) {
-                 case 'mark_as_selected' :
+                 case 'mark_as_unread' :
                     $number_of_selected_messages = count($_POST['id']);
                     if (is_array($_POST['id'])) {
                         foreach ($_POST['id'] as $index => $message_id) {
-                            MessageManager::update_message_status(api_get_user_id(), $message_id);
+                            MessageManager::update_message_status(api_get_user_id(), $message_id, MESSAGE_STATUS_UNREAD);
                         }
                     }
-                    $html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
+                    $html .= Display::return_message(api_xml_http_response_encode($success_unread), 'normal', false);
+                    break;
+                case 'mark_as_read' :
+                    $number_of_selected_messages = count($_POST['id']);
+                    if (is_array($_POST['id'])) {
+                        foreach ($_POST['id'] as $index => $message_id) {
+                            MessageManager::update_message_status(api_get_user_id(), $message_id, MESSAGE_STATUS_NEW);
+                        }
+                    }
+                    $html .= Display::return_message(api_xml_http_response_encode($success_read), 'normal', false);
                     break;
                 case 'delete' :
                     $number_of_selected_messages = count($_POST['id']);
@@ -1331,7 +1343,7 @@ class MessageManager
             $parameters['f'] = 'social';
             $table->set_additional_parameters($parameters);
         }
-        $table->set_form_actions(array('delete' => get_lang('DeleteSelectedMessages'),'mark_as_selected' => get_lang('MailMarkSelectedAsRead')));
+        $table->set_form_actions(array('delete' => get_lang('DeleteSelectedMessages'),'mark_as_unread' => get_lang('MailMarkSelectedAsUnRead'),'mark_as_read' => get_lang('MailMarkSelectedAsRead')));
         $html .= $table->return_table();
         return $html;
     }

+ 4 - 1
main/inc/lib/usermanager.lib.php

@@ -397,8 +397,10 @@ class UserManager
     {
         $result = false;
         $ids = is_array($ids) ? $ids : func_get_args();
+        if (!is_array($ids) or count($ids) == 0) { return false; }
         $ids = array_map('intval', $ids);
         foreach ($ids as $id) {
+            if (empty($id) or $id < 1) { continue; }
             $deleted = self::delete_user($id);
             $result = $deleted || $result;
         }
@@ -495,13 +497,14 @@ class UserManager
      * @param int The department of HR in which the user is registered (optional, defaults to 0)
      * @param    array    A series of additional fields to add to this user as extra fields (optional, defaults to null)
      * @return boolean true if the user information was updated
-     * @assert (false) === false
+     * @assert (false, false, false, false, false, false, false, false, false, false, false, false, false) === false
      */
     public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '', $send_email = false, $reset_password = 0)
     {
         global $_configuration;
         $original_password = $password;
 
+        if (empty($user_id)) { return false; }
         $user_info = api_get_user_info($user_id, false, true);
 
         if ($reset_password == 0) {

+ 131 - 6
main/social/search.php

@@ -12,9 +12,125 @@ $language_file = array('registration','admin','userInfo');
 $cidReset = true;
 require_once '../inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
-
+require_once api_get_path(LIBRARY_PATH).'magpierss/rss_fetch.inc';
+$ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
 api_block_anonymous_users();
 
+$htmlHeadXtra[] = '<script>
+
+function checkLength( o, n, min, max ) {
+    if ( o.val().length > max || o.val().length < min ) {
+        o.addClass( "ui-state-error" );
+        //updateTips( "Length of " + n + " must be between " + min + " and " + max + "." );
+        return false;
+    } else {
+        return true;
+    }
+}
+
+function send_message_to_user(user_id) {
+    var subject = $( "#subject_id" );
+    var content = $( "#content_id" );
+
+    $("#send_message_form").show();
+    $("#send_message_div").dialog({
+        modal:true,
+        height:350,
+        buttons: {
+            "'.  addslashes(get_lang('Sent')).'": function() {
+                var bValid = true;
+                bValid = bValid && checkLength( subject, "subject", 1, 255 );
+                bValid = bValid && checkLength( content, "content", 1, 255 );
+
+                if ( bValid ) {
+                    var url = "'.$ajax_url.'?a=send_message&user_id="+user_id;
+                    var params = $("#send_message_form").serialize();
+                    $.ajax({
+                        url: url+"&"+params,
+                        success:function(data) {
+                            $("#message_ajax_reponse").attr("class", "");
+                            $("#message_ajax_reponse").html(data);
+                            $("#message_ajax_reponse").show();
+                            $("#send_message_div").dialog({ buttons:{}});
+                            $("#send_message_form").hide();
+                            $("#send_message_div").dialog("close");
+
+                            $("#subject_id").val("");
+                            $("#content_id").val("");
+                        }
+                    });
+                }
+            },
+        },
+        close: function() {
+        }
+    });
+    $("#send_message_div").dialog("open");
+    //prevent the browser to follow the link
+}
+
+function send_invitation_to_user(user_id) {
+    var content = $( "#content_invitation_id" );
+    $("#send_invitation_form").show();
+    $("#send_invitation_div").dialog({
+        modal:true,
+        buttons: {
+            "'.  addslashes(get_lang('SendInvitation')).'": function() {
+                var bValid = true;
+                bValid = bValid && checkLength( content, "content", 1, 255 );
+                if (bValid) {
+                    var url = "'.$ajax_url.'?a=send_invitation&user_id="+user_id;
+                    var params = $("#send_invitation_form").serialize();
+                    $.ajax({
+                        url: url+"&"+params,
+                        success:function(data) {
+                            $("#message_ajax_reponse").attr("class", "");
+                            $("#message_ajax_reponse").html(data);
+                            $("#message_ajax_reponse").show();
+
+                            $("#send_invitation_div").dialog({ buttons:{}});
+
+                            $("#send_invitation_form").hide();
+                            $("#send_invitation_div").dialog("close");
+                            $("#content_invitation_id").val("");
+                        }
+                    });
+                }
+            },
+        },
+        close: function() {
+        }
+    });
+    $("#send_invitation_div").dialog("open");
+    //prevent the browser to follow the link
+}
+
+$(document).ready(function (){
+    $("input#id_btn_send_invitation").bind("click", function(){
+        if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
+            $("#form_register_friend").submit();
+        }
+    });
+
+    $("#send_message_div").dialog({
+        autoOpen: false,
+        modal    : false,
+        width    : 550,
+        height    : 300
+       });
+
+    $("#send_invitation_div").dialog({
+        autoOpen: false,
+        modal    : false,
+        width    : 550,
+        height    : 300
+       });
+
+});
+
+
+</script>';
+
 if (api_get_setting('allow_social_tool') !='true') {
     api_not_allowed();
 }
@@ -41,14 +157,22 @@ if ($query !='') {
     }
 
     $results = '<div id="online_grid_container"><div class="span9">';
-
-    if (is_array($users) && count($users)> 0) {
+    //$list_friends = SocialManager::get_friends(api_get_user_id());
+    //$count = count($list_friends);
+    //$list_friends = $list_friends[0];
+     if (is_array($users) && count($users)> 0) {
         $results .=  Display::page_subheader(get_lang('Users'));
         $results .= '<ul class="thumbnails">';
         foreach($users as $user) {
+            $send_inv = '';
+            $relation_type =  intval(SocialManager::get_relation_between_contacts(api_get_user_id(), $user['user_id'] ));
             $user_info = api_get_user_info($user['user_id'], true);
             $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
-
+            //Show send invitation icon if they are not friends yet
+            if ($relation_type != 3 && $relation_type != 4 && $user['user_id'] != api_get_user_id()) {
+                $send_inv = '<a href="javascript:void(0);" onclick="javascript:send_invitation_to_user(\''.$user['user_id'].'\');"/>'.Display::span('', array('class' => 'send_inv_in_text')).'</a>';
+            }
+            $send_msg = '<a href="javascript:void(0);" onclick="javascript:send_message_to_user(\''.$user['user_id'].'\');"/>'.Display::span('', array('class' => 'send_msg_in_text')).'</a>';
             if (empty($user['picture_uri'])) {
                 $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
                 $img = '<img src="'.$picture['file'].'">';
@@ -62,7 +186,7 @@ if ($query !='') {
                 $status_icon = Display::span('', array('class' => 'offline_user_in_text'));
             }
             $user['tag'] = isset($user['tag']) ? $user['tag'] : null;
-            $user_info['complete_name'] = Display::url($status_icon.$user_info['complete_name'], $url).'<br />'.$user['tag'];
+            $user_info['complete_name'] = Display::url($status_icon.$user_info['complete_name'], $url).'<br />'.$user['tag'].$send_inv.$send_msg;
             $results .= '<li class="span3"><div class="thumbnail">'.$img.'<div class="caption">'.$user_info['complete_name'].$user['tag'].'</div</div></li>';
         }
         $results .='</ul></div></div>';
@@ -153,7 +277,8 @@ if ($query !='') {
     $visibility = array(true,true,true,true,true);
     $social_right_content .= Display::return_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false, $visibility);
 }
-
+$social_right_content .= MessageManager::generate_message_form('send_message');
+$social_right_content .= MessageManager::generate_invitation_form('send_invitation');
 
 $tpl = new Template($tool_name);
 $tpl->assign('social_left_content', $social_left_content);

+ 10 - 2
main/survey/survey.lib.php

@@ -1647,7 +1647,11 @@ class ch_yesno extends survey_question {
 
 		if (is_array($form_content['options'])) { // Check if data is correct
 			foreach ($form_content['options'] as $key => & $value) {
-                $this->html .= '<label class="radio">';
+                if ($form_content['display'] == 'vertical') {
+                    $this->html .= '<label class="radio">';
+                } else {
+                    $this->html .= '<label class="radio inline">';
+                }
                 $value_to_show = $value;
 
                 if (substr_count($value, '<p>') == 1) {
@@ -1927,7 +1931,11 @@ class ch_multipleresponse extends survey_question {
 	 */
 	function render_question($form_content, $answers = array()) {
 		foreach ($form_content['options'] as $key => & $value) {
-			$this->html .= '<label class="checkbox"><input name="question'.$form_content['question_id'].'[]" type="checkbox" value="'.$key.'"';
+			if ($form_content['display'] == 'vertical') {
+			    $this->html .= '<label class="checkbox"><input name="question'.$form_content['question_id'].'[]" type="checkbox" value="'.$key.'"';
+            } else {
+                $this->html .= '<label class="checkbox inline"><input name="question'.$form_content['question_id'].'[]" type="checkbox" value="'.$key.'"';
+            }
 			if (is_array($answers)) {
 				if (in_array($key, $answers)) {
 					$this->html .= 'checked="checked"';

+ 1 - 1
tests/build.xml

@@ -99,7 +99,7 @@
 
  <target name="phpdoc" description="Generate API documentation">
    <exec executable="phpdoc">
-     <arg line="-d ${basedir}/../ -t ${basedir}/logs/docs -ti ChamiloLMS -i archive/,home/,entity/,symfony/,phpdocx/,phpqrcode/,mpdf/,transliteration/*,phpmailer/*,htmlpurifier/,fckeditor/*,formvalidator/*,upload/users/,lang/,courses/,.htaccess -ct covers,assert" />
+     <arg line="-d ${basedir}/../ -t ${basedir}/logs/docs -ti ChamiloLMS -i archive/,home/,entity/,symfony/,phpdocx/,phpqrcode/,mpdf/,transliteration/*,phpmailer/*,htmlpurifier/,fckeditor/*,formvalidator/*,upload/users/,lang/,courses/,main/inc/lib/internationalization_database/,.htaccess -ct covers,assert" />
    </exec>
  </target>
  <target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">

+ 0 - 47
tests/phpunit/classes/AccessurleditsessionstourlTest.lib.php

@@ -1,47 +0,0 @@
-<?php
-/**
- * Generated by PHPUnit_SkeletonGenerator on 2013-02-17 at 00:38:50.
- */
-class AccessurleditsessionstourlTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * @var Accessurleditsessionstourl
-     */
-    protected $object;
-
-    /**
-     * Sets up the fixture, for example, opens a network connection.
-     * This method is called before a test is executed.
-     */
-    protected function setUp()
-    {
-        ob_start();
-        require_once dirname(__FILE__).'/../../../main/inc/lib/access_url_edit_sessions_to_url_functions.lib.php';
-        require_once dirname(__FILE__).'/../../../main/inc/lib/main_api.lib.php';
-        $this->object = new Accessurleditsessionstourl;
-    }
-
-    /**
-     * Tears down the fixture, for example, closes a network connection.
-     * This method is called after a test is executed.
-     */
-    protected function tearDown()
-    {
-        ob_end_clean();
-    }
-
-    /**
-     * Generated from @assert () === false.
-     *
-     * @covers Accessurleditsessionstourl::search_sessions
-     */
-    public function testSearch_sessions()
-    {
-        ob_start();
-        $this->assertSame(
-          false,
-          $this->object->search_sessions(null,null)
-        );
-        ob_end_clean();
-    }
-}

+ 1 - 0
tests/phpunit/classes/AddCourseToSessionTest.lib.php

@@ -16,6 +16,7 @@ class AddCourseToSessionTest extends PHPUnit_Framework_TestCase
     protected function setUp()
     {
         require_once dirname(__FILE__).'/../../../main/inc/global.inc.php';
+        require_once dirname(__FILE__).'/../../../main/inc/lib/database.lib.php';
         $this->object = new AddCourseToSession;
     }
 

+ 2 - 2
tests/phpunit/classes/UserManagerTest.lib.php

@@ -272,7 +272,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Generated from @assert (false) === false.
+     * Generated from @assert (false, false, false, false, false, false, false, false, false, false, false, false, false) === false.
      *
      * @covers UserManager::update_user
      */
@@ -280,7 +280,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase
     {
         $this->assertSame(
           false,
-          UserManager::update_user(false)
+          UserManager::update_user(false,false,false,false,false,false,false,false,false,false,false,false,false)
         );
     }