Ejemplo n.º 1
0
/********************
* CONNECTION SECTION
*********************/
$is_allowedToManage = claro_is_allowed_to_edit();
/*
* DB tables definition
*/
$tbl_cdb_names = claro_sql_get_course_tbl();
$tbl_mdb_names = claro_sql_get_main_tbl();
$tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
$tbl_user = $tbl_mdb_names['user'];
$tbl_bb_forum = $tbl_cdb_names['bb_forums'];
$tbl_group_rel_team_user = $tbl_cdb_names['group_rel_team_user'];
$tbl_group_team = $tbl_cdb_names['group_team'];
/****************************************************************************/
$_groupProperties = claro_get_current_group_properties_data();
// COUNT IN HOW MANY GROUPS CURRENT USER ARE IN
// (needed to give or refuse selfreg right)
$groupMemberCount = group_count_students_in_group(claro_get_current_group_id());
$groupMemberQuotaExceeded = (bool) (!is_null(claro_get_current_group_data('maxMember')) && claro_get_current_group_data('maxMember') <= $groupMemberCount);
// no limit assign to group per user;
$userGroupRegCount = group_count_group_of_a_user(claro_get_current_user_id());
// The previous request compute the quantity of subscription for the current user.
// the following request compare with the quota of subscription allowed to each student
$userGroupQuotaExceeded = (bool) ($_groupProperties['nbGroupPerUser'] <= $userGroupRegCount && !is_null($_groupProperties['nbGroupPerUser']) && $_groupProperties['nbGroupPerUser'] != 'ALL');
// no limit assign to group per user;
$is_allowedToSelfRegInGroup = (bool) ($_groupProperties['registrationAllowed'] && !$groupMemberQuotaExceeded && !$userGroupQuotaExceeded && (!claro_is_course_tutor() || claro_is_course_tutor() && get_conf('tutorCanBeSimpleMemberOfOthersGroupsAsStudent')));
$is_allowedToSelfRegInGroup = (bool) $is_allowedToSelfRegInGroup && claro_is_in_a_course() && !claro_is_group_member() && claro_is_course_member();
$is_allowedToSelfUnregInGroup = (bool) $_groupProperties['unregistrationAllowed'] && claro_is_in_a_course() && claro_is_group_member() && claro_is_course_member();
$is_allowedToDocAccess = (bool) (claro_is_course_manager() || claro_is_group_member() || claro_is_group_tutor());
$is_allowedToChatAccess = (bool) (claro_is_course_manager() || claro_is_group_member() || claro_is_group_tutor());
Ejemplo n.º 2
0
 * @version     $Revision: 14314 $
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @copyright   (c) 2001 The phpBB Group
 * @author      Claroline Team <*****@*****.**>
 * @author      FUNDP - WebCampus <*****@*****.**>
 * @license     http://www.gnu.org/copyleft/gpl.html
 *              GNU GENERAL PUBLIC LICENSE version 2 or later
 * @package     CLFRM
 */
