当前位置: 首页>>代码示例>>PHP>>正文


PHP DocumentManager::getDocumentSuffix方法代码示例

本文整理汇总了PHP中DocumentManager::getDocumentSuffix方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::getDocumentSuffix方法的具体用法?PHP DocumentManager::getDocumentSuffix怎么用?PHP DocumentManager::getDocumentSuffix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentManager的用法示例。


在下文中一共展示了DocumentManager::getDocumentSuffix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_unexisting_directory

/**
 * Creates a new directory trying to find a directory name
 * that doesn't already exist
 * (we could use unique_name() here...)
 *
 * @author  Hugues Peeters <hugues.peeters@claroline.net>
 * @author  Bert Vanderkimpen
 * @param   array   $_course current course information
 * @param   int     $user_id current user id
 * @param   int     $session_id
 * @param   int     $to_group_id
 * @param   int     $to_user_id
 * @param   string  $base_work_dir /var/www/chamilo/courses/ABC/document
 * @param   string  $desired_dir_name complete path of the desired name
 * Example: /folder1/folder2
 * @param   string  $title "folder2"
 * @param   int     $visibility (0 for invisible, 1 for visible, 2 for deleted)
 * @param   bool $generateNewNameIfExists
 * @return  string  actual directory name if it succeeds,
 *          boolean false otherwise
 */
function create_unexisting_directory($_course, $user_id, $session_id, $to_group_id, $to_user_id, $base_work_dir, $desired_dir_name, $title = null, $visibility = null, $generateNewNameIfExists = false)
{
    $course_id = $_course['real_id'];
    $session_id = intval($session_id);
    $folderExists = DocumentManager::folderExists($desired_dir_name, $_course, $session_id, $to_group_id);
    if ($folderExists == true) {
        if ($generateNewNameIfExists) {
            $counter = 1;
            while (1) {
                $folderExists = DocumentManager::folderExists($desired_dir_name . '_' . $counter, $_course, $session_id, $to_group_id);
                if ($folderExists == false) {
                    break;
                }
                $counter++;
            }
            $desired_dir_name = $desired_dir_name . '_' . $counter;
        } else {
            return false;
        }
    }
    $systemFolderName = $desired_dir_name;
    // Adding suffix
    $suffix = DocumentManager::getDocumentSuffix($_course, $session_id, $to_group_id);
    $systemFolderName .= $suffix;
    if ($title == null) {
        $title = basename($desired_dir_name);
    }
    if (!is_dir($base_work_dir . $systemFolderName)) {
        $result = mkdir($base_work_dir . $systemFolderName, api_get_permissions_for_new_directories(), true);
        if ($result) {
            // Check if pathname already exists inside document table
            $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
            $sql = "SELECT id, path FROM {$tbl_document}\n                    WHERE\n                        c_id = {$course_id} AND\n                        (\n                            path = '" . $systemFolderName . "'\n                        )\n            ";
            $rs = Database::query($sql);
            if (Database::num_rows($rs) == 0) {
                $document_id = add_document($_course, $systemFolderName, 'folder', 0, $title, null, 0, true, $to_group_id);
                if ($document_id) {
                    // Update document item_property
                    if (!empty($visibility)) {
                        $visibilities = array(0 => 'invisible', 1 => 'visible', 2 => 'delete');
                        api_item_property_update($_course, TOOL_DOCUMENT, $document_id, $visibilities[$visibility], $user_id, $to_group_id, $to_user_id, null, null, $session_id);
                    } else {
                        api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'FolderCreated', $user_id, $to_group_id, $to_user_id, null, null, $session_id);
                    }
                    $documentData = DocumentManager::get_document_data_by_id($document_id, $_course['code'], false, $session_id);
                    return $documentData;
                }
            } else {
                $document = Database::fetch_array($rs);
                $documentData = DocumentManager::get_document_data_by_id($document['id'], $_course['code'], false, $session_id);
                /* This means the folder NOT exist in the filesystem
                   (now this was created) but there is a record in the Database*/
                return $documentData;
            }
        }
    }
    return false;
}
开发者ID:daffef,项目名称:chamilo-lms,代码行数:79,代码来源:fileUpload.lib.php

示例2: isset

$form->setDefaults($defaults);
// If form validates -> save the new document
if ($form->validate()) {
    $values = $form->exportValues();
    $readonly = isset($values['readonly']) ? 1 : 0;
    $values['title'] = trim($values['title']);
    if ($dir[strlen($dir) - 1] != '/') {
        $dir .= '/';
    }
    // Setting the filename
    $filename = $values['title'];
    $filename = addslashes(trim($filename));
    $filename = Security::remove_XSS($filename);
    $filename = replace_dangerous_char($filename);
    $filename = disable_dangerous_file($filename);
    $filename .= DocumentManager::getDocumentSuffix($_course, api_get_session_id(), api_get_group_id());
    // Setting the title
    $title = $values['title'];
    // Setting the extension
    $extension = 'html';
    $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
    if (strpos($content, '/css/frames.css') == false) {
        $content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
    }
    // Don't create file with the same name.
    if (file_exists($filepath . $filename . '.' . $extension)) {
        Display::display_header($nameTools, 'Doc');
        Display::display_error_message(get_lang('FileExists') . ' ' . $title, false);
        Display::display_footer();
        exit;
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:create_document.php

示例3: api_get_session_id

if (!empty($_course['path']) && $editor != "stand_alone") {
    if (!empty($group_properties['directory'])) {
        $PathChamiloAjaxFileManager = '../../../../../../../courses/' . $_course['path'] . '/document' . $group_properties['directory'] . '/';
    } else {
        if (api_is_allowed_to_edit()) {
            $PathChamiloAjaxFileManager = '../../../../../../../courses/' . $_course['path'] . '/document/';
        } else {
            $current_session_id = api_get_session_id();
            if ($current_session_id == 0) {
                $PathChamiloAjaxFileManager = '../../../../../../../courses/' . $_course['path'] . '/document/shared_folder/sf_user_' . api_get_user_id() . '/';
            } else {
                $courseInfo = api_get_course_info();
                $sessionId = api_get_session_id();
                $groupId = api_get_group_id();
                $PathChamiloAjaxFileManager = '../../../../../../../courses/' . $_course['path'] . '/document/shared_folder_session_' . $current_session_id . '/sf_user_' . api_get_user_id();
                $PathChamiloAjaxFileManager .= DocumentManager::getDocumentSuffix($courseInfo, $sessionId, $groupId) . '/';
            }
        }
    }
} else {
    if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
        //home page portal
        $PathChamiloAjaxFileManager = '../../../../../../../home/default_platform_document/';
    } else {
        //my profile
        $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'none');
        if (!empty($my_path['dir'])) {
            $dir = api_get_path(SYS_CODE_PATH) . $my_path['dir'];
            if (!is_dir($dir)) {
                mkdir($dir);
            }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:config.base.php


注:本文中的DocumentManager::getDocumentSuffix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。