Пример #1
0
            $form->addElement('file', 'import_content', _UPLOADLESSONFILE, 'class = "inputText"');
            $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
            //getUploadMaxSize returns size in KB
            $form->addElement('submit', 'submit_lesson', _SUBMIT, 'class = "flatButton"');
            try {
                if ($form->isSubmitted() && $form->validate()) {
                    //If the form is submitted and validated
                    $directionsTree = new EfrontDirectionsTree();
                    if (sizeof($directionsTree->tree) == 0) {
                        eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_YOUMUSTFIRSTCREATEDIRECTION) . '&message_type=failure');
                        exit;
                    }
                    //changed because of #1462
                    $newLesson = EfrontLesson::createLesson();
                    $filesystem = new FileSystemTree($newLesson->getDirectory(), true);
                    $file = $filesystem->uploadFile('import_content', $newLesson->getDirectory());
                    $newLesson->import($file, false, true, true);
                    $message = _OPERATIONCOMPLETEDSUCCESSFULLY;
                    $message_type = 'success';
                }
            } catch (EfrontFileException $e) {
                handleNormalFlowExceptions($e);
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            //Create a smarty renderer
            $renderer->setRequiredTemplate('{$html}{if $required}
           		&nbsp;<span class = "formRequired">*</span>
            {/if}');
            $renderer->setErrorTemplate('{$html}{if $error}
	            <div class = "formError">{$error}</div>
	        {/if}');
Пример #2
0
    if (!in_array($value['name'], $existingModules)) {
        $modulesList[] = array('className' => $value['name'], 'not_installed' => 1, 'errors' => _MODULEFILESPRESENTNOTINSTALLED);
    }
}
$smarty->assign("T_MODULES", $modulesList);
$upload_form = new HTML_QuickForm("upload_file_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=modules', "", null, true);
$upload_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$upload_form->addElement('file', 'file_upload[0]', null, 'class = "inputText"');
$upload_form->addElement('checkbox', 'overwrite', _OVERWRITEIFFOLDEREXISTS);
$upload_form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
//getUploadMaxSize returns size in KB
$upload_form->addElement('submit', 'submit_upload_file', _UPLOAD, 'class = "flatButton"');
if ($upload_form->isSubmitted() && $upload_form->validate()) {
    $filesystem = new FileSystemTree(G_MODULESPATH);
    $uploadedFile = $filesystem->uploadFile('file_upload', G_MODULESPATH, 0);
    if (isset($_GET['upgrade'])) {
        $prev_module_version = eF_getTableData("modules", "position", "className = '" . $_GET['upgrade'] . "'");
        $prev_module_folder = $prev_module_version[0]['position'];
        // The name of the temp folder to extract the new version of the module
        $module_folder = $prev_module_folder;
        //basename($filename[0], '.zip') . time();
        $module_position = $prev_module_folder;
        //basename($filename[0], '.zip');
    } else {
        $module_folder = basename($uploadedFile['path'], '.zip');
        $module_position = $module_folder;
    }
    if (is_dir(G_MODULESPATH . $module_folder) && !isset($_GET['upgrade']) && !isset($_POST['overwrite'])) {
        $message = _FOLDERWITHMODULENAMEEXISTSIN . G_MODULESPATH;
        $message_type = 'failure';
     $smarty->assign("T_EDITPDFCONTENT", true);
 }
 //You can't change a unit's parent from this form. You must use the content tree management page
 if ($_GET['edit']) {
     $form->setDefaults(array('parent_content_ID' => $currentUnit['parent_content_ID']));
     $form->freeze(array('parent_content_ID'));
 }
 //If the form was submitted with pdf content, take special care
 if ($form->isSubmitted() && $form->validate()) {
     try {
         $values = $form->exportValues();
         if ($_FILES['pdf_upload']['name'] != "") {
             if (strpos($_FILES['pdf_upload']['name'], ".pdf") !== false) {
                 $destinationDir = new EfrontDirectory(G_LESSONSPATH . $_SESSION['s_lessons_ID']);
                 $filesystem = new FileSystemTree(G_LESSONSPATH . $_SESSION['s_lessons_ID']);
                 $uploadedFile = $filesystem->uploadFile('pdf_upload', $destinationDir);
                 $values['data'] = '<iframe src="view_file.php?file=' . $uploadedFile['id'] . '"  name="pdfaccept" width="100%" height="600"></iframe>';
                 //$values['data'] = '<iframe src="'.$currentLesson -> getDirectoryUrl().'/'.$uploadedFile["physical_name"].'"  name="pdfaccept" width="100%" height="600"></iframe>';
             } else {
                 throw new Exception(_YOUMUSTUPLOADAPDFFILE);
             }
         }
         $options = serialize(array('complete_unit_setting' => $values['complete_unit_setting'], 'hide_navigation' => $values['hide_navigation'], 'indexed' => $values['indexed'], 'maximize_viewport' => $values['maximize_viewport'], 'scorm_asynchronous' => $values['scorm_asynchronous'], 'scorm_times' => $values['scorm_times'], 'scorm_logging' => $values['scorm_logging'], 'object_ids' => $values['object_ids'], 'no_before_unload' => $values['no_before_unload'], 'reentry_action' => isset($values['reentry_action']) ? $values['reentry_action'] : false, 'complete_question' => $values['complete_question'] ? $values['complete_question'] : 0, 'complete_time' => $values['complete_time'] ? $values['complete_time'] : ''));
         if (isset($_GET['edit'])) {
             //You can't edit data in scorm units
             if (strpos($currentUnit['ctg_type'], 'scorm') === false && strpos($currentUnit['scorm_version'], 'tincan') === false) {
                 $currentUnit['data'] = applyEditorOffset($values['data']);
             } else {
                 if ($values['data'] != $currentUnit['data']) {
                     $currentUnit['data'] = $values['data'];
                 } elseif ($values['embed_type'] == 'iframe' && strpos($currentUnit['data'], 'window.open') !== false) {
Пример #4
0
     if ($form->isSubmitted() && $form->validate()) {
         //If the form is submitted and validated
         $directionsTree = new EfrontDirectionsTree();
         if (sizeof($directionsTree->tree) == 0) {
             eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_TOCREATECOURSEYOUMUSTFIRSTCREATECATEGORY) . '&message_type=failure');
             exit;
         }
         $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
         if (!is_dir($userTempDir)) {
             //If the user's temp directory does not exist, create it
             $userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
         } else {
             $userTempDir = new EfrontDirectory($userTempDir);
         }
         $filesystem = new FileSystemTree($userTempDir, true);
         $file = $filesystem->uploadFile('import_content', $userTempDir);
         $newCourse = EfrontCourse::createCourse();
         $exportedFile = $file;
         $newCourse->import($exportedFile, false, true);
     }
 } catch (EfrontFileException $e) {
     $file->delete();
     handleNormalFlowExceptions($e);
 }
 $renderer = prepareFormRenderer($form);
 $form->accept($renderer);
 //Assign this form to the renderer, so that corresponding template code is created
 $smarty->assign('T_IMPORT_COURSE_FORM', $renderer->toArray());
 //Assign the form to the template
 /** Calculate and display course ajax lists*/
 $sortedColumns = array('name', 'location', 'num_students', 'num_skills', 'start_date', 'end_date', 'price', 'created', 'active', 'operations');
Пример #5
0
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $layout_form->accept($renderer);
     $smarty->assign('T_ADD_BLOCK_FORM', $renderer->toArray());
 } else {
     $form = new HTML_QuickForm("import_settings_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=themes&theme=' . $layoutTheme->{$layoutTheme->entity}['id'] . (isset($_GET['theme_layout']) ? '&theme_layout=' . $_GET['theme_layout'] : ''), "", null, true);
     $form->addElement('file', 'file_upload', _SETTINGSFILE, 'class = "inputText"');
     $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
     //getUploadMaxSize returns size in KB
     $form->addElement('submit', 'submit_import', _SUBMIT, 'class = "flatButton"');
     $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
     if ($form->isSubmitted() && $form->validate()) {
         try {
             $values = $form->exportValues();
             $basedir = G_THEMESPATH . $layoutTheme->themes['path'] . 'external/';
             $filesystem = new FileSystemTree($basedir);
             $uploadedFile = $filesystem->uploadFile('file_upload', $basedir);
             $uploadedFile->uncompress();
             $uploadedFile->delete();
             $settings = file_get_contents($basedir . 'layout_settings.php.inc');
             if ($settings = unserialize($settings)) {
                 $layoutTheme->layout = $settings;
                 $layoutTheme->persist();
             }
             EfrontCache::getInstance()->delete(G_DBNAME . ':themes');
             eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=themes&theme=" . $layoutTheme->{$layoutTheme->entity}['id'] . (isset($_GET['theme_layout']) ? '&theme_layout=' . $_GET['theme_layout'] : '') . "&message=" . rawurlencode(_SETTINGSIMPORTEDSUCCESFULLY) . "&message_type=success");
             //$message      = _SETTINGSIMPORTEDSUCCESFULLY;
             //$message_type = 'success';
         } catch (Exception $e) {
             handleNormalFlowExceptions($e);
         }
     }
Пример #6
0
     FileSystemTree::checkFile($urlUpload);
     $urlArray = explode("/", $urlUpload);
     $urlFile = preg_replace("/\\?.*/", "", urldecode($urlArray[sizeof($urlArray) - 1]));
     if (!copy($urlUpload, $currentLesson->getDirectory() . $urlFile)) {
         $error = error_get_last();
         throw new Exception(_PROBLEMUPLOADINGFILE . ': ' . $error['message']);
     } else {
         $scormFiles[] = new EfrontFile($currentLesson->getDirectory() . $urlFile);
     }
 } else {
     $filesystem = new FileSystemTree($currentLesson->getDirectory(), true);
     foreach ($_FILES['scorm_file']['name'] as $key => $value) {
         if (!in_array($value, $scormFiles)) {
             //This way we bypass duplicates
             try {
                 $scormFiles[$value] = $filesystem->uploadFile("scorm_file", $currentLesson->getDirectory(), $key);
             } catch (EfrontFileException $e) {
                 if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                     throw $e;
                 }
             }
         }
     }
 }
 //pr($scormFiles);exit;
 foreach ($scormFiles as $scormFile) {
     /* Imports scorm package to database */
     $scormFolderName = EfrontFile::encode(basename($scormFile['name'], '.zip'));
     $scormPath = $currentLesson->getDirectory() . $scormFolderName . '/';
     is_dir($scormPath) or mkdir($scormPath, 0755);
     //pr($scormPath.$scormFile['name']);
Пример #7
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     $values = $form->exportValues();
     $forumUser = EfrontUserFactory::factory($_SESSION['s_login']);
     $forumAttachmentDirectory = $forumUser->getDirectory() . 'forum';
     if (!is_dir($forumAttachmentDirectory)) {
         mkdir($forumAttachmentDirectory, 0755);
     }
     $filesystem = new FileSystemTree($forumAttachmentDirectory);
     $attachmentBody = '';
     foreach ($_FILES['attachment_upload']['error'] as $key => $value) {
         if ($value != UPLOAD_ERR_NO_FILE) {
             $uploadedFile = $filesystem->uploadFile('attachment_upload', $certificateDirectory, $key);
             $attachmentid = $uploadedFile['id'];
             $attachmentBody .= '<p style="font-style:italic"><a href="view_file.php?action=download&file=' . $attachmentid . '">' . $uploadedFile['name'] . '</a></p>';
         }
     }
     if (isset($_GET['edit'])) {
         $fields = array("title" => $values['title'], "body" => $values['body'] . $attachmentBody);
         if ($this->{$this->entity}['users_LOGIN'] != $_SESSION['s_login'] && strstr($fields['body'], _FORUMMESSAGEEDITEDBY . " " . formatLogin($_SESSION['s_login'])) === false) {
             $fields['body'] .= " " . _FORUMMESSAGEEDITEDBY . " " . formatLogin($_SESSION['s_login']) . " (" . formatTimestamp(time()) . ")";
         }
         $this->{$this->entity} = array_merge($this->{$this->entity}, $fields);
         $this->persist();
     } else {
         $fields = array("title" => $values['title'], "body" => $values['body'] . $attachmentBody, "f_topics_ID" => $_GET['topic_id'], "users_LOGIN" => $_SESSION['s_login'], "timestamp" => time(), "replyto" => $values['replyto'] ? $values['replyto'] : 0);
         self::create($fields);
     }
 }
Пример #8
0
     $form->setMaxFileSize($maxFileSize * 1024);
     $form->addElement('submit', 'submit_upload_project', _SENDPROJECT, 'class = "flatButton"');
 }
 $smarty->assign("T_MAX_FILE_SIZE", $maxFileSize);
 if ($form->isSubmitted() && $form->validate() && !$currentProject->expired) {
     try {
         $projectDirectory = G_UPLOADPATH . $currentUser->user['login'] . '/projects';
         if (!is_dir($projectDirectory)) {
             EfrontDirectory::createDirectory($projectDirectory);
         }
         $projectDirectory = G_UPLOADPATH . $currentUser->user['login'] . '/projects/' . $currentProject->project['id'];
         if (!is_dir($projectDirectory)) {
             EfrontDirectory::createDirectory($projectDirectory);
         }
         $filesystem = new FileSystemTree($projectDirectory);
         $uploadedFile = $filesystem->uploadFile('filename', $projectDirectory);
         //$uploadedFile -> rename($uploadedFile['directory'].'/project_'.$currentProject -> project['id'].'.'.$uploadedFile['extension']);
         $fields_update = array("filename" => $uploadedFile['id'], "upload_timestamp" => time());
         eF_updateTableData("users_to_projects", $fields_update, "users_LOGIN='******'login'] . "' AND projects_ID=" . $_GET['view_project']);
         EfrontEvent::triggerEvent(array("type" => EfrontEvent::PROJECT_SUBMISSION, "users_LOGIN" => $currentUser->user['login'], "lessons_ID" => $currentLesson->lesson['id'], "lessons_name" => $currentLesson->lesson['name'], "entity_ID" => $currentProject->project['id'], "entity_name" => $currentProject->project['title']));
         eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=projects&view_project=" . $_GET['view_project'] . "&message=" . urlencode(_FILEUPLOADED) . "&message_type=success");
     } catch (EfrontFileException $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _SOMEPROBLEMOCCURED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 } elseif ($currentProject->expired) {
     $message = _PROJECTEXPIRED;
     $message_type = 'failure';
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
Пример #9
0
 if (isset($recipients)) {
     $pm = new eF_PersonalMessage($currentUser->user['login'], $recipients, $values['subject'], $values['body'], $values['bcc']);
     if ($_FILES['attachment']['name'][0] != "") {
         $maxFileSize = FileSystemTree::getUploadMaxSize();
         if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
             //	G_MAXFILESIZE is deprecated                                                          //If the directory could not be created, display an erro message
             $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . $maxFileSize . _KB;
             $message_type = 'failure';
         }
         //Upload user avatar file
         $pm->sender_attachment_timestamp = time();
         $user_dir = G_UPLOADPATH . $currentUser->user['login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
         mkdir($user_dir, 0755);
         $filesystem = new FileSystemTree($user_dir);
         try {
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         } catch (EfrontFileException $e) {
             //echo $e -> getMessage();
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = $e->getMessage() . "<br />";
             $message_type = 'failure';
         }
     }
     if ($pm->send($values['email'], $values)) {
         $message .= _MESSAGEWASSENT;
         $message_type = 'success';
         if (!$popup) {
             eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=messages&message=" . rawurlencode($message) . '&message_type=' . $message_type);
         }
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     global $load_editor;
     $load_editor = true;
     $current_user = $this->getCurrentUser();
     $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType());
     $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'");
     $form->addElement('hidden', 'recipients', $_GET['rec']);
     $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"');
     $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"');
     $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"');
     $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"');
     $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         switch ($values['recipients']) {
             case "lesson_students":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("student");
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 //pr($mail_recipients);return;
                 break;
             case "lesson_professors":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("professor");
                 if (isset($_SESSION['s_courses_ID'])) {
                     $course = new EfrontCourse($_SESSION['s_courses_ID']);
                     $course_users = $course->getCourseUsers();
                     foreach ($lessonUsers as $key => $value) {
                         if (!isset($course_users[$key])) {
                             unset($lessonUsers[$key]);
                         }
                     }
                 }
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
             case "admin":
                 $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0");
                 //not
                 foreach ($result as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
         }
         //$list = implode(",",$mail_recipients);
         $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']);
         if ($_FILES['attachment']['name'][0] != "") {
             $maxFileSize = FileSystemTree::getUploadMaxSize();
             if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
                 //	G_MAXFILESIZE is deprecated
                 $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes";
                 $message_type = 'failure';
             }
             //Upload user avatar file
             $pm->sender_attachment_timestamp = time();
             $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
             mkdir($user_dir, 0755);
             $filesystem = new FileSystemTree($user_dir);
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         }
         if ($pm->send($values['email'], $values)) {
             $message = _MESSAGEWASSENT;
             $message_type = 'success';
         } else {
             $message = $pm->errorMessage;
             $message_type = 'failure';
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     //Create a smarty renderer
     $renderer->setRequiredTemplate('{$html}{if $required}
     	&nbsp;<span class = "formRequired">*</span>
 		{/if}');
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     //Set javascript error messages
     $form->setRequiredNote(_REQUIREDNOTE);
     $form->accept($renderer);
     //Assign this form to the renderer, so that corresponding template code is created
     $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray());
     $smarty->assign("T_MESSAGE_MAIL", $message);
     $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type);
     //pr($renderer -> toArray());
     return true;
 }
Пример #11
0
$smarty->assign("T_HELP_IMPORT_INFO", $help_info);
if (isset($_GET['csv_sample']) && $_GET['csv_sample'] == 1 && isset($_GET['sample_type'])) {
    $sample_type = $_GET['sample_type'];
    header("content-type:text/plain");
    header('content-disposition: attachment; filename= "csv_' . $sample_type . '_sample.csv"');
    echo implode(",", EfrontImport::getMandatoryFields($sample_type)) . "," . implode(",", EfrontImport::getOptionalFields($sample_type)) . "\n";
    exit;
}
if ($importForm->isSubmitted()) {
    try {
        if (!is_dir($currentUser->user['directory'] . "/temp")) {
            mkdir($currentUser->user['directory'] . "/temp", 0755);
        }
        $importForm->exportValue('import_keep') ? $replaceUsers = false : ($replaceUsers = true);
        $filesystem = new FileSystemTree($currentUser->user['directory'] . "/temp");
        $uploadedFile = $filesystem->uploadFile('import_file');
        $options = array("replace_existing" => $replaceUsers, "date_format" => $importForm->exportValue('date_format'), "replace_assignments" => $importForm->exportValue('replace_assignments'));
        $importer = EfrontImportFactory::factory("csv", $uploadedFile, $options);
        $importType = $importForm->exportValue('import_type');
        if ($importType == "anything") {
            $import_types = $import_export_types;
            unset($import_types['anything']);
            if (G_VERSIONTYPE == 'enterprise') {
                #cpp#ifdef ENTERPRISE
                $import_types['employees'] = 1;
            }
            #cpp#endif
            $log = array("success" => array(), "failure" => array());
            foreach ($import_types as $import_type => $import_name) {
                $templog = $importer->import($import_type);
                $headerType = EfrontImport::getImportTypeName($import_type);
Пример #12
0
 /**
  * Handle uploaded file associated with question
  *
  * This function is used to handle any uploaded files that have to do with the current question
  * <br/>Example:
  * <code>
  * $test = new EfrontTest(23);
  * foreach ($test -> questions as $id => $question) {
  *     if ($question -> question['type'] == 'raw_text') {
  *         $question -> handleQuestionFiles($this -> getDirectory());
  *     }
  * }
  * </code>
  *
  * @param mixed $uploadDirectory The directory to upload the file to, a string or an EfrontDirectory object
  * @since 3.5.2
  * @access public
  */
 public function handleQuestionFiles($uploadDirectory)
 {
     $uploadedFiles = array();
     if (!$uploadDirectory instanceof EfrontDirectory && !is_dir($uploadDirectory) && !mkdir($uploadDirectory, 0755)) {
         throw new EfrontTestException(_COULDNOTCREATETESTSDIRECTORY . ': ' . $uploadDirectory, EfrontTestException::ERROR_CREATING_DIRECTORY);
     } else {
         $filesystem = new FileSystemTree($uploadDirectory);
         foreach ($_FILES as $key => $value) {
             foreach ($value['name'] as $offset => $filename) {
                 if ($filename && str_replace('file_', '', $key) == $this->question['id']) {
                     $uploadedFile = $filesystem->uploadFile($key, $uploadDirectory, $offset);
                     $this->files[] = $uploadedFile['id'];
                 }
             }
         }
     }
 }
Пример #13
0
$appearanceFaviconForm->addElement("advcheckbox", "default_favicon", _USEDEFAULTFAVICON, null, 'class = "inputCheckBox"  id = "set_default_favicon" onclick = "$(\'favicon_settings\').select(\'input\').each(function(s) {if (s.type != \'submit\' && s.id != \'set_default_favicon\') s.disabled ? s.disabled = \'\' : s.disabled = \'disabled\' })"', array(0, 1));
$appearanceFaviconForm->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $appearanceFaviconForm->freeze();
} else {
    $appearanceFaviconForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($appearanceFaviconForm->isSubmitted() && $appearanceFaviconForm->validate()) {
        try {
            //If the form is submitted and validated
            if ($appearanceFaviconForm->exportValue('default_favicon')) {
                EfrontConfiguration::setValue('favicon', '');
            } else {
                $faviconDirectory = new EfrontDirectory(G_LOGOPATH);
                $filesystem = new FileSystemTree(G_LOGOPATH);
                try {
                    $faviconFile = $filesystem->uploadFile('favicon', $logoDirectory);
                    if (strpos($faviconFile['mime_type'], 'image') === false) {
                        throw new EfrontFileException(_NOTANIMAGEFILE, EfrontFileException::NOT_APPROPRIATE_TYPE);
                    }
                    EfrontConfiguration::setValue('favicon', $faviconFile['id']);
                    clearTemplatesCache();
                } catch (Exception $e) {
                    if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                        throw $e;
                    }
                }
            }
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=appearance&tab=favicon&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
        } catch (Exception $e) {
            handleNormalFlowExceptions($e);
        }
Пример #14
0
         if ($values['custom']) {
             $uploadedFile->rename(dirname($uploadedFile['path']) . '/custom-' . $values['english_name'] . '.php.inc', true);
         } else {
             $uploadedFile->rename(dirname($uploadedFile['path']) . '/lang-' . $values['english_name'] . '.php.inc', true);
         }
     }
     $fields = array("name" => $values['english_name'], "translation" => $values['translation'], "rtl" => $values['rtl']);
     eF_updateTableData("languages", $fields, "name='" . $values['selected_language'] . "'");
     EfrontCache::getInstance()->deleteCache('languages');
     //include "editor/tiny_mce/langs/language.php";
     //$RetValues = file(G_SERVERNAME."/editor/tiny_mce/langs/language.php?langname=".$values['english_name']);
     eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=languages&message=" . urlencode(_SUCCESSFULLYUPDATEDLANGUAGE) . "&message_type=success");
 } else {
     if ($_FILES['language_upload']['error'] == 0) {
         $filesystem = new FileSystemTree(G_ROOTPATH . 'libraries/language');
         $uploadedFile = $filesystem->uploadFile('language_upload', G_ROOTPATH . 'libraries/language');
         if ($uploadedFile['extension'] == "zip") {
             $lang_zip_file_temp = new EfrontFile($uploadedFile['path']);
             $lang_zip_file = $lang_zip_file_temp->uncompress(false);
             $lang_file_rename = new EfrontFile($lang_zip_file[0]);
             if ($values['custom']) {
                 $lang_file_rename->rename(dirname($uploadedFile['path']) . '/custom-' . $values['english_name'] . '.php.inc', true);
             } else {
                 $lang_file_rename->rename(dirname($uploadedFile['path']) . '/lang-' . $values['english_name'] . '.php.inc', true);
             }
         } else {
             if ($values['custom']) {
                 $uploadedFile->rename(dirname($uploadedFile['path']) . '/custom-' . $values['english_name'] . '.php.inc', true);
             } else {
                 $uploadedFile->rename(dirname($uploadedFile['path']) . '/lang-' . $values['english_name'] . '.php.inc', true);
             }
Пример #15
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     if ($form->exportValue('remote_theme')) {
         $file = $form->exportValue('remote_theme');
         if (!fopen($file, 'r')) {
             throw new EfrontFileException(_FILEDOESNOTEXIST . ': ' . $file, EfrontFileException::FILE_NOT_EXIST);
         }
     } else {
         try {
             $filesystem = new FileSystemTree(G_THEMESPATH, true);
             $themeFile = $filesystem->uploadFile('theme_file', G_THEMESPATH);
             $filesList = $themeFile->listContents();
             if (mb_substr($filesList[0], 0, mb_strpos($filesList[0], "/")) == "default") {
                 throw new Exception(_DEFAULTTHEMECANNOTBEIMPORTED, EfrontThemesException::DEFAULT_IMPORTED);
             }
             $themeFile->uncompress(false);
             //$pathInfo = pathinfo($themeFile['path']);
             //copy(G_DEFAULTTHEMEPATH.'css/css_global.php', $pathInfo['dirname'].'/'.$pathInfo['filename'].'/css/css_global.php');
             $themeFile->delete();
             $file = new EfrontFile($themeFile['directory'] . '/' . str_replace('.zip', '', $themeFile['name']) . "/theme.xml");
         } catch (EfrontFileException $e) {
             //Don't halt if no file was uploaded (errcode = 4). Otherwise, throw the exception
             if ($e->getCode() != 4) {
                 throw $e;
             }
         }
     }
     if ($file) {
         $xmlValues = themes::parseFile($file);
         if ($_GET['add']) {
             $theme = self::create($xmlValues);
         }
         /*
         else {
             $this -> options = array_merge($this -> options, $xmlValues);
             $this -> layout  =
             $this -> persist();
         }
         */
     }
     //$smarty -> assign("T_RELOAD_ALL", 1);
 }
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     $dir = $this->moduleBaseDir . 'assets/';
     if (!is_dir($dir)) {
         mkdir($dir, 0755);
     }
     if ($_SESSION['s_type'] == 'administrator') {
         try {
             $form = new HTML_QuickForm("upload_files_form", "post", $this->moduleBaseUrl . '&tab=upload', "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('file', 'file', _UPLOADFILE);
             if (G_VERSIONTYPE == 'enterprise') {
                 $tree = new EfrontBranchesTree();
                 $pathString = $tree->toPathString();
                 //$result = eF_getTableData("module_hcd_branch", "*", "url is not null and url !=''");
                 $handle = '<img id = "busy" src = "images/16x16/clock.png" style = "display:none;" alt = "{$smarty.const._LOADING}" title = "{$smarty.const._LOADING}"/><div id = "autocomplete_leaflet_branches" class = "autocomplete"></div>&nbsp;&nbsp;&nbsp;';
                 $form->addElement('static', 'sidenote', $handle);
                 $form->addElement('text', 'leaflet_branch_autoselect', _BRANCH, 'class = "autoCompleteTextBox" id = "autocomplete"');
                 $form->addElement('hidden', 'leaflet_branch', '', 'id = "leaflet_branch_value"');
             }
             $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
             $form->addElement('submit', 'submit_upload', _UPLOAD, 'class = "flatButton"');
             if ($form->isSubmitted() && $form->validate()) {
                 $values = $form->exportValues();
                 try {
                     if ($values['leaflet_branch'] && eF_checkParameter($values['leaflet_branch'], 'id')) {
                         $branch = new EfrontBranch($values['leaflet_branch']);
                         if (!$branch->branch['url']) {
                             throw new Exception("You must assign a url to the selected branch to upload files for it");
                         }
                         $dir = $this->moduleBaseDir . 'assets/' . $branch->branch['url'];
                         mkdir($dir, 0755);
                     }
                     $filesystem = new FileSystemTree($dir);
                     $file = $filesystem->uploadFile("file", $dir);
                 } catch (Exception $e) {
                     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                     $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                     $message_type = failure;
                     $this->setMessageVar($message, $message_type);
                 }
             }
             $smarty->assign('T_UPLOAD_FORM', $form->toArray());
             $url = $this->moduleBaseUrl;
             $basedir = $dir;
             $options = array('zip' => false, 'upload' => false, 'create_folder' => false, 'folders' => true);
             /**The file manager*/
             include "file_manager.php";
         } catch (Exception $e) {
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
             $message_type = 'failure';
             $this->setMessageVar($message, $message_type);
         }
     } else {
         if (defined('G_BRANCH_URL') && G_BRANCH_URL) {
             try {
                 $assets_path = $root_path = $this->moduleBaseDir . 'assets/' . G_BRANCH_URL;
             } catch (Exception $e) {
                 //do nothing here if the directory doesn't exist
             }
         } else {
             $assets_path = $root_path = $this->moduleBaseDir . 'assets/';
         }
         $files = array();
         if (!empty($_GET['folder'])) {
             $folder = urldecode($_GET['folder']);
             if (is_dir($assets_path . $folder)) {
                 $folder = new EfrontDirectory($assets_path . $folder);
                 if (strpos(realpath($folder['path']), $root_path) === false) {
                     throw new Exception("Invalid folder");
                 }
                 $parent_folder = dirname($folder['path']);
                 $url = urlencode(str_replace($root_path, '', $folder['path']));
                 $assets_path = $folder['path'];
                 $parent_url = $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', dirname($folder['path']) . '/'));
                 $parent_url or $parent_url = $this->moduleBaseUrl . 'assets/';
                 $files[] = array('text' => '.. (Up one level)', 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $parent_url);
             }
         }
         //pr($url);pr($parent_url);
         //
         $filesystem = new FileSystemTree($assets_path, true);
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontDirectory) {
                 $files[] = array('text' => basename($key), 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', $value['path'] . '/')));
             }
         }
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontFile) {
                 if (is_file($this->moduleBaseDir . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png')) {
                     $icon = $this->moduleBaseLink . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png';
                 } else {
                     $icon = $this->moduleBaseLink . 'ico/unknown.png';
                 }
                 $files[] = array('text' => basename($key), 'image' => $icon, 'href' => $this->moduleBaseLink . str_replace($this->moduleBaseDir, '', $key));
             }
         }
         $smarty->assign("T_FILES", $files);
     }
     return true;
 }
Пример #17
0
             //Lesson file
             $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
             //getUploadMaxSize returns size in KB
             $form->addElement('submit', 'submit_import_course', _SUBMIT, 'class = "flatButton"');
             $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
             if ($form->isSubmitted() && $form->validate()) {
                 try {
                     $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
                     if (!is_dir($userTempDir)) {
                         //If the user's temp directory does not exist, create it
                         $userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
                     } else {
                         $userTempDir = new EfrontDirectory($userTempDir);
                     }
                     $filesystem = new FileSystemTree($userTempDir);
                     $uploadedFile = $filesystem->uploadFile('file_upload', $userTempDir);
                     $currentCourse->import($uploadedFile);
                     $message = _COURSEIMPORTEDSUCCESFULLY;
                     $message_type = 'success';
                 } catch (Exception $e) {
                     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                     $message = _PROBLEMIMPORTINGFILE . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                     $message_type = 'failure';
                 }
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->accept($renderer);
             $smarty->assign('T_IMPORT_COURSE_FORM', $renderer->toArray());
         }
     }
 }
     }
     $editedUser->user = array_merge($editedUser->user, $userProperties);
     $editedUser->persist();
     if ($currentUser->user['login'] == $editedUser->user['login'] && $_SESSION['s_password'] != $editedUser->user['password']) {
         $_SESSION['s_password'] = $editedUser->user['password'];
     }
     if ($currentUser->user['login'] == $editedUser->user['login'] && $_SESSION['s_language'] != $editedUser->user['languages_NAME']) {
         $_SESSION['s_language'] = $editedUser->user['languages_NAME'];
     }
 }
 if (!in_array('file_upload', $constrainAccess) && $constrainAccess != 'all') {
     $avatarDirectory = G_UPLOADPATH . $editedUser->user['login'] . '/avatars';
     is_dir($avatarDirectory) or mkdir($avatarDirectory, 0755);
     try {
         $filesystem = new FileSystemTree($avatarDirectory);
         $uploadedFile = $filesystem->uploadFile('file_upload', $avatarDirectory);
         if (strpos($uploadedFile['mime_type'], 'image') === false) {
             throw new EfrontFileException(_NOTANIMAGEFILE, EfrontFileException::NOT_APPROPRIATE_TYPE);
         }
         eF_normalizeImage($avatarDirectory . "/" . $uploadedFile['name'], $uploadedFile['extension'], 150, 100);
         // Normalize avatar picture to 150xDimY or DimX x 100
         $editedUser->user['avatar'] = $uploadedFile['id'];
         //pr($editedUser -> user['avatar']);exit;
     } catch (Exception $e) {
         //pr($e);	exit;
         if ($e->getCode() == EfrontFileException::NOT_APPROPRIATE_TYPE) {
             $uploadedFile->delete();
         }
         if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
             throw $e;
         }
Пример #19
0
//getUploadMaxSize returns size in KB
$form->addElement('submit', 'import_submit', _IMPORT, 'class = "flatButton"');
if ($form->isSubmitted() && $form->validate()) {
    try {
        $values = $form->exportValues();
        $errors = $uploadedFiles = array();
        //Create, if it does not exist, the folder where the files will be uploaded
        //is_dir($uploadDir = $currentUser -> getDirectory().'temp/') OR mkdir($uploadDir, 0755);
        $uploadDir = $currentLesson->getDirectory();
        $filesystem = new FileSystemTree($uploadDir, true);
        //Perform any direct file uploads
        foreach ($_FILES['import_file']['name'] as $key => $name) {
            if (!in_array($name, $uploadedFiles)) {
                //This way we bypass duplicates
                try {
                    $uploadedFiles[$name] = $filesystem->uploadFile("import_file", $uploadDir, $key);
                } catch (EfrontFileException $e) {
                    if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                        $errors[] = $e->getMessage();
                    }
                }
            }
        }
        //Perform any url uploads
        foreach ($values['import_url'] as $key => $urlUpload) {
            if ($urlUpload && !in_array(basename($urlUpload), $uploadedFiles)) {
                FileSystemTree::checkFile($urlUpload);
                $urlArray = explode("/", $urlUpload);
                $urlFile = urldecode($urlArray[sizeof($urlArray) - 1]);
                if (!copy(dirname($urlUpload) . '/' . rawurlencode(basename($urlUpload)), $uploadDir . "/" . $urlFile)) {
                    $errors[] = _PROBLEMUPLOADINGFILE . ': ' . $urlUpload;
Пример #20
0
            $currentLesson->initialize(array_keys($values['options']));
            $filesystem = new FileSystemTree($currentLesson->getDirectory());
            $urlUpload = $values['url_upload'];
            if ($urlUpload != "") {
                FileSystemTree::checkFile($urlUpload);
                $urlArray = explode("/", $urlUpload);
                $urlFile = urldecode($urlArray[sizeof($urlArray) - 1]);
                if (!copy($urlUpload, $currentLesson->getDirectory() . $urlFile)) {
                    $error = error_get_last();
                    throw new Exception(_PROBLEMUPLOADINGFILE . ': ' . $error['message']);
                } else {
                    $uploadedFile = new EfrontFile($currentLesson->getDirectory() . $urlFile);
                    $currentLesson->import($uploadedFile, $values['options'], false, false, $values['exclude_search']);
                }
            } else {
                $uploadedFile = $filesystem->uploadFile('file_upload', $currentLesson->getDirectory());
                $currentLesson->import($uploadedFile, $values['options'], false, false, $values['exclude_search']);
            }
            $smarty->assign("T_REFRESH_SIDE", 1);
            $message = _LESSONIMPORTEDSUCCESFULLY;
            $message_type = 'success';
        } catch (Exception $e) {
            $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
            $message = _PROBLEMIMPORTINGFILE . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
            $message_type = 'failure';
        }
    }
    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
    $form->accept($renderer);
    $smarty->assign('T_IMPORT_LESSON_FORM', $renderer->toArray());
} elseif ($_GET['op'] == 'export_lesson') {