Browse Source

Merge with 1.9.x

Julio Montoya 12 years ago
parent
commit
594fe1a78e
2 changed files with 32 additions and 16 deletions
  1. 24 0
      main/inc/lib/events.lib.inc.php
  2. 8 16
      main/inc/lib/group_portal_manager.lib.php

+ 24 - 0
main/inc/lib/events.lib.inc.php

@@ -707,6 +707,30 @@ function get_latest_event_by_user_and_type($user_id, $event_type) {
     }
 }
 
+function get_events_by_user_and_type($user_id, $event_type) {
+    global $TABLETRACK_DEFAULT;
+    $user_id = intval($user_id);
+    $event_type = Database::escape_string($event_type);
+
+    $sql = "SELECT * FROM $TABLETRACK_DEFAULT
+            WHERE default_value_type = 'user_id' AND
+                  default_value = $user_id AND
+                  default_event_type = '$event_type'
+            ORDER BY default_date ";
+    $result = Database::query($sql);
+    if ($result) {
+        return Database::store_result($result, 'ASSOC');
+    }
+    return false;
+}
+
+function get_latest_event_by_user_and_type($user_id, $event_type) {
+    $result = get_events_by_user_and_type($user_id, $event_type);
+    if ($result && !empty($result)) {
+        return $result[0];
+    }
+}
+
 /**
  * Save the new message for one event and for one language
  *

+ 8 - 16
main/inc/lib/group_portal_manager.lib.php

@@ -95,8 +95,7 @@ class GroupPortalManager
 	* @param int id
 	* @return boolean true if success
 	* */
-	public static function delete($id)
-	{
+    public static function delete($id) {
 		$id = intval($id);
 		$table = Database :: get_main_table(TABLE_MAIN_GROUP);
 		$sql= "DELETE FROM $table WHERE id = ".Database::escape_string($id);
@@ -117,8 +116,7 @@ class GroupPortalManager
 	 * @param int	number of items
 	 * @return array
 	 * */
-	public static function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10)
-	{
+    public static function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from = 0, $number_of_items = 10) {
 		$table	= Database :: get_main_table(TABLE_MAIN_GROUP);
 		$visibility = intval($visibility);
 		$sql = "SELECT name, description, picture_uri FROM $table WHERE visibility = $visibility ";
@@ -154,8 +152,7 @@ class GroupPortalManager
 	 *
 	 *
 	 */
-	public static function get_group_data($group_id)
-	{
+    public static function get_group_data($group_id) {
 		$table	= Database :: get_main_table(TABLE_MAIN_GROUP);
 		$group_id = intval($group_id);
 		$sql = "SELECT id, name, description, picture_uri, url, visibility  FROM $table WHERE id = $group_id ";
@@ -494,8 +491,7 @@ class GroupPortalManager
 	 * @param int group id
 	 * @return array
 	 */
-	public static function get_all_users_by_group($group_id)
-	{
+    public static function get_all_users_by_group($group_id) {
 		$table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$tbl_user				= Database::get_main_table(TABLE_MAIN_USER);
 		$group_id 				= intval($group_id);
@@ -522,8 +518,7 @@ class GroupPortalManager
 	* @param int group_id
 	* @return int 0 if there are not relationship otherwise returns the user group
 	* */
-	public static function get_user_group_role($user_id, $group_id)
-	{
+    public static function get_user_group_role($user_id, $group_id) {
 		$table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$return_value = 0;
 		if (!empty($user_id) && !empty($group_id)) {
@@ -600,8 +595,7 @@ class GroupPortalManager
 	* @param int relation type (optional)
 	* @return boolean true if success
 	* */
-	public static function delete_users($group_id,$relation_type='')
-	{
+    public static function delete_users($group_id, $relation_type = '') {
 		$table_	= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$condition_relation = "";
 		if (!empty($relation_type)) {
@@ -634,8 +628,7 @@ class GroupPortalManager
 	 * @param int group id
 	 * @param int relation type
 	 * */
-	public static function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
-	{
+    public static function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER) {
 		$table_group_rel_user	= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$group_id = intval($group_id);
 		$user_id = intval($user_id);
@@ -646,8 +639,7 @@ class GroupPortalManager
 	}
 
 
-	public static function get_group_admin_list($user_id, $group_id)
-	{
+    public static function get_group_admin_list($user_id, $group_id) {
 		$table_group_rel_user	= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$group_id = intval($group_id);
 		$user_id = intval($user_id);