|
@@ -80,7 +80,7 @@ class UserGroup extends Model
|
|
|
";
|
|
|
$result = Database::query($sql);
|
|
|
if (Database::num_rows($result)) {
|
|
|
- $row = Database::fetch_array($result);
|
|
|
+ $row = Database::fetch_array($result);
|
|
|
|
|
|
return $row['count'];
|
|
|
}
|
|
@@ -99,7 +99,7 @@ class UserGroup extends Model
|
|
|
";
|
|
|
$result = Database::query($sql);
|
|
|
if (Database::num_rows($result)) {
|
|
|
- $row = Database::fetch_array($result);
|
|
|
+ $row = Database::fetch_array($result);
|
|
|
return $row['count'];
|
|
|
}
|
|
|
}
|
|
@@ -124,7 +124,7 @@ class UserGroup extends Model
|
|
|
";
|
|
|
$result = Database::query($sql);
|
|
|
if (Database::num_rows($result)) {
|
|
|
- $row = Database::fetch_array($result);
|
|
|
+ $row = Database::fetch_array($result);
|
|
|
return $row['count'];
|
|
|
}
|
|
|
|
|
@@ -145,7 +145,7 @@ class UserGroup extends Model
|
|
|
";
|
|
|
$result = Database::query($sql);
|
|
|
if (Database::num_rows($result)) {
|
|
|
- $row = Database::fetch_array($result);
|
|
|
+ $row = Database::fetch_array($result);
|
|
|
return $row['count'];
|
|
|
}
|
|
|
|
|
@@ -532,13 +532,13 @@ class UserGroup extends Model
|
|
|
INNER JOIN {$this->table} g
|
|
|
ON (u.usergroup_id = g.id)
|
|
|
";
|
|
|
- $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
|
|
|
+ $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
|
|
|
} else {
|
|
|
$from = $this->usergroup_rel_user_table." u
|
|
|
INNER JOIN {$this->table} g
|
|
|
ON (u.usergroup_id = g.id)
|
|
|
";
|
|
|
- $where = array('where' => array('user_id = ?' => $userId));
|
|
|
+ $where = array('where' => array('user_id = ?' => $userId));
|
|
|
}
|
|
|
|
|
|
if ($filterByType !== null) {
|
|
@@ -571,10 +571,10 @@ class UserGroup extends Model
|
|
|
$urlId = api_get_current_access_url_id();
|
|
|
$from = $this->usergroup_rel_user_table." u
|
|
|
INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)";
|
|
|
- $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
|
|
|
+ $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
|
|
|
} else {
|
|
|
$from = $this->usergroup_rel_user_table." u ";
|
|
|
- $where = array('where' => array('user_id = ?' => $userId));
|
|
|
+ $where = array('where' => array('user_id = ?' => $userId));
|
|
|
}
|
|
|
|
|
|
$results = Database::select(
|
|
@@ -894,7 +894,7 @@ class UserGroup extends Model
|
|
|
}
|
|
|
$result = $new_result;
|
|
|
}
|
|
|
- $columns = array('name', 'users', 'courses','sessions', 'group_type');
|
|
|
+ $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
|
|
|
|
|
|
if (!in_array($sidx, $columns)) {
|
|
|
$sidx = 'name';
|
|
@@ -1297,7 +1297,7 @@ class UserGroup extends Model
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return));
|
|
|
+ $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
|
|
|
|
|
|
return $response;
|
|
|
}
|
|
@@ -1401,7 +1401,7 @@ class UserGroup extends Model
|
|
|
* @param string style css
|
|
|
* @return array with the file and the style of an image i.e $array['file'] $array['style']
|
|
|
*/
|
|
|
- public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
|
|
|
+ public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
|
|
|
{
|
|
|
$picture = array();
|
|
|
//$picture['style'] = $style;
|
|
@@ -1594,7 +1594,7 @@ class UserGroup extends Model
|
|
|
GROUP_USER_PERMISSION_READER,
|
|
|
GROUP_USER_PERMISSION_HRM,
|
|
|
);
|
|
|
- $user_role = self::get_user_group_role($user_id, $group_id);
|
|
|
+ $user_role = self::get_user_group_role($user_id, $group_id);
|
|
|
if (in_array($user_role, $roles)) {
|
|
|
return true;
|
|
|
} else {
|
|
@@ -1611,7 +1611,7 @@ class UserGroup extends Model
|
|
|
* */
|
|
|
public function get_user_group_role($user_id, $group_id)
|
|
|
{
|
|
|
- $table_group_rel_user= $this->usergroup_rel_user_table;
|
|
|
+ $table_group_rel_user = $this->usergroup_rel_user_table;
|
|
|
$return_value = 0;
|
|
|
if (!empty($user_id) && !empty($group_id)) {
|
|
|
$sql = "SELECT relation_type FROM $table_group_rel_user
|
|
@@ -1619,8 +1619,8 @@ class UserGroup extends Model
|
|
|
usergroup_id = ".intval($group_id)." AND
|
|
|
user_id = ".intval($user_id)." ";
|
|
|
$result = Database::query($sql);
|
|
|
- if (Database::num_rows($result)>0) {
|
|
|
- $row = Database::fetch_array($result,'ASSOC');
|
|
|
+ if (Database::num_rows($result) > 0) {
|
|
|
+ $row = Database::fetch_array($result, 'ASSOC');
|
|
|
$return_value = $row['relation_type'];
|
|
|
}
|
|
|
}
|
|
@@ -1675,7 +1675,7 @@ class UserGroup extends Model
|
|
|
if (is_array($user_list) && is_array($group_list)) {
|
|
|
foreach ($group_list as $group_id) {
|
|
|
foreach ($user_list as $user_id) {
|
|
|
- $role = self::get_user_group_role($user_id,$group_id);
|
|
|
+ $role = self::get_user_group_role($user_id, $group_id);
|
|
|
if ($role == 0) {
|
|
|
$sql = "INSERT INTO $table_url_rel_group
|
|
|
SET
|
|
@@ -1706,7 +1706,7 @@ class UserGroup extends Model
|
|
|
public function delete_user_rel_group($user_id, $group_id)
|
|
|
{
|
|
|
$table = $this->usergroup_rel_user_table;
|
|
|
- $sql= "DELETE FROM $table
|
|
|
+ $sql = "DELETE FROM $table
|
|
|
WHERE
|
|
|
user_id = ".intval($user_id)." AND
|
|
|
usergroup_id = ".intval($group_id)." ";
|
|
@@ -1762,7 +1762,7 @@ class UserGroup extends Model
|
|
|
|
|
|
$sql = "UPDATE $table_group_rel_user
|
|
|
SET relation_type = ".intval($relation_type)."
|
|
|
- WHERE user_id = $user_id AND usergroup_id = $group_id" ;
|
|
|
+ WHERE user_id = $user_id AND usergroup_id = $group_id";
|
|
|
Database::query($sql);
|
|
|
}
|
|
|
|
|
@@ -1804,7 +1804,7 @@ class UserGroup extends Model
|
|
|
if (Database::num_rows($result) > 0) {
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
|
|
if ($with_image) {
|
|
|
- $picture = self::get_picture_group($row['id'], $row['picture'],80);
|
|
|
+ $picture = self::get_picture_group($row['id'], $row['picture'], 80);
|
|
|
$img = '<img src="'.$picture['file'].'" />';
|
|
|
$row['picture'] = $img;
|
|
|
}
|
|
@@ -1840,11 +1840,11 @@ class UserGroup extends Model
|
|
|
ORDER BY count DESC
|
|
|
LIMIT $num";
|
|
|
|
|
|
- $result=Database::query($sql);
|
|
|
+ $result = Database::query($sql);
|
|
|
$array = array();
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
|
|
if ($with_image) {
|
|
|
- $picture = self::get_picture_group($row['id'], $row['picture'],80);
|
|
|
+ $picture = self::get_picture_group($row['id'], $row['picture'], 80);
|
|
|
$img = '<img src="'.$picture['file'].'" />';
|
|
|
$row['picture'] = $img;
|
|
|
}
|
|
@@ -1889,11 +1889,11 @@ class UserGroup extends Model
|
|
|
ORDER BY created_at DESC
|
|
|
LIMIT $num ";
|
|
|
|
|
|
- $result=Database::query($sql);
|
|
|
+ $result = Database::query($sql);
|
|
|
$array = array();
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
|
|
if ($with_image) {
|
|
|
- $picture = self::get_picture_group($row['id'], $row['picture'],80);
|
|
|
+ $picture = self::get_picture_group($row['id'], $row['picture'], 80);
|
|
|
$img = '<img src="'.$picture['file'].'" />';
|
|
|
$row['picture'] = $img;
|
|
|
}
|
|
@@ -1927,7 +1927,7 @@ class UserGroup extends Model
|
|
|
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
$group_id = intval($group_id);
|
|
|
|
|
|
- if (empty($group_id)){
|
|
|
+ if (empty($group_id)) {
|
|
|
return array();
|
|
|
}
|
|
|
|
|
@@ -1942,9 +1942,9 @@ class UserGroup extends Model
|
|
|
$where_relation_condition = '';
|
|
|
} else {
|
|
|
$new_relation_type = array();
|
|
|
- foreach($relation_type as $rel) {
|
|
|
+ foreach ($relation_type as $rel) {
|
|
|
$rel = intval($rel);
|
|
|
- $new_relation_type[] ="'$rel'";
|
|
|
+ $new_relation_type[] = "'$rel'";
|
|
|
}
|
|
|
$relation_type = implode(',', $new_relation_type);
|
|
|
if (!empty($relation_type))
|
|
@@ -1988,7 +1988,7 @@ class UserGroup extends Model
|
|
|
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
$group_id = intval($group_id);
|
|
|
|
|
|
- if (empty($group_id)){
|
|
|
+ if (empty($group_id)) {
|
|
|
return array();
|
|
|
}
|
|
|
|
|
@@ -1999,7 +1999,7 @@ class UserGroup extends Model
|
|
|
WHERE gu.usergroup_id= $group_id
|
|
|
ORDER BY relation_type, firstname";
|
|
|
|
|
|
- $result=Database::query($sql);
|
|
|
+ $result = Database::query($sql);
|
|
|
$array = array();
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
|
|
$array[$row['id']] = $row;
|
|
@@ -2027,33 +2027,33 @@ class UserGroup extends Model
|
|
|
case GROUP_USER_PERMISSION_READER:
|
|
|
// I'm just a reader
|
|
|
$relation_group_title = get_lang('IAmAReader');
|
|
|
- $links .= '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
|
|
|
- $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
- Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
|
|
|
+ $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
|
|
|
+ $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
+ Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
|
|
|
if (UserGroup::canLeave($group_info)) {
|
|
|
- $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
- Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
|
|
|
+ $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
+ Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
|
|
|
}
|
|
|
break;
|
|
|
case GROUP_USER_PERMISSION_ADMIN:
|
|
|
$relation_group_title = get_lang('IAmAnAdmin');
|
|
|
- $links .= '<li class="'. ($show == 'group_edit' ? 'active' : '') .'"><a href="group_edit.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('group_edit.png', get_lang('EditGroup')) . get_lang('EditGroup') . '</a></li>';
|
|
|
- $links .= '<li class="'. ($show == 'member_list' ? 'active' : '') .'"><a href="group_waiting_list.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
|
|
|
- $links .= '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
|
|
|
+ $links .= '<li class="'.($show == 'group_edit' ? 'active' : '').'"><a href="group_edit.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('group_edit.png', get_lang('EditGroup')).get_lang('EditGroup').'</a></li>';
|
|
|
+ $links .= '<li class="'.($show == 'member_list' ? 'active' : '').'"><a href="group_waiting_list.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
|
|
|
+ $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
|
|
|
if (UserGroup::canLeave($group_info)) {
|
|
|
$links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
- Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
|
|
|
+ Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
|
|
|
}
|
|
|
break;
|
|
|
case GROUP_USER_PERMISSION_PENDING_INVITATION:
|
|
|
// $links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a></li>';
|
|
|
break;
|
|
|
case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
|
|
|
- $relation_group_title = get_lang('WaitingForAdminResponse');
|
|
|
+ $relation_group_title = get_lang('WaitingForAdminResponse');
|
|
|
break;
|
|
|
case GROUP_USER_PERMISSION_MODERATOR:
|
|
|
$relation_group_title = get_lang('IAmAModerator');
|
|
@@ -2061,28 +2061,28 @@ class UserGroup extends Model
|
|
|
//$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
|
|
|
//$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
|
|
|
if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
|
|
|
- $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
|
|
|
+ $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
|
|
|
}
|
|
|
- $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
|
|
|
+ $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
|
|
|
if (UserGroup::canLeave($group_info)) {
|
|
|
- $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
- Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
|
|
|
+ $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
+ Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
|
|
|
}
|
|
|
break;
|
|
|
case GROUP_USER_PERMISSION_HRM:
|
|
|
$relation_group_title = get_lang('IAmAHRM');
|
|
|
$links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="ajax" title="'.get_lang('ComposeMessage').'" data-size="lg" data-title="'.get_lang('ComposeMessage').'">'.
|
|
|
- Display::return_icon('new-message.png', get_lang('NewTopic')) . get_lang('NewTopic') . '</a></li>';
|
|
|
- $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('message_list.png', get_lang('MessageList')) . get_lang('MessageList') . '</a></li>';
|
|
|
- $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
|
|
|
- $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
|
|
|
- Display::return_icon('member_list.png', get_lang('MemberList')) . get_lang('MemberList') . '</a></li>';
|
|
|
- $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
- Display::return_icon('delete_data.gif', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
|
|
|
+ Display::return_icon('new-message.png', get_lang('NewTopic')).get_lang('NewTopic').'</a></li>';
|
|
|
+ $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('message_list.png', get_lang('MessageList')).get_lang('MessageList').'</a></li>';
|
|
|
+ $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
|
|
|
+ $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
|
|
|
+ Display::return_icon('member_list.png', get_lang('MemberList')).get_lang('MemberList').'</a></li>';
|
|
|
+ $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
|
|
|
+ Display::return_icon('delete_data.gif', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
|
|
|
break;
|
|
|
default:
|
|
|
//$links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>';
|
|
@@ -2174,7 +2174,7 @@ class UserGroup extends Model
|
|
|
}
|
|
|
|
|
|
$direction = 'ASC';
|
|
|
- if (!in_array($direction, array('ASC','DESC'))) {
|
|
|
+ if (!in_array($direction, array('ASC', 'DESC'))) {
|
|
|
$direction = 'ASC';
|
|
|
}
|
|
|
|
|
@@ -2185,8 +2185,8 @@ class UserGroup extends Model
|
|
|
$sql .= " LIMIT $from,$number_of_items";
|
|
|
|
|
|
$res = Database::query($sql);
|
|
|
- if (Database::num_rows($res)> 0) {
|
|
|
- while ($row = Database::fetch_array($res,'ASSOC')) {
|
|
|
+ if (Database::num_rows($res) > 0) {
|
|
|
+ while ($row = Database::fetch_array($res, 'ASSOC')) {
|
|
|
if (!in_array($row['id'], $return)) {
|
|
|
$return[$row['id']] = $row;
|
|
|
}
|
|
@@ -2211,7 +2211,7 @@ class UserGroup extends Model
|
|
|
if ($i == $max_level) {
|
|
|
$select_part .= "rg$rg_number.group_id as id_$rg_number ";
|
|
|
} else {
|
|
|
- $select_part .="rg$rg_number.group_id as id_$rg_number, ";
|
|
|
+ $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
|
|
|
}
|
|
|
if ($i == 1) {
|
|
|
$cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
|
|
@@ -2396,7 +2396,7 @@ class UserGroup extends Model
|
|
|
$nameList = '<ul class="list-unstyled">';
|
|
|
|
|
|
foreach ($groupsNameListParsed as $name) {
|
|
|
- $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>';
|
|
|
+ $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>';
|
|
|
}
|
|
|
|
|
|
$nameList .= '</ul>';
|