本文整理汇总了PHP中DocumentManager::is_folder_to_avoid方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::is_folder_to_avoid方法的具体用法?PHP DocumentManager::is_folder_to_avoid怎么用?PHP DocumentManager::is_folder_to_avoid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::is_folder_to_avoid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_all_document_folders
/**
* Gets the paths of all folders in a course
* can show all folders (exept for the deleted ones) or only visible ones
* @param array $_course
* @param boolean $can_see_invisible
* @param int $to_group_id
* @return array with paths
*/
public static function get_all_document_folders($_course, $to_group_id = '0', $can_see_invisible = false)
{
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$to_group_id = intval($to_group_id);
if (empty($_course)) {
return false;
}
if ($can_see_invisible) {
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
if ($to_group_id != 0) {
$sql = "SELECT DISTINCT docs.id, path\n FROM {$TABLE_ITEMPROPERTY} AS last INNER JOIN {$TABLE_DOCUMENT} AS docs\n ON (docs.id = last.ref AND last.tool = '" . TOOL_DOCUMENT . "' AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} )\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tdocs.filetype \t\t= 'folder' AND\n\t\t\t\t\t\t\tlast.to_group_id\t= " . $to_group_id . " AND\n docs.path NOT LIKE '%shared_folder%' AND\n \t\t\t\tlast.visibility \t<> 2 {$condition_session} ";
} else {
$sql = "SELECT DISTINCT docs.id, path\n FROM {$TABLE_ITEMPROPERTY} AS last INNER JOIN {$TABLE_DOCUMENT} AS docs\n ON (docs.id = last.ref AND last.tool = '" . TOOL_DOCUMENT . "' AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} )\n WHERE\n docs.filetype \t\t= 'folder' AND\n last.to_group_id\t= 0 AND\n last.visibility \t<> 2 {$condition_session} ";
}
$result = Database::query($sql);
if ($result && Database::num_rows($result) != 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
if (DocumentManager::is_folder_to_avoid($row['path'])) {
continue;
}
$document_folders[$row['id']] = $row['path'];
}
//sort($document_folders);
if (!empty($document_folders)) {
natsort($document_folders);
}
//return results
return $document_folders;
} else {
return false;
}
} else {
//no invisible folders
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
//get visible folders
$visible_sql = "SELECT DISTINCT docs.id, path\n FROM " . $TABLE_ITEMPROPERTY . " AS last, " . $TABLE_DOCUMENT . " AS docs\n WHERE docs.id = last.ref\n AND docs.filetype = 'folder'\n AND last.tool = '" . TOOL_DOCUMENT . "'\n AND last.to_group_id = " . $to_group_id . "\n AND last.visibility = 1 {$condition_session} AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']} ";
$visibleresult = Database::query($visible_sql);
while ($all_visible_folders = Database::fetch_array($visibleresult, 'ASSOC')) {
$visiblefolders[$all_visible_folders['id']] = $all_visible_folders['path'];
}
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
//get invisible folders
$invisible_sql = "SELECT DISTINCT docs.id, path\n FROM " . $TABLE_ITEMPROPERTY . " AS last, " . $TABLE_DOCUMENT . " AS docs\n WHERE docs.id = last.ref\n AND docs.filetype = 'folder'\n AND last.tool = '" . TOOL_DOCUMENT . "'\n AND last.to_group_id = " . $to_group_id . "\n AND last.visibility = 0 {$condition_session} AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']} ";
$invisibleresult = Database::query($invisible_sql);
while ($invisible_folders = Database::fetch_array($invisibleresult, 'ASSOC')) {
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
//get visible folders in the invisible ones -> they are invisible too
$folder_in_invisible_sql = "SELECT DISTINCT docs.id, path\n FROM " . $TABLE_ITEMPROPERTY . " AS last, " . $TABLE_DOCUMENT . " AS docs\n WHERE docs.id = last.ref\n AND docs.path LIKE '" . Database::escape_string($invisible_folders['path']) . "/%'\n AND docs.filetype = 'folder'\n AND last.tool = '" . TOOL_DOCUMENT . "'\n AND last.to_group_id = " . $to_group_id . "\n AND last.visibility = 1 {$condition_session} AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']} ";
$folder_in_invisible_result = Database::query($folder_in_invisible_sql);
while ($folders_in_invisible_folder = Database::fetch_array($folder_in_invisible_result, 'ASSOC')) {
$invisiblefolders[$folders_in_invisible_folder['id']] = $folders_in_invisible_folder['path'];
}
}
//if both results are arrays -> //calculate the difference between the 2 arrays -> only visible folders are left :)
if (is_array($visiblefolders) && is_array($invisiblefolders)) {
$document_folders = array_diff($visiblefolders, $invisiblefolders);
natsort($document_folders);
return $document_folders;
} elseif (is_array($visiblefolders)) {
//only visible folders found
//sort($visiblefolders);
natsort($visiblefolders);
return $visiblefolders;
} else {
//no visible folders found
return false;
}
}
}
示例2: get_all_document_folders
/**
* Gets the paths of all folders in a course
* can show all folders (except for the deleted ones) or only visible ones
*
* @param array $_course
* @param int $to_group_id
* @param boolean $can_see_invisible
*
* @return array with paths
*/
public static function get_all_document_folders($_course, $to_group_id = 0, $can_see_invisible = false)
{
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$to_group_id = intval($to_group_id);
$document_folders = array();
$students = CourseManager::get_user_list_from_course_code($_course['code'], api_get_session_id());
$sharedCondition = null;
if (!empty($students)) {
$conditionList = array();
foreach ($students as $studentId => $studentInfo) {
$conditionList[] = '/shared_folder/sf_user_' . $studentInfo['user_id'];
}
}
$groupCondition = " last.to_group_id = {$to_group_id}";
if (empty($to_group_id)) {
$groupCondition = " (last.to_group_id = 0 OR last.to_group_id IS NULL)";
}
if ($can_see_invisible) {
// condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id');
$show_users_condition = "";
if (api_get_setting('document.show_users_folders') == 'false') {
$show_users_condition = " AND docs.path NOT LIKE '%shared_folder%'";
}
if ($to_group_id != 0) {
$sql = "SELECT DISTINCT docs.id, path\n FROM {$TABLE_ITEMPROPERTY} AS last\n INNER JOIN {$TABLE_DOCUMENT} AS docs\n ON (\n docs.id = last.ref AND\n last.tool = '" . TOOL_DOCUMENT . "' AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']}\n )\n WHERE\n docs.filetype \t\t= 'folder' AND\n {$groupCondition} AND\n docs.path NOT LIKE '%shared_folder%' AND\n docs.path NOT LIKE '%_DELETED_%' AND\n last.visibility \t<> 2\n {$condition_session} ";
} else {
$sql = "SELECT DISTINCT docs.id, path\n FROM {$TABLE_ITEMPROPERTY} AS last\n INNER JOIN {$TABLE_DOCUMENT} AS docs\n ON (\n docs.id = last.ref AND\n last.tool = '" . TOOL_DOCUMENT . "' AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']}\n )\n WHERE\n docs.filetype \t\t= 'folder' AND\n docs.path NOT LIKE '%_DELETED_%' AND\n {$groupCondition} AND\n last.visibility \t<> 2\n {$show_users_condition} {$condition_session} ";
}
$result = Database::query($sql);
if ($result && Database::num_rows($result) != 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
if (DocumentManager::is_folder_to_avoid($row['path'])) {
continue;
}
if (strpos($row['path'], '/shared_folder/') !== false) {
if (!in_array($row['path'], $conditionList)) {
continue;
}
}
$document_folders[$row['id']] = $row['path'];
}
if (!empty($document_folders)) {
natsort($document_folders);
}
return $document_folders;
} else {
return false;
}
} else {
// No invisible folders
// Condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id');
//get visible folders
$sql = "SELECT DISTINCT docs.id, path\n FROM\n {$TABLE_ITEMPROPERTY} AS last, {$TABLE_DOCUMENT} AS docs\n WHERE\n docs.id = last.ref AND\n docs.filetype = 'folder' AND\n last.tool = '" . TOOL_DOCUMENT . "' AND\n {$groupCondition} AND\n last.visibility = 1\n {$condition_session} AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']} ";
$result = Database::query($sql);
$visibleFolders = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
$visibleFolders[$row['id']] = $row['path'];
}
// Condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id');
//get invisible folders
$sql = "SELECT DISTINCT docs.id, path\n FROM {$TABLE_ITEMPROPERTY} AS last, {$TABLE_DOCUMENT} AS docs\n WHERE\n docs.id = last.ref AND\n docs.filetype = 'folder' AND\n last.tool = '" . TOOL_DOCUMENT . "' AND\n {$groupCondition} AND\n last.visibility = 0 {$condition_session} AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']} ";
$result = Database::query($sql);
$invisibleFolders = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, false, 'docs.session_id');
//get visible folders in the invisible ones -> they are invisible too
$sql = "SELECT DISTINCT docs.id, path\n FROM {$TABLE_ITEMPROPERTY} AS last, {$TABLE_DOCUMENT} AS docs\n WHERE\n docs.id = last.ref AND\n docs.path LIKE '" . Database::escape_string($row['path'] . '/%') . "' AND\n docs.filetype = 'folder' AND\n last.tool = '" . TOOL_DOCUMENT . "' AND\n {$groupCondition} AND\n last.visibility = 1 {$condition_session} AND\n last.c_id = {$_course['real_id']} AND\n docs.c_id = {$_course['real_id']} ";
$folder_in_invisible_result = Database::query($sql);
while ($folders_in_invisible_folder = Database::fetch_array($folder_in_invisible_result, 'ASSOC')) {
$invisibleFolders[$folders_in_invisible_folder['id']] = $folders_in_invisible_folder['path'];
}
}
//if both results are arrays -> //calculate the difference between the 2 arrays -> only visible folders are left :)
if (is_array($visibleFolders) && is_array($invisibleFolders)) {
$document_folders = array_diff($visibleFolders, $invisibleFolders);
natsort($document_folders);
return $document_folders;
} elseif (is_array($visibleFolders)) {
natsort($visibleFolders);
return $visibleFolders;
} else {
//.........这里部分代码省略.........
示例3: get_total_folder_size
$invisibility_span_open = $is_visible == 0 ? '<span class="muted">' : '';
$invisibility_span_close = $is_visible == 0 ? '</span>' : '';
// Size (or total size of a directory)
$size = $document_data['filetype'] == 'folder' ? get_total_folder_size($document_data['path'], $is_allowed_to_edit) : $document_data['size'];
// Get the title or the basename depending on what we're using
if ($document_data['title'] != '') {
$document_name = $document_data['title'];
} else {
$document_name = basename($document_data['path']);
}
$row['name'] = $document_name;
// Data for checkbox
if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) {
$row[] = $document_data['id'];
}
if (DocumentManager::is_folder_to_avoid($document_data['path'], $is_certificate_mode)) {
continue;
}
// Show the owner of the file only in groups
$user_link = '';
if (!empty($groupId)) {
if (!empty($document_data['insert_user_id'])) {
$user_info = api_get_user_info($document_data['insert_user_id']);
$user_link = '<div class="document_owner">' . get_lang('Owner') . ': ' . UserManager::getUserProfileLink($user_info) . '</div>';
}
}
// Icons (clickable)
$row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible);
$path_info = pathinfo($document_data['path']);
if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) {
$count++;