Example #1
0
                              EDIT : STEP 2
   ------------------------------------------------------------------------*/
 if ('exEdit' == $cmd) {
     if (isset($_REQUEST['url'])) {
         $url = trim($_REQUEST['url']);
         if (!empty($url)) {
             /* First check for the presence of a protocol in the url
              * If the user forget "http://" or "ftp://" or whatever,
              * the link won't work.
              * In this case, add "http://" as default url protocol
              */
             if (!preg_match('/:\\/\\//', $url)) {
                 $url = 'http://' . $url;
             }
             // else $url = $url ...
             create_link_file($baseWorkDir . $_REQUEST['file'], $url);
         }
     }
     $directoryName = dirname($_REQUEST['file']);
     if ($directoryName == '/' || $directoryName == '\\') {
         // When the dir is root, PHP dirname leaves a '\' for windows or a '/' for Unix
         $directoryName = '';
     }
     $_REQUEST['newName'] = secure_file_path(trim($_REQUEST['newName']));
     if (!empty($_REQUEST['newName'])) {
         $newPath = $directoryName . '/' . $_REQUEST['newName'];
     } else {
         $newPath = secure_file_path($_REQUEST['file']);
     }
     $oldPath = secure_file_path($_REQUEST['file']);
     $newPath = claro_rename_file($baseWorkDir . $oldPath, $baseWorkDir . $newPath);
Example #2
0
                } else {
                    // if the main thing to provide is a file and that no file was sent
                    $dialogBox->error(get_lang('Unable to copy file : %filename', array('%filename' => basename($submitGroupWorkUrl))));
                    $formCorrectlySent = false;
                }
            } elseif ($submission->getParentId() == 0) {
                // if the main thing to provide is a file and that no file was sent
                $dialogBox->error(get_lang('Field \'%name\' is required', array('%name' => get_lang('File'))));
                $formCorrectlySent = false;
            }
        } elseif ($assignmentContent == "TEXTFILE") {
            // attached file is optionnal if work type is TEXT AND FILE
            // so the attached file can be deleted only in this mode
            if (!is_null($submitGroupWorkUrl)) {
                $wrkForm['filename'] = $assignment->createUniqueFilename(basename($submitGroupWorkUrl) . '.url');
                create_link_file($assignment->getAssigDirSys() . $wrkForm['filename'], get_path('coursesRepositoryWeb') . claro_get_course_path() . '/' . $submitGroupWorkUrl);
            }
            // if delete of the file is required
            if (isset($_REQUEST['delAttacheDFile'])) {
                $wrkForm['filename'] = '';
                // empty DB field
                @unlink($assignment->getAssigDirSys() . $_REQUEST['currentWrkUrl']);
                // physically remove the file
            }
        }
    }
    // if($formCorrectlySent)
}
//end if($_REQUEST['submitWrk'])
/*============================================================================
                          ADMIN ONLY COMMANDS