Пример #1
0
/**
 * Remove all user of a group
 *
 * @param mixed $groupIdList indicates wich group(s) will be emptied            *
 *        integer:group_id | array: array of group_id | string 'ALL'            *
 *        default : ALL
 * @param string $course_id course context where the  group(s) can be founded   *
 *        default : null (get id from init)
 * @return true
 * @throws claro_failure errors
 *
 */
function empty_group($groupIdList = 'ALL', $course_id = null)
{
    $groupFilter = false;
    $tbl_c_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
    if (ctype_digit($groupIdList)) {
        $groupIdList[] = (int) $groupIdList;
    }
    if (strtoupper($groupIdList) == 'ALL') {
        $sql_condition = '';
    } elseif (is_array($groupIdList)) {
        foreach ($groupIdList as $thisGroupId) {
            if (!is_int($thisGroupId)) {
                return claro_failure::set_failure('GROUP_LIST_ACTION_UNKNOWN');
            }
        }
        $groupFilter = true;
        $sql_condition = implode(" , ", $groupIdList);
    } else {
        return claro_failure::set_failure('GROUP_LIST_ACTION_UNKNOWN');
    }
    $sql = " DELETE " . " FROM `" . $tbl_c_names['group_rel_team_user'] . "`" . ($groupFilter ? " WHERE team IN (" . $sql_condition . ")" : "");
    if (!claro_sql_query($sql)) {
        return claro_failure::get_last_failure();
    }
    $sql = " UPDATE `" . $tbl_c_names['group_team'] . "` SET tutor='0'" . ($groupFilter ? "WHERE id IN (" . $sql_condition . ")" : "");
    if (!claro_sql_query($sql)) {
        return claro_failure::get_last_failure();
    }
    return true;
}
Пример #2
0
                 $dialogBox->error($ex->getMessage());
             }
         }
     } else {
         $dialogBox->warning(get_lang('There are currently no forum categories!') . '<br/>' . get_lang('Please create a category first'));
         $cmd = 'show';
     }
 }
 if ('exDelCat' == $cmd) {
     if (delete_category($catId)) {
         $dialogBox->success(get_lang('Category deleted'));
     } else {
         $dialogBox->error(get_lang('Unable to delete category'));
         if (claro_failure::get_last_failure() == 'GROUP_FORUMS_CATEGORY_REMOVALE_FORBIDDEN') {
             $dialogBox->error(get_lang('Group forums category can\'t be deleted'));
         } elseif (claro_failure::get_last_failure() == 'GROUP_FORUM_REMOVALE_FORBIDDEN') {
             $dialogBox->error(get_lang('You can not remove a group forum. You have to remove the group first'));
         }
     }
 }
 if ('exDelForum' == $cmd) {
     $forumSettingList = get_forum_settings($forumId);
     if (is_null($forumSettingList['idGroup'])) {
         if (delete_forum($forumId)) {
             $dialogBox->success(get_lang('Forum deleted'));
         } else {
             $dialogBox->error(get_lang('Unable to delete Forum'));
         }
     } else {
         $dialogBox->error(get_lang('You can\'t remove a group forum. You have to remove the group first'));
     }
Пример #3
0
/**
 * unsubscribe a specific user to a class
 *
 * @author damien Garros <*****@*****.**>
 *
 * @param int $user_id user ID from the course_user table
 * @param int $class_id course code from the class table
 *
 * @return boolean TRUE  if subscribtion succeed
 *         boolean FALSE otherwise.
 */
function user_remove_to_class($user_id, $class_id)
{
    $user_id = (int) $user_id;
    $class_id = (int) $class_id;
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_class = $tbl_mdb_names['class'];
    $tbl_course_class = $tbl_mdb_names['rel_course_class'];
    $tbl_course = $tbl_mdb_names['course'];
    $tbl_class_user = $tbl_mdb_names['rel_class_user'];
    // 1. See if there is a user with such ID in the main database
    $user_data = user_get_properties($user_id);
    if (!$user_data) {
        return claro_failure::get_last_failure('USER_NOT_FOUND');
    }
    // 2. See if there is a class with such ID in the main DB
    $sql = "SELECT `id`\n              FROM `" . $tbl_class . "`\n              WHERE `id` = '" . $class_id . "' ";
    $result = claro_sql_query_fetch_all($sql);
    if (!isset($result[0]['id'])) {
        return claro_failure::set_failure('CLASS_NOT_FOUND');
        // the class doesn't exist
    }
    // 3 - Check if user is subscribe to class and if class exist
    $sql = "SELECT  cu.id\n              FROM `" . $tbl_class_user . "` cu, `" . $tbl_class . "` c\n              WHERE cu.`class_id` = c.`id`\n              AND cu.`class_id` = " . (int) $class_id . "\n              AND cu.`user_id` = " . (int) $user_id;
    if (is_null(claro_sql_query_get_single_value($sql))) {
        return claro_failure::set_failure('USER_NOT_SUSCRIBE_TO_CLASS');
    }
    // 4 - Get the child class from this class and call the fonction recursively
    $sql = " SELECT `id`\n              FROM `" . $tbl_class . "`\n              WHERE `class_parent_id` = " . $class_id;
    $classList = claro_sql_query_fetch_all($sql);
    foreach ($classList as $class) {
        if (isset($class['id'])) {
            user_remove_to_class($user_id, $class['id']);
            //TODO Bug tracking ? !
        }
    }
    //3 - remove user to class in rel_class_user
    $sql = "DELETE FROM `" . $tbl_class_user . "`\n              WHERE `user_id` = " . (int) $user_id . "\n              AND `class_id` = " . (int) $class_id;
    claro_sql_query($sql);
    //4 - Get the list of course whose link with class and unsubscribe user for each
    $sql = "SELECT c.`code`\n              FROM `" . $tbl_course_class . "` cc, `" . $tbl_course . "` c\n              WHERE cc.`courseId` = c.`code`\n              AND cc.`classId` = " . $class_id;
    $courseList = claro_sql_query_fetch_all($sql);
    foreach ($courseList as $course) {
        if (isset($course['code'])) {
            //Check the return value of the function.
            if (!user_remove_from_course($user_id, $course['code'], false, false, $class_id)) {
                return claro_failure::set_failure('PROBLEM_WITH_COURSE_UNSUSCRIBTION');
                //TODO : ameliorer la detection d'erreur
            }
        }
    }
    return true;
}
Пример #4
0
 /**
  * insert or update course data
  *
  * @return boolean success
  */
 public function save()
 {
     if (empty($this->courseId)) {
         // Insert
         $keys = define_course_keys($this->officialCode, '', get_conf('dbNamePrefix'));
         $courseSysCode = trim($keys['currentCourseId']);
         $courseDbName = trim($keys['currentCourseDbName']);
         $courseDirectory = trim($keys['currentCourseRepository']);
         if (empty($courseSysCode) || empty($courseDbName) || empty($courseDirectory)) {
             throw new Exception("Error missing data for course {$this->officialCode}");
         }
         if (!$this->useExpirationDate) {
             $this->expirationDate = 'NULL';
         }
         // Session courses are created without categories links:
         // so we duplicate the source course's categories links
         /*if ( !is_null($this->sourceCourseId) && !empty($this->sourceCourseId) )
           {
               $sourceCourse = new claroCourse();
               $sourceCourse->load(claroCourse::getCodeFromId($this->sourceCourseId));
               
               $this->categories = $sourceCourse->categories;
           }*/
         if (!is_null($this->sourceCourseId) && !empty($this->sourceCourseId)) {
             $sourceCourse = new claroCourse();
             $sourceCourse->load(claroCourse::getCodeFromId($this->sourceCourseId));
             if ($sourceCourse->sourceCourseId) {
                 throw new Exception('You cannot create a course session from another course session');
             }
         }
         if (prepare_course_repository($courseDirectory, $courseSysCode) && register_course($courseSysCode, $this->officialCode, $this->sourceCourseId, $courseDirectory, $courseDbName, $this->titular, $this->email, $this->categories, $this->title, $this->language, $GLOBALS['_uid'], $this->access, $this->registration, $this->registrationKey, $this->visibility, $this->departmentName, $this->extLinkUrl, $this->publicationDate, $this->expirationDate, $this->status, $this->userLimit) && install_course_database($courseDbName) && install_course_tools($courseDbName, $this->language, $courseDirectory)) {
             $courseObj = new Claro_Course($courseSysCode);
             $courseObj->load();
             $courseRegistration = new Claro_CourseUserRegistration(AuthProfileManager::getUserAuthProfile($GLOBALS['_uid']), $courseObj, null, null);
             $courseRegistration->ignoreRegistrationKeyCheck();
             $courseRegistration->ignoreCategoryRegistrationCheck();
             $courseRegistration->setCourseAdmin();
             $courseRegistration->setCourseTutor();
             $courseRegistration->forceSuperUser();
             if ($courseRegistration->addUser()) {
                 // Set course id
                 $this->courseId = $courseSysCode;
                 // Notify event manager
                 $args['courseSysCode'] = $courseSysCode;
                 $args['courseDbName'] = $courseDbName;
                 $args['courseDirectory'] = $courseDirectory;
                 $args['courseCategory'] = $this->categories;
                 $GLOBALS['eventNotifier']->notifyEvent("course_created", $args);
                 return true;
             } else {
                 $this->backlog->failure($courseRegistration->getErrorMessage());
                 return false;
             }
         } else {
             $lastFailure = claro_failure::get_last_failure();
             $this->backlog->failure('Error : ' . $lastFailure);
             return false;
         }
     } else {
         // Update
         $tbl_mdb_names = claro_sql_get_main_tbl();
         $tbl_course = $tbl_mdb_names['course'];
         $tbl_cdb_names = claro_sql_get_course_tbl();
         $tbl_course_properties = $tbl_cdb_names['course_properties'];
         if (!$this->useExpirationDate) {
             $this->expirationDate = null;
         }
         $sqlExpirationDate = is_null($this->expirationDate) ? 'NULL' : 'FROM_UNIXTIME(' . claro_sql_escape($this->expirationDate) . ')';
         $sqlCreationDate = is_null($this->publicationDate) ? 'NULL' : 'FROM_UNIXTIME(' . claro_sql_escape($this->publicationDate) . ')';
         $sql = "UPDATE `" . $tbl_course . "`\n                    SET `intitule`             = '" . claro_sql_escape($this->title) . "',\n                        `titulaires`           = '" . claro_sql_escape($this->titular) . "',\n                        `administrativeNumber` = '" . claro_sql_escape($this->officialCode) . "',\n                        `language`             = '" . claro_sql_escape($this->language) . "',\n                        `extLinkName`          = '" . claro_sql_escape($this->departmentName) . "',\n                        `extLinkUrl`           = '" . claro_sql_escape($this->extLinkUrl) . "',\n                        `email`                = '" . claro_sql_escape($this->email) . "',\n                        `visibility`           = '" . ($this->visibility ? 'visible' : 'invisible') . "',\n                        `access`               = '" . claro_sql_escape($this->access) . "',\n                        `registration`         = '" . claro_sql_escape($this->registration) . "',\n                        `registrationKey`      = '" . claro_sql_escape($this->registrationKey) . "',\n                        `lastEdit`             = NOW(),\n                        `creationDate`         = " . $sqlCreationDate . ",\n                        `expirationDate`       = " . $sqlExpirationDate . ",\n                        `status`               = '" . claro_sql_escape($this->status) . "',\n                        `userLimit`            = '" . (int) $this->userLimit . "'\n                    WHERE code='" . claro_sql_escape($this->courseId) . "'";
         // Handle categories
         // 1/ Remove all links in database
         $this->unlinkCategories();
         // 2/ Link new categories selection
         $this->linkCategories($this->categories);
         // If it's a source course, do the same for all its session courses
         if ($this->isSourceCourse) {
             $sql2 = "SELECT cours_id FROM `" . $tbl_course . "`\n                        WHERE sourceCourseId = " . $this->id;
             $sessionCourses = claro_sql_query_fetch_all_rows($sql2);
             foreach ($sessionCourses as $sessionCourse) {
                 unlink_course_categories($sessionCourse['cours_id']);
                 link_course_categories($sessionCourse['cours_id'], $this->categories);
             }
         }
         return claro_sql_query($sql);
     }
 }
Пример #5
0
             $_user['lastLogin'] = claro_time() - 24 * 60 * 60;
             // DATE_SUB(CURDATE(), INTERVAL 1 DAY)
             $is_allowedCreateCourse = $userData['isCourseCreator'] == 1 ? TRUE : FALSE;
             $_SESSION['_uid'] = claro_get_current_user_id();
             $_SESSION['_user'] = $_user;
             $_SESSION['is_allowedCreateCourse'] = $is_allowedCreateCourse;
             // track user login
             $claroline->notifier->event('user_login', array('data' => array('ip' => $_SERVER['REMOTE_ADDR'])));
             // last user login date is now
             $user_last_login_datetime = 0;
             // used as a unix timestamp it will correspond to : 1 1 1970
             $_SESSION['user_last_login_datetime'] = $user_last_login_datetime;
             // send info to user by email
             $mailSent = user_send_registration_mail(claro_get_current_user_id(), $userData);
         } else {
             if ('MISSING_DATA' == claro_failure::get_last_failure()) {
                 $messageList[] = get_lang('Data missing');
             } else {
                 $messageList[] = get_lang('Unknown error');
             }
         }
     } else {
         // User validate form return error messages
         $error = true;
     }
 }
 if ('registration' == $cmd && $error == false) {
     $display = DISP_REGISTRATION_SUCCEED;
 } elseif ('agree' == $cmd || !get_conf('show_agreement_panel') || 'registration' == $cmd || '' == $agreementText) {
     $display = DISP_REGISTRATION_FORM;
     $subscriptionText = claro_text_zone::get_content('textzone_inscription_form');
        $pathInfo = strtolower(str_replace('\\', '/', $pathInfo));
    }
    $document_url = str_replace($rootSys, $urlAppend . '/', $pathInfo);
    if (get_conf('useSendfile', true) && ($mimeType != 'text/html' || $extension == 'url') || $wasFolder) {
        if (claro_send_file($pathInfo) !== false) {
            $claroline->notifier->event('download', array('data' => array('url' => $document_url)));
            if ($wasFolder) {
                unlink($pathInfo);
            }
            if (!$canRetry) {
                $sql = 'DELETE FROM `' . $tableName . '` WHERE token = \'' . claro_sql_escape($token) . '\'';
                Claroline::getDatabase()->exec($sql);
            }
        } else {
            header('HTTP/1.1 404 Not Found');
            claro_die(get_lang('File download failed : %failureMSg%', array('%failureMsg%' => claro_failure::get_last_failure())));
        }
    } else {
        $sql = 'DELETE FROM `' . $tableName . '` WHERE token = \'' . claro_sql_escape($token) . '\'';
        Claroline::getDatabase()->exec($sql);
        // redirect to document
        claro_redirect($document_url);
    }
} else {
    header('HTTP/1.1 404 Not Found');
}
//Clean left zip here
$sql = 'SELECT * FROM `' . $tableName . '` WHERE ADDTIME(`requestTime`,\'0 0:0:30\') < NOW() AND NOT `wasFolder` = \'0\'';
$result = Claroline::getDatabase()->query($sql);
while (($row = $result->fetch()) !== false) {
    if (is_file($row['requestedPath'])) {
Пример #7
0
 pushClaroMessage(__LINE__ . '<pre>$_REQUEST =' . var_export($_REQUEST, 1) . '</pre>', 'dbg');
 // Thread uploaded file
 if (array_key_exists('uploadedModule', $_FILES)) {
     pushClaroMessage(__LINE__ . 'files founds', 'dbg');
     if (file_upload_failed($_FILES['uploadedModule'])) {
         $summary = get_lang('Module upload failed');
         $details = get_file_upload_error_message($_FILES['uploadedModule']);
         $dialogBox->error(Backlog_Reporter::report($summary, $details));
     } else {
         // move uploadefile to package repository, and unzip them
         // actually it's done in function wich must be splited.
         if (false !== ($modulePath = get_and_unzip_uploaded_package())) {
             $moduleInstallable = true;
         } else {
             $summary = get_lang('Module unpackaging failed');
             $details = implode("<br />\n", claro_failure::get_last_failure());
             $dialogBox->error(Backlog_Reporter::report($summary, $details));
         }
     }
 } elseif (array_key_exists('packageCandidatePath', $_REQUEST)) {
     // If the target is a zip file, it must be unpack
     // If it's a unziped package, We copye the content
     if (is_package_file($_REQUEST['packageCandidatePath'])) {
         pushClaroMessage(__LINE__ . 'packageCandidatePath is a package', 'dbg');
         $modulePath = unzip_package($_REQUEST['packageCandidatePath']);
         pushClaroMessage(__LINE__ . '<pre>$modulePath =' . var_export($modulePath, 1) . '</pre>', 'dbg');
     } elseif (file_exists($_REQUEST['packageCandidatePath'])) {
         // COPY THE FILE TO WORK REPOSITORY
         pushClaroMessage(__LINE__ . 'packageCandidatePath is a path', 'dbg');
         claro_mkdir(get_package_path());
         $modulePath = create_unexisting_directory(get_package_path() . basename($_REQUEST['packageCandidatePath']));
Пример #8
0
/**
 * Remove database for all modules in the given course
 * @param   string courseId
 * @return  array(
 *  boolean success
 *  Backlog log )
 * @author  Frederic Minne <*****@*****.**>
 */
function delete_all_modules_from_course($courseId)
{
    $backlog = new Backlog();
    $success = true;
    if (!($moduleLabelList = get_module_label_list(false))) {
        $success = false;
        $backlog->failure(claro_failure::get_last_failure());
    } else {
        foreach ($moduleLabelList as $moduleLabel) {
            if (!delete_module_in_course($moduleLabel, $courseId)) {
                $backlog->failure(get_lang('delete failed for module %module', array('%module' => $moduleLabel)));
                $success = false;
            } else {
                $backlog->success(get_lang('delete succeeded for module %module', array('%module' => $moduleLabel)));
            }
        }
    }
    return array($success, $backlog);
}
Пример #9
0
     if ($assignment->validate()) {
         $lastAssigId = $assignment->save();
         // confirmation message
         $dialogBox->success(get_lang('New assignment created'));
         if ($lastAssigId) {
             //notify eventmanager that a new assignement is created
             $eventNotifier->notifyCourseEvent("work_added", claro_get_current_course_id(), claro_get_current_tool_id(), $lastAssigId, claro_get_current_group_id(), "0");
         }
     } else {
         if (claro_failure::get_last_failure() == 'assignment_no_title') {
             $dialogBox->error(get_lang('Assignment title required'));
         }
         if (claro_failure::get_last_failure() == 'assignment_title_already_exists') {
             $dialogBox->error(get_lang('Assignment title already exists'));
         }
         if (claro_failure::get_last_failure() == 'assignment_incorrect_dates') {
             $dialogBox->error(get_lang('Start date must be before end date ...'));
         }
         $cmd = 'rqMkAssig';
     }
 }
 /*-----------------------------------
       STEP 1 : display form
   -------------------------------------*/
 //--- create an assignment / display form
 if ($cmd == 'rqMkAssig') {
     require_once get_path('incRepositorySys') . '/lib/form.lib.php';
     // modify the command 'cmd' sent by the form
     $cmdToSend = 'exMkAssig';
     // ask the display of the form
     $displayAssigForm = true;
 /**
  * Returns the documents contained into args['curDirPath']
  * @param array $args array of parameters, can contain :
  * - (boolean) recursive : if true, return the content of the requested directory and its subdirectories, if any. Default = true
  * - (String) curDirPath : returns the content of the directory specified by this path. Default = '' (root)
  * @throws InvalidArgumentException if $cid is missing
  * @webservice{/module/MOBILE/CLDOC/getResourceList/cidReq/[?recursive=BOOL&curDirPath='']}
  * @ws_arg{Method,getResourcesList}
  * @ws_arg{cidReq,SYSCODE of requested cours}
  * @ws_arg{recursive,[Optionnal: if true\, return the content of the requested directory and its subdirectories\, if any. Default = true]}
  * @ws_arg{curDirPath,[Optionnal: returns the content of the directory specified by this path. Default = '' (root)]}
  * @return array of document object
  */
 function getResourcesList($args)
 {
     $recursive = isset($args['recursive']) ? $args['recursive'] : true;
     $curDirPath = isset($args['curDirPath']) ? $args['curDirPath'] : '';
     $cid = claro_get_current_course_id();
     if (is_null($cid)) {
         throw new InvalidArgumentException('Missing cid argument!');
     } elseif (!claro_is_course_allowed()) {
         throw new RuntimeException('Not allowed', 403);
     }
     /* READ CURRENT DIRECTORY CONTENT
     		 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
     $claroline = Claroline::getInstance();
     $exSearch = false;
     $groupContext = FALSE;
     $courseContext = TRUE;
     $dbTable = get_module_course_tbl(array('document'), $cid);
     $dbTable = $dbTable['document'];
     $docToolId = get_course_tool_id('CLDOC');
     $groupId = claro_get_current_group_id();
     $date = $claroline->notification->getLastActionBeforeLoginDate(claro_get_current_user_id());
     if (!defined('A_DIRECTORY')) {
         define('A_DIRECTORY', 1);
     }
     if (!defined('A_FILE')) {
         define('A_FILE', 2);
     }
     $baseWorkDir = get_path('coursesRepositorySys') . claro_get_course_path($cid) . '/document';
     /*----------------------------------------------------------------------------
     		 LOAD FILES AND DIRECTORIES INTO ARRAYS
     		----------------------------------------------------------------------------*/
     $searchPattern = '';
     $searchRecursive = false;
     $searchBasePath = $baseWorkDir . $curDirPath;
     $searchExcludeList = array();
     $searchBasePath = secure_file_path($searchBasePath);
     if (false === ($filePathList = claro_search_file(search_string_to_pcre($searchPattern), $searchBasePath, $searchRecursive, 'ALL', $searchExcludeList))) {
         switch (claro_failure::get_last_failure()) {
             case 'BASE_DIR_DONT_EXIST':
                 pushClaroMessage($searchBasePath . ' : call to an unexisting directory in groups');
                 break;
             default:
                 pushClaroMessage('Search failed');
                 break;
         }
         $filePathList = array();
     }
     for ($i = 0; $i < count($filePathList); $i++) {
         $filePathList[$i] = str_replace($baseWorkDir, '', $filePathList[$i]);
     }
     if ($exSearch && $courseContext) {
         $sql = "SELECT path FROM `" . $dbTable . "`\n\t\t\t\t\tWHERE comment LIKE '%" . claro_sql_escape($searchPattern) . "%'";
         $dbSearchResult = claro_sql_query_fetch_all_cols($sql);
         $filePathList = array_unique(array_merge($filePathList, $dbSearchResult['path']));
     }
     $fileList = array();
     if (count($filePathList) > 0) {
         /*--------------------------------------------------------------------------
         		 SEARCHING FILES & DIRECTORIES INFOS ON THE DB
         		------------------------------------------------------------------------*/
         /*
          * Search infos in the DB about the current directory the user is in
          */
         if ($courseContext) {
             $sql = "SELECT `path`, `visibility`, `comment`\n\t\t\t\t\t\tFROM `" . $dbTable . "`\n\t\t\t\t\t\t\t\tWHERE path IN ('" . implode("', '", array_map('claro_sql_escape', $filePathList)) . "')";
             $xtraAttributeList = claro_sql_query_fetch_all_cols($sql);
         } else {
             $xtraAttributeList = array('path' => array(), 'visibility' => array(), 'comment' => array());
         }
         foreach ($filePathList as $thisFile) {
             $fileAttributeList['cours']['sysCode'] = $cid;
             $fileAttributeList['path'] = $thisFile;
             $fileAttributeList['resourceId'] = $thisFile;
             $tmp = explode('/', $thisFile);
             if (is_dir($baseWorkDir . $thisFile)) {
                 $fileYear = date('n', time()) < 8 ? date('Y', time()) - 1 : date('Y', time());
                 $fileAttributeList['title'] = $tmp[count($tmp) - 1];
                 $fileAttributeList['isFolder'] = true;
                 $fileAttributeList['type'] = A_DIRECTORY;
                 $fileAttributeList['size'] = 0;
                 $fileAttributeList['date'] = $fileYear . '-09-20';
                 $fileAttributeList['extension'] = "";
                 $fileAttributeList['url'] = null;
             } elseif (is_file($baseWorkDir . $thisFile)) {
                 $fileAttributeList['title'] = implode('.', explode('.', $tmp[count($tmp) - 1], -1));
                 $fileAttributeList['type'] = A_FILE;
                 $fileAttributeList['isFolder'] = false;
                 $fileAttributeList['size'] = claro_get_file_size($baseWorkDir . $thisFile);
                 $fileAttributeList['date'] = date('Y-m-d', filemtime($baseWorkDir . $thisFile));
                 $fileAttributeList['extension'] = get_file_extension($baseWorkDir . $thisFile);
                 $fileAttributeList['url'] = $_SERVER['SERVER_NAME'] . claro_get_file_download_url($thisFile);
             }
             $xtraAttributeKey = array_search($thisFile, $xtraAttributeList['path']);
             if ($xtraAttributeKey !== false) {
                 $fileAttributeList['description'] = $xtraAttributeList['comment'][$xtraAttributeKey];
                 $fileAttributeList['visibility'] = $xtraAttributeList['visibility'][$xtraAttributeKey] == 'v';
                 unset($xtraAttributeList['path'][$xtraAttributeKey]);
             } else {
                 $fileAttributeList['description'] = null;
                 $fileAttributeList['visibility'] = true;
             }
             $notified = $claroline->notification->isANotifiedDocument($cid, $date, claro_get_current_user_id(), $groupId, $docToolId, $fileAttributeList, false);
             $fileAttributeList['notifiedDate'] = $notified ? $date : $fileAttributeList['date'];
             $d = new DateTime($date);
             $d->sub(new DateInterval('P1D'));
             $fileAttributeList['seenDate'] = $d->format('Y-m-d');
             if ($fileAttributeList['visibility'] || claro_is_allowed_to_edit()) {
                 $fileList[] = $fileAttributeList;
             }
         }
         // end foreach $filePathList
     }
     if ($recursive) {
         foreach ($fileList as $thisFile) {
             if ($thisFile['type'] == A_DIRECTORY) {
                 $args = array('curDirPath' => $thisFile['path'], 'recursive' => true);
                 $new_list = $this->getResourcesList($args);
                 $fileList = array_merge($fileList, $new_list);
             }
         }
     }
     return $fileList;
 }
Пример #11
0
         if ($cmd == 'exEdit' && $catId) {
             $questionCategory->setTitle($_REQUEST['title']);
             $questionCategory->setDescription($_REQUEST['description']);
             if ($questionCategory->validate()) {
                 if ($questionCategory->save()) {
                     if ($catId == -1) {
                         $dialogBox->success(get_lang('Category created'));
                     } else {
                         $dialogBox->success(get_lang('Category updated'));
                     }
                 }
             } else {
                 if (claro_failure::get_last_failure() == 'category_no_title') {
                     $dialogBox->error(get_lang('Field \'%name\' is required', array('%name' => get_lang('Title'))));
                 } else {
                     if (claro_failure::get_last_failure() == 'category_already_exists') {
                         $dialogBox->error(get_lang('Category alreday exists'));
                     }
                 }
             }
         }
     }
 }
 if ($cmd == 'add') {
     $questionCategory->load();
     $catId = -1;
     $form['title'] = '';
     $form['description'] = '';
     $cmd = 'rqEdit';
 }
 if ($cmd == 'exDel' && $catId) {
Пример #12
0
if (isset($_REQUEST['cmd'])) {
    $cmd = $_REQUEST['cmd'];
} else {
    $cmd = '';
}
if ($cmd == 'registration') {
    // get params from the form
    $userData = user_initialise();
    $userData['language'] = null;
    // validate forum params
    $messageList = user_validate_form_registration($userData);
    if (count($messageList) == 0) {
        // register the new user in the claroline platform
        $userId = user_create($userData);
        if (false === $userId) {
            $dialogBox->error(claro_failure::get_last_failure());
        } else {
            $dialogBox->success(get_lang('The new user has been sucessfully created'));
            $newUserMenu[] = claro_html_cmd_link('../auth/courses.php?cmd=rqReg&amp;uidToEdit=' . $userId . '&amp;category=&amp;fromAdmin=settings', get_lang('Register this user to a course'));
            $newUserMenu[] = claro_html_cmd_link('admin_profile.php?uidToEdit=' . $userId . '&amp;category=', get_lang('User settings'));
            $newUserMenu[] = claro_html_cmd_link('adminaddnewuser.php', get_lang('Create another new user'));
            $newUserMenu[] = claro_html_cmd_link('index.php', get_lang('Back to administration page'));
            $display = DISP_REGISTRATION_SUCCEED;
            // Send a mail to the user
            if (false !== user_send_registration_mail($userId, $userData)) {
                $dialogBox->success(get_lang('Mail sent to user'));
            } else {
                $dialogBox->warning(get_lang('No mail sent to user'));
                // TODO  display in a popup "To Print" with  content to give to user.
            }
        }
Пример #13
0
/**
 * Install a specific module to the platform
 * @param string $modulePath path to the module
 * @param bool $skipCheckDir skip checking if module directory already exists (default false)
 * @return array( backlog, int )
 *      backlog object containing the messages
 *      int moduleId if the install process suceeded, false otherwise
 * @todo remove the need of the Backlog and use Exceptions instead
 */
function install_module($modulePath, $skipCheckDir = false, $registerModuleInCourses = false)
{
    $backlog = new Backlog();
    $moduleId = false;
    if (false === ($module_info = readModuleManifest($modulePath))) {
        claro_delete_file($modulePath);
        $backlog->failure(claro_failure::get_last_failure());
    } else {
        //check if a module with the same LABEL is already installed, if yes, we cancel everything
        // TODO extract from install function should be tested BEFORE calling install_module
        if (!$skipCheckDir && check_name_exist(get_module_path($module_info['LABEL']) . '/')) {
            $backlog->failure(get_lang('Module %module is already installed on your platform', array('%module' => $module_info['LABEL'])));
            // claro_delete_file($modulePath);
            // TODO : add code to point on existing instance of tool.
            // TODO : how to overwrite . prupose uninstall ?
        } else {
            //3- Save the module information into DB
            if (false === ($moduleId = register_module_core($module_info))) {
                claro_delete_file($modulePath);
                $backlog->failure(claro_failure::get_last_failure());
                $backlog->failure(get_lang('Module registration failed'));
            } else {
                //in case of tool type module, the dock can not be selected and must added also now
                if ('tool' == $module_info['TYPE']) {
                    // TODO FIXME handle failure
                    register_module_tool($moduleId, $module_info);
                }
                if (array_key_exists('DEFAULT_DOCK', $module_info)) {
                    foreach ($module_info['DEFAULT_DOCK'] as $dock) {
                        // TODO FIXME handle failure
                        add_module_in_dock($moduleId, $dock);
                    }
                }
                //4- Rename the module repository with label
                $currentPlace = realpath($modulePath) . '/';
                $destPath = get_module_path($module_info['LABEL']);
                claro_mkdir(get_path('rootSys') . 'module/', CLARO_FILE_PERMISSIONS, true);
                if (!@rename($currentPlace, $destPath)) {
                    $backlog->failure(get_lang("Error while renaming module folder") . ' from:' . $currentPlace . ' to:' . $destPath);
                } else {
                    // force access rights on module root dir after rename() because some modules written on M$ Win$#!t are causing issues
                    chmod($destPath, CLARO_FILE_PERMISSIONS);
                    //5-Include the local 'install.sql' and 'install.php' file of the module if they exist
                    if (isset($installSqlScript)) {
                        unset($installSqlScript);
                    }
                    $installSqlScript = get_module_path($module_info['LABEL']) . '/setup/install.sql';
                    if (file_exists($installSqlScript)) {
                        $sql = file_get_contents($installSqlScript);
                        if (!empty($sql)) {
                            $sql = str_replace('__CL_MAIN__', get_conf('mainTblPrefix'), $sql);
                            if (claro_sql_multi_query($sql) === false) {
                                $backlog->failure(get_lang('Sql installation query failed'));
                            } else {
                                $backlog->failure(get_lang('Sql installation query succeeded'));
                            }
                        }
                    }
                    // generate the conf if a def file exists
                    if (file_exists(get_module_path($module_info['LABEL']) . '/conf/def/' . $module_info['LABEL'] . '.def.conf.inc.php')) {
                        require_once dirname(__FILE__) . '/../config.lib.inc.php';
                        $config = new Config($module_info['LABEL']);
                        list($confMessage, $status) = generate_conf($config);
                        $backlog->info($confMessage);
                    }
                    // call install.php after initialising database in case it requires database to run
                    if (isset($installPhpScript)) {
                        unset($installPhpScript);
                    }
                    $installPhpScript = get_module_path($module_info['LABEL']) . '/setup/install.php';
                    if (file_exists($installPhpScript)) {
                        language::load_translation();
                        language::load_locale_settings();
                        language::load_module_translation($module_info['LABEL']);
                        load_module_config($module_info['LABEL']);
                        // FIXME this is very dangerous !!!!
                        require $installPhpScript;
                        $backlog->info(get_lang('Module installation script called'));
                    }
                    $moduleInfo = get_module_info($moduleId);
                    if ($registerModuleInCourses && $moduleInfo['type'] == 'tool' && $moduleId) {
                        list($backlog2, $success2) = register_module_in_courses($moduleId);
                        if ($success2) {
                            $backlog->success(get_lang('Module installed in all courses'));
                        } else {
                            $backlog->append($backlog2);
                        }
                    }
                    //6- cache file with the module's include must be renewed after installation of the module
                    if (!generate_module_cache()) {
                        $backlog->failure(get_lang('Module cache update failed'));
                    } else {
                        $backlog->success(get_lang('Module cache update succeeded'));
                    }
                }
            }
        }
    }
    return array($backlog, $moduleId);
}
Пример #14
0
         if (!empty($title)) {
             $subject .= $title;
         } else {
             $subject .= get_lang('Message from your lecturer');
         }
         $msgContent = $content;
         // Enclosed resource
         $body = $msgContent . "\n" . "\n" . ResourceLinker::renderLinkList($currentLocator, true);
         require_once dirname(__FILE__) . '/../messaging/lib/message/messagetosend.lib.php';
         require_once dirname(__FILE__) . '/../messaging/lib/recipient/courserecipient.lib.php';
         $courseRecipient = new CourseRecipient(claro_get_current_course_id());
         $message = new MessageToSend(claro_get_current_user_id(), $subject, $body);
         $message->setCourse(claro_get_current_course_id());
         $message->setTools('CLANN');
         $messageId = $courseRecipient->sendMessage($message);
         if ($failure = claro_failure::get_last_failure()) {
             $dialogBox->warning($failure);
         }
     }
     // end if $emailOption==1
 }
 // end if $submit Announcement
 if ($autoExportRefresh) {
     /**
      * in future, the 2 following calls would be pas by event manager.
      */
     // rss update
     /*if ( get_conf('enableRssInCourse',1))
       {
           require_once get_path('incRepositorySys') . '/lib/rss.write.lib.php';
           build_rss( array('course' => claro_get_current_course_id()));
Пример #15
0
                $dialogBox->success(get_lang('Exercise added'));
                $eventNotifier->notifyCourseEvent("exercise_added", claro_get_current_course_id(), claro_get_current_tool_id(), $insertedId, claro_get_current_group_id(), "0");
                $exId = $insertedId;
            } else {
                $dialogBox->success(get_lang('Exercise modified'));
                $eventNotifier->notifyCourseEvent("exercise_updated", claro_get_current_course_id(), claro_get_current_tool_id(), $insertedId, claro_get_current_group_id(), "0");
            }
            $displaySettings = true;
        } else {
            // sql error in save() ?
            $cmd = 'rqEdit';
        }
    } else {
        if (claro_failure::get_last_failure() == 'exercise_no_title') {
            $dialogBox->error(get_lang('Field \'%name\' is required', array('%name' => get_lang('Title'))));
        } elseif (claro_failure::get_last_failure() == 'exercise_incorrect_dates') {
            $dialogBox->error(get_lang('Start date must be before end date ...'));
        }
        $cmd = 'rqEdit';
    }
}
if ($cmd == 'rqEdit') {
    $form['title'] = $exercise->getTitle();
    $form['description'] = $exercise->getDescription();
    $form['displayType'] = $exercise->getDisplayType();
    $form['randomize'] = (bool) $exercise->getShuffle() > 0;
    $form['questionDrawn'] = $exercise->getShuffle();
    $form['useSameShuffle'] = (bool) $exercise->getUseSameShuffle();
    $form['showAnswers'] = $exercise->getShowAnswers();
    $form['startDate'] = $exercise->getStartDate();
    // unix
Пример #16
0
        // user validate form return error messages
        foreach ($errorMsgList as $errorMsg) {
            $dialogBox->error($errorMsg);
        }
        $error = true;
    }
} elseif (!claro_is_allowed_to_create_course() && get_conf('can_request_course_creator_status') && 'exCCstatus' == $cmd) {
    // send a request for course creator status
    profile_send_request_course_creator_status($_REQUEST['explanation']);
    $dialogBox->success(get_lang('Your request to become a course creator has been sent to platform administrator(s).'));
} elseif (get_conf('can_request_revoquation') && 'exRevoquation' == $cmd) {
    // send a request for revoquation
    if (profile_send_request_revoquation($_REQUEST['explanation'], $_REQUEST['loginToDelete'], $_REQUEST['passwordToDelete'])) {
        $dialogBox->success(get_lang('Your request to remove your account has been sent'));
    } else {
        switch (claro_failure::get_last_failure()) {
            case 'EXPLANATION_EMPTY':
                $dialogBox->error(get_lang('You left some required fields empty'));
                $noQUERY_STRING = true;
                ClaroBreadCrumbs::getInstance()->prepend($nameTools, $_SERVER['PHP_SELF']);
                $nameTools = get_lang('Request to remove this account');
                $display = DISP_REQUEST_REVOQUATION;
                break;
        }
    }
} elseif (!claro_is_allowed_to_create_course() && get_conf('can_request_course_creator_status') && 'reqCCstatus' == $cmd) {
    // display course creator status form
    $noQUERY_STRING = true;
    $display = DISP_REQUEST_COURSE_CREATOR_STATUS;
    ClaroBreadCrumbs::getInstance()->prepend($nameTools, $_SERVER['PHP_SELF']);
    $nameTools = get_lang('Request course creation status');
Пример #17
0
            // if create a new question in exercise context
            if (is_null($quId) && !is_null($exId)) {
                $exercise->addQuestion($insertedId);
            }
            // create a new question
            if (is_null($quId)) {
                // Go to answer edition
                header('Location: ' . Url::Contextualize('edit_answers.php?exId=' . $exId . '&quId=' . $insertedId));
                exit;
            }
        } else {
            // sql error in save() ?
            $cmd = 'rqEdit';
        }
    } else {
        if (claro_failure::get_last_failure() == 'question_no_title') {
            $dialogBox->error(get_lang('Field \'%name\' is required', array('%name' => get_lang('Title'))));
        }
        $cmd = 'rqEdit';
    }
}
if ($cmd == 'rqEdit') {
    $form['title'] = $question->getTitle();
    $form['description'] = $question->getDescription();
    $form['attachment'] = $question->getAttachment();
    $form['type'] = $question->getType();
    $form['categoryId'] = $question->getCategoryId();
    $displayForm = true;
}
/*
 * Output