function filedepotAjaxServer_generateLeftSideNavigation in filedepot 7
Same name and namespace in other branches
- 6 lib-ajaxserver.php \filedepotAjaxServer_generateLeftSideNavigation()
Generate Left Side Navigation code which is used to create the YUI menu's in the AJAX handler javascript.
2 calls to filedepotAjaxServer_generateLeftSideNavigation()
File
- ./
lib-ajaxserver.php, line 106 - lib-ajaxserver.php Library functions for the ajax_server
Code
function filedepotAjaxServer_generateLeftSideNavigation($data = '') {
global $user;
$filedepot = filedepot_filedepot();
$display_recent_folders = variable_get('filedepot_show_recent_folders', 1);
if (empty($data)) {
$data = array(
'retcode' => 200,
);
}
$approvals = filedepot_getSubmissionCnt();
$data['reports'] = array();
$data['recentfolders'] = array();
$data['topfolders'] = array();
$data['reports'][] = array(
'label' => t('Latest Files'),
'report' => 'latestfiles',
'parent' => 'allitems',
'icon' => 'icon-filelisting',
);
if (user_is_logged_in()) {
$data['reports'][] = array(
'label' => t('Notifications'),
'report' => 'notifications',
'parent' => 'allitems',
'icon' => 'icon-fileowned',
);
$data['reports'][] = array(
'label' => t('Owned by me'),
'report' => 'myfiles',
'parent' => 'allitems',
'icon' => 'icon-fileowned',
);
$data['reports'][] = array(
'label' => t('Downloaded by me'),
'report' => 'downloads',
'parent' => 'allitems',
'icon' => 'icon-fileowned',
);
$data['reports'][] = array(
'label' => t('Unread Files'),
'report' => 'unread',
'parent' => 'allitems',
'icon' => 'icon-fileowned',
);
$data['reports'][] = array(
'label' => t('Locked by me'),
'report' => 'lockedfiles',
'parent' => 'allitems',
'icon' => 'icon-filelocked',
);
$data['reports'][] = array(
'label' => t('Flagged by me'),
'report' => 'flaggedfiles',
'parent' => 'allitems',
'icon' => 'icon-fileflagged',
);
}
if ($approvals > 0) {
$approvals = " ({$approvals})";
$data['reports'][] = array(
'label' => t('Waiting approval') . "{$approvals}",
'report' => 'approvals',
'parent' => 'allitems',
'icon' => 'icon-fileowned',
);
}
if (user_is_logged_in()) {
if (user_access('administer filedepot', $user)) {
$res = db_query("SELECT COUNT(id) as incoming FROM {filedepot_import_queue}");
}
else {
$res = db_query("SELECT COUNT(id) as incoming FROM {filedepot_import_queue} WHERE uid=:uid", array(
':uid' => $user->uid,
));
}
$A = $res
->fetchAssoc();
if ($A['incoming'] > 0) {
$incoming_msg = " ({$A['incoming']})";
$data['reports'][] = array(
'label' => t('Incoming Files') . "{$incoming_msg}",
'report' => 'incoming',
'parent' => 'allitems',
'icon' => 'icon-fileowned',
);
}
}
// Setup the Most Recent folders for this user
if (user_is_logged_in() && $display_recent_folders != 0) {
$sql = "SELECT a.id,a.cid,b.name FROM {filedepot_recentfolders} a ";
$sql .= "LEFT JOIN {filedepot_categories} b ON b.cid=a.cid ";
if ($filedepot->ogmode_enabled and !empty($filedepot->allowableGroupViewFoldersSql)) {
$sql .= "WHERE a.cid in ({$filedepot->allowableGroupViewFoldersSql}) AND a.cid != {$filedepot->ogrootfolder} AND b.pid != {$filedepot->ogrootfolder} ";
}
else {
$sql .= "WHERE 1=1 ";
}
$sql .= "AND uid=:uid ORDER BY id";
$res = db_query($sql, array(
':uid' => $user->uid,
));
while ($A = $res
->fetchAssoc()) {
$data['recentfolders'][] = array(
'label' => filter_xss($A['name']),
'cid' => $A['cid'],
'icon' => 'icon-allfolders',
);
}
}
$display_order = "ORDER BY " . (variable_get('filedepot_override_folderorder', 0) ? 'name ASC,' : '') . ' folderorder';
$sql = "SELECT cid,pid,name,description from {filedepot_categories} ";
if ($filedepot->ogmode_enabled and !empty($filedepot->allowableGroupViewFoldersSql)) {
$sql .= "WHERE pid = :cid {$display_order}";
$res = db_query($sql, array(
':cid' => $filedepot->ogrootfolder,
));
}
else {
$sql .= "WHERE pid=0 {$display_order}";
$res = db_query($sql);
}
while ($A = $res
->fetchAssoc()) {
if ($filedepot
->checkPermission($A['cid'], 'view')) {
$data['topfolders'][] = array(
'label' => filter_xss($A['name']),
'cid' => $A['cid'],
'parent' => 'allfolders',
'icon' => 'icon-allfolders',
);
}
}
if (function_exists('filedepot_customLeftsideNavigation')) {
$data = filedepot_customLeftsideNavigation($data);
}
if ($display_recent_folders == 0) {
$data['recentfolders'] = NULL;
}
return $data;
}