Julio Montoya 12 years ago
parent
commit
1ebed13843
5 changed files with 173 additions and 130 deletions
  1. 21 1
      README.txt
  2. 4 3
      main/auth/profile.php
  3. 2 2
      main/inc/lib/main_api.lib.php
  4. 134 105
      main/social/home.php
  5. 12 19
      src/ChamiloLMS/Controller/IndexController.php

+ 21 - 1
README.txt

@@ -1,2 +1,22 @@
-For more information on Chamilo, open documentation/index.html in this directory with a web browser.
+Chamilo LMS
+=============
 
+See documentation/index.html for a complete overview of Chamilo.
+
+Installation
+------------
+
+You need a working web server + PHP + MySQL setup.
+Refer to documentation/installation_guide.html for instructions.
+
+Reporting bugs
+--------------
+
+Please submit any bugs, feature requests and non-trivial patches to
+http://support.chamilo.org/
+
+Learn more
+----------
+
+For news, events and more information on Chamilo LMS please visit
+http://www.chamilo.org/

+ 4 - 3
main/auth/profile.php

@@ -368,13 +368,14 @@ function is_platform_authentication()
 }
 
 /**
- * Can a user edit his/her profile?
+ * Returns whether a user can edit his/her profile. Defaults to false if
+ * profileIsEditable is not set in $GLOBALS.
  *
  * @return    boolean    Editability of the profile
  */
 function is_profile_editable()
 {
-    return $GLOBALS['profileIsEditable'];
+    return isset($GLOBALS['profileIsEditable']) ? $GLOBALS['profileIsEditable'] : false;
 }
 
 /*
@@ -837,4 +838,4 @@ if (api_get_setting('allow_social_tool') == 'true') {
     echo '</div>';
     $form->display();
 }
-Display :: display_footer();
+Display :: display_footer();

+ 2 - 2
main/inc/lib/main_api.lib.php

@@ -3484,10 +3484,10 @@ function api_display_language_form($hide_if_no_choice = false) {
     $language_list = api_get_languages();
 
     if (!empty($language_list) && count($language_list['name']) <= 1 && $hide_if_no_choice) {
-        return; //don't show any form
+        return; // Don't show any form
     }
 
-    // The the current language of the user so that his/her language occurs as selected in the dropdown menu.
+    // The current language of the user so that his/her language occurs as selected in the dropdown menu.
     if (isset($_SESSION['user_language_choice'])) {
         $user_selected_language = $_SESSION['user_language_choice'];
     }

+ 134 - 105
main/social/home.php

@@ -14,7 +14,7 @@ require_once '../inc/global.inc.php';
 
 $user_id = api_get_user_id();
 $show_full_profile = true;
-//social tab
+// Social tab
 $this_section = SECTION_SOCIAL;
 unset($_SESSION['this_section']);//for hmtl editor repository
 
@@ -27,34 +27,34 @@ if (api_get_setting('allow_social_tool') !='true' ) {
     api_not_allowed();
 }
 
-//fast upload image
+// Fast upload image
 if (api_get_setting('profile', 'picture') == 'true') {
-	$form = new FormValidator('profile', 'post', 'home.php', null, array());
-
-	//	PICTURE
-	$form->addElement('file', 'picture', get_lang('AddImage'));
-	$form->add_progress_bar();
-	if (!empty($user_data['picture_uri'])) {
-		$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
-	}
-	$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
-	$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
-	$form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"');
-
-	if ($form->validate()) {
-		$user_data = $form->getSubmitValues();
-		// upload picture if a new one is provided
-		if ($_FILES['picture']['size']) {
-			if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
-				$table_user = Database :: get_main_table(TABLE_MAIN_USER);
-				$sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id =  ".api_get_user_id();
-				$result = Database::query($sql);
-			}
-		}
-	}
+    $form = new FormValidator('profile', 'post', 'home.php', null, array());
+
+    // Picture
+    $form->addElement('file', 'picture', get_lang('AddImage'));
+    $form->add_progress_bar();
+    if (!empty($user_data['picture_uri'])) {
+        $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
+    }
+    $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
+    $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
+    $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"');
+
+    if ($form->validate()) {
+        $user_data = $form->getSubmitValues();
+        // upload picture if a new one is provided
+        if ($_FILES['picture']['size']) {
+            if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
+                $table_user = Database :: get_main_table(TABLE_MAIN_USER);
+                $sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id =  ".api_get_user_id();
+                $result = Database::query($sql);
+            }
+        }
+    }
 }
 
-$user_info = UserManager :: get_user_info_by_id(api_get_user_id());
+$user_info = UserManager::get_user_info_by_id(api_get_user_id());
 
 $social_left_content = SocialManager::show_social_menu('home');
 
@@ -69,7 +69,8 @@ $list = array(
 
 $usergroup = new UserGroup();
 
-// information current user
+// Current user information
+>>>>>>> Minor - code style
 $social_right_content .= '<div>'.Display::description($list).'</div>';
 $social_right_content .= '
     <div class="form-actions">
@@ -78,89 +79,117 @@ $social_right_content .= '
     </a>
     </div></div>';
 
-    if (api_get_setting('allow_skills_tool') == 'true') {
-        $social_right_content .= '<div class="well_border">';
-        $skill = new Skill();
-        $ranking =  $skill->get_user_skill_ranking(api_get_user_id());
-        $url = api_get_path(WEB_CODE_PATH).'social/skills_ranking.php';
-        $ranking_url = Display::url(sprintf(get_lang('YourSkillRankingX'), $ranking), $url, array('class' => 'btn'));
+if (api_get_setting('allow_skills_tool') == 'true') {
+    $social_right_content .= '<div class="well_border">';
+    $skill = new Skill();
+    $ranking =  $skill->get_user_skill_ranking(api_get_user_id());
+    $url = api_get_path(WEB_CODE_PATH).'social/skills_ranking.php';
+    $ranking_url = Display::url(sprintf(get_lang('YourSkillRankingX'), $ranking), $url, array('class' => 'btn'));
 
-        $skills =  $skill->get_user_skills(api_get_user_id(), true);
+    $skills =  $skill->get_user_skills(api_get_user_id(), true);
 
-        $social_right_content .= '<h3>'.get_lang('Skills').'</h3>';
-        $lis = '';
-        if (!empty($skills)) {
-            foreach($skills as $skill) {
-                $lis .= Display::tag('li', Display::span($skill['name'], array('class'=>'label_tag skill')));
-            }
-            $social_right_content .= Display::tag('ul', $lis);
+    $social_right_content .= '<h3>'.get_lang('Skills').'</h3>';
+    $lis = '';
+    if (!empty($skills)) {
+        foreach($skills as $skill) {
+            $lis .= Display::tag('li', Display::span($skill['name'], array('class'=>'label_tag skill')));
         }
-        $url = api_get_path(WEB_CODE_PATH).'social/skills_wheel.php';
-        $skill_wheel_url = Display::url(get_lang('ViewSkillsWheel'), $url, array('class' => 'btn'));
-        $social_right_content .= '<div class="btn-group">'.$skill_wheel_url.$ranking_url.'</div>';
-        $social_right_content .= '</div>';
+        $social_right_content .= Display::tag('ul', $lis);
     }
-
+    $url = api_get_path(WEB_CODE_PATH).'social/skills_wheel.php';
+    $skill_wheel_url = Display::url(get_lang('ViewSkillsWheel'), $url, array('class' => 'btn'));
+    $social_right_content .= '<div class="btn-group">'.$skill_wheel_url.$ranking_url.'</div>';
     $social_right_content .= '</div>';
+}
+
+$social_right_content .= '</div>';
+
+// Search box
+$social_right_content .= '<div class="span4">';
+$social_right_content .= UserManager::get_search_form('');
+$social_right_content .= '<br />';
+
+// Group box by age
+$results = GroupPortalManager::get_groups_by_age(1,false);
+
+$groups_newest = array();
+if (!empty($results)) {
+    foreach ($results as $result) {
+        $id = $result['id'];
+        $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
+        $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
+        if ($result['count'] == 1 ) {
+            $result['count'] = '1 '.get_lang('Member');
+        } else {
+            $result['count'] = $result['count'].' '.get_lang('Members');
+        }
+        $group_url = "groups.php?id=$id";
+        $result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
+        $picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
+        $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
+        $group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
+        $groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], cut($result['description'],120,true).$group_actions);
+    }
+}
+
+// Search box
+$social_right_content .= '<div class="span4">';
+$social_right_content .= UserManager::get_search_form('');
+$social_right_content .= '<br />';
+
+// Group box by age
+$results = $usergroup->get_groups_by_age(1,false);
+
+$groups_newest = array();
+if (!empty($results)) {
+    foreach ($results as $result) {
+        $id = $result['id'];
+        $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
+        $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
+        if ($result['count'] == 1 ) {
+            $result['count'] = '1 '.get_lang('Member');
+        } else {
+            $result['count'] = $result['count'].' '.get_lang('Members');
+        }
+        $group_url = "groups.php?id=$id";
+        $result['name'] = Display::url(api_ucwords(Text::cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
+        $picture = $usergroup->get_picture_group($id, $result['picture'],80);
+        $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
+        $group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
+        $groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], Text::cut($result['description'],120,true).$group_actions);
+    }
+}
+
+$results = $usergroup->get_groups_by_popularity(1,false);
+
+$groups_pop = array();
+foreach ($results as $result) {
+    $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
+    $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
+    $id = $result['id'];
+    $group_url = "groups.php?id=$id";
 
-            //Search box
-			$social_right_content .= '<div class="span4">';
-    			$social_right_content .= UserManager::get_search_form('');
-    			$social_right_content .= '<br />';
-
-    			//Group box by age
-    			$results = $usergroup->get_groups_by_age(1,false);
-
-    			$groups_newest = array();
-    			if (!empty($results)) {
-        			foreach ($results as $result) {
-        				$id = $result['id'];
-        				$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
-        				$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
-        			    if ($result['count'] == 1 ) {
-                            $result['count'] = '1 '.get_lang('Member');
-                        } else {
-                            $result['count'] = $result['count'].' '.get_lang('Members');
-                        }
-        				$group_url = "groups.php?id=$id";
-        				$result['name'] = Display::url(api_ucwords(Text::cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
-        				$picture = $usergroup->get_picture_group($id, $result['picture'],80);
-        				$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
-        				$group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
-        				$groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], Text::cut($result['description'],120,true).$group_actions);
-        			}
-    			}
-
-    			$results = $usergroup->get_groups_by_popularity(1,false);
-
-    			$groups_pop = array();
-    			foreach ($results as $result) {
-    				$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
-    				$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
-    				$id = $result['id'];
-                    $group_url = "groups.php?id=$id";
-
-    				if ($result['count'] == 1 ) {
-    					$result['count'] = '1 '.get_lang('Member');
-    				} else {
-    					$result['count'] = $result['count'].' '.get_lang('Members');
-    				}
-    				$result['name'] = Display::url(api_ucwords(Text::cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
-    				$picture = $usergroup->get_picture_group($id, $result['picture'],80);
-    				$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
-    				$group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
-    				$groups_pop[]= array(Display::url($result['picture_uri'], $group_url) , $result['name'], Text::cut($result['description'],120,true).$group_actions);
-    			}
-
-    			if (count($groups_newest) > 0) {
-    				$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
-    				$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));
-    			}
-
-    			if (count($groups_pop) > 0) {
-    				$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
-    				$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
-    			}
+    if ($result['count'] == 1 ) {
+        $result['count'] = '1 '.get_lang('Member');
+    } else {
+        $result['count'] = $result['count'].' '.get_lang('Members');
+    }
+    $result['name'] = Display::url(api_ucwords(Text::cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
+    $picture = $usergroup->get_picture_group($id, $result['picture'],80);
+    $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
+    $group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
+    $groups_pop[]= array(Display::url($result['picture_uri'], $group_url) , $result['name'], Text::cut($result['description'],120,true).$group_actions);
+}
+
+if (count($groups_newest) > 0) {
+    $social_right_content .= '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
+    $social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));
+}
+
+if (count($groups_pop) > 0) {
+    $social_right_content .= '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
+    $social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
+}
 $social_right_content .= '</div>';
 
 $app['title'] = get_lang('SocialNetwork');
@@ -169,4 +198,4 @@ $tpl = $app['template'];
 $tpl->assign('social_left_content', $social_left_content);
 $tpl->assign('social_right_content', $social_right_content);
 $social_layout = $tpl->get_template('layout/social_layout.tpl');
-$tpl->display($social_layout);
+$tpl->display($social_layout);

+ 12 - 19
src/ChamiloLMS/Controller/IndexController.php

@@ -62,14 +62,14 @@ class IndexController extends CommonController
         $app['extraJS'] = $extraJS;
         $request = $app['request'];
         $app['languages_file'] = array('courses', 'index', 'admin');
+        $app['cidReset'] = true;
 
-        // Testing translation using translator component
+        // Testing translation using translator
         //echo $app['translator']->trans('Wiki Search Results');
         //echo $app['translator']->trans('Profile');
 
-        //$token = $app['security']->getToken();
 
-        //Testing Doctrine ORM + pagination using pagerfanta
+        //$token = $app['security']->getToken();
 
         //$article = $app['orm.em']->getRepository('Entity\Course');
         //$courses_query = $app['orm.em']->createQuery('SELECT a FROM Entity\Course a');
@@ -95,7 +95,7 @@ class IndexController extends CommonController
             unset($_SESSION['term_and_condition']);
         }
 
-        //If we are not logged in and customapages activated
+        // If we are not logged in and customapages activated
         if (!api_get_user_id() && \CustomPages::enabled()) {
             $loggedOut = $request->get('loggedout');
             if ($loggedOut) {
@@ -109,7 +109,7 @@ class IndexController extends CommonController
             $app['template']->assign('course_category_block', $app['page_controller']->return_courses_in_categories());
         }
 
-        // Facebook connexion, if activated
+        // Facebook connection, if activated
         if (api_is_facebook_auth_activated() && !api_get_user_id()) {
             facebook_connect();
         }
@@ -127,7 +127,7 @@ class IndexController extends CommonController
             }
         }
 
-        //Hot courses & announcements
+        // Hot courses & announcements
         $hotCourses         = null;
         $announcementsBlock = null;
 
@@ -142,10 +142,10 @@ class IndexController extends CommonController
         $app['template']->assign('hot_courses', $hotCourses);
         $app['template']->assign('announcements_block', $announcementsBlock);
 
-        //Homepage
+        // Homepage
         $app['template']->assign('home_page_block', $app['page_controller']->return_home_page());
 
-        //Navigation links
+        // Navigation links
         $navLinks = $app['template']->returnNavigationLinks();
 
         $app['template']->assign('navigation_course_links', $navLinks);
@@ -158,11 +158,6 @@ class IndexController extends CommonController
             $app['page_controller']->return_skills_links();
         }
 
-        if (isset($loginError)) {
-            $message = $this->handle_login_failed($loginError);
-            $app['template']->assign('login_failed', $message);
-        }
-
         $response = $app['template']->render_layout('layout_2_col.tpl');
 
         //return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, public'));
@@ -182,8 +177,8 @@ class IndexController extends CommonController
         if (!empty($_POST['submitAuth'])) {
             // The user has been already authenticated, we are now to find the last login of the user.
             if (!empty($this->user_id)) {
-                $track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
-                $sql_last_login    = "SELECT login_date
+                $track_login_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
+                $sql_last_login = "SELECT login_date
                                     FROM $track_login_table
                                     WHERE login_user_id = '".$this->user_id."'
                                     ORDER BY login_date DESC LIMIT 1";
@@ -198,7 +193,7 @@ class IndexController extends CommonController
                 Database::free_result($result_last_login);
 
                 if (api_is_platform_admin()) {
-                    // decode all open event informations and fill the track_c_* tables
+                    // Decode all open event informations and fill the track_c_* tables
                     include api_get_path(LIBRARY_PATH).'stats.lib.inc.php';
                     decodeOpenInfos();
                 }
@@ -244,9 +239,7 @@ class IndexController extends CommonController
      */
     public function display_login_form(Application $app)
     {
-        /*
-          symfony2 form way
-          {{ form_widget(form) }}
+        /* {{ form_widget(form) }}
           $form = $app['form.factory']->createBuilder('form')
           ->add('name')
           ->add('email')