$tlabelReq = 'CLFRM';
require '../inc/claro_init_global.inc.php';
require_once get_path('incRepositorySys') . '/lib/forum.lib.php';
require_once get_path('incRepositorySys') . '/lib/group.lib.inc.php';
require_once get_path('incRepositorySys') . '/lib/user.lib.php';
$last_visit = claro_get_current_user_data('lastLogin');
$is_groupPrivate = claro_get_current_group_properties_data('private');
$is_allowedToEdit = claro_is_allowed_to_edit();
if (!claro_is_in_a_course() || !claro_is_course_allowed()) {
    claro_disp_auth_form(true);
}
if (isset($_REQUEST['searchUser'])) {
    $sqlClauseString = ' p.poster_id = ' . (int) $_REQUEST['searchUser'];
} elseif (isset($_REQUEST['searchPattern'])) {
    $searchPatternString = trim($_REQUEST['searchPattern']);
    if ($searchPatternString != '') {
        $searchPatternList = explode(' ', $searchPatternString);
        $sqlClauseList = '';
        foreach ($searchPatternList as $thisSearchPattern) {
            $thisSearchPattern = str_replace('_', '\\_', $thisSearchPattern);
            $thisSearchPattern = str_replace('%', '\\%', $thisSearchPattern);
            $thisSearchPattern = str_replace('?', '_', $thisSearchPattern);
Ejemplo n.º 3
0
/**
 * This dirty function is a blackbox to provide normalised output of tool list for a group
 * like  get_course_tool_list($course_id=NULL) in course_home.
 *
 * It's dirty because data structure is dirty.
 * Tool_list (with clarolabel and tid come from tool tables and  group properties and localinit)
 * @param $course_id
 * @param boolean $active, if set to true, only activated tools of the platform must be returned
 * @author Christophe Gesche <*****@*****.**>
 * @return array
 */
function get_group_tool_list($course_id = NULL, $active = true)
{
    global $forumId;
    $_groupProperties = claro_get_current_group_properties_data();
    $isAllowedToEdit = claro_is_course_manager() || claro_is_platform_admin();
    $tbl = claro_sql_get_main_tbl(array('module', 'course_tool'));
    $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
    $tbl['course_tool'] = $tbl_cdb_names['tool'];
    // This stupid array is an hack to simulate the context
    // managing by module structure
    // It's represent tools aivailable to work in a group context.
    // $aivailable_tool_in_group = array('CLFRM','CLCHT','CLDOC','CLWIKI');
    $sql = "\nSELECT tl.id                               id,\n       tl.script_name                      name,\n       tl.visibility                       visibility,\n       tl.rank                             rank,\n       IFNULL(ct.script_url,tl.script_url) url,\n       ct.claro_label                      label,\n       ct.icon                             icon,\n       m.activation                        activation\nFROM      `" . $tbl['course_tool'] . "`       tl\nLEFT JOIN `" . $tbl['tool'] . "` `ct`\nON        ct.id = tl.tool_id\nLEFT JOIN `" . $tbl['module'] . "` `m`\nON        m.label = ct.claro_label\nLEFT JOIN `" . $tbl['module_contexts'] . "` `mc`\nON        m.id = mc.module_id\nWHERE `mc`.`context` = 'group'\nORDER BY tl.rank\n\n";
    $tool_list = claro_sql_query_fetch_all($sql);
    $group_tool_list = array();
    foreach ($tool_list as $tool) {
        $tool['label'] = trim($tool['label'], '_');
        if ($active !== true || 'activated' == $tool['activation']) {
            switch ($tool['label']) {
                case 'CLFRM':
                    if (!empty($_groupProperties['tools']['CLFRM']) || $isAllowedToEdit) {
                        $tool['url'] = 'viewforum.php?forum=' . $forumId . claro_url_relay_context('&amp;');
                        $group_tool_list[] = $tool;
                    }
                    break;
                default:
                    if (isset($_groupProperties['tools'][$tool['label']]) && $_groupProperties['tools'][$tool['label']] || $isAllowedToEdit) {
                        $tool['url'] .= claro_url_relay_context('?');
                        $group_tool_list[] = $tool;
                    }
                    break;
            }
        }
    }
    return $group_tool_list;
}
Ejemplo n.º 4
0
function printInit($selection = "*")
{
    global $uidReset, $cidReset, $gidReset, $tidReset, $uidReq, $cidReq, $gidReq, $tidReq, $tlabelReq, $_user, $_course, $_groupUser, $_courseTool, $_SESSION, $_claro_local_run;
    if ($_claro_local_run) {
        echo "local init runned";
    } else {
        echo '<font color="red"> local init never runned during this script </font>';
    }
    echo '
<table width="100%" border="1" cellspacing="4" cellpadding="1" bordercolor="#808080" bgcolor="#C0C0C0" lang="en">
    <TR>';
    if ($selection == "*" or strstr($selection, "u")) {
        echo '
        <TD valign="top" >
            <strong>User</strong> :
            (_uid)             : ' . var_export(claro_get_current_user_id(), 1) . ' |
            (session[_uid]) : ' . var_export($_SESSION["_uid"], 1) . '
            <br />
            reset = ' . var_export($uidReset, 1) . ' |
            req = ' . var_export($uidReq, 1) . '<br />
            _user : <pre>' . var_export($_user, 1) . '</pre>
            <br />is_platformAdmin            :' . var_export(claro_is_platform_admin(), 1) . '
            <br />is_allowedCreateCourse    :' . var_export(claro_is_allowed_to_create_course(), 1) . '
        </TD>';
    }
    if ($selection == "*" or strstr($selection, "c")) {
        echo "\n        <TD valign=\"top\" >\n            <strong>Course</strong> : (_cid)" . var_export(claro_get_current_course_id(), 1) . "\n            <br />\n            reset = " . var_export($cidReset, 1) . " | req = " . var_export($cidReq, 1) . "\n            <br />\n            _course : <pre>" . var_export($_course, 1) . "</pre>\n            <br />\n            _groupProperties :\n            <PRE>\n                " . var_export(claro_get_current_group_properties_data(), 1) . "\n            </PRE>\n        </TD>";
    }
    echo '
    </TR>
    <TR>';
    if ($selection == "*" or strstr($selection, "g")) {
        echo '<TD valign="top" ><strong>Group</strong> : (_gid) ' . var_export(claro_get_current_group_id(), 1) . '<br />
        reset = ' . var_export($GLOBALS['gidReset'], 1) . ' | req = ' . var_export($gidReq, 1) . "<br />\n        _group :<pre>" . var_export(claro_get_current_group_data(), 1) . "</pre></TD>";
    }
    if ($selection == "*" or strstr($selection, "t")) {
        echo '<TD valign="top" ><strong>Tool</strong> : (_tid)' . var_export(claro_get_current_tool_id(), 1) . '<br />
        reset = ' . var_export($tidReset, 1) . ' |
        req = ' . var_export($tidReq, 1) . '|
        req = ' . var_export($tlabelReq, 1) . '
        <br />
        _tool :' . var_export(get_init('_tool'), 1) . "</TD>";
    }
    echo "</TR>";
    if ($selection == "*" or strstr($selection, "u") && strstr($selection, "c")) {
        echo '<TR><TD valign="top" colspan="2"><strong>Course-User</strong>';
        if (claro_is_user_authenticated()) {
            echo '<br /><strong>User</strong> :' . var_export(claro_is_in_a_course(), 1);
        }
        if (claro_is_in_a_course()) {
            echo ' in ' . var_export(claro_get_current_course_id(), 1) . '<br />';
        }
        if (claro_is_user_authenticated() && claro_get_current_course_id()) {
            echo '_courseUser            : <pre>' . var_export(getInit('_courseUser'), 1) . '</pre>';
        }
        echo '<br />is_courseMember    : ' . var_export(claro_is_course_member(), 1);
        echo '<br />is_courseAdmin    : ' . var_export(claro_is_course_manager(), 1);
        echo '<br />is_courseAllowed    : ' . var_export(claro_is_course_allowed(), 1);
        echo '<br />is_courseTutor    : ' . var_export(claro_is_course_tutor(), 1);
        echo '</TD></TR>';
    }
    echo "";
    if ($selection == "*" or strstr($selection, "u") && strstr($selection, "g")) {
        echo '<TR><TD valign="top"  colspan="2">' . '<strong>Course-Group-User</strong>';
        if (claro_is_user_authenticated()) {
            echo '<br /><strong>User</strong> :' . var_export(claro_is_in_a_course(), 1);
        }
        if (claro_is_in_a_group()) {
            echo ' in ' . var_export(claro_get_current_group_id(), 1);
        }
        if (claro_is_in_a_group()) {
            echo '<br />_groupUser:'******'_groupUser'), 1);
        }
        echo '<br />is_groupMember:' . var_export(claro_is_group_member(), 1) . '<br />is_groupTutor: ' . var_export(claro_is_group_tutor(), 1) . '<br />is_groupAllowed:' . var_export(claro_is_group_allowed(), 1) . '</TD>' . '</tr>';
    }
    if ($selection == "*" or strstr($selection, "c") && strstr($selection, "t")) {
        echo '<tr>
        <TD valign="top" colspan="2" ><strong>Course-Tool</strong><br />';
        if (claro_get_current_tool_id()) {
            echo 'Tool :' . claro_get_current_tool_id();
        }
        if (claro_is_in_a_course()) {
            echo ' in ' . claro_get_current_course_id() . '<br />';
        }
        if (claro_get_current_tool_id()) {
            echo "_courseTool    : <pre>" . var_export($_courseTool, 1) . '</pre><br />';
        }
        echo 'is_toolAllowed : ' . var_export(claro_is_tool_allowed(), 1);
        echo "</TD>";
    }
    echo "</TR></TABLE>";
}
Ejemplo n.º 5
0
function get_access_mode_to_group_forum($forum)
{
    if (claro_is_user_authenticated()) {
        $userGroupList = get_user_group_list(claro_get_current_user_id());
        $userGroupList = array_keys($userGroupList);
        $tutorGroupList = get_tutor_group_list(claro_get_current_user_id());
    } else {
        $userGroupList = array();
        $tutorGroupList = array();
    }
    $is_groupPrivate = claro_get_current_group_properties_data('private');
    $group_id = is_null($forum['group_id']) ? null : (int) $forum['group_id'];
    if (!is_null($group_id)) {
        if (in_array($group_id, $userGroupList) || in_array($group_id, $tutorGroupList) || !$is_groupPrivate || claro_is_allowed_to_edit()) {
            if (is_array($tutorGroupList) && in_array($group_id, $tutorGroupList)) {
                $accessMode = 'tutor';
            } elseif (is_array($userGroupList) && in_array($group_id, $userGroupList)) {
                $accessMode = 'member';
            } else {
                $accessMode = 'visitor';
            }
        } else {
            $accessMode = 'private';
        }
        return $accessMode;
    }
    return false;
}