Пример #1
0
 /**
  * notify by email the user of the reception of a message
  *
  * @param array of int: $userDataList user identificatin list
  * @param MessageToSend $message message envoy�
  * @param int $messageId identification of the message
  * 
  */
 public function notify($userDataList, $message, $messageId)
 {
     if (!get_conf('mailNotification', TRUE)) {
         return;
     }
     // sender name and email
     if ($message->getSender() == 0) {
         $userData = array('mail' => get_conf('no_reply_mail') ? get_conf('no_reply_mail') : get_conf('administrator_email'), 'firstName' => get_lang('Message from %platformName', array('%platformName' => get_conf('siteName'))), 'lastName' => '');
     } else {
         $userData = claro_get_current_user_data();
     }
     //************************************ IS MANAGER
     $stringManager = false;
     $courseManagers = claro_get_course_manager_id($message->getCourseCode());
     $nbrOfManagers = count($courseManagers);
     for ($countManager = 0; $countManager < $nbrOfManagers; $countManager++) {
         if ($message->getSender() == $courseManagers[$countManager]) {
             $courseData = claro_get_course_data($message->getCourseCode());
             $stringManager = get_block('Course manager of %course%(%courseCode%)', array('%course%' => $courseData['name'], '%courseCode%' => $courseData['officialCode']));
         }
     }
     //---------------------- email subject
     $emailSubject = '[' . get_conf('siteName');
     if (!is_null($message->getCourseCode())) {
         $courseData = claro_get_course_data($message->getCourseCode());
         if ($courseData) {
             $emailSubject .= ' - ' . $courseData['officialCode'];
         }
     }
     $emailSubject .= '] ' . $message->getSubject();
     //------------------------------subject
     /* $altBody = get_lang('If you can\'t read this message go to: ') . rtrim( get_path('rootWeb'), '/' ) . '/claroline/messaging/readmessage.php?messageId=' . $messageId . '&type=received' . "\n\n"
        . '-- '
        . claro_get_current_user_data('lastName') . " " . claro_get_current_user_data('firstName') . "\n"
        . $stringManager
        . "\n\n" . get_conf('siteName') ." <" . get_conf('rootWeb') . '>' . "\n"
        . '   ' . get_lang('Administrator') . ' : ' . get_conf('administrator_name') . ' <' . get_conf('administrator_email') . '>' . "\n"
        ; */
     //-------------------------BODY
     $msgContent = claro_parse_user_text($message->getMessage());
     $urlAppend = get_path('url');
     if (!empty($urlAppend)) {
         $msgContent = preg_replace('!href="' . get_path('url') . '!', 'href="' . rtrim(get_path('rootWeb'), '/') . '/', $msgContent);
         $msgContent = preg_replace('!\\>' . get_path('url') . '!', '>' . get_path('rootWeb'), $msgContent);
     } else {
         $msgContent = preg_replace('!href="/!', 'href="' . rtrim(get_path('rootWeb'), '/') . '/', $msgContent);
     }
     $emailBody = "<html><head></head><body>" . $msgContent . '<br /><br />' . '-- <br />' . get_lang('%firstName %lastName', array('%firstName' => $userData['firstName'], '%lastName' => $userData['lastName'])) . "<br />" . $stringManager . '<br /><br /><a href="' . get_conf('rootWeb') . '">' . get_conf('siteName') . '</a><br />' . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . get_lang('Administrator') . ': <a href="mailto:' . get_conf('administrator_email') . '">' . get_conf('administrator_name') . '</a><br />' . '</body></html>';
     //******************************** END BODY
     //******************************************
     if (empty($userData['mail']) || !is_well_formed_email_address($userData['mail'])) {
         // do not send email for a user with no mail address
         pushClaroMessage('Mail Notification Failed : User has no email or an invalid one : ' . var_export($userData, true) . '!');
         return claro_failure::set_failure(get_lang("Mail Notification Failed : You don't have any email address defined in your user profile or the defined email address is not valid."));
     }
     self::emailNotification($userDataList, $emailBody, $emailSubject, $userData['mail'], get_lang('%firstName %lastName', array('%firstName' => $userData['firstName'], '%lastName' => $userData['lastName'])));
 }
Пример #2
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.
            }
        }
Пример #3
0
<?php

// $Id: course_install.php 9706 2007-12-12 13:30:11Z mlaurent $
// vim: expandtab sw=4 ts=4 sts=4:
if (count(get_included_files()) == 1) {
    die('The file ' . basename(__FILE__) . ' cannot be accessed directly, use include instead');
}
$moduleWorkingDirectory = get_path('coursesRepositorySys') . $courseDirectory . '/chat';
if (!claro_mkdir($moduleWorkingDirectory, CLARO_FILE_PERMISSIONS, true)) {
    return claro_failure::set_failure(get_lang('Unable to create folder %folder', array('%folder' => $moduleWorkingDirectory)));
}
Пример #4
0
/**
 * Send e-mail using Main settings
 */
function claro_mail($subject, $message, $to, $toName, $from, $fromName)
{
    $mail = new ClaroPHPMailer();
    if (empty($from)) {
        $from = get_conf('administrator_email');
        if (empty($fromName)) {
            $fromName = get_conf('administrator_name');
        }
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->From = $from;
    $mail->FromName = $fromName;
    $mail->Sender = $from;
    $mail->AddAddress($to, $toName);
    if ($mail->Send()) {
        return true;
    } else {
        return claro_failure::set_failure($mail->getError());
    }
}
Пример #5
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()));
Пример #6
0
/**
 * This function empties all classes,
 * remove link between classes and users
 * delete related users from related courses
 */
function empty_all_class()
{
    $tbl = claro_sql_get_main_tbl();
    $sql = "\n        SELECT id FROM `" . $tbl['class'] . "`";
    $searchResultList = claro_sql_query_fetch_all($sql);
    foreach ($searchResultList as $thisClass) {
        $classId = $thisClass['id'];
        // find all the students enrolled in that class
        $sql2 = "\n            SELECT user_id from `" . $tbl['rel_class_user'] . "`\n            WHERE class_id = '" . claro_sql_escape($classId) . "'";
        $thisClassUser = claro_sql_query_fetch_all($sql2);
        // Find all the courses to whom the class is enrolled
        $sql2 = "\n            SELECT courseId\n            FROM `" . $tbl['rel_course_class'] . "`\n            WHERE classId = '" . claro_sql_escape($classId) . "'";
        $searchResultList2 = claro_sql_query_fetch_all($sql2);
        foreach ($searchResultList2 as $thisCourse) {
            $courseCode = $thisCourse['courseId'];
            foreach ($thisClassUser as $thisUser) {
                $user_id = $thisUser['user_id'];
                if (!user_remove_from_course($user_id, $courseCode, false, false, $classId)) {
                    return claro_failure::set_failure('PROBLEM_WITH_COURSE_UNSUSCRIBTION ' . $user_id . ' ' . $courseCode);
                    //TODO : ameliorer la detection d'erreur
                }
            }
        }
        class_remove_all_users($classId);
    }
    return true;
}
Пример #7
0
function claro_is_module_allowed()
{
    if (!array_key_exists('tlabelReq', $GLOBALS)) {
        return claro_failure::set_failure('MISSING TOOL LABEL');
    }
    $moduleLabel = $GLOBALS['tlabelReq'];
    $moduleData = get_module_data($moduleLabel);
    if ($moduleData['type'] == 'tool') {
        $contextList = get_module_context_list($moduleLabel);
        // pushClaroMessage(var_export(iterator_to_array($contextList), true),'kernel');
        if (!claro_is_in_a_course() && in_array('platform', iterator_to_array($contextList))) {
            return get_module_data($moduleLabel, 'activation') == 'activated';
        }
        // if a course tool, use claro_is_tool_allowed
        return claro_is_tool_allowed();
    } else {
        // if an applet "tool", return true if activated
        // and let module manage it's access by itself
        return $moduleData['activation'] == 'activated';
    }
}
Пример #8
0
/**
 * Execute SQL files at course creation
 */
function execute_sql_at_course_creation($sqlPath, $courseDbName)
{
    if (file_exists($sqlPath)) {
        $sql = file_get_contents($sqlPath);
        $currentCourseDbNameGlu = get_conf('courseTablePrefix') . $courseDbName . get_conf('dbGlu');
        $sql = str_replace('__CL_COURSE__', $currentCourseDbNameGlu, $sql);
        if (!claro_sql_multi_query($sql)) {
            return claro_failure::set_failure('SQL_QUERY_FAILED');
        } else {
            return true;
        }
    } else {
        return claro_failure::set_failure('SQL_FILE_NOT_FOUND');
    }
}
Пример #9
0
/**
 * Read a file from the file system and echo it
 *
 * Workaround for the readfile bug in PHP 5.0.4 and with host where
 * PHP readfile is deactivated
 *
 * @param   string $path file path
 * @param   boolean $retbytes return file length (default true)
 * @return  int file length if $retbytes
 *          boolean true on success if not $retbytes
 *          boolean false on failure
 *          set claro_failure on failure
 * @deprecated since Claroline 1.9 and PHP 5.1
 */
function claro_readfile($path, $retbytes = true)
{
    if (!file_exists($path)) {
        return claro_failure::set_failure('FILE_NOT_FOUND');
    }
    $chunksize = 1 * (1024 * 1024);
    // how many bytes per chunk
    $buffer = '';
    $cnt = 0;
    $handle = fopen($path, 'rb');
    if (!$handle) {
        return claro_failure::set_failure('CANNOT_OPEN_FILE');
    }
    while (!feof($handle)) {
        $buffer = fread($handle, $chunksize);
        if ($buffer === false) {
            return claro_failure::set_failure('CANNOT_READ_FILE');
        }
        echo $buffer;
        if ($retbytes) {
            $cnt += strlen($buffer);
        }
    }
    $status = fclose($handle);
    if ($retbytes && $status) {
        return $cnt;
    } else {
        return $status;
    }
}
Пример #10
0
/**
 * function delete_groups($groupIdList = 'ALL')
 * deletes groups and their datas.
 *
 * @param  mixed   $groupIdList - group(s) to delete. It can be a single id
 *                                (int) or a list of id (array). If no id is
 *                                given all the course group are deleted
 *
 * @return integer : number of groups deleted.
 * @throws claro_failure
 */
function delete_groups($groupIdList = 'ALL')
{
    global $eventNotifier;
    $tbl_c_names = claro_sql_get_course_tbl();
    $tbl_groups = $tbl_c_names['group_team'];
    $tbl_groupsUsers = $tbl_c_names['group_rel_team_user'];
    $tbl_courseCalendar = $tbl_c_names['calendar_event'];
    require_once get_module_path('CLWIKI') . '/lib/lib.createwiki.php';
    require_once dirname(__FILE__) . '/forum.lib.php';
    if (is_tool_activated_in_course(get_tool_id_from_module_label('CLWIKI'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLWIKI')) {
        delete_group_wikis($groupIdList);
    }
    if (is_tool_activated_in_course(get_tool_id_from_module_label('CLFRM'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLFRM')) {
        delete_group_forums($groupIdList);
    }
    /**
     * Check the data and notify eventmanager of the deletion
     */
    if (strtoupper($groupIdList) == 'ALL') {
        $sql_condition = '';
    } elseif (is_array($groupIdList)) {
        foreach ($groupIdList as $thisGroupId) {
            if (!is_int($thisGroupId)) {
                return false;
            }
        }
        $sql_condition = 'WHERE id IN (' . implode(' , ', $groupIdList) . ')';
    } else {
        if (settype($groupIdList, 'integer')) {
            $sql_condition = '  WHERE id = ' . (int) $groupIdList;
            $eventNotifier->notifyCourseEvent('group_deleted', claro_get_current_course_id(), claro_get_current_tool_id(), '0', $groupIdList, '0');
        } else {
            // TODO : perhaps a trigger erro is better
            return claro_failure::set_failure('CANT_SET_ID_GROUP_AS_INTEGER ' . __LINE__);
        }
    }
    /*
     * Search the groups data necessary to delete them
     */
    $sql_searchGroup = "SELECT `id` AS `id`,\n                               `secretDirectory` AS `directory`\n                        FROM `" . $tbl_groups . "`" . $sql_condition;
    $groupList = claro_sql_query_fetch_all_cols($sql_searchGroup);
    //notify event manager about the deletion for each group
    foreach ($groupList['id'] as $thisGroupId) {
        $eventNotifier->notifyCourseEvent('group_deleted', claro_get_current_course_id(), claro_get_current_tool_id(), '0', $thisGroupId, '0');
    }
    if (count($groupList['id']) > 0) {
        /*
         * Remove users, group(s) and group forum(s) from the course tables
         */
        $sql_deleteGroup = "DELETE FROM `" . $tbl_groups . "`\n                                   WHERE id IN (" . implode(' , ', $groupList['id']) . ")\n                                    # " . __FUNCTION__ . "\n                                    # " . __FILE__ . "\n                                    # " . __LINE__;
        $sql_cleanOutGroupUsers = "DELETE FROM `" . $tbl_groupsUsers . "`\n                                   WHERE team IN (" . implode(' , ', $groupList['id']) . ")\n                                    # " . __FUNCTION__ . "\n                                    # " . __FILE__ . "\n                                    # " . __LINE__;
        $sql_cleanOutGroupEvent = "DELETE FROM `" . $tbl_courseCalendar . "`\n                                    WHERE group_id IN (" . implode(' , ', $groupList['id']) . ")\n                                    # " . __FUNCTION__ . "\n                                    # " . __FILE__ . "\n                                    # " . __LINE__;
        // Deleting group record in table
        $deletedGroupNumber = claro_sql_query_affected_rows($sql_deleteGroup);
        // Delete all members of deleted group(s)
        claro_sql_query($sql_cleanOutGroupUsers);
        // Delete all calendar events for deleted group(s)
        claro_sql_query($sql_cleanOutGroupEvent);
        /**
         * Archive and delete the group files
         */
        // define repository for deleted element
        $groupGarbage = $GLOBALS['garbageRepositorySys'] . '/' . $GLOBALS['currentCourseRepository'] . '/group/';
        if (!file_exists($groupGarbage)) {
            claro_mkdir($groupGarbage, CLARO_FILE_PERMISSIONS, true);
        }
        foreach ($groupList['directory'] as $thisDirectory) {
            if (file_exists($GLOBALS['coursesRepositorySys'] . $GLOBALS['currentCourseRepository'] . '/group/' . $thisDirectory)) {
                rename($GLOBALS['coursesRepositorySys'] . $GLOBALS['currentCourseRepository'] . '/group/' . $thisDirectory, $groupGarbage . $thisDirectory);
            }
        }
        return $deletedGroupNumber;
    } else {
        return FALSE;
    }
}
Пример #11
0
function repairTree()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_category = $tbl_mdb_names['category'];
    //  get  list of all node
    $sql = " SELECT code, code_P, treePos, name, nb_childs\n               FROM `" . $tbl_category . "`\n               ORDER BY `treePos`";
    $catList = claro_sql_query_fetch_all($sql);
    $newTreePos = 1;
    $listSize = count($catList);
    // foreach node check code_parent,  treepos and nbchilds
    foreach ($catList as $cat) {
        $newCatList[$cat['code']] = $cat;
        $parentCatData = get_cat_data(get_cat_id_from_code($cat['code_P']));
        if ($cat['treePos'] < $parentCatData['treePos']) {
            $newCatList[$cat['code']]['newCode_P'] = ' root ';
            $newCatList[$cat['code']]['newTreePos'] = $listSize--;
        } else {
            if (!is_null($cat['code_P']) && !get_cat_id_from_code($cat['code_P'])) {
                $newCatList[$cat['code']]['newCode_P'] = ' root ';
                $newCatList[$cat['code']]['newTreePos'] = $listSize--;
            } else {
                $newCatList[$cat['code']]['newTreePos'] = $newTreePos++;
                $newCatList[$cat['code']]['newNb_childs'] = countChild($cat['code']);
            }
        }
    }
    reset($newCatList);
    $node_moved = false;
    // rescan node list  and  update data if difference was detected.
    foreach ($newCatList as $cat) {
        if (isset($cat['newCode_P']) && $cat['code_P'] != $cat['newCode_P']) {
            $sql = "UPDATE  `" . $tbl_category . "` " . ($cat['newCode_P'] == ' root ' ? "   SET code_P = null " : "   SET code_P = " . (int) $cat['newCode_P']) . " WHERE code = '" . claro_sql_escape($cat['code']) . "'";
            $node_moved = true;
            // repair ownance but brok countchild
            claro_sql_query($sql);
        }
        if (isset($cat['newNb_childs']) && $cat['nb_childs'] != $cat['newNb_childs']) {
            $sql = "UPDATE  `" . $tbl_category . "` " . "   SET nb_childs = " . (int) $cat['newNb_childs'] . " WHERE code = '" . claro_sql_escape($cat['code']) . "'";
            claro_sql_query($sql);
        }
        if ($cat['treePos'] != $cat['newTreePos']) {
            $sql = "UPDATE  `" . $tbl_category . "` " . "   SET treePos = " . (int) $cat['newTreePos'] . " WHERE code = '" . claro_sql_escape($cat['code']) . "'";
            claro_sql_query($sql);
        }
    }
    if ($node_moved) {
        return claro_failure::set_failure('node_moved');
    } else {
        return 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;
 }
Пример #13
0
 /**
  * check if data are valide
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @return boolean
  */
 public function validate()
 {
     // title is a mandatory element
     $title = trim(strip_tags($this->title));
     if (empty($title)) {
         claro_failure::set_failure('assignment_no_title');
         return false;
     } else {
         // check if title already exists
         if ($this->id == -1) {
             // insert
             $sql = "SELECT `title`\n                        FROM `" . $this->tblAssignment . "`\n                        WHERE `title` = '" . claro_sql_escape($this->title) . "'";
         } else {
             // update
             $sql = "SELECT `title`\n                        FROM `" . $this->tblAssignment . "`\n                        WHERE `title` = '" . claro_sql_escape($this->title) . "'\n                        AND `id` != " . (int) $this->id;
         }
         $query = claro_sql_query($sql);
         if (mysql_num_rows($query) != 0) {
             claro_failure::set_failure('assignment_title_already_exists');
             return false;
         }
     }
     // dates : check if start date is lower than end date else we will have a paradox
     if ($this->endDate <= $this->startDate) {
         claro_failure::set_failure('assignment_incorrect_dates');
         return false;
     }
     return true;
     // no errors, form is valide
 }
Пример #14
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) {
Пример #15
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');
Пример #16
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;
Пример #17
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);
     }
 }
Пример #18
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
Пример #19
0
/**
 * Return course list which have an unexisting category as parent
 *
 * @author Christophe Gesché <*****@*****.**>
 * @since 1.8
 *
 * @return array('Course code'=>string, 'Unknow faculty'=>string)
 */
function checkCourseOwnance()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $sql = "SELECT c.code    AS `Course code`,\n                   c.faculte AS `Unknow faculty`\n        FROM  `" . $tbl_mdb_names['course'] . "`       AS c\n        LEFT JOIN  `" . $tbl_mdb_names['category'] . "` AS f\n        ON c.FACULTE = f.code\n        WHERE f.id IS null ";
    if (false !== ($res = claro_sql_query_fetch_all($sql))) {
        return $res;
    } else {
        return claro_failure::set_failure('QUERY_ERROR_' . __LINE__);
    }
}
Пример #20
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']));
Пример #21
0
/**
 * edit a bloc for information category
 *
 * @param  integer $def_id,
 * @param  integer $user_id,
 * @param  string  $user_ip, DEFAULT $REMOTE_ADDR
 * @param  string  $content ; if empty call delete the bloc
 * @return boolean true if succeed, else bolean false
 */
function claro_user_info_edit_cat_content($def_id, $user_id, $content = "", $user_ip = "", $course_id = NULL)
{
    $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
    $tbl_userinfo_content = $tbl_cdb_names['userinfo_content'];
    if (empty($user_ip)) {
        global $REMOTE_ADDR;
        $user_ip = $REMOTE_ADDR;
    }
    if (0 == (int) $user_id || 0 == (int) $def_id) {
        return claro_failure::set_failure('id_nul');
    }
    $content = trim($content);
    if ('' == trim($content)) {
        return claro_user_info_cleanout_cat_content($user_id, $def_id);
    }
    $sql = "UPDATE `" . $tbl_userinfo_content . "` SET\n            `content`    = '" . claro_sql_escape($content) . "',\n            `ed_ip`        = '" . $user_ip . "',\n            `ed_date`    = now()\n            WHERE def_id = " . (int) $def_id . "\n              AND user_id = " . (int) $user_id;
    claro_sql_query($sql);
    return true;
}
 function announcement_get_item($announcement_id, $course_id = NULL)
 {
     $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
     $sql = "SELECT                id,\n\t\t\t\t\t\t\t\t\t  title,\n\t\t\t\t\t   contenu     AS content,\n\t\t\t\t\t\t   temps   AS `time`,\n\t\t\t\t\t\t\t\t\t  visibility,\n\t\t\t\t\t   ordre       AS rank\n\t\t\t\tFROM  `" . $tbl['announcement'] . "`\n\t\t\t\tWHERE id=" . (int) $announcement_id;
     $announcement = claro_sql_query_get_single_row($sql);
     if ($announcement) {
         return $announcement;
     } else {
         return claro_failure::set_failure('ANNOUNCEMENT_UNKNOW');
     }
 }
Пример #23
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'));
     }
Пример #24
0
/**
 * build the rss file and place it in directory
 *
 * @param array $context context of claroline
 * @param string $calType : ics,xcs,rdf
 * @return string ical file path
 */
function buildICal($context, $calType = 'ics')
{
    if (is_array($context) && count($context) > 0) {
        $iCalRepositorySys = get_path('rootSys') . get_conf('iCalRepositoryCache', 'tmp/cache/iCal/');
        if (!file_exists($iCalRepositorySys)) {
            require_once dirname(__FILE__) . '/fileManage.lib.php';
            claro_mkdir($iCalRepositorySys, CLARO_FILE_PERMISSIONS, true);
            if (!file_exists($iCalRepositorySys)) {
                claro_failure::set_failure('CANT_CREATE_ICAL_DIR');
            }
        }
        $iCal = (object) new iCal('', 0, $iCalRepositorySys);
        // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory)
        $toolLabelList = ical_get_tool_compatible_list();
        foreach ($toolLabelList as $toolLabel) {
            if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) {
                if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) {
                    install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]);
                }
                $icalToolLibPath = get_module_path($toolLabel) . '/connector/ical.write.cnr.php';
                $icalToolFuncName = $toolLabel . '_write_ical';
                if (file_exists($icalToolLibPath)) {
                    require_once $icalToolLibPath;
                    if (function_exists($icalToolFuncName)) {
                        $iCal = call_user_func($icalToolFuncName, $iCal, $context);
                    }
                }
            }
        }
        $iCalFilePath = $iCalRepositorySys;
        if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) {
            $iCalFilePath .= $context[CLARO_CONTEXT_COURSE] . '.';
        }
        if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) {
            $iCalFilePath .= 'g' . $context[CLARO_CONTEXT_GROUP] . '.';
        }
        if ('ics' == $calType || get_conf('iCalGenStandard', true)) {
            $stdICalFilePath = $iCalFilePath . 'ics';
            if (false !== ($fpICal = @fopen($stdICalFilePath, 'w'))) {
                fwrite($fpICal, $iCal->getOutput('ics'));
                fclose($fpICal);
            }
        }
        if ('xcs' == $calType || get_conf('iCalGenXml', true)) {
            $xmlICalFilePath = $iCalFilePath . 'xml';
            if (false !== ($fpICal = @fopen($xmlICalFilePath, 'w'))) {
                fwrite($fpICal, $iCal->getOutput('xcs'));
                fclose($fpICal);
            }
        }
        if ('rdf' == $calType || get_conf('iCalGenRdf', false)) {
            $rdfICalFilePath = $iCalFilePath . 'rdf';
            if (false !== ($fpICal = @fopen($rdfICalFilePath, 'w'))) {
                fwrite($fpICal, $iCal->getOutput('rdf'));
                fclose($fpICal);
            }
        }
        switch ($calType) {
            case 'xcs':
                return $xmlICalFilePath;
                break;
            case 'rdf':
                return $rdfICalFilePath;
                break;
            default:
                return $stdICalFilePath;
                break;
        }
    }
    return false;
}
Пример #25
0
/**
 * unzip safly a zipfile
 *
 * @author Hugues Peeters <*****@*****.**>
 *
 * @param string $fileName file name of zip
 * @param string $filePath file path of zip
 * @param string $extractPath
 * @param integer $maxFilledSpace (byte) count  of byte size aivailable
 * @param boolean $allowPHP whether True the file can't contain php or phtml files
 * @return true
 * @throws claro_failure on error
 */
function treat_secure_file_unzip($fileName, $filePath, $extractPath, $maxFilledSpace, $allowPHP = false)
{
    $zipFile = new pclZip($fileName);
    // Check the zip content (real size and file extension)
    $zipContentArray = $zipFile->listContent();
    if (!is_array($zipContentArray)) {
        return false;
    }
    foreach ($zipContentArray as $thisContent) {
        if (!$allowPHP) {
            if (preg_match('~.(php.?|phtml)$~i', $thisContent['filename'])) {
                return claro_failure::set_failure(get_lang('The zip file can not contain .PHP files'));
            }
        }
        if (!isset($realFileSize)) {
            $realFileSize = 0;
        }
        $realFileSize += $thisContent['size'];
    }
    if (!enough_size($realFileSize, $extractPath, $maxFilledSpace)) {
        return claro_failure::set_failure(get_lang('The upload has failed. There is not enough space in your directory'));
    }
    $extractedFileNameList = $zipFile->extract(PCLZIP_OPT_PATH, $extractPath . $filePath, PCLZIP_OPT_SET_CHMOD, CLARO_FILE_PERMISSIONS);
    if (is_array($extractedFileNameList)) {
        return $extractedFileNameList;
    } else {
        return false;
    }
}
Пример #26
0
/**
 * search files or directory whose name fit a pattern
 *
 * @param string $searchPattern - Perl compatible regex to search on file name
 * @param string $baseDirPath - directory path where to start the search
 * @param string $fileType (optional) - filter allowing to restrict search
 *        on files or directories (allowed value are 'ALL', 'FILE', 'DIR').
 * @param array $excludedPathList (optional) - list of files or directories
 *        that have to be excluded from the search
 * @return array path list of the files fitting the search pattern
 */
function claro_search_file($searchPattern, $baseDirPath, $recursive = false, $fileType = 'ALL', $excludedPathList = array())
{
    $searchResultList = array();
    //$baseDirPath unexisting is  a devel error or a data incoherence,
    if (!file_exists($baseDirPath)) {
        // TODO would push an error but return empty array instead of false.
        return claro_failure::set_failure('BASE_DIR_DONT_EXIST');
    }
    $dirPt = opendir($baseDirPath);
    //can't be false as if (! file_exists($baseDirPath))  have make a good control
    //if ( ! $dirPt) return false;
    while ($fileName = readdir($dirPt)) {
        $filePath = $baseDirPath . '/' . $fileName;
        if ($fileName == '.' || $fileName == '..' || in_array('/' . ltrim($filePath, '/'), $excludedPathList)) {
            continue;
        } else {
            if (is_dir($filePath)) {
                $dirList[] = $filePath;
            }
            if ($fileType == 'DIR' && is_file($filePath)) {
                continue;
            }
            if ($fileType == 'FILE' && is_dir($filePath)) {
                continue;
            }
            if (preg_match($searchPattern, $fileName)) {
                $searchResultList[] = $filePath;
            }
        }
    }
    closedir($dirPt);
    if ($recursive && isset($dirList) && count($dirList) > 0) {
        foreach ($dirList as $thisDir) {
            $searchResultList = array_merge($searchResultList, claro_search_file($searchPattern, $thisDir, $recursive, $fileType, $excludedPathList));
        }
    }
    return $searchResultList;
}
Пример #27
0
/**
 * Returns data for the announcement  of the given id of the given or current course.
 *
 * @param integer   $announcement_id id the requested announcement
 * @param string    $course_id       sysCode of the course (leaveblank for current course)
 * @return array(id, title, content, visibility, rank) of the announcement
 * @since 1.7
 */
function announcement_get_item($announcement_id, $course_id = null)
{
    $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
    $sql = "SELECT id,\n                   title,\n                   contenu      AS content,\n                   visibleFrom,\n                   visibleUntil,\n                   visibility,\n                   ordre        AS rank\n            FROM  `" . $tbl['announcement'] . "`\n            WHERE id = " . (int) $announcement_id;
    $announcement = claro_sql_query_get_single_row($sql);
    if ($announcement) {
        return $announcement;
    } else {
        return claro_failure::set_failure('ANNOUNCEMENT_UNKNOW');
    }
}
Пример #28
0
        $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'])) {
Пример #29
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');
Пример #30
0
/**
 * Add common info about a module in main module registry.
 * In Claroline this  info is split in two type of info
 * into two tables :
 * * module  for really use info,
 * * module_info for descriptive info
 *
 * @param array $module_info.
 * @return int moduleId in the registry.
 */
function register_module_core($module_info)
{
    $tbl = claro_sql_get_tbl(array('module', 'module_info', 'tool', 'module_contexts'));
    $tbl_name = claro_sql_get_main_tbl();
    $missingElement = array_diff(array('LABEL', 'NAME', 'TYPE'), array_keys($module_info));
    if (count($missingElement) > 0) {
        return claro_failure::set_failure(get_lang('Missing elements in module Manifest : %MissingElements', array('%MissingElements' => implode(',', $missingElement))));
    }
    if (isset($module_info['ENTRY'])) {
        $script_url = $module_info['ENTRY'];
    } else {
        $script_url = 'entry.php';
    }
    $sql = "INSERT INTO `" . $tbl['module'] . "`\n            SET label      = '" . claro_sql_escape($module_info['LABEL']) . "',\n                name       = '" . claro_sql_escape($module_info['NAME']) . "',\n                type       = '" . claro_sql_escape($module_info['TYPE']) . "',\n                script_url = '" . claro_sql_escape($script_url) . "'\n                ";
    $moduleId = claro_sql_query_insert_id($sql);
    $sql = "INSERT INTO `" . $tbl['module_info'] . "`\n            SET module_id      = " . (int) $moduleId . ",\n                version        = '" . claro_sql_escape($module_info['VERSION']) . "',\n                author         = '" . claro_sql_escape($module_info['AUTHOR']['NAME']) . "',\n                author_email   = '" . claro_sql_escape($module_info['AUTHOR']['EMAIL']) . "',\n                author_website = '" . claro_sql_escape($module_info['AUTHOR']['WEB']) . "',\n                website        = '" . claro_sql_escape($module_info['WEB']) . "',\n                description    = '" . claro_sql_escape($module_info['DESCRIPTION']) . "',\n                license        = '" . claro_sql_escape($module_info['LICENSE']) . "'";
    claro_sql_query($sql);
    foreach ($module_info['CONTEXTS'] as $context) {
        $sql = "INSERT INTO `{$tbl['module_contexts']}`\n" . "SET\n" . "  `module_id` = " . (int) $moduleId . ",\n" . "  `context` = '" . claro_sql_escape($context) . "'";
        claro_sql_query($sql);
    }
    return $moduleId;
}