/**
  * Send a personal message
  *
  * This function is used to send the personal message. If $email is specified,
  * the message is also emailed to the recipients
  * <br/>Example:
  * <code>
  * $pm = new eF_PersonalMessage("professor", array("professor", "student", "admin"), 'Test subject', 'Test personal message body');
  * $pm -> send();
  * </code>
  *
  * @param boolean If true, the personal message will be send as an email as well
  * @return true on success, false on error
  * @since 1.0
  * @access public
  */
 public function send($email = false)
 {
     if (sizeof($this->recipients) == 0) {
         $this->errorMessage = _INVALIDRECIPIENT;
         return false;
     }
     $timestamp = time();
     if ($email) {
         //Check if the messag should be sent as an email also. This will be sent no matter the user quotas
         $recipientsMail = array();
         foreach ($this->recipients as $recipient) {
             if ($this->userData[$recipient]['email'] != "") {
                 $recipientsMail[] = $this->userData[$recipient]['email'];
             } else {
                 $this->errorMessage .= $this->userData[$recipient]['login'] . ' ' . _HASNOTANEMAILADDRESS . '<br/>';
             }
         }
         $recipientsList = implode(",", $recipientsMail);
         $this->body = _THISISAPMFROMSITE . " <a href=" . G_SERVERNAME . ">" . G_SERVERNAME . "</a><br />" . $this->body;
         $emailBody = str_replace('##EFRONTINNERLINK##', 'student', $this->body);
         if (($result = eF_mail($this->userData[$this->sender]['email'], $recipientsList, $this->subject, $emailBody, $this->attachments, false, $this->bcc)) !== true) {
             $this->errorMessage .= _THEMESSAGEWASNOTSENTASEMAIL . '<br/>';
         }
     }
     foreach ($this->recipients as $recipient) {
         $fields_insert = array("users_LOGIN" => $recipient, "recipient" => implode(", ", $this->recipients), "sender" => $this->sender, "timestamp" => $timestamp, "title" => $this->subject, "body" => $this->body, "bcc" => $this->bcc ? 1 : 0, "f_folders_ID" => $this->userData[$recipient]['folders']['Incoming'], "viewed" => 0);
         //It is not viewed yet
         if (!empty($this->attachments) && $this->attachments[0]) {
             if ($this->checkUserQuota($recipient)) {
                 $attachment = new EfrontFile($this->sender_attachment_fileId);
                 $recipient_dir = G_UPLOADPATH . $recipient . '/message_attachments/Incoming/' . $timestamp . '/';
                 mkdir($recipient_dir, 0755);
                 $newFile = $attachment->copy($recipient_dir, false, true);
                 $fields_insert["attachments"] = $newFile['id'];
             } else {
                 $fields_insert["body"] .= '<br /><span class="failure">' . _THEREWASATTACHMENTCUTBECAUSEOFQUOTA . '</span>';
             }
         }
         $id = eF_insertTableData("f_personal_messages", $fields_insert);
         EfrontSearch::insertText($fields_insert['body'], $id, "f_personal_messages", "data");
         EfrontSearch::insertText($fields_insert['title'], $id, "f_personal_messages", "title");
     }
     //it should not come here if sender has reached maximum space limit
     //if ($this -> checkUserQuota($this -> sender)) {
     $fields_insert = array("users_LOGIN" => $this->sender, "recipient" => implode(", ", $this->recipients), "sender" => $this->sender, "timestamp" => $timestamp, "title" => $this->subject, "body" => $this->body, "bcc" => $this->bcc ? 1 : 0, "f_folders_ID" => $this->userData[$this->sender]['folders']['Sent'], "viewed" => 0);
     if (!empty($this->attachments) && $this->attachments[0]) {
         $attachment = new EfrontFile($this->sender_attachment_fileId);
         $fields_insert["attachments"] = $this->sender_attachment_fileId;
     }
     $id = eF_insertTableData("f_personal_messages", $fields_insert);
     EfrontSearch::insertText($fields_insert['body'], $id, "f_personal_messages", "data");
     EfrontSearch::insertText($fields_insert['title'], $id, "f_personal_messages", "title");
     //} else {
     //    $this -> errorMessage .= _COULDNOTBECOPIEDTOYOURSENTBOX.' '._BECAUSEYOURMESSAGEBOXISFULL.'<br />';
     //}
     if ($this->errorMessage) {
         return false;
     } else {
         return true;
     }
 }
예제 #2
0
 /**
  * Create The MS Word Document from given HTML
  *
  * @param String $html :: HTML Content or HTML File Name like path/to/html/file.html
  * @param String $file :: Document File Name
  * @param Boolean $download :: Wheather to download the file or save the file
  * @return boolean 
  */
 function createDoc($html, $file, $download = false)
 {
     if (is_file($html)) {
         $html = @file_get_contents($html);
     }
     $this->_parseHtml($html);
     $this->setDocFileName($file);
     $doc = $this->getHeader();
     $doc .= $this->htmlBody;
     $doc .= $this->getFotter();
     if ($download) {
         if (!empty($this->localimgs)) {
             if (file_exists($this->lessonDirectory . $file)) {
                 $tmpDir = new EfrontDirectory($this->lessonDirectory . $file);
             } else {
                 $tmpDir = EfrontDirectory::createDirectory($this->lessonDirectory . $file);
             }
             $array_cp = $tmpDir->getArrayCopy();
             foreach ($this->localimgs as $img) {
                 $file = new EfrontFile($img['path'] . $img['src']);
                 $file->copy($array_cp['path'] . "/" . $img['src']);
             }
             $this->write_file($array_cp['path'] . "/" . $this->docFile, $doc);
             $zipfile = $tmpDir->compress();
             $tmpDir->delete();
             $zipfile->sendFile();
             exit;
         } else {
             @header("Cache-Control: ");
             // leave blank to avoid IE errors
             @header("Pragma: ");
             // leave blank to avoid IE errors
             @header("Content-type: application/octet-stream");
             @header("Content-Disposition: attachment; filename=\"{$this->docFile}\"");
             echo $doc;
         }
         return true;
     } else {
         return $this->write_file($this->docFile, $doc);
     }
 }
예제 #3
0
 /**
  * Copy simple unit
  *
  * This function copies a unit (NOT its children) into the current content tree
  * <br/>Example:
  * <code>
  * $currentContent = new EfrontContentTree(5);           //Initialize content for lesson with id 5
  * $sourceUnit = new EfrontUnit(20);                     //Get the unit with id = 20
  * $currentContent -> copySimpleUnit($sourceUnit, false);   //Copy the source unit into the content tree (at its end)
  * </code>
  *
  * @param EfrontUnit $sourceUnit The unit object to be copied
  * @param mixed $targetUnit The id of the parent unit (or the parent EfrontUnit)in which the new unit will be copied, or false (the unit will be appended at the end)
  * @param mixed $previousUnit The id of the previous unit (or the unit itself) of the new unit, or false (the unit will be put to the end of the units)
  * @param boolean $copyFiles whether to copy files as well.
  * @param boolean $copyQuestions Whether to copy questions as well
  * @return EfrontUnit The newly created unit object
  * @since 3.5.0
  * @access public
  */
 public function copySimpleUnit($sourceUnit, $targetUnit = false, $previousUnit = false, $copyFiles = true, $copyQuestions = true)
 {
     if (!$sourceUnit instanceof EfrontUnit) {
         $sourceUnit = new EfrontUnit($sourceUnit);
     }
     $newUnit['name'] = $sourceUnit->offsetGet('name');
     $newUnit['ctg_type'] = $sourceUnit->offsetGet('ctg_type');
     $newUnit['data'] = $sourceUnit->offsetGet('data');
     $options = $sourceUnit->offsetGet('options');
     $newOptions['complete_unit_setting'] = $options['complete_unit_setting'];
     $newOptions['hide_navigation'] = $options['hide_navigation'];
     $newOptions['maximize_viewport'] = $options['maximize_viewport'];
     $newOptions['object_ids'] = $options['object_ids'];
     $newUnit['options'] = serialize($newOptions);
     $newUnit['lessons_ID'] = $this->lessonId;
     if ($targetUnit) {
         if ($targetUnit instanceof EfrontUnit) {
             $newUnit['parent_content_ID'] = $targetUnit->offsetGet('id');
         } else {
             if (eF_checkParameter($targetUnit, 'id')) {
                 $newUnit['parent_content_ID'] = $targetUnit;
             }
         }
         if ($previousUnit instanceof EfrontUnit) {
             $newUnit['previous_content_ID'] = $previousUnit->offsetGet('id');
         } else {
             if (eF_checkParameter($previousUnit, 'id')) {
                 $newUnit['previous_content_ID'] = $previousUnit;
             }
         }
         $unit = $this->insertNode($newUnit);
     } else {
         $unit = $this->appendUnit($newUnit);
     }
     if ($copyFiles) {
         $files = $unit->getFiles();
         $lesson = new EfrontLesson($this->lessonId);
         $data = $unit->offsetGet('data');
         foreach ($files as $file) {
             try {
                 $sourceFile = new EfrontFile($file);
                 $sourceFileOffset = preg_replace("#" . G_LESSONSPATH . "#", "", $sourceFile['directory']);
                 $position = strpos($sourceFileOffset, "/");
                 //check case that the file is in a subfolder of the lesson
                 if ($position !== false) {
                     $sourceLink = mb_substr($sourceFileOffset, $position + 1);
                     mkdir($lesson->getDirectory() . $sourceLink . '/', 0755, true);
                     $destinationPath = $lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']);
                     $copiedFile = $sourceFile->copy($destinationPath, false);
                 } else {
                     $destinationPath = $lesson->getDirectory() . basename($sourceFile['path']);
                     $copiedFile = $sourceFile->copy($destinationPath, false);
                 }
                 //@todo view_file.php?action=download&file=10410
                 //$data = str_replace("view_file.php?file=".$file, "view_file.php?file=".$copiedFile -> offsetGet('id'), $data);
                 //$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data);
                 //$data = str_replace("&amp;file=".$file, "&amp;file=".$copiedFile -> offsetGet('id'), $data);
                 $data = preg_replace('#view_file\\.php(.*)file=' . $file . '#', 'view_file.php${1}file=' . $copiedFile->offsetGet('id'), $data);
                 $folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id'];
                 $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceUnit['lessons_ID'] . "/(.*)#", "content/lessons/" . $folderId . '/${2}', $data);
             } catch (EfrontFileException $e) {
                 if ($e->getCode() == EfrontFileException::FILE_ALREADY_EXISTS) {
                     $copiedFile = new EfrontFile($destinationPath);
                     //$data = str_replace("view_file.php?file=".$file, "view_file.php?file=".$copiedFile -> offsetGet('id'), $data);
                     //$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data);
                     //$data = str_replace("&amp;file=".$file, "&amp;file=".$copiedFile -> offsetGet('id'), $data);
                     $data = preg_replace('#view_file\\.php(.*)file=' . $file . '#', 'view_file.php${1}file=' . $copiedFile->offsetGet('id'), $data);
                     $folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id'];
                     $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceUnit['lessons_ID'] . "/(.*)#", "content/lessons/" . $folderId . '/${2}', $data, -1, $count);
                 }
             }
             //this means that the file already exists
         }
         $unit->offsetSet('data', $data);
         if ($file && $unit['ctg_type'] == 'scorm' || $unit['ctg_type'] == 'scorm_test') {
             $d = new EfrontDirectory(dirname($file));
             $d->copy($lesson->getDirectory() . basename(dirname($file)), true);
         }
     }
     $unit->persist();
     // copying questions that belong to this unit
     if ($copyQuestions) {
         $questions = eF_getTableData("questions", "*", "content_ID=" . $sourceUnit->offsetGet('id'));
         if ($copyFiles) {
             $folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id'];
         }
         for ($k = 0; $k < sizeof($questions); $k++) {
             if ($copyFiles) {
                 $questions[$k]['text'] = replaceQuestionPaths($questions[$k]['text'], $questions[$k]['lessons_ID'], $folderId);
                 $questions[$k]['explanation'] = replaceQuestionPaths($questions[$k]['explanation'], $questions[$k]['lessons_ID'], $folderId);
             }
             $questions[$k]['content_ID'] = $unit->offsetGet('id');
             $questions[$k]['lessons_ID'] = $unit->offsetGet('lessons_ID');
             unset($questions[$k]['id']);
             eF_insertTableData("questions", $questions[$k]);
         }
     }
     return $unit;
 }
예제 #4
0
파일: projects.php 프로젝트: bqq1986/efront
         foreach ($result as $project) {
             $projectFiles[$project['title']] = new EfrontFile($project['filename']);
         }
         if (!is_dir($currentUser->user['directory'] . '/projects/')) {
             mkdir($currentUser->user['directory'] . '/projects/', 0755);
         }
         $projectDir = $currentUser->user['directory'] . '/projects/' . $_GET['compress_user'];
         if (!is_dir($projectDir)) {
             mkdir($projectDir, 0755);
         }
         $projectDirectory = new EfrontDirectory($projectDir);
         foreach ($projectFiles as $title => $file) {
             try {
                 $projectFile = new EfrontFile($file['id']);
                 $newFileName = EfrontFile::encode($title . '_' . date("d.m.Y", $file['upload_timestamp']) . '_' . $projectFile['name']);
                 $projectFile->copy($projectDir . '/' . $newFileName);
             } catch (EfrontFileException $e) {
                 //Don't halt for a single file
                 $message .= $e->getMessage() . ' (' . $e->getCode() . ')';
             }
         }
         $zipFileName = $currentUser->user['directory'] . '/projects/' . EfrontFile::encode($_GET['compress_user']) . '.zip';
         $zipFile = $projectDirectory->compress($zipFileName, false, true);
         $projectDirectory->delete();
         eF_redirect("view_file.php?file=" . urlencode($zipFile['path']) . "&action=download");
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _FILESCOULDNOTBEDOWNLOADED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 } else {
예제 #5
0
    /**
     * Create HTML representation of file system tree
     *
     * This function creates the file manager HTML code. It also handles any AJAX calls,
     * composes and prints upload and create directory forms, as well as makes sure the
     * correct folder contents are displayed.
     * <code>
     * $basedir    = G_LESSONSPATH.'test/';
     * $filesystem = new FileSystemTree($basedir);									//Set the base directory that the file manager displayes
     * $url        = 'administrator.php?ctg=file_manager';			//Set the url where file manager resides
     * echo $filesystem -> toHTML($url); 											//Display file manager
     * </code>
     * The available options are (the default value in parenthesis):
     * - show_type (true)				//Whether to show the "type" column
     * - show_date (true)				//Whether to show the "last modified" column
     * - show_name (true)				//Whether to show the "name" column
     * - show_size (true)				//Whether to show the "size" column
     * - show_tools (true)				//Whether to show the "tools" column
     * - metadata (true)				//Whether to allow for metadata
     * - db_files_only (false) 			//Whether to display only files that have a db representation
     * - delete (true)					//Whether to display delete icon
     * - download (true)				//Whether to display download icon
     * - zip  (true)					//Whether to display zip icon
     * - share (true)					//Whether to display share icon
     * - create_folder (true)			//Whether to display create folder link
     * - upload (true)					//Whether to display upload file link
     * - copy (true)					//Whether to display copy icon
     * - folders (true)					//Whether to display folders in files list
     *
     * The $extraFileTools, $extraHeaderOptions, $extraDirectoryTools paramaters are used to add custom
     * extra tools to various places of the file manager. The format of these parameters is of the form:
     * $extraFileTools = array(array('image' => 'images/16x16/restore.png', 'title' => _RESTORE, 'action' => 'restore'));
     * $extraHeaderOptions = array(array('image' => 'images/16x16/undo.png', 'title' => _BACKUP, 'action' => 'backup'));
     *
     * @param string $url The url where the file manager resides
     * @param string $currentDirectory The directory to use as base directory
     * @param array $ajaxOptions AJAX-specific options: sort, order, limit, offset, filter
     * @param array $options Options for the file manager
     * @param array $extraFileTools Extra tools for files
     * @param array $extraDirectoryTools Extra tools for directories
     * @param array $extraHeaderOptions Extra tools for file manager header
     * @param array $defaultIterator A specific iterator to use for files display
     * @param bool 	$show_tooltip If tooltip is dislayed in name
     * @return string The HTML representation of the file system
     * @since 3.5.0
     * @access public
     */
    public function toHTML($url, $currentDirectory = '', $ajaxOptions = array(), $options, $extraFileTools = array(), $extraDirectoryTools = array(), $extraHeaderOptions = array(), $defaultIterator = false, $show_tooltip = true, $extraColumns = array())
    {
        //Set default options
        !isset($options['show_type']) ? $options['show_type'] = true : null;
        !isset($options['show_date']) ? $options['show_date'] = true : null;
        !isset($options['show_name']) ? $options['show_name'] = true : null;
        !isset($options['show_size']) ? $options['show_size'] = true : null;
        !isset($options['show_tools']) ? $options['show_tools'] = true : null;
        !isset($options['delete']) ? $options['delete'] = true : null;
        !isset($options['download']) ? $options['download'] = true : null;
        !isset($options['zip']) ? $options['zip'] = true : null;
        !isset($options['share']) ? $options['share'] = true : null;
        !isset($options['edit']) ? $options['edit'] = true : null;
        !isset($options['copy']) ? $options['copy'] = true : null;
        !isset($options['create_folder']) ? $options['create_folder'] = true : null;
        !isset($options['upload']) ? $options['upload'] = true : null;
        !isset($options['folders']) ? $options['folders'] = true : null;
        !isset($options['db_files_only']) ? $options['db_files_only'] = false : null;
        !isset($options['table_id']) ? $tableId = 'filesTable' : ($tableId = $options['table_id']);
        //Make sure that current directory is a path
        //$currentDirectory = new EfrontDirectory($currentDirectory);
        if ($currentDirectory instanceof EfrontDirectory) {
            $currentDirectory = $currentDirectory['path'];
        }
        if (isset($_POST['upload_current_directory']) && strpos(EfrontDirectory::normalize($_POST['upload_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['upload_current_directory'];
        }
        if (isset($_POST['current_directory']) && strpos(EfrontDirectory::normalize($_POST['current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['current_directory'];
        }
        if (isset($_POST['copy_current_directory']) && strpos(EfrontDirectory::normalize($_POST['copy_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['copy_current_directory'];
        }
        if ($currentDirectory && $currentDirectory != $this->dir['path']) {
            //Check that the current directory actually exists
            $currentDir = new EfrontDirectory($currentDirectory);
            //Get its parent directory
            $parentDir = new EfrontDirectory($currentDir['directory']);
            //Build a new (shallow) file system tree on the current directory
            $innerFileSystem = new FileSystemTree($currentDir, false);
            //Assign each node as a child to the currentDir, thus creating a new tree with currentDir as parent
            foreach ($innerFileSystem->tree as $key => $value) {
                $currentDir[$key] = $value;
            }
            //$currentDir = $this -> seekNode($currentDirectory);
            //$parentDir  = new EfrontDirectory($currentDir['directory']);
        } else {
            $currentDirectory = $this->dir['path'];
            $currentDir = $this->tree;
        }
        try {
            $uploadForm = new HTML_QuickForm("upload_file_form_{$tableId}", "post", $url, "", "target = 'POPUP_FRAME'", true);
            $uploadFormString = $this->getUploadForm($uploadForm);
            if ($uploadForm->isSubmitted() && $uploadForm->validate()) {
                $uploadedFile = $this->handleUploadForm($uploadForm);
                $uploadFormString .= '
                	  <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');parent.$(\'uploading_image\').hide()}</script>';
            }
            $createFolderForm = new HTML_QuickForm("create_folder_form", "post", $url, "", "target = 'POPUP_FRAME'", true);
            $createFolderString = $this->getCreateDirectoryForm($createFolderForm);
            if ($createFolderForm->isSubmitted() && $createFolderForm->validate()) {
                $this->handleCreateDirectoryForm($createFolderForm);
                $createFolderString .= '
                	  <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');}</script>';
            }
            /*
            $copyForm       = new HTML_QuickForm("copy_file_form", "post", $url, "", "", true);
            
            foreach ($iterator = new EfrontDirectoryOnlyFilterIterator(new EfrontNodeFilterIterator($currentDir)) as $key => $value) {
            $directories[$key] = str_replace($this -> dir['path'].'/', '', EfrontFile :: decode($value['path']));
            }
            $copyForm -> addElement('select', 'destination', null, $directories, 'class = "inputText"');
            $copyFormString = $this -> getCopyForm($copyForm);
            
            if ($copyForm -> isSubmitted() && $copyForm -> validate()) {
            $copiedFile = $this -> handleCopyForm($copyForm);
            }
            */
            //pr($currentDirectory);
            if (isset($_POST['copy_files']) && sizeof($_POST['copy_files']) > 0) {
                $copyFiles = explode(",", $_POST["copy_files"]);
                foreach ($copyFiles as $file) {
                    $file = new EfrontFile($file);
                    //pr('copying to '.$currentDirectory.'/'.basename($file['path']));
                    $file->copy($currentDirectory . '/' . basename($file['path']));
                }
            }
        } catch (Exception $e) {
            echo "<script>if (top && top.mainframe) {w=top.mainframe} else {w=parent;}w.document.getElementById('messageError').innerHTML = '" . $e->getMessage() . "';parent.\$('uploading_image').hide();</script>";
            //Don't halt for uploading and create directory errors
            $GLOBALS['smarty']->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
            $GLOBALS['message'] = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        }
        $files = array();
        $fileArrays = array();
        $foldersArray = array();
        $filesArray = array();
        if ($options['folders']) {
            $iterator = new EfrontDirectoryOnlyFilterIterator(new ArrayIterator($currentDir));
            //Plain ArrayIterator so that it iterates only on the current's folder files
            if ($options['db_files_only']) {
                //Filter out directories without database representation
                $iterator = new EfrontDBOnlyFilterIterator($iterator);
            }
            foreach ($iterator as $key => $value) {
                //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily
                $current = (array) $iterator->current();
                foreach ($current as $k => $v) {
                    //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering
                    if ($v instanceof ArrayObject) {
                        unset($current[$k]);
                    }
                }
                $current['size'] = 0;
                $current['extension'] = '';
                $current['shared'] = 10;
                //Add these 3 parameters, so that sorting below works correctly (10 means nothing, since a folder cannot be shared, but it is handy for sorting)
                $foldersArray[] = (array) $current;
                //Array representation of directory objects, on which we can apply sorting, filtering, etc
            }
            $foldersArray = eF_multiSort($foldersArray, 'name', 'asc');
        }
        if ($defaultIterator) {
            $iterator = $defaultIterator;
        } else {
            $iterator = new EfrontFileOnlyFilterIterator(new EfrontNodeFilterIterator(new ArrayIterator($currentDir)));
            //Plain ArrayIterator so that it iterates only on the current folder's files
            if ($options['db_files_only']) {
                //Filter out directories without database representation
                $iterator = new EfrontDBOnlyFilterIterator($iterator);
            }
        }
        foreach ($iterator as $key => $value) {
            //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily
            $current = (array) $iterator->current();
            foreach ($current as $k => $v) {
                //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering
                if ($v instanceof ArrayObject) {
                    unset($current[$k]);
                }
            }
            $filesArray[] = (array) $current;
            //Array representation of file objects, on which we can apply sorting, filtering, etc
        }
        $filesArray = eF_multiSort($filesArray, 'name', 'asc');
        $fileArrays = array_merge($foldersArray, $filesArray);
        isset($ajaxOptions['order']) && $ajaxOptions['order'] == 'asc' ? $ajaxOptions['order'] = 'asc' : ($ajaxOptions['order'] = 'desc');
        !isset($ajaxOptions['sort']) ? $ajaxOptions['sort'] = 'name' : null;
        !isset($ajaxOptions['limit']) ? $ajaxOptions['limit'] = 20 : null;
        !isset($ajaxOptions['offset']) ? $ajaxOptions['offset'] = 0 : null;
        !isset($ajaxOptions['filter']) ? $ajaxOptions['filter'] = '' : null;
        $size = sizeof($fileArrays);
        if ($size) {
            $fileArrays = eF_multiSort($fileArrays, $ajaxOptions['sort'], $ajaxOptions['order']);
            $ajaxOptions['filter'] ? $fileArrays = eF_filterData($fileArrays, $ajaxOptions['filter']) : null;
            $fileArrays = array_slice($fileArrays, $ajaxOptions['offset'], $ajaxOptions['limit']);
        }
        $extraColumnsString = '';
        foreach ($extraColumns as $value) {
            $extraColumnsString = '<td class = "topTitle centerAlign" name = "' . $value . '">' . $value . '</td>';
        }
        $filesCode = '
                        <table class = "sortedTable" style = "width:100%" size = "' . $size . '" id = "' . $tableId . '" useAjax = "1" rowsPerPage = "20" other = "' . urlencode($currentDirectory) . '" url = "' . $url . '&" nomass = "1" currentDir = "' . (isset($currentDir['path']) ? $currentDir['path'] : '') . '">
                    		<tr>' . ($options['show_type'] ? '<td class = "topTitle centerAlign" name = "extension">' . _TYPE . '</td>' : '') . '
                    			' . ($options['show_name'] ? '<td class = "topTitle" name = "name" id = "filename_' . $tableId . '">' . _NAME . '</td>' : '') . '
                    			' . ($options['show_size'] ? '<td class = "topTitle" name = "size">' . _SIZE . '</td>' : '') . '
                    			' . ($options['show_date'] ? '<td class = "topTitle" name = "timestamp">' . _MODIFIED . '</td>' : '') . '
								' . $extraColumnsString . '
                    			' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign" name = "shared">' . _SHARE . '</td>' : '') . '
                    			' . ($options['show_tools'] ? '<td class = "topTitle centerAlign noSort">' . _OPERATIONS . '</td>' : '') . '
                    			' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign">' . _SELECT . '</td>' : '') . '
                    		</tr>';
        if (isset($parentDir)) {
            if ($parentDir['path'] == $this->dir['path']) {
                $parentDir['path'] = '';
            }
            $filesCode .= '
            			<tr class = "defaultRowHeight eventRowColor"><td class = "centerAlign" colspan = "100%">' . _CURRENTLYBROWSINGFOLDER . ': ' . EfrontFile::decode(str_replace($this->dir['path'], '', $currentDir['path'])) . '</td></tr>
                    	<tr class = "defaultRowHeight oddRowColor">
                    		<td class = "centerAlign"><span style = "display:none"></span><img src = "images/16x16/folder_up.png" alt = "' . _UPONELEVEL . '" title = "' . _UPONELEVEL . '"/></td>
                    		<td><a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($parentDir['path']) . '\');">.. (' . _UPONELEVEL . ')</a></td>
                    		<td colspan = "5"></td></tr>';
        }
        $i = 0;
        if ($_SESSION['supervises_branches'] != "") {
            $currentEmployee = EfrontUserFactory::factory($_SESSION['s_login']);
            $employees = eF_getTableData("users LEFT OUTER JOIN module_hcd_employee_has_job_description ON users.login = module_hcd_employee_has_job_description.users_LOGIN LEFT OUTER JOIN module_hcd_employee_works_at_branch ON users.login = module_hcd_employee_works_at_branch.users_LOGIN", "users.*, count(job_description_ID) as jobs_num", " users.user_type <> 'administrator' AND ((module_hcd_employee_works_at_branch.branch_ID IN (" . $_SESSION['supervises_branches'] . " ) AND module_hcd_employee_works_at_branch.assigned='1') OR EXISTS (SELECT module_hcd_employees.users_login FROM module_hcd_employees LEFT OUTER JOIN module_hcd_employee_works_at_branch ON module_hcd_employee_works_at_branch.users_login = module_hcd_employees.users_login WHERE users.login=module_hcd_employees.users_login AND module_hcd_employee_works_at_branch.branch_ID IS NULL)) GROUP BY login", "login");
            $supervisedLogins = array();
            foreach ($employees as $key2 => $value2) {
                if (!$value2['active'] || $value2['archive'] || !$value2['jobs_num']) {
                    unset($employees[$key2]);
                } else {
                    $supervisedLogins[] = $value2['login'];
                }
            }
        }
        foreach ($fileArrays as $key => $value) {
            $toolsString = '';
            $sharedString = '';
            if (is_file($value['path'])) {
                $value['id'] == -1 ? $identifier = $value['path'] : ($identifier = $value['id']);
                //The file/directory identifier will be the id, if the entity has a database representation, or the file path otherwise
                $value = new EfrontFile($value);
                //Restore file/directory representation, so we can use its methods
                $link = $url . '&view=' . urlencode($identifier);
                foreach ($extraFileTools as $tool) {
                    //$toolsString .= '<a href = "javascript:void(0)"><img src = "'.$tool['image'].'" alt = "'.$tool['title'].'" title = "'.$tool['title'].'" border = "0" onclick = "'.$tool['action'].'(this, \''.urlencode($identifier).'\')"  /></a>&nbsp;';
                    $toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a>&nbsp;';
                }
                if (($value['extension'] == 'zip' || $value['extension'] == 'gz') && $options['zip']) {
                    $toolsString .= '<a href = "javascript:void(0)"><img src = "images/16x16/uncompress.png" alt = "' . _UNCOMPRESS . '" title = "' . _UNCOMPRESS . '" border = "0" onclick = "uncompressFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"  /></a>&nbsp;';
                }
                if ($options['download']) {
                    $toolsString .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "images/16x16/import.png" alt = "' . _DOWNLOADFILE . '" title = "' . _DOWNLOADFILE . '" border = "0"/></a>&nbsp;';
                }
                if ($_SESSION['s_lessons_ID'] && $options['share']) {
                    $sharedString = '
	                    	<img class = "ajaxHandle" src = "images/16x16/trafficlight_green.png" alt = "' . _UNSHARE . '" title = "' . _UNSHARE . '" onclick = "unshareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" style = "' . (!$value['shared'] ? 'display:none' : null) . '" />
	                    	<img class = "ajaxHandle" src = "images/16x16/trafficlight_red.png"   alt = "' . _SHARE . '"   title = "' . _SHARE . '"   onclick = "shareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"   style = "' . ($value['shared'] ? 'display:none' : null) . '" />';
                }
                if ($options['metadata']) {
                    $toolsString .= '<a href = "' . $url . '&popup=1&display_metadata=' . urlencode($identifier) . '" target = "POPUP_FRAME"><img src = "images/16x16/information.png" alt = "' . _METADATA . '" title = "' . _METADATA . '" onclick = "eF_js_showDivPopup(event, \'' . _METADATA . '\', 2)" border = "0"/></a>&nbsp;';
                }
                if ($options['edit'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins)) && isset($value['users_LOGIN']) || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) {
                    $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                }
                if ($options['delete'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins) || $value['users_LOGIN'] == "") || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) {
                    $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}"/></a>&nbsp;';
                }
            } else {
                if (is_dir($value['path'])) {
                    $identifier = $value['path'];
                    $value = new EfrontDirectory($value['path']);
                    $link = $url . '&view_dir=' . urlencode($identifier);
                    foreach ($extraDirectoryTools as $tool) {
                        $toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"  /></a>&nbsp;';
                    }
                    if ($options['edit']) {
                        $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                    }
                    if ($options['delete']) {
                        $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFolder(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}" />&nbsp;';
                    }
                }
            }
            $filesCode .= '<tr class = "defaultRowHeight ' . (fmod($i++, 2) ? 'oddRowColor' : 'evenRowColor') . '">';
            if ($options['show_type']) {
                $filesCode .= '<td class = "centerAlign"><span style = "display:none">' . (isset($value['extension']) ? $value['extension'] : '') . '</span>';
                if ($value['type'] == 'file') {
                    if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "html") !== false || strpos($value['mime_type'], "video") !== false || strpos($value['mime_type'], "flash") !== false) {
                        $filesCode .= '<a href = "javascript:void(0);" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');$(\'preview_frame\').src = \'' . $link . '\';" ><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a></td>';
                    } else {
                        $filesCode .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a>';
                    }
                } else {
                    isset($value['mime_type']) ? $mimeType = $value['mime_type'] : ($mimeType = '');
                    $filesCode .= '<img src = "' . $value->getTypeImage() . '" alt = "' . $mimeType . '" title = "' . $mimeType . '" border = "0"/></td>';
                }
            }
            if ($options['show_name']) {
                $filesCode .= '<td><span id = "span_' . urlencode($identifier) . '" style = "display:none;">' . urlencode($identifier) . '</span>';
                if ($value['type'] == 'file') {
                    if ($show_tooltip) {
                        $filesCode .= $value->toHTMLTooltipLink($link, true, $tableId);
                    } else {
                        if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "flash") !== false || strpos($value['mime_type'], "video") !== false) {
                            $filesCode .= '<a href = "' . $link . '" target = "PREVIEW_FRAME" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');">' . $value['name'] . '</a>';
                        } else {
                            $filesCode .= '<a target = "PREVIEW_FRAME" href = "' . $url . '&download=' . urlencode($identifier) . '">' . $value['name'] . '</a>';
                        }
                    }
                } else {
                    $filesCode .= '<a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($identifier) . '\');">' . $value['name'] . '</a>';
                }
                $filesCode .= '<span id = "edit_' . urlencode($identifier) . '" style = "display:none"><input type = "text" value = "' . $value['name'] . '" onkeypress = "if (event.which == 13 || event.keyCode == 13) {Element.extend(this).next().down().onclick(); return false;}"/>&nbsp;<a href = "javascript:void(0)"><img id = "editImage_' . urlencode($identifier) . '"src = "images/16x16/success.png" style = "vertical-align:middle" onclick = "editFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML, Element.extend(this).up().previous().value, \'' . $value['type'] . '\',\'' . eF_addslashes($value['name']) . '\')" border = "0"></a></span></td>';
            }
            $extraColumnsString = '';
            foreach ($extraColumns as $column) {
                $extraColumnsString = '<td class = "centerAlign">' . $value[$column] . '</td>';
            }
            $filesCode .= '' . ($options['show_size'] ? '<td>' . ($value['type'] == 'file' ? $value['size'] . ' ' . _KB : '') . '</td>' : '') . '
                        		' . ($options['show_date'] ? '<td>' . formatTimestamp($value['timestamp'], 'time_nosec') . '</td>' : '') . '
                        		' . $extraColumnsString . '
                        		' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . $sharedString . '</td>' : '') . '
                        		' . ($options['show_tools'] ? '<td class = "centerAlign">' . $toolsString . '</td>' : '') . '
	                        		' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . ($value['type'] == 'file' ? '<input type = "checkbox" id = "' . $identifier . '" value = "' . $identifier . '" />' : '') . '</td>' : '') . '
                        	</tr>';
        }
        $massOperationsCode = '';
        if ($size) {
            $filesCode .= '
        				</table>';
            if ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share']) {
                $massOperationsCode = '
            			<div class = "horizontalSeparatorAbove">
            				<span style = "vertical-align:middle">' . _WITHSELECTEDFILES . ':</span>
            				' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_green.png" title = "' . _SHARESELECTED . '" alt = "' . _SHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "shareSelected()"></a><a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_red.png" title = "' . _UNSHARESELECTED . '" alt = "' . _UNSHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "unshareSelected()"></a>' : '');
                if ($options['copy']) {
                    $massOperationsCode .= '
                			<form name = "copy_files_form" id = "copy_files_form" method = "post" style = "display:none;"><input type = "hidden" name = "copy_current_directory" id = "copy_current_directory"><input type = "hidden" name = "copy_files" id = "copy_files" value = "" /></form>
							<img class = "ajaxHandle" src = "images/16x16/copy.png" title = "' . _COPYSELECTED . '" alt = "' . _COPYSELECTED . '" onclick = "copyFiles(this);">
                            <img style = "display:none" class = "ajaxHandle" src = "images/16x16/paste.png" title = "' . _PASTESELECTED . '" alt = "' . _PASTESELECTED . '" onclick = "pasteFiles(this, \'' . $tableId . '\');">&nbsp;';
                }
                $massOperationsCode .= ($options['delete'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/error_delete.png" title = "' . _DELETESELECTED . '" alt = "' . _DELETESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) deleteSelected()"></a>' : '') . '
            			</div>';
            }
        } elseif (!isset($parentDir)) {
            //Don't display 'no data found' if in subdirectory, because it doesn't show up well with the .. (up one level)
            $filesCode .= '
            				<tr class = "oddRowColor defaultRowHeight"><td colspan = "100%" class = "emptyCategory">' . _NODATAFOUND . '</td></tr>
        				</table>';
        }
        $str = '
        	<div class = "headerTools">';
        if ($options['upload']) {
            $str .= '
        		<span>
            		<img src = "images/16x16/add.png" alt = "' . _UPLOADFILE . '" title = "' . _UPLOADFILE . '"/>
        			<a href = "javascript:void(0)" onclick = "$(\'url_upload\').value = \'\';$$(\'input\').each(function(s)  {if (s.type == \'file\') s.value = \'\'});$(\'upload_current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _UPLOADFILE . '\', 0, \'upload_file_table_' . $tableId . '\')">' . _UPLOADFILE . '</a>&nbsp;
        		</span>';
        }
        if ($options['create_folder']) {
            $str .= '
        		<span>
        			<img src = "images/16x16/folder_add.png" alt = "' . _CREATEFOLDER . '" title = "' . _CREATEFOLDER . '">
        			<a href = "javascript:void(0)" onclick = "$(\'current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _CREATEFOLDER . '\', 0, \'create_directory_table_' . $tableId . '\')">' . _CREATEFOLDER . '</a>&nbsp;
        		</span>';
        }
        foreach ($extraHeaderOptions as $option) {
            $str .= '
            	<span>
	        		<img src = "' . $option['image'] . '" alt = "' . $option['title'] . '" title = "' . $option['title'] . '">
    	    		<a href = "' . (isset($option['href']) ? $option['href'] : 'javascript:void(0)') . '" onclick = "' . $option['action'] . '">' . $option['title'] . '</a>&nbsp;
    	    	</span>';
        }
        $str .= '
        	</div>

        	<table style = "width:100%">
        		<tr><td>
<!--ajax:' . $tableId . '-->
        				' . $filesCode . '
<!--/ajax:' . $tableId . '-->
						' . $massOperationsCode . '
        			</td></tr>
        	</table>
        	<script>
        	var url = "' . $url . '";
        	var tableId = "' . $tableId . '";
        	</script>
        	<div id = "upload_file_table_' . $tableId . '" 	   style = "display:none;" class = "filemanagerBlock">' . $uploadFormString . '</div>
        	<div id = "create_directory_table_' . $tableId . '" style = "display:none;" class = "filemanagerBlock">' . $createFolderString . '</div>

        	<div id = "preview_table_' . $tableId . '" style = "height:100%;display:none" class = "filemanagerBlock">
                <iframe name = "PREVIEW_FRAME" id = "preview_frame" src = "about:blank" style = "border-width:0px;width:100%;height:400px;padding:0px 0px 0px 0px">Sorry, but your browser needs to support iframes to see this</iframe>
            </div>';
        /*
                $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $uploadFormString);
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "upload_file_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._UPLOADFILE.'" data=$T_BLOCK_DATA image="32x32/import.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
                $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $createFolderString);
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "create_directory_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._CREATEFOLDER.'" data=$T_BLOCK_DATA image="32x32/folder.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "preview_table_'.$tableId.'" style = "display:none">{eF_template_printBlock title="'._PREVIEW.'" data="<iframe name = \"PREVIEW_FRAME\" id = \"preview_frame\" src = \"about:blank\" style = \"border-width:0px;width:100%;height:100%;padding:0px\">Sorry, but your browser needs to support iframes to see this</iframe>" image="32x32/folder.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
        */
        return $str;
    }
예제 #6
0
                     $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);
                     }
                 }
             } else {
                 $file = new EfrontFile(G_ROOTPATH . 'libraries/language/lang-english.php.inc');
                 $file->copy(G_ROOTPATH . 'libraries/language/lang-' . $values['english_name'] . '.php.inc');
             }
             $fields = array("name" => $values['english_name'], "translation" => $values['translation'], "active" => 1, "rtl" => $values['rtl']);
             if (!$values['custom']) {
                 eF_insertTableData("languages", $fields);
             }
             EfrontCache::getInstance()->deleteCache('languages');
             //$RetValues = file(G_SERVERNAME."/editor/tiny_mce/langs/language.php?langname=".$values['english_name']);
             eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=languages&message=" . urlencode(_SUCCESSFULLYADDEDLANGUAGE) . "&message_type=success");
         }
     } 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';
     }
 }
예제 #7
0
function replaceQuestionPaths($data, $sourceId, $newId)
{
    //$data = $question['text'];
    preg_match_all("/view_file\\.php\\?file=(\\d+)/", $data, $matchesId);
    $filesId = $matchesId[1];
    preg_match_all("#(" . G_SERVERNAME . ")*content/lessons/(.*)\"#U", $data, $matchesPath);
    $filesPath = $matchesPath[2];
    foreach ($filesId as $file) {
        $files[] = $file;
    }
    foreach ($filesPath as $file) {
        $files[] = G_LESSONSPATH . html_entity_decode($file);
    }
    $lesson = new EfrontLesson($newId);
    //$data   = $unit -> offsetGet('data');
    foreach ($files as $file) {
        try {
            $sourceFile = new EfrontFile($file);
            $sourceFileOffset = preg_replace("#" . G_LESSONSPATH . "#", "", $sourceFile['directory']);
            $position = strpos($sourceFileOffset, "/");
            //check case that the file is in a subfolder of the lesson
            if ($position !== false) {
                $sourceLink = mb_substr($sourceFileOffset, $position + 1);
                mkdir($lesson->getDirectory() . $sourceLink . '/', 0755, true);
                $destinationPath = $lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']);
                $copiedFile = $sourceFile->copy($lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']), false);
            } else {
                $destinationPath = $lesson->getDirectory() . basename($sourceFile['path']);
                $copiedFile = $sourceFile->copy($lesson->getDirectory() . basename($sourceFile['path']), false);
            }
            str_replace("view_file.php?file=" . $file, "view_file.php?file=" . $copiedFile->offsetGet('id'), $data);
            $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceId . "/(.*)#", "content/lessons/" . $newId . '/${2}', $data);
        } catch (EfrontFileException $e) {
            if ($e->getCode() == EfrontFileException::FILE_ALREADY_EXISTS) {
                $copiedFile = new EfrontFile($destinationPath);
                str_replace("view_file.php?file=" . $file, "view_file.php?file=" . $copiedFile->offsetGet('id'), $data);
                $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceId . "/(.*)#", "content/lessons/" . $newId . '/${2}', $data, -1, $count);
            }
        }
        //this means that the file already exists
    }
    //$question['text'] = $data;
    return $data;
}
예제 #8
0
define("PHPLIVEDOCXAPI","' . $defaultConfig['phplivedocx_server'] . '");
?>';
                file_put_contents($path . "phplivedocx_config.php", $phplivedocxConfig);
                eF_updateTableData("users", array('email' => $values['admin_email'], 'password' => EfrontUser::createPassword($values['admin_password']), 'last_login' => '0'));
                eF_updateTableData("users", array('login' => $values['admin_name']), "id=1");
                eF_updateTableData("courses", array('created' => time()));
                eF_updateTableData("courses", array('created' => time(), 'creator_LOGIN' => $values['admin_name']));
                eF_updateTableData("lessons", array('created' => time(), 'creator_LOGIN' => $values['admin_name']));
                eF_updateTableData("users_to_courses", array('from_timestamp' => time()));
                eF_updateTableData("users_to_lessons", array('from_timestamp' => time()));
                eF_deleteTableData("logs", "");
                eF_deleteTableData("events", "");
                EfrontConfiguration::setValue("database_version", G_VERSION_NUM);
                EfrontConfiguration::setValue("system_Email", $values['admin_email']);
                $file = new EfrontFile(EfrontDirectory::normalize(getcwd()) . '/lessons.zip');
                $newFile = $file->copy(G_LESSONSPATH, true);
                $newFile->uncompress();
                $newFile->delete();
                if (G_VERSIONTYPE == 'community') {
                    #cpp#ifdef COMMUNITY
                    $modulesToRemove[] = 'content_reports';
                    $modulesToRemove[] = 'course_reports';
                    $modulesToRemove[] = 'fuze_meetings';
                    $modulesToRemove[] = 'training_reports';
                }
                #cpp#endif
                if (G_VERSIONTYPE != 'enterprise') {
                    #cpp#ifndef ENTERPRISE
                    $modulesToRemove[] = 'branch_reports';
                    $modulesToRemove[] = 'jobs_manager';
                }