コード例 #1
0
 /**
  * Load rights of a profile/course
  */
 public function load($profile)
 {
     // Load toolAction of the parent
     parent::load($profile);
     $this->defaultToolActionList = $this->getToolActionList();
     // load value of action of the courseId
     $sql = " SELECT PA.action_id, PA.value, A.tool_id, A.name\n                 FROM `" . $this->tbl['rel_profile_action'] . "` `PA`,\n                      `" . $this->tbl['action'] . "` `A`\n                 WHERE PA.profile_id = " . $this->profile->id . "\n                 AND PA.action_id = A.id\n                 AND PA.courseId = '" . claro_sql_escape($this->courseId) . "'";
     $action_list = claro_sql_query_fetch_all($sql);
     // load all actions value for the profile
     foreach ($action_list as $this_action) {
         $actionName = $this_action['name'];
         $actionValue = (bool) $this_action['value'];
         $toolId = $this_action['tool_id'];
         if (isset($this->toolActionList[$toolId][$actionName])) {
             $this->toolActionList[$toolId][$actionName] = $actionValue;
         }
     }
     // Remove deactivated tool
     $sql = "SELECT t.id\n                FROM `" . $this->tbl['module'] . "`  AS m,\n                    `" . $this->tbl['course_tool'] . "` AS t\n                WHERE t.claro_label = m.label\n                  AND m.activation <> 'activated'";
     $deactivatedToolList = claro_sql_query_fetch_all($sql);
     foreach ($deactivatedToolList as $deactivatedTool) {
         if (isset($this->toolActionList[$deactivatedTool['id']])) {
             unset($this->toolActionList[$deactivatedTool['id']]);
         }
         if (isset($this->defaultToolActionList[$deactivatedTool['id']])) {
             unset($this->defaultToolActionList[$deactivatedTool['id']]);
         }
     }
 }
コード例 #2
0
ファイル: manage.lib.php プロジェクト: rhertzog/lcs
/**
 * Store all unique info about a tool during install
 * @param integer $moduleId
 * @param array $moduleToolData, data from manifest
 * @return int tool id or false
 */
function register_module_tool($moduleId, $module_info)
{
    $tbl = claro_sql_get_tbl('course_tool');
    if (is_array($module_info)) {
        $icon = array_key_exists('ICON', $module_info) ? "'" . claro_sql_escape($module_info['ICON']) . "'" : 'NULL';
        if (!isset($module_info['ENTRY'])) {
            $module_info['ENTRY'] = 'entry.php';
        }
        // find max rank in the course_tool table
        $sql = "SELECT MAX(def_rank) AS maxrank FROM `" . $tbl['course_tool'] . "`";
        $maxresult = claro_sql_query_get_single_row($sql);
        // insert the new course tool
        $sql = "INSERT INTO `" . $tbl['course_tool'] . "`\n                SET\n                claro_label = '" . claro_sql_escape($module_info['LABEL']) . "',\n                script_url = '" . claro_sql_escape($module_info['ENTRY']) . "',\n                icon = " . $icon . ",\n                def_access = 'ALL',\n                def_rank = (" . (int) $maxresult['maxrank'] . "+1),\n                add_in_course = 'AUTOMATIC',\n                access_manager = 'COURSE_ADMIN' ";
        $tool_id = claro_sql_query_insert_id($sql);
        // Init action/right
        // Manage right - Add read action
        $action = new RightToolAction();
        $action->setName('read');
        $action->setToolId($tool_id);
        $action->save();
        // Manage right - Add edit action
        $action = new RightToolAction();
        $action->setName('edit');
        $action->setToolId($tool_id);
        $action->save();
        // Init all profile/right
        $profileList = array_keys(claro_get_all_profile_name_list());
        foreach ($profileList as $profileId) {
            $profile = new RightProfile();
            $profile->load($profileId);
            $profileRight = new RightProfileToolRight();
            $profileRight->load($profile);
            if (claro_get_profile_id('manager') == $profileId) {
                $profileRight->setToolRight($tool_id, 'manager');
            } else {
                $profileRight->setToolRight($tool_id, 'user');
            }
            $profileRight->save();
        }
        return $tool_id;
    } else {
        return false;
    }
}
コード例 #3
0
function init_default_right_profile()
{
    require_once get_conf('includePath') . '/lib/right/profileToolRight.class.php';
    $tbl_mdb_names = claro_sql_get_tbl(array('course_tool', 'right_profile', 'right_rel_profile_action', 'right_action'));
    $sql = " SELECT `id` as `toolId`\n             FROM `" . $tbl_mdb_names['course_tool'] . "`";
    $result = claro_sql_query_fetch_all_cols($sql);
    $toolList = $result['toolId'];
    /**
     * Initialise anonymous profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(ANONYMOUS_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'user');
    $profileAction->save();
    /**
     * Initialise guest profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(GUEST_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'user');
    $profileAction->save();
    /**
     * Initialise user profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(USER_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'user');
    $profileAction->save();
    /**
     * Initialise manager profile
     */
    $profile = new RightProfile();
    $profile->load(claro_get_profile_id(MANAGER_PROFILE));
    $profileAction = new RightProfileToolRight();
    $profileAction->load($profile);
    $profileAction->setToolListRight($toolList, 'manager');
    $profileAction->save();
    return true;
}
コード例 #4
0
ファイル: profile.php プロジェクト: rhertzog/lcs
// Display section
//=================================
// define bredcrumb
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Rights'), get_path('rootAdminWeb') . 'right/profile.php?display_profile=' . $display_profile_url_param);
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Course profile list'), get_path('rootAdminWeb') . 'right/profile_list.php');
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Administration'), get_path('rootAdminWeb'));
$dialogBox = new DialogBox();
$out = '';
// Set display right
$profileRightHtml = new RightProfileToolRightHtml();
$profileRightHtml->addUrlParam('display_profile', $display_profile_url_param);
$profileFoundCount = 0;
foreach ($display_profile_list as $profileId) {
    $profile = new RightProfile();
    if ($profile->load($profileId)) {
        $profileRight = new RightProfileToolRight();
        $profileRight->load($profile);
        $profileRightHtml->addRightProfileToolRight($profileRight);
        $profileFoundCount++;
    }
}
if ($profileFoundCount == 0) {
    $dialogBox->error(get_lang('Profile not found'));
    $out .= $dialogBox->render();
} else {
    if ($profileFoundCount == 1) {
        // display tool title
        $out .= claro_html_tool_title(array('mainTitle' => get_lang('Manage Right'), 'subTitle' => $profile->getName()));
        $out .= '<p>' . $profile->getDescription() . '</p>';
        $out .= '<p><a href="' . $_SERVER['PHP_SELF'] . '?display_profile=all">' . get_lang('View all right profile') . '</a></p>';
    } else {