コード例 #1
0
ファイル: group.lib.inc.php プロジェクト: rhertzog/lcs
/**
 * Create a new group
 *
 * @param  string $groupName - name of the group
 * @param  integer $maxMember  - max user allowed for this group
 * @return integer : id of the new group
 *
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 */
function create_group($prefixGroupName, $maxMember)
{
    require_once dirname(__FILE__) . '/forum.lib.php';
    require_once dirname(__FILE__) . '/fileManage.lib.php';
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_groups = $tbl_cdb_names['group_team'];
    // Check name of group
    $sql = "SELECT name FROM  `" . $tbl_groups . "` WHERE name LIKE  '" . claro_sql_escape($prefixGroupName) . "%'";
    $existingGroupList = claro_sql_query_fetch_all_cols($sql);
    $existingGroupList = $existingGroupList['name'];
    $i = 1;
    do {
        $groupName = $prefixGroupName . str_pad($i, 4, ' ', STR_PAD_LEFT);
        $i++;
        if ($i - 2 > count($existingGroupList)) {
            die($groupName . 'infiniteloop');
        }
    } while (in_array($groupName, $existingGroupList));
    /**
     * Create a directory allowing group student to upload documents
     */
    //  Create a Unique ID path preventing other enter
    $globalPath = $GLOBALS['coursesRepositorySys'] . $GLOBALS['currentCourseRepository'] . '/group/';
    do {
        $groupRepository = str_replace(' ', '_', substr(uniqid(substr($groupName, 0, 19) . ' ', ''), 0, 30));
    } while (check_name_exist($globalPath . $groupRepository));
    claro_mkdir($globalPath . $groupRepository, CLARO_FILE_PERMISSIONS);
    /*
     * Insert a new group in the course group table and keep its ID
     */
    $sql = "INSERT INTO `" . $tbl_groups . "`\n            SET name = '" . $groupName . "',\n               `maxStudent`  = " . (is_null($maxMember) ? 'NULL' : "'" . (int) $maxMember . "'") . ",\n                secretDirectory = '" . claro_sql_escape($groupRepository) . "'";
    $createdGroupId = claro_sql_query_insert_id($sql);
    /*
     * Create a forum for the group in the forum table
     */
    if (is_tool_activated_in_course(get_tool_id_from_module_label('CLFRM'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLFRM')) {
        create_forum($groupName . ' - ' . strtolower(get_lang('Forum')), '', 2, (int) GROUP_FORUMS_CATEGORY, '', $createdGroupId);
    }
    if (is_tool_activated_in_course(get_tool_id_from_module_label('CLWIKI'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLWIKI')) {
        require_once get_module_path('CLWIKI') . '/lib/lib.createwiki.php';
        create_wiki($createdGroupId, $groupName . ' - Wiki');
    }
    return $createdGroupId;
}
コード例 #2
0
ファイル: helpers.lib.php プロジェクト: rhertzog/lcs
/**
 * @param int $gid 
 * @param string $courseId 
 * @param boolean $active if set to true, only actvated tool will be considered for display
 */
function get_group_tool_menu($gid = null, $courseId = null, $active = true)
{
    $toolList = array();
    if (is_null($gid)) {
        $gid = claro_get_current_group_id();
    }
    if (is_null($courseId)) {
        $courseId = claro_get_current_course_id();
    }
    require_once dirname(__FILE__) . '/../group.lib.inc.php';
    $groupToolList = get_group_tool_list($courseId, $active);
    // group space links
    /* $toolList[] =
       claro_html_cmd_link(
           claro_htmlspecialchars(Url::Contextualize( get_module_url('CLGRP').'/group_space.php' ))
           , '<img src="' . get_icon_url('group') . '" alt="" />&nbsp;'
           . get_lang('Group area')
       ); */
    $courseGroupData = claro_get_main_group_properties($courseId);
    foreach ($groupToolList as $groupTool) {
        if (is_tool_activated_in_groups($courseId, $groupTool['label']) && (isset($courseGroupData['tools'][$groupTool['label']]) && $courseGroupData['tools'][$groupTool['label']])) {
            $toolList[] = claro_html_cmd_link(claro_htmlspecialchars(Url::Contextualize(get_module_url($groupTool['label']) . '/' . $groupTool['url'])), '<img src="' . get_module_url($groupTool['label']) . '/' . $groupTool['icon'] . '" alt="" />' . '&nbsp;' . claro_get_tool_name($groupTool['label']), array('class' => $groupTool['visibility'] ? 'visible' : 'invisible'));
        }
    }
    if (count($toolList)) {
        return claro_html_menu_horizontal($toolList);
    } else {
        return '';
    }
}
コード例 #3
0
    }
    if (get_module_data($tlabelReq, 'type') == 'crsmanage' && !(claro_is_course_manager() || claro_is_platform_admin())) {
        if (!claro_is_user_authenticated()) {
            claro_disp_auth_form(true);
        } else {
            claro_die(get_lang('Not allowed'));
        }
    }
    if ($tlabelReq !== 'CLWRK' && $tlabelReq !== 'CLGRP' && !claro_is_module_allowed() && !(isset($_SESSION['inPathMode']) && $_SESSION['inPathMode'] && ($tlabelReq == 'CLQWZ' || $tlabelReq == 'CLDOC'))) {
        if (!claro_is_user_authenticated()) {
            claro_disp_auth_form(true);
        } else {
            claro_die(get_lang('Not allowed'));
        }
    }
    if ($tlabelReq !== 'CLGRP' && $tlabelReq !== 'CLWRK' && claro_is_in_a_group() && (!claro_is_group_allowed() || !claro_is_allowed_to_edit() && !is_tool_activated_in_groups($_cid, $tlabelReq))) {
        claro_die(get_lang('Not allowed'));
    }
    /*----------------------------------------------------------------------
          Install module
      ----------------------------------------------------------------------*/
    if (claro_is_in_a_course() && !is_module_installed_in_course($tlabelReq, claro_get_current_course_id())) {
        install_module_database_in_course($tlabelReq, claro_get_current_course_id());
    }
}
/*----------------------------------------------------------------------
  Context from URL
  ----------------------------------------------------------------------*/
// if page is called from another tool ... (from LP for an example)
if (isset($_REQUEST['calledFrom'])) {
    $calledFrom = $_REQUEST['calledFrom'];