Beispiel #1
0
 /**
  *
  *
  * @author Sebastien Piraux <*****@*****.**>
  */
 public function moveAttachment()
 {
     if (!empty($this->attachment) && !empty($this->tmpQuestionDirSys)) {
         if (claro_move_file($this->tmpQuestionDirSys . $this->attachment, $this->questionDirSys . $this->attachment)) {
             claro_delete_file($this->tmpQuestionDirSys);
             $this->tmpQuestionDirSys = '';
             return true;
         } else {
             return false;
         }
     }
     return true;
 }
Beispiel #2
0
     if ($courseContext) {
         $form .= '<p><label for="comment">' . get_lang('Comment') . '</label>' . '<br />' . "\n" . '<textarea rows="2" cols="50" id="comment" name="comment"></textarea>' . "\n" . '</p>' . "\n";
     }
     $form .= '<input type="submit" value="' . get_lang('Ok') . '" />&nbsp; ' . claro_html_button(claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exChDir&file=' . base64_encode($cwd))), get_lang('Cancel')) . '</form>' . "\n";
     $dialogBox->form($form);
 }
 /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
                          MOVE FILE OR DIRECTORY
   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
 /*------------------------------------------------------------------------
                       MOVE FILE OR DIRECTORY : STEP 2
   --------------------------------------------------------------------------*/
 if ('exMv' == $cmd) {
     $_REQUEST['file'] = secure_file_path($_REQUEST['file']);
     $_REQUEST['destination'] = secure_file_path($_REQUEST['destination']);
     if (claro_move_file($baseWorkDir . $_REQUEST['file'], $baseWorkDir . $_REQUEST['destination'])) {
         if ($courseContext) {
             update_db_info('update', $_REQUEST['file'], array('path' => $_REQUEST['destination'] . '/' . basename($_REQUEST['file'])));
             update_Doc_Path_in_Assets("update", $_REQUEST['file'], $_REQUEST['destination'] . '/' . basename($_REQUEST['file']));
         }
         $ressource['old_uri'] = $_REQUEST['file'];
         $ressource['new_uri'] = $_REQUEST['destination'] . '/' . basename($_REQUEST['file']);
         $eventNotifier->notifyCourseEvent('document_moved', claro_get_current_course_id(), claro_get_current_tool_id(), $ressource, claro_get_current_group_id(), '0');
         $dialogBox->success(get_lang('Element moved'));
     } else {
         $dialogBox->error(get_lang('File cannot be moved there'));
         if (claro_failure::get_last_failure() == 'FILE EXISTS') {
             $dialogBox->error('A file with the same name already exists.');
         } elseif (claro_failure::get_last_failure() == 'MOVE INSIDE ITSELF') {
             $dialogBox->error('You can not move an element inside itself.');
         }
Beispiel #3
0
 public function importAttachment($importedFilePath)
 {
     // copy file in a tmp directory known by object,
     // attached file will be copied to its final destination when saving question
     $dir = $this->tmpQuestionDirSys;
     $filename = basename($importedFilePath);
     if (!is_dir($dir)) {
         // create it
         if (!claro_mkdir($dir, CLARO_FILE_PERMISSIONS)) {
             claro_failure::set_failure('cannot_create_tmp_dir');
             return false;
         }
     }
     if (claro_move_file($importedFilePath, $dir . $filename)) {
         $this->attachment = $filename;
         return true;
     } else {
         return false;
     }
 }