浏览代码

Adding missing function (due recent merge of social group into social class) + using api_get_user_language() instead of a $_SESSION variable

Julio Montoya 12 年之前
父节点
当前提交
cae3b1e818
共有 2 个文件被更改,包括 22 次插入1 次删除
  1. 1 1
      main/admin/system_announcements.php
  2. 21 0
      main/inc/lib/usergroup.lib.php

+ 1 - 1
main/admin/system_announcements.php

@@ -33,7 +33,7 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd
 $tool_name = null;
 
 if (empty($_GET['lang'])) {
-    $_GET['lang'] = $_SESSION['user_language_choice'];
+    $_GET['lang'] = api_get_user_language();
 }
 
 $usergroup = new UserGroup();

+ 21 - 0
main/inc/lib/usergroup.lib.php

@@ -1514,4 +1514,25 @@ class UserGroup extends Model
     public function getAllowedPictureExtensions() {
         return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
     }
+
+    /**
+     * Gets a list of all group
+     * @param id of a group not to include (i.e. to exclude)
+     * @return array : id => name
+     **/
+    public static function get_groups_list($without_this_one = NULL ) {
+        $where='';
+        if ( isset($without_this_one) && (intval($without_this_one) == $without_this_one) ) {
+            $where = "WHERE id <> $without_this_one";
+        }
+        $table	= Database :: get_main_table(TABLE_USERGROUP);
+        $sql = "SELECT id, name FROM $table $where order by name";
+        $res = Database::query($sql);
+        $list = array ();
+        while ($item = Database::fetch_assoc($res)) {
+            $list[$item['id']] = $item['name'];
+        }
+        return $list;
+    }
+
 }