Пример #1
0
/**
 * Base config file
*/
require_once realpath(dirname(__FILE__)) . '/../../config_path.inc.php';
/**
 * Clear node and layout variable in $_SESSION
*/
$variableToClearAR = array('node', 'layout', 'course', 'user');
/**
 * Users (types) allowed to access this module.
*/
$allowedUsersAr = array(AMA_TYPE_SWITCHER);
/**
 * Get needed objects
*/
$neededObjAr = array(AMA_TYPE_SWITCHER => array('layout'));
/**
 * Performs basic controls before entering this module
*/
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
require_once ROOT_DIR . '/include/FileUploader.inc.php';
$fileUploader = new FileUploader(ADA_UPLOAD_PATH);
if ($fileUploader->upload() == false) {
    $data = $fileUploader->getErrorMessage();
} else {
    $_SESSION['importHelper']['filename'] = $fileUploader->getPathToUploadedFile();
    $data = '1';
    // '1' means okay
}
echo $data;
Пример #2
0
$neededObjAr = array(AMA_TYPE_SWITCHER => array('layout', 'user', 'course', 'course_instance'));
require_once ROOT_DIR . '/include/module_init.inc.php';
$self = whoami();
require_once 'include/switcher_functions.inc.php';
require_once 'include/Subscription.inc.php';
include_once ROOT_DIR . '/include/token_classes.inc.php';
require_once ROOT_DIR . '/include/FileUploader.inc.php';
require_once ROOT_DIR . '/include/Forms/FileUploadForm.inc.php';
/*
 * YOUR CODE HERE
 */
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    //    $fileUploader = new FileUploader(ROOT_DIR . '/upload_file/uploaded_files/switcher/' . $userObj->getId().'/');
    $fileUploader = new FileUploader(ADA_UPLOAD_PATH . $userObj->getId() . '/');
    if ($fileUploader->upload() == false) {
        $data = new CText($fileUploader->getErrorMessage());
    } else {
        $courseId = $_POST['id_course'];
        $courseInstanceId = $_POST['id_course_instance'];
        $FlagFileWellFormat = true;
        if (is_readable($fileUploader->getPathToUploadedFile())) {
            $usersToSubscribe = file($fileUploader->getPathToUploadedFile());
            /*remove blanck line form array*/
            foreach ($usersToSubscribe as $key => $value) {
                if (!trim($value)) {
                    unset($usersToSubscribe[$key]);
                }
            }
            foreach ($usersToSubscribe as $subscriber) {
                $userDataAr = explode(',', $subscriber);
                $countAr = count($userDataAr);