parent
76529c85da
commit
545ca410a2
File diff suppressed because it is too large
Load Diff
@ -1,113 +1,72 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* @package chamilo.social |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
|
||||
// Language files that should be included |
||||
$language_file = array('userInfo'); |
||||
$cidReset = true; |
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
api_block_anonymous_users(); |
||||
if (api_get_setting('allow_social_tool') !='true') { |
||||
if (api_get_setting('allow_social_tool') != 'true') { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$this_section = SECTION_SOCIAL; |
||||
|
||||
$libpath = api_get_path(LIBRARY_PATH); |
||||
|
||||
$htmlHeadXtra[] = '<script type="text/javascript"> |
||||
var textarea = ""; |
||||
var num_characters_permited = 255; |
||||
function textarea_maxlength(){ |
||||
num_characters = document.forms[0].description.value.length; |
||||
if (num_characters > num_characters_permited){ |
||||
document.forms[0].description.value = textarea; |
||||
}else{ |
||||
textarea = document.forms[0].description.value; |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
$group_id = isset($_GET['id']) ? intval($_GET['id']) : intval($_POST['id']); |
||||
$tool_name = get_lang('GroupEdit'); |
||||
|
||||
$interbreadcrumb[] = array('url' => 'home.php','name' => get_lang('Social')); |
||||
$interbreadcrumb[] = array('url' => 'groups.php','name' => get_lang('Groups')); |
||||
|
||||
$table_group = Database::get_main_table(TABLE_MAIN_GROUP); |
||||
$group_data = GroupPortalManager::get_group_data($group_id); |
||||
$usergroup = new UserGroup(); |
||||
$group_data = $usergroup->get($group_id); |
||||
|
||||
if (empty($group_data)) { |
||||
api_not_allowed(); |
||||
header('Location: group_view.php?id='.$group_id); |
||||
exit; |
||||
} |
||||
|
||||
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups')); |
||||
$interbreadcrumb[] = array('url' => 'group_view.php?id='.$group_id, 'name' => $group_data['name']); |
||||
|
||||
|
||||
//only group admins can edit the group |
||||
if (!GroupPortalManager::is_group_admin($group_id)) { |
||||
if (!$usergroup->is_group_admin($group_id)) { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
// Create the form |
||||
$form = new FormValidator('group_edit', 'post', '', ''); |
||||
$form->addElement('hidden', 'id', $group_id); |
||||
$form = GroupPortalManager::setGroupForm($form, $group_data); |
||||
// Submit button |
||||
$form->addButtonSave(get_lang('ModifyInformation'), 'submit'); |
||||
$usergroup->setGroupType($usergroup::SOCIAL_CLASS); |
||||
$usergroup->setForm($form, 'edit', $group_data); |
||||
|
||||
// Set default values |
||||
$form->setDefaults($group_data); |
||||
|
||||
// Validate form |
||||
if ($form->validate()) { |
||||
$group = $form->exportValues(); |
||||
$picture_element = $form->getElement('picture'); |
||||
$picture = $picture_element->getValue(); |
||||
$picture_uri = $group_data['picture_uri']; |
||||
|
||||
if ($group['delete_picture']) { |
||||
$picture_uri = GroupPortalManager::delete_group_picture($group_id); |
||||
} elseif (!empty($picture['name'])) { |
||||
$picture_uri = GroupPortalManager::update_group_picture( |
||||
$group_id, |
||||
$_FILES['picture']['name'], |
||||
$_FILES['picture']['tmp_name'] |
||||
); |
||||
} |
||||
|
||||
$name = $group['name']; |
||||
$description = $group['description']; |
||||
$url = $group['url']; |
||||
$status = intval($group['visibility']); |
||||
|
||||
$allowMemberGroupToLeave = null; |
||||
if (GroupPortalManager::canLeaveFeatureEnabled($group_data)) { |
||||
$allowMemberGroupToLeave = isset($group['allow_members_leave_group']) ? true : false; |
||||
} |
||||
GroupPortalManager::update($group_id, $name, $description, $url, $status, $picture_uri, $allowMemberGroupToLeave); |
||||
$tok = Security::get_token(); |
||||
header('Location: groups.php?id='.$group_id.'&action=show_message&message='.urlencode(get_lang('GroupUpdated')).'&sec_token='.$tok); |
||||
$group['id'] = $group_id; |
||||
$group['type'] = $usergroup::SOCIAL_CLASS; |
||||
$usergroup->update($group); |
||||
Display::addFlash(Display::return_message(get_lang('GroupUpdated'))); |
||||
header('Location: group_view.php?id='.$group_id); |
||||
exit(); |
||||
} |
||||
|
||||
// Group picture |
||||
$image_path = GroupPortalManager::get_group_picture_path_by_id($group_id, 'web'); |
||||
$image_dir = $image_path['dir']; |
||||
$image = $image_path['file']; |
||||
$image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown_group.jpg'); |
||||
$image_size = api_getimagesize($image_file); |
||||
|
||||
// get the path,width and height from original picture |
||||
$big_image = $image_dir.'big_'.$image; |
||||
$big_image_size = api_getimagesize($big_image); |
||||
$big_image_width = $big_image_size['width']; |
||||
$big_image_height = $big_image_size['height']; |
||||
$url_big_image = $big_image.'?rnd='.time(); |
||||
|
||||
$social_avatar_block = SocialManager::show_social_avatar_block('group_edit', $group_id); |
||||
$social_menu_block = SocialManager::show_social_menu('group_edit', $group_id); |
||||
$social_left_content = SocialManager::show_social_menu('group_edit', $group_id); |
||||
$social_right_content = $form->returnForm(); |
||||
|
||||
$tpl = new Template($tool_name); |
||||
$tpl->set_help('Groups'); |
||||
$tpl->assign('social_avatar_block', $social_avatar_block); |
||||
$tpl->assign('social_menu_block', $social_menu_block); |
||||
$tpl = new Template(get_lang('Edit')); |
||||
|
||||
SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id); |
||||
|
||||
$tpl->setHelp('Groups'); |
||||
$tpl->assign('social_menu_block', $social_left_content); |
||||
$tpl->assign('social_right_content', $social_right_content); |
||||
$social_layout = $tpl->get_template('social/groups.tpl'); |
||||
|
||||
$social_layout = $tpl->get_template('social/add_groups.tpl'); |
||||
$tpl->display($social_layout); |
||||
|
@ -0,0 +1,257 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.social |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
$language_file = array('userInfo'); |
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
api_block_anonymous_users(); |
||||
|
||||
if (api_get_setting('allow_social_tool') !='true') { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$this_section = SECTION_SOCIAL; |
||||
|
||||
// prepare anchor for message group topic |
||||
$anchor = ''; |
||||
if (isset($_GET['anchor_topic'])) { |
||||
$anchor = Security::remove_XSS($_GET['anchor_topic']); |
||||
} else { |
||||
$match = 0; |
||||
$param_names = array_keys($_GET); |
||||
foreach ($param_names as $param) { |
||||
if (preg_match('/^items_(\d)_page_nr$/', $param, $match)) { |
||||
break; |
||||
} |
||||
} |
||||
if (isset($match[1])) { |
||||
$anchor = 'topic_'.$match[1]; |
||||
} |
||||
} |
||||
$htmlHeadXtra[] = '<script> |
||||
|
||||
var counter_image = 1; |
||||
function remove_image_form(id_elem1) { |
||||
var elem1 = document.getElementById(id_elem1); |
||||
elem1.parentNode.removeChild(elem1); |
||||
counter_image--; |
||||
var filepaths = document.getElementById("filepaths"); |
||||
if (filepaths.childNodes.length < 3) { |
||||
var link_attach = document.getElementById("link-more-attach"); |
||||
if (link_attach) { |
||||
link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>\'; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function add_image_form() { |
||||
// Multiple filepaths for image form |
||||
var filepaths = document.getElementById("filepaths"); |
||||
if (document.getElementById("filepath_"+counter_image)) { |
||||
counter_image = counter_image + 1; |
||||
} else { |
||||
counter_image = counter_image; |
||||
} |
||||
var elem1 = document.createElement("div"); |
||||
elem1.setAttribute("id","filepath_"+counter_image); |
||||
filepaths.appendChild(elem1); |
||||
id_elem1 = "filepath_"+counter_image; |
||||
id_elem1 = "\'"+id_elem1+"\'"; |
||||
document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" size=\"20\" /> <a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.api_get_path(WEB_IMG_PATH).'delete.gif\"></a>"; |
||||
|
||||
if (filepaths.childNodes.length == 3) { |
||||
var link_attach = document.getElementById("link-more-attach"); |
||||
if (link_attach) { |
||||
link_attach.innerHTML=""; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function validate_text_empty (str,msg) { |
||||
var str = str.replace(/^\s*|\s*$/g,""); |
||||
if (str.length == 0) { |
||||
alert(msg); |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
</script>'; |
||||
|
||||
$allowed_views = array('mygroups','newest','pop'); |
||||
$content = null; |
||||
|
||||
if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) { |
||||
if ($_GET['view'] == 'mygroups') { |
||||
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
||||
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups')); |
||||
} else if ( $_GET['view'] == 'newest') { |
||||
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
||||
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest')); |
||||
} else { |
||||
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
||||
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular')); |
||||
} |
||||
} else { |
||||
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); |
||||
if (!isset($_GET['id'])) { |
||||
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList')); |
||||
} else { |
||||
//$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group')); |
||||
} |
||||
} |
||||
|
||||
// getting group information |
||||
$group_id = isset($_GET['id']) ? intval($_GET['id']) : null; |
||||
$relation_group_title = ''; |
||||
$my_group_role = 0; |
||||
|
||||
$usergroup = new UserGroup(); |
||||
|
||||
if ($group_id != 0) { |
||||
$group_info = $usergroup->get($group_id); |
||||
|
||||
$interbreadcrumb[]= array ('url' =>'#','name' => $group_info['name']); |
||||
|
||||
if (isset($_GET['action']) && $_GET['action']=='leave') { |
||||
$user_leaved = intval($_GET['u']); |
||||
//I can "leave me myself" |
||||
if (api_get_user_id() == $user_leaved) { |
||||
$usergroup->delete_user_rel_group($user_leaved, $group_id); |
||||
Display::addFlash( |
||||
Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false) |
||||
); |
||||
} |
||||
} |
||||
// add a user to a group if its open |
||||
if (isset($_GET['action']) && $_GET['action']=='join') { |
||||
// we add a user only if is a open group |
||||
$user_join = intval($_GET['u']); |
||||
if (api_get_user_id() == $user_join && !empty($group_id)) { |
||||
if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
||||
$usergroup->add_user_to_group($user_join, $group_id); |
||||
Display::addFlash( |
||||
Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false) |
||||
); |
||||
} else { |
||||
$usergroup->add_user_to_group($user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER); |
||||
Display::addFlash( |
||||
Display::return_message(get_lang('InvitationSent'), 'confirmation', false) |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
$create_thread_link = ''; |
||||
$social_right_content = null; |
||||
|
||||
$group_info = $usergroup->get($group_id); |
||||
|
||||
//Loading group information |
||||
if (isset($_GET['status']) && $_GET['status']=='sent') { |
||||
$social_right_content .= Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation', false); |
||||
} |
||||
|
||||
$is_group_member = $usergroup->is_group_member($group_id); |
||||
|
||||
if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) { |
||||
$role = $usergroup->get_user_group_role(api_get_user_id(), $group_id); |
||||
if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) { |
||||
$social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation')); |
||||
} |
||||
} |
||||
|
||||
if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
||||
if (!$is_group_member) { |
||||
if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) { |
||||
$social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>'; |
||||
} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) { |
||||
$social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>'; |
||||
} |
||||
$social_right_content .= '<br /><br />'; |
||||
} |
||||
$content = MessageManager::display_messages_for_group($group_id); |
||||
if ($is_group_member) { |
||||
if (empty($content)) { |
||||
$create_thread_link = '<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 btn" title="'.get_lang('ComposeMessage').'">'. |
||||
get_lang('YouShouldCreateATopic').'</a></li>'; |
||||
} else { |
||||
$create_thread_link = '<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 btn" title="'.get_lang('ComposeMessage').'">'. |
||||
get_lang('NewTopic').'</a>'; |
||||
} |
||||
} |
||||
$members = $usergroup->get_users_by_group($group_id, true); |
||||
$member_content = ''; |
||||
|
||||
// Members |
||||
if (count($members) > 0) { |
||||
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN) { |
||||
$member_content .= Display::url( |
||||
Display::return_icon('edit.gif', get_lang('EditMembersList')).' '.get_lang('EditMembersList'), |
||||
'group_members.php?id='.$group_id |
||||
); |
||||
} |
||||
foreach ($members as $member) { |
||||
// if is a member |
||||
if (in_array($member['relation_type'], array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))) { |
||||
//add icons |
||||
if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { |
||||
$icon= Display::return_icon('social_group_admin.png', get_lang('Admin')); |
||||
} elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { |
||||
$icon= Display::return_icon('social_group_moderator.png', get_lang('Moderator')); |
||||
} else{ |
||||
$icon= ''; |
||||
} |
||||
|
||||
$userPicture = UserManager::getUserPicture($member['user_id']); |
||||
|
||||
$member_content .= '<div class="">'; |
||||
$member_name = Display::url(api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).' '.$icon, $member['user_info']['profile_url']); |
||||
$member_content .= Display::div('<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="'.$userPicture.'"/> '.$member_name); |
||||
$member_content .= '</div>'; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (!empty($create_thread_link)) { |
||||
$create_thread_link = Display::div($create_thread_link, array('style'=>'padding-top:2px;height:40px')); |
||||
} |
||||
$headers = array(get_lang('Discussions'), get_lang('Members')); |
||||
$social_right_content .= Display::tabs($headers, array($content, $member_content),'tabs'); |
||||
} else { |
||||
// if I already sent an invitation message |
||||
if (!in_array( |
||||
$my_group_role, |
||||
array( |
||||
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, |
||||
GROUP_USER_PERMISSION_PENDING_INVITATION, |
||||
) |
||||
) |
||||
) { |
||||
$social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>'; |
||||
} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) { |
||||
$social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>'; |
||||
} |
||||
} |
||||
|
||||
$tpl = new Template(null); |
||||
|
||||
// Block Social Avatar |
||||
SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id); |
||||
//Block Social Menu |
||||
$social_menu_block = SocialManager::show_social_menu('groups', $group_id); |
||||
|
||||
$tpl->setHelp('Groups'); |
||||
|
||||
$tpl->assign('create_link', $create_thread_link); |
||||
$tpl->assign('is_group_member', $is_group_member); |
||||
$tpl->assign('group_info', $group_info); |
||||
|
||||
$tpl->assign('social_menu_block', $social_menu_block); |
||||
$tpl->assign('social_right_content', $social_right_content); |
||||
$social_layout = $tpl->get_template('social/group_view.tpl'); |
||||
$tpl->display($social_layout); |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,4 @@ |
||||
<div class="panel panel-info social-avatar"> |
||||
{{ socialAvatarBlock }} |
||||
<p class="lead">{{ group_info.complete_name }}</p> |
||||
</div> |
@ -0,0 +1,38 @@ |
||||
{% extends template ~ "/layout/layout_1_col.tpl" %} |
||||
|
||||
{% block content %} |
||||
<div class="row" xmlns="http://www.w3.org/1999/html"> |
||||
<div class="col-md-3"> |
||||
<div class="social-menu"> |
||||
{{ social_avatar_block }} |
||||
{{ social_menu_block }} |
||||
</div> |
||||
</div> |
||||
<div class="col-md-9" style="min-height:1px"> |
||||
|
||||
<div id="social-group-details"> |
||||
<h4>{{ group_info.name }}</h4> |
||||
</div> |
||||
|
||||
{{ create_link }} |
||||
|
||||
{% if is_group_member == false %} |
||||
<div class="social-group-details-info"> |
||||
{{ 'Privacy' | get_lang }} |
||||
|
||||
{% if group_info.visibility == 1 %} |
||||
{{ 'ThisIsAnOpenGroup' | get_lang }} |
||||
{% else %} |
||||
{{ 'ThisIsACloseGroup' | get_lang }} |
||||
{% endif %} |
||||
</div> |
||||
{% endif %} |
||||
|
||||
{{ social_right_content }} |
||||
|
||||
<div id="display_response_id" class="col-md-5"></div> |
||||
{{ social_auto_extend_link }} |
||||
</div> |
||||
|
||||
</div> |
||||
{% endblock %} |
Loading…
Reference in new issue