本文整理汇总了PHP中DocumentManager::documents_total_space方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::documents_total_space方法的具体用法?PHP DocumentManager::documents_total_space怎么用?PHP DocumentManager::documents_total_space使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::documents_total_space方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
* @param string $formName Form's name.
* @param string $method (optional)Form's method defaults to 'POST'
* @param string $action (optional)Form's action
* @param string $target (optional)Form's target defaults to '_self'
* @param mixed $attributes (optional)Extra attributes for <form> tag
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
* @access public
*/
public function __construct($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false)
{
HTML_Common::HTML_Common($attributes);
$method = strtoupper($method) == 'GET' ? 'get' : 'post';
// Modified by Chamilo team, 16-MAR-2010
//$action = ($action == '') ? $_SERVER['PHP_SELF'] : $action;
$action = $action == '' ? api_get_self() : $action;
//
$target = empty($target) ? array() : array('target' => $target);
$form_id = $formName;
if (isset($attributes['id']) && !empty($attributes['id'])) {
$form_id = Security::remove_XSS($attributes['id']);
}
$attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $form_id) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
if (1 == get_magic_quotes_gpc()) {
$this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method ? $_GET : $_POST);
foreach ($_FILES as $keyFirst => $valFirst) {
foreach ($valFirst as $keySecond => $valSecond) {
if ('name' == $keySecond) {
$this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond);
} else {
$this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
}
}
}
} else {
$this->_submitValues = 'get' == $method ? $_GET : $_POST;
$this->_submitFiles = $_FILES;
}
$this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0;
}
if ($trackSubmit) {
unset($this->_submitValues['_qf__' . $formName]);
$this->addElement('hidden', '_qf__' . $formName, null);
}
if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
// see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
switch (strtoupper($matches['2'])) {
case 'G':
$this->_maxFileSize = $matches['1'] * 1073741824;
break;
case 'M':
$this->_maxFileSize = $matches['1'] * 1048576;
break;
case 'K':
$this->_maxFileSize = $matches['1'] * 1024;
break;
default:
$this->_maxFileSize = $matches['1'];
}
}
$course_id = api_get_course_int_id();
//If I'm in a course replace the default max filesize with the course limits
if (!empty($course_id)) {
$free_course_quota = DocumentManager::get_course_quota() - DocumentManager::documents_total_space();
if (empty($this->_maxFileSize) || $free_course_quota <= $this->_maxFileSize) {
$this->_maxFileSize = intval($free_course_quota);
}
}
}
示例2: round
if (!empty($quota_bytes)) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
if ($session_id == $session_data['id']) {
$session_data['name'] = $session_data['name'] . ' * ';
}
$used_quota_bytes += $quota_bytes;
$session[] = array(addslashes(get_lang('Session') . ': ' . $session_data['name']) . ' (' . format_file_size($quota_bytes) . ')', $quota_percentage);
}
}
$group_list = GroupManager::get_groups();
if (!empty($group_list)) {
foreach ($group_list as $group_data) {
$quota_percentage = 0;
$my_group_id = $group_data['id'];
$quota_bytes = intval(DocumentManager::documents_total_space($course_id, $my_group_id, 0));
if (!empty($quota_bytes)) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
if ($group_id == $my_group_id) {
$group_data['name'] = $group_data['name'] . ' * ';
}
$used_quota_bytes += $quota_bytes;
$session[] = array(addslashes(get_lang('Group') . ': ' . $group_data['name']) . ' (' . format_file_size($quota_bytes) . ')', $quota_percentage);
}
}
//Showing weight of documents uploaded by user
$document_list = DocumentManager::get_all_document_data($_course);
if (is_array($document_list)) {
foreach ($document_list as $document_data) {
if ($document_data['insert_user_id'] == api_get_user_id() && $document_data['filetype'] == 'file') {
示例3: verify_document_size
function verify_document_size($s)
{
$post_max = ini_get('post_max_size');
$upl_max = ini_get('upload_max_filesize');
$documents_total_space = DocumentManager::documents_total_space();
$course_max_space = DocumentManager::get_course_quota();
$total_size = filesize($s) + $documents_total_space;
if (filesize($s) > $post_max || filesize($s) > $upl_max || $total_size > $course_max_space) {
return true;
} else {
return false;
}
}
示例4: array
} else {
Display::display_introduction_section(TOOL_DOCUMENT);
}
$toolbar = Display::toolbarAction('toolbar-document', array(0 => $actionsLeft, 1 => $actionsRight));
echo $toolbar;
echo $templateForm;
echo $moveForm;
echo $dirForm;
echo $selector;
$table->display();
if (count($documentAndFolders) > 1) {
if ($is_allowed_to_edit || $group_member_with_upload_rights) {
// Getting the course quota
$course_quota = DocumentManager::get_course_quota();
// Calculating the total space
$already_consumed_space_course = DocumentManager::documents_total_space(api_get_course_int_id());
// Displaying the quota
DocumentManager::display_simple_quota($course_quota, $already_consumed_space_course);
}
}
if (!empty($table_footer)) {
Display::display_warning_message($table_footer);
}
echo '
<div id="convertModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="text-align: center;">
<button type="button" class="close" data-dismiss="modal" aria-label="' . get_lang('Close') . '">
<span aria-hidden="true">×</span>
</button>
示例5: api_get_cidreq
$actions = '<a href="document.php?id=' . $document_id . '&selectcat=' . $selectcat . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
$actions = '<a href="document.php?id=' . $document_id . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
}
// Link to create a folder
echo $toolbar = Display::toolbarAction('toolbar-upload', array(0 => $actions), 1);
// Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
if (!$is_certificate_mode) {
echo DocumentManager::build_directory_selector($folders, $document_id, isset($group_properties['directory']) ? $group_properties['directory'] : array());
}
$action = api_get_self() . '?' . api_get_cidreq() . '&id=' . $document_id;
$form = new FormValidator('upload', 'POST', $action . '#tabs-2', '', array('enctype' => 'multipart/form-data'));
$form->addElement('hidden', 'id', $document_id);
$form->addElement('hidden', 'curdirpath', $path);
$course_quota = format_file_size(DocumentManager::get_course_quota() - DocumentManager::documents_total_space());
$label = get_lang('MaxFileSize') . ': ' . ini_get('upload_max_filesize') . '<br/>' . get_lang('DocumentQuota') . ': ' . $course_quota;
$form->addElement('file', 'file', array(get_lang('File'), $label), 'style="width: 250px" id="user_upload"');
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'title_file'));
$form->addElement('textarea', 'comment', get_lang('Comment'));
// Advanced parameters
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
// Check box options
$form->addElement('checkbox', 'unzip', get_lang('Options'), get_lang('Uncompress'), 'onclick="javascript: check_unzip();" value="1"');
if (api_get_setting('search.search_enabled') == 'true') {
//TODO: include language file
$supported_formats = get_lang('SupportedFormatsForIndex') . ': HTML, PDF, TXT, PDF, Postscript, MS Word, RTF, MS Power Point';
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument') . '<div style="font-size: 80%" >' . $supported_formats . '</div>');
$form->addElement('html', '<br /><div class="sub-form">');
$form->addElement('html', '<div class="label">' . get_lang('SearchFeatureDocumentLanguage') . '</div>');
示例6: uploadWork
/**
* @param array $my_folder_data
* @param array $_course
* @return array
*/
function uploadWork($my_folder_data, $_course)
{
if (empty($_FILES['file']['size'])) {
return array('error' => Display :: return_message(get_lang('UplUploadFailedSizeIsZero'), 'error'));
}
$updir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work/'; //directory path to upload
// Try to add an extension to the file if it has'nt one
$filename = add_ext_on_mime(stripslashes($_FILES['file']['name']), $_FILES['file']['type']);
// Replace dangerous characters
$filename = replace_dangerous_char($filename, 'strict');
// Transform any .php file in .phps fo security
$filename = php2phps($filename);
$filesize = filesize($_FILES['file']['tmp_name']);
if (empty($filesize)) {
return array('error' => Display :: return_message(get_lang('UplUploadFailedSizeIsZero'), 'error'));
} elseif (!filter_extension($new_file_name)) {
return array('error' => Display :: return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'error'));
}
$totalSpace = DocumentManager::documents_total_space($_course['real_id']);
$course_max_space = DocumentManager::get_course_quota($_course['code']);
$total_size = $filesize + $totalSpace;
if ($total_size > $course_max_space) {
return array(
'error' => Display :: return_message(get_lang('NoSpace'), 'error')
);
}
// Compose a unique file name to avoid any conflict
$new_file_name = api_get_unique_id();
$curdirpath = basename($my_folder_data['url']);
// If we come from the group tools the groupid will be saved in $work_table
if (is_dir($updir.$curdirpath) || empty($curdirpath)) {
$result = move_uploaded_file(
$_FILES['file']['tmp_name'],
$updir.$curdirpath.'/'.$new_file_name
);
} else {
return array(
'error' => Display :: return_message(
get_lang('FolderDoesntExistsInFileSystem'),
'error'
)
);
}
$url = null;
if ($result) {
$url = 'work/'.$curdirpath.'/'.$new_file_name;
}
return array(
'url' => $url,
'filename' => $filename,
'error' => null
);
}
示例7: verify_document_size
public function verify_document_size($s)
{
$post_max = ini_get('post_max_size');
if (substr($post_max, -1, 1) == 'M') {
$post_max = intval(substr($post_max, 0, -1)) * 1024 * 1024;
} elseif (substr($post_max, -1, 1) == 'G') {
$post_max = intval(substr($post_max, 0, -1)) * 1024 * 1024 * 1024;
}
$upl_max = ini_get('upload_max_filesize');
if (substr($upl_max, -1, 1) == 'M') {
$upl_max = intval(substr($upl_max, 0, -1)) * 1024 * 1024;
} elseif (substr($upl_max, -1, 1) == 'G') {
$upl_max = intval(substr($upl_max, 0, -1)) * 1024 * 1024 * 1024;
}
$documents_total_space = DocumentManager::documents_total_space();
$course_max_space = DocumentManager::get_course_quota();
$total_size = filesize($s) + $documents_total_space;
if (filesize($s) > $post_max || filesize($s) > $upl_max || $total_size > $course_max_space) {
return true;
} else {
return false;
}
}
示例8: api_get_unique_id
$title = $_FILES['file']['name'];
}
// Compose a unique file name to avoid any conflict
$new_file_name = api_get_unique_id();
$curdirpath = basename($my_folder_data['url']);
// If we come from the group tools the groupid will be saved in $work_table
$result = move_uploaded_file($_FILES['file']['tmp_name'], $updir . $curdirpath . '/' . $new_file_name);
if ($result) {
$url = 'work/' . $curdirpath . '/' . $new_file_name;
$contains_file = 1;
}
}
if (empty($title)) {
$title = get_lang('Untitled');
}
$documents_total_space = DocumentManager::documents_total_space();
$course_max_space = DocumentManager::get_course_quota();
$total_size = $filesize + $documents_total_space;
if ($total_size > $course_max_space) {
$error_message .= Display::return_message(get_lang('NoSpace'), 'warning');
} else {
$active = '1';
$sql_add_publication = "INSERT INTO " . $work_table . " SET\n c_id \t\t= {$course_id} ,\n url \t= '" . $url . "',\n title \t= '" . Database::escape_string($title) . "',\n description\t= '" . Database::escape_string($description) . "',\n contains_file = '" . $contains_file . "',\n active\t\t= '" . $active . "',\n accepted\t\t= '1',\n post_group_id = '" . $group_id . "',\n sent_date\t= '" . api_get_utc_datetime() . "',\n parent_id \t= '" . $work_id . "' ,\n session_id\t= '" . intval($id_session) . "' ,\n user_id \t\t= '" . $user_id . "'";
Database::query($sql_add_publication);
$id = Database::insert_id();
}
if ($id) {
api_item_property_update($course_info, 'work', $id, 'DocumentAdded', $user_id, api_get_group_id());
$succeed = true;
}
} else {