Example #1
0
/**
 * functions that check if sharing is allowed for a course
 * @param int $course_id
 * @return boolean
 */
function is_sharing_allowed($course_id) {
    if (get_config('enable_social_sharing_links') && course_status($course_id) == COURSE_OPEN) { //sharing is allowed only for open courses
        return true;
    }
    else {
        return false;
    }
}
Example #2
0
            if ($is_dir) {
                $tool_content .= "<td>&nbsp;</td><td class='center'>{$date}</td>";
            } else {
                if ($entry['format'] == ".meta") {
                    $size = format_file_size($entry['size']);
                    $tool_content .= "<td class='center'>{$size}</td><td class='center'>{$date}</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $tool_content .= "<td class='center'>{$size}</td><td class='center' title='{$date_with_time}'>{$date}</td>";
                }
            }
            if (!$is_in_tinymce) {
                if ($can_upload) {
                    $tool_content .= "<td class='option-btn-cell'>";
                    $xmlCmdDirName = $entry['format'] == ".meta" && get_file_extension($cmdDirName) == "xml" ? substr($cmdDirName, 0, -4) : $cmdDirName;
                    $tool_content .= action_button(array(array('title' => $langGroupSubmit, 'url' => "{$urlAppend}modules/work/group_work.php?course={$course_code}&amp;group_id={$group_id}&amp;submit={$cmdDirName}", 'icon' => 'fa-book', 'show' => $subsystem == GROUP and isset($is_member) and $is_member), array('title' => $dload_msg, 'url' => $download_url, 'icon' => 'fa-save'), array('title' => $langVisible, 'url' => "{$base_url}" . ($entry['visible'] ? "mkInvisibl={$cmdDirName}" : "mkVisibl={$cmdDirName}"), 'icon' => $entry['visible'] ? 'fa-eye' : 'fa-eye-slash'), array('title' => $langResourceAccess, 'url' => "{$base_url}limited={$cmdDirName}", 'icon' => 'fa-unlock', 'show' => $course_id > 0 and course_status($course_id) == COURSE_OPEN and $entry['public']), array('title' => $langMove, 'url' => "{$base_url}move={$cmdDirName}", 'icon' => 'fa-arrows', 'show' => $entry['format'] != '.meta'), array('title' => $langRename, 'url' => "{$base_url}rename={$cmdDirName}", 'icon' => 'fa-repeat', 'show' => $entry['format'] != '.meta'), array('title' => $langComments, 'url' => "{$base_url}comment={$cmdDirName}", 'icon' => 'fa-comment-o', 'show' => $entry['format'] != '.meta'), array('title' => $langReplace, 'url' => "{$base_url}replace={$cmdDirName}", 'icon' => 'fa-reply', 'show' => !$is_dir && $entry['format'] != '.meta'), array('title' => $langMetadata, 'url' => "{$base_url}metadata={$xmlCmdDirName}", 'icon' => 'fa-tags', 'show' => get_config("insert_xml_metadata")), array('title' => $langResourceAccess, 'url' => "{$base_url}public={$cmdDirName}", 'icon' => 'fa-lock', 'show' => $course_id > 0 and course_status($course_id) == COURSE_OPEN and !$entry['public']), array('title' => $langDelete, 'url' => "{$base_url}filePath={$cmdDirName}&amp;delete=1", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => "{$langConfirmDelete} {$entry['filename']}")));
                    $tool_content .= "</td>";
                } else {
                    // student view
                    $tool_content .= "<td class='text-center'>" . icon('fa-save', $dload_msg, $download_url) . "</td>";
                }
            }
            $tool_content .= "</tr>";
        }
    }
    $tool_content .= "</table>\n            </div>\n        </div>\n    </div>";
    if ($can_upload && !$is_in_tinymce) {
        $tool_content .= "<br><div class='text-right'>{$langMaxFileSize} " . ini_get('upload_max_filesize') . "</div>";
    }
}
if (defined('SAVED_COURSE_CODE')) {
Example #3
0
    header("Location: ${urlServer}");
    exit();
}

if ($uid) {
    require_once 'include/action.php';
    $action = new action();
    $action->record(MODULE_ID_VIDEO);
}

// ----------------------
// download video
// ----------------------
$res2 = Database::get()->querySingle("SELECT * FROM video
                  WHERE course_id = ?d AND id = ?d", $course_id, $_GET['id']);

if (!$res2) {
    header("Location: ${urlServer}");
    exit();
}

$valid = ($uid || course_status($course_id) == COURSE_OPEN) ? true : token_validate($row2['path'], $_GET['token'], 30);
if (!$valid) {
    header("Location: ${urlServer}");
    exit();
}

$vObj = MediaResourceFactory::initFromVideo($res2);
$real_file = $webDir . "/video/" . q($_GET['course']) . q($vObj->getPath());
send_file_to_client($real_file, my_basename(q($vObj->getUrl())), $disposition, true);
Example #4
0
        	$checkCommentEn = "";
        }
        if (setting_get(SETTING_BLOG_RATING_ENABLE, $course_id) == 1) {
        	$checkRatingDis = "";
        	$checkRatingEn = "checked ";
        } else {
        	$checkRatingDis = "checked ";
        	$checkRatingEn = "";
        }
        if (!$sharing_allowed) {
            $sharing_radio_dis = " disabled";
            $sharing_dis_label = "<tr><td><em>";
            if (!get_config('enable_social_sharing_links')) {
                $sharing_dis_label .= $langSharingDisAdmin;
            }
            if (course_status($course_id) != COURSE_OPEN) {
                $sharing_dis_label .= " ".$langSharingDisCourse;
            }
            $sharing_dis_label .= "</em></td></tr>";
        } else {
            $sharing_radio_dis = "";
            $sharing_dis_label = "";
        }
		
        if ($sharing_enabled == 1) {
            $checkSharingDis = "";
            $checkSharingEn = "checked";
        } else {
            $checkSharingDis = "checked";
            $checkSharingEn = "";
        }
Example #5
0
 /**
  * Check if a user has permission to rate course resources
  * @param isEditor boolean showing if user is teacher
  * @param uid the user id
  * @param courseId the course id
  * @return boolean
  */
 public static function permRate($isEditor, $uid, $courseId, $rtype)
 {
     if ($rtype == 'course') {
         if (course_status($courseId) == COURSE_OPEN and setting_get(SETTING_COURSE_ANONYMOUS_RATING_ENABLE, $courseId) == 1) {
             return true;
         }
     }
     if ($isEditor) {
         //teacher is always allowed to rate
         return true;
     } else {
         //students allowed to rate
         $sql = "SELECT COUNT(`user_id`) as c FROM `course_user` WHERE `course_id` = ?d AND `user_id` = ?d";
         $result = Database::get()->querySingle($sql, $courseId, $uid);
         if ($result->c > 0) {
             //user is course member
             return true;
         } else {
             //user is not course member
             return false;
         }
     }
 }
Example #6
0
 }
 $langModify_temp = htmlspecialchars($langModify);
 $langConfirmYourChoice_temp = addslashes(htmlspecialchars($langConfirmYourChoice));
 $langDelete_temp = htmlspecialchars($langDelete);
 
 $tool_content .= "<td class='option-btn-cell'>".action_button(array(
         array('title' => $langEditChange,
               'url' => "admin.php?course=$course_code&amp;exerciseId=$row->id",
               'icon' => 'fa-edit'),
         array('title' => $row->active ?  $langViewHide : $langViewShow,
               'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;".($row->active ? "choice=disable" : "choice=enable").(isset($page) ? "&amp;page=$page" : "")."&amp;exerciseId=" . $row->id,
               'icon' => $row->active ? 'fa-eye-slash' : 'fa-eye' ),
         array('title' => $row->public ? $langResourceAccessLock : $langResourceAccessUnlock,
               'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;".($row->public ? "choice=limited" : "choice=public")."&amp;exerciseId=$row->id",
               'icon' => $row->public ? 'fa-lock' : 'fa-unlock',
               'show' => course_status($course_id) == COURSE_OPEN),
         array('title' => $langUsage,
               'url' => "exercise_stats.php?course=$course_code&amp;exerciseId=$row->id",
               'icon' => 'fa-line-chart'),
         array('title' => $langCreateDuplicate,
               'icon-class' => 'warnLink',
               'icon-extra' => "data-exerciseid='$row->id'",
               'url' => "#",
               'icon' => 'fa-copy'),
         array('title' => $langPurgeExerciseResults,
               'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=purge&amp;exerciseId=$row->id",
               'icon' => 'fa-eraser',
               'confirm' => $langConfirmPurgeExerciseResults),
         array('title' => $langDelete,
               'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=delete&amp;exerciseId=$row->id",
               'icon' => 'fa-times',
Example #7
0
function rss_check_access()
{
    global $course_code, $course_id, $course_status, $module_id;
    if (isset($_GET['c'])) {
        $course_code = $_GET['c'];
        $course_id = course_code_to_id($course_code);
        $course_status = course_status($course_id);
    } else {
        $course_code = '';
        $course_id = false;
    }
    if ($course_id === false) {
        header("HTTP/1.0 404 Not Found");
        echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head>', '<title>404 Not Found</title></head><body>', '<h1>Not Found</h1><p>The requested course "', htmlspecialchars($course_code), '" does not exist.</p></body></html>';
        exit;
    }
    if ($course_status == COURSE_INACTIVE or !visible_module($module_id) or $course_status != COURSE_OPEN and !(isset($_GET['token']) and isset($_GET['uid']) and rss_token_valid($_GET['token'], $_GET['uid']))) {
        forbidden($_SERVER['REQUEST_URI']);
    }
}
Example #8
0
    // $disk_path is set if common file link
    $disk_path = common_doc_path($file_info->extra_path, true);
    if (!$disk_path) {
        // external file URL
        header("Location: {$file_info->extra_path}");
        exit;
    } elseif (!$common_doc_visible) {
        forbidden(preg_replace('/^.*file\\.php/', '', $uri));
    }
} else {
    // Normal file
    $disk_path = $basedir . $file_info->path;
}
if (file_exists($disk_path)) {
    if (!$is_in_playmode) {
        $valid = $uid || course_status($course_id) == COURSE_OPEN ? true : token_validate($file_info->path, $_GET['token'], 30);
        if (!$valid) {
            not_found(preg_replace('/^.*file\\.php/', '', $uri));
            exit;
        }
        send_file_to_client($disk_path, $file_info->filename);
    } else {
        require_once 'include/lib/fileDisplayLib.inc.php';
        require_once 'include/lib/multimediahelper.class.php';
        $mediaPath = file_url($file_info->path, $file_info->filename);
        $mediaURL = $urlServer . 'modules/document/index.php?course=' . $course_code . '&amp;download=' . $file_info->path;
        if (defined('GROUP_DOCUMENTS')) {
            $mediaURL = $urlServer . 'modules/group/index.php?course=' . $course_code . '&amp;group_id=' . $group_id . '&amp;download=' . $file_info->path;
        }
        $token = token_generate($file_info->path, true);
        $mediaAccess = $mediaPath . '?token=' . $token;
Example #9
0
/**
 * @brief checks if user is notified via email from a given course 
 * @param type $user_id
 * @param type $course_id
 * @return boolean
 */
function get_user_email_notification($user_id, $course_id = null)
{
    // checks if a course is active or not
    if (isset($course_id)) {
        if (course_status($course_id) == COURSE_INACTIVE) {
            return false;
        }
    }
    // checks if user has verified his email address
    if (get_config('email_verification_required') && get_config('dont_mail_unverified_mails')) {
        $verified_mail = get_mail_ver_status($user_id);
        if ($verified_mail == EMAIL_VERIFICATION_REQUIRED or $verified_mail == EMAIL_UNVERIFIED) {
            return false;
        }
    }
    // checks if user has choosen not to be notified by email from all courses
    if (!get_user_email_notification_from_courses($user_id)) {
        return false;
    }
    if (isset($course_id)) {
        // finally checks if user has choosen not to be notified from a specific course
        $r = Database::get()->querySingle("SELECT receive_mail FROM course_user\n                                            WHERE user_id = ?d\n                                            AND course_id = ?d", $user_id, $course_id);
        if ($r) {
            $row = $r->receive_mail;
            return $row;
        } else {
            return false;
        }
    }
    return true;
}
Example #10
0
/**
 * @brief display links of category (if category is defined) else display all
 * @global type $is_in_tinymce
 * @global type $themeimg
 * @global type $tool_content
 * @global type $is_editor
 * @global type $course_id
 * @global type $course_code
 * @global type $langDelete
 * @global type $langViewHide
 * @global type $langViewShow
 * @global type $langPreview
 * @global type $langDownload
 * @global type langResourceAccessLock
 * @global type langResourceAccessUnlock
 * @global type $langEditChange
 * @global type $langConfirmDelete
 * @global type $filterv
 * @global type $filterl
 * @param type $cat_id
 */
function showlinksofcategory($cat_id = 0) {
    global $course_id, $is_in_tinymce, $tool_content, $is_editor, $course_code,
        $langDelete, $langViewHide, $langViewShow, $langConfirmDelete,
        $display_tools, $is_in_tinymce, $langDownload, $langResourceAccessLock,
        $langResourceAccessUnlock, $langEditChange, $filterv, $filterl, $order,
        $compatiblePlugin, $langcreator, $langpublisher;

    if ($is_editor) {
        $vis_q = '';
    } else {
        $vis_q = "AND visible = 1";
    }
    if ($cat_id > 0) {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id);
    } else {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id);
    }

    foreach ($results as $table => $result) {
        foreach ($result as $myrow) {
            $myrow->course_id = $course_id;
            if (resource_access($myrow->visible, $myrow->public) || $is_editor) {
                switch ($table) {
                    case 'video':
                        $vObj = MediaResourceFactory::initFromVideo($myrow);
                        if ($is_in_tinymce && !$compatiblePlugin) { // use Access/DL URL for non-modable tinymce plugins
                            $vObj->setPlayURL($vObj->getAccessURL());
                        }
                        $link_href = MultimediaHelper::chooseMediaAhref($vObj);
                        $link_to_save = $vObj->getAccessURL() . '&amp;attachment';
                        break;
                    case "videolink":
                        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
                        $link_href = MultimediaHelper::chooseMedialinkAhref($vObj);
                        $link_to_save = $vObj->getPath();
                        break;
                    default:
                        exit;
                }
                $row_class = !$myrow->visible ? "class='not_visible'" : "";
                $tool_content .= "<tr $row_class><td class='nocategory-link'>" . $link_href;
                if (!$is_in_tinymce and ( !empty($myrow->creator) or ! empty($myrow->publisher))) {
                    $tool_content .= '<br><small>';
                    if ($myrow->creator == $myrow->publisher) {
                        $tool_content .= "$langcreator: " . q($myrow->creator);
                    } else {
                        $emit = false;
                        if (!empty($myrow->creator)) {
                            $tool_content .= "$langcreator: " . q($myrow->creator);
                            $emit = true;
                        }
                        if (!empty($myrow->publisher)) {
                            $tool_content .= ($emit ? ', ' : '') . "$langpublisher: " . q($myrow->publisher);
                        }
                    }
                    $tool_content .= "</small>";
                }
                $tool_content .= "</td>
                    <td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td>";
                if (!$is_in_tinymce) {
                    if ($display_tools) {
                        $tool_content .= "<td class='option-btn-cell'>" .
                            action_button(array(
                                array('title' => $langEditChange,
                                     'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$myrow->id&amp;table_edit=$table",
                                     'icon' => 'fa-edit',
                                     'show' => !$is_in_tinymce and $is_editor),
                                array('title' => $myrow->visible ? $langViewHide : $langViewShow,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;vid=$myrow->id&amp;table=$table&amp;vis=" .
                                          ($myrow->visible ? '0' : '1'),
                                      'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'),
                                array('title' => $myrow->public ? $langResourceAccessLock : $langResourceAccessUnlock,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;vid=$myrow->id&amp;table=$table&amp;" .
                                         ($myrow->public ? 'limited=1' : 'public=1'),
                                      'icon' => $myrow->public ? 'fa-lock' : 'fa-unlock',
                                      'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN),
                                array('title' => $langDownload,
                                      'url' => $link_to_save,
                                      'icon' => 'fa-download'),
                                array('title' => $langDelete,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$myrow->id&amp;delete=yes&amp;table=$table",
                                      'icon' => 'fa-times',
                                      'confirm' => $langConfirmDelete,
                                      'class' => 'delete'))) .
                            "</td>";
                    } else {
                        $tool_content .= "<td class='text-center'>" .
                            ($table == 'video'? icon('fa-download', $langDownload, $link_to_save): '&nbsp;') .
                            '</td>';
                    }
                }
                $tool_content .= "</tr>";
            } // end of check resource access
        } // foreach row
    } // foreach table
}
Example #11
0
        header("Location: $file_info->extra_path");
        exit;
    } elseif (!$common_doc_visible) {
        forbidden(preg_replace('/^.*file\.php/', '', $uri));
    }
} else {
    // Normal file
    $disk_path = $basedir . $file_info->path;
}

if (file_exists($disk_path)) {
    if (!$is_in_playmode) {
        $valid = $uid ||
            defined('COMMON_DOCUMENTS') ||
            defined('MY_DOCUMENTS') ||
            course_status($course_id) == COURSE_OPEN ||
            (isset($_GET['token']) && token_validate($file_info->path, $_GET['token'], 30));
        if (!$valid) {
            not_found(preg_replace('/^.*file\.php/', '', $uri));
            exit();
        }
        send_file_to_client($disk_path, $file_info->filename);
    } else {
        require_once 'include/lib/fileDisplayLib.inc.php';
        require_once 'include/lib/multimediahelper.class.php';

        $mediaPath = file_url($file_info->path, $file_info->filename);
        $mediaURL = $urlServer . 'modules/document/index.php?course=' . $course_code . '&amp;download=' . $file_info->path;
        if (defined('GROUP_DOCUMENTS'))
            $mediaURL = $urlServer . 'modules/group/index.php?course=' . $course_code . '&amp;group_id=' . $group_id . '&amp;download=' . $file_info->path;
        $token = token_generate($file_info->path, true);
Example #12
0
/**
 * @brief display links of category (if category is defined) else display all
 * @global type $is_in_tinymce
 * @global type $themeimg
 * @global type $tool_content
 * @global type $is_editor
 * @global type $course_id
 * @global type $course_code
 * @global type $langDelete
 * @global type $langVisible
 * @global type $langPreview
 * @global type $langSave
 * @global type $langResourceAccess
 * @global type $langResourceAccess
 * @global type $langModify
 * @global type $langConfirmDelete
 * @global type $filterv
 * @global type $filterl
 * @param type $cat_id
 */
function showlinksofcategory($cat_id = 0)
{
    global $course_id, $is_in_tinymce, $themeimg, $tool_content, $is_editor, $course_code;
    global $langDelete, $langVisible, $langConfirmDelete;
    global $langPreview, $langSave, $langResourceAccess, $langResourceAccess, $langModify;
    global $filterv, $filterl, $compatiblePlugin, $langcreator, $langpublisher;
    if ($is_editor) {
        $vis_q = '';
    } else {
        $vis_q = "AND visible = 1";
    }
    if ($cat_id > 0) {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id);
    } else {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id);
    }
    $i = 0;
    foreach ($results as $table => $result) {
        foreach ($result as $myrow) {
            $myrow->course_id = $course_id;
            if (resource_access($myrow->visible, $myrow->public) || $is_editor) {
                switch ($table) {
                    case 'video':
                        $vObj = MediaResourceFactory::initFromVideo($myrow);
                        if ($is_in_tinymce && !$compatiblePlugin) {
                            // use Access/DL URL for non-modable tinymce plugins
                            $vObj->setPlayURL($vObj->getAccessURL());
                        }
                        $link_href = MultimediaHelper::chooseMediaAhref($vObj);
                        $link_to_save = $vObj->getAccessURL();
                        break;
                    case "videolink":
                        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
                        $link_href = MultimediaHelper::chooseMedialinkAhref($vObj);
                        $link_to_save = $vObj->getPath();
                        break;
                    default:
                        exit;
                }
                $row_class = !$myrow->visible ? "class='not_visible'" : "";
                $tool_content .= "<tr {$row_class}><td>" . $link_href;
                if (!$is_in_tinymce and (!empty($myrow->creator) or !empty($myrow->publisher))) {
                    $tool_content .= '<br><small>';
                    if ($myrow->creator == $myrow->publisher) {
                        $tool_content .= "{$langcreator}: " . q($myrow->creator);
                    } else {
                        $emit = false;
                        if (!empty($myrow->creator)) {
                            $tool_content .= "{$langcreator}: " . q($myrow->creator);
                            $emit = true;
                        }
                        if (!empty($myrow->publisher)) {
                            $tool_content .= ($emit ? ', ' : '') . "{$langpublisher}: " . q($myrow->publisher);
                        }
                    }
                    $tool_content .= '</small>';
                }
                $tool_content .= "</td><td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td><td class='option-btn-cell'>" . action_button(array(array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$myrow->id}&amp;delete=yes&amp;table={$table}", 'icon' => 'fa-times', 'confirm' => $langConfirmDelete, 'class' => 'delete'), array('title' => $langSave, 'url' => $link_to_save, 'icon' => 'fa-floppy-o'), array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$myrow->id}&amp;table_edit={$table}", 'icon' => 'fa-edit', 'show' => !$is_in_tinymce and $is_editor), array('title' => $langVisible, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;vid={$myrow->id}&amp;table={$table}&amp;vis=" . ($myrow->visible ? '0' : '1'), 'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'), array('title' => $langResourceAccess, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;vid={$myrow->id}&amp;table={$table}&amp;" . ($myrow->public ? 'limited=1' : 'public=1'), 'icon' => $myrow->public ? 'fa-unlock' : 'fa-lock', 'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN))) . "</td></tr>";
            }
            // end of check resource access
        }
        // foreach row
    }
    // foreach table
}
Example #13
0
         $descr = "<br/>{$row->description}";
     } else {
         $descr = '';
     }
     $tool_content .= "<td><a " . (isset($paused_exercises_ids) && in_array($row->id, $paused_exercises_ids) ? 'class="paused_exercise"' : '') . " href='exercise_submit.php?course={$course_code}&amp;exerciseId={$row->id}'>" . q($row->title) . "</a>{$descr}</td>";
     $eid = $row->id;
     $NumOfResults = Database::get()->querySingle("SELECT COUNT(*) as count FROM exercise_user_record WHERE eid = ?d", $eid)->count;
     if ($NumOfResults) {
         $tool_content .= "<td class='text-center'><a href='results.php?course={$course_code}&amp;exerciseId={$row->id}'>{$langExerciseScores1}</a> |\n\t\t\t\t<a href='csv.php?course={$course_code}&amp;exerciseId=" . $row->id . "' target=_blank>" . $langExerciseScores3 . "</a></td>";
     } else {
         $tool_content .= "<td class='text-center'>\t-&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;- </td>";
     }
     $langModify_temp = htmlspecialchars($langModify);
     $langConfirmYourChoice_temp = addslashes(htmlspecialchars($langConfirmYourChoice));
     $langDelete_temp = htmlspecialchars($langDelete);
     $tool_content .= "<td class='option-btn-cell'>" . action_button(array(array('title' => $langModify, 'url' => "admin.php?course={$course_code}&amp;exerciseId={$row->id}", 'icon' => 'fa-edit'), array('title' => $langPurgeExercise, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;choice=delete&amp;exerciseId={$row->id}", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmPurgeExercise), array('title' => $langPurgeExerciseResults, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;choice=purge&amp;exerciseId={$row->id}", 'icon' => 'fa-trash', 'confirm' => $langConfirmPurgeExerciseResults), array('title' => $langVisible, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;" . ($row->active ? "choice=disable" : "choice=enable") . (isset($page) ? "&amp;page={$page}" : "") . "&amp;exerciseId=" . $row->id, 'icon' => $row->active ? 'fa-eye' : 'fa-eye-slash'), array('title' => $langResourceAccess, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;" . ($row->public ? "choice=limited" : "choice=public") . "&amp;exerciseId={$row->id}", 'icon' => $row->public ? 'fa-unlock' : 'fa-lock', 'show' => course_status($course_id) == COURSE_OPEN), array('title' => $langExerciseStats, 'url' => "exercise_stats.php?course={$course_code}&amp;exerciseId={$row->id}", 'icon' => 'fa-pie-chart'), array('title' => $langCreateDuplicate, 'url' => "index.php?course={$course_code}&amp;choice=clone&amp;exerciseId={$row->id}", 'icon' => 'fa-copy'))) . "</td></tr>";
     // student only
 } else {
     if (!resource_access($row->active, $row->public)) {
         continue;
     }
     $currentDate = date("Y-m-d H:i");
     //These convertions do not seem to be necessary
     $temp_StartDate = mktime(substr($row->start_date, 11, 2), substr($row->start_date, 14, 2), 0, substr($row->start_date, 5, 2), substr($row->start_date, 8, 2), substr($row->start_date, 0, 4));
     $temp_EndDate = mktime(substr($row->end_date, 11, 2), substr($row->end_date, 14, 2), 0, substr($row->end_date, 5, 2), substr($row->end_date, 8, 2), substr($row->end_date, 0, 4));
     $currentDate = mktime(substr($currentDate, 11, 2), substr($currentDate, 14, 2), 0, substr($currentDate, 5, 2), substr($currentDate, 8, 2), substr($currentDate, 0, 4));
     if ($currentDate >= $temp_StartDate && $currentDate <= $temp_EndDate) {
         $tool_content .= "<td>" . icon('fa-angle-double-right') . " <a href='exercise_submit.php?course={$course_code}&amp;exerciseId={$row->id}'>" . q($row->title) . "</a>";
     } elseif ($currentDate <= $temp_StartDate) {
         // exercise has not yet started
         $tool_content .= "<td class='not_visible'>" . icon('fa-angle-double-right') . " " . q($row->title) . "&nbsp;&nbsp;";