-
Notifications
You must be signed in to change notification settings - Fork 1
/
visualscience.module
executable file
·175 lines (154 loc) · 5 KB
/
visualscience.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* @file
* The VisualScience Module, from QScience.
*
* It allows you to sort, contact and visualize scientific data about you users.
*/
// Tools pre-made by Vahe.
require_once 'includes/visualscience.settings.inc';
require_once 'includes/visualscience.utils.inc';
// Classes for each functionality.
require_once 'includes/visualscience.searchtable.class.php';
include_once 'includes/visualscience.message.class.php';
include_once 'includes/visualscience.upload.class.php';
include_once 'includes/visualscience.config.class.php';
// define('VISUALSCIENCE_NUSER_LOADED', 1000);
/**
* Implements hook_menu().
*/
function visualscience_menu() {
$items['visualscience'] = array(
'title' => 'Visual Science',
'description' => 'Visual Science description',
'page callback' => 'visualscience_page',
'access arguments' => array('access visualscience'),
// 'access callback' => TRUE,
'weight' => 30,
);
$items['visualscience/users'] = array(
'title' => 'VisualScience Users Access',
'description' => 'Get Users of VisualScience',
'page callback' => 'visualscience_users',
'access arguments' => array('access visualscience'),
'type' => MENU_CALLBACK,
);
$items['visualscience/upload'] = array(
'title' => 'VisualScience Upload',
'description' => 'Upload a file in VisualScience',
'page callback' => 'drupal_get_form',
'page arguments' => array('visualscience_upload_form'),
'access arguments' => array('access visualscience'),
'type' => MENU_CALLBACK,
);
$items['visualscience/file'] = array(
'title' => 'VisualScience Attachment Access',
'description' => 'Access a file uploaded from VisualScience',
'page callback' => 'visualscience_get_file_with_id',
// 'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['visualscience/mail'] = array(
'title' => 'VisualScience Mail Send',
'description' => 'Send Mail from VisualScience',
'page callback' => 'visualscience_send_message',
'access arguments' => array('access visualscience'),
'type' => MENU_CALLBACK,
);
$items['admin/config/media/visualscience'] = array(
'title' => 'VisualScience Configuration',
'description' => 'Configuration for the VisualScience module.',
'page callback' => 'visualscience_config_page',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Implements hook_form().
*/
function visualscience_upload_form($form, &$form_state) {
$upload = new VisualscienceUpload();
return $upload->visualscienceUploadForm($form, $form_state);
}
/**
* Downloading a file if allowed.
*
* @return file
* A webpage if denied else the requested file.
*/
function visualscience_get_file_with_id() {
$upload = new VisualscienceUpload();
return $upload->visualscienceGetFileWithId();
}
/**
* Sending an email throught this Drupal's installation.
*
* @return string
* Notification if success or error.
*/
function visualscience_send_message() {
$message = new VisualscienceMessage();
return $message->visualscienceSendMessage();
}
/**
* Handles the upload of a file.
*/
function visualscience_upload_submit($form, &$form_state) {
$upload = new VisualscienceUpload();
return $upload->visualscienceUploadSubmit($form, $form_state);
}
/**
* The main page for VisualScience.
*
* @return string
* The webpage to be printed.
*/
function visualscience_page() {
$search = new VisualscienceSearch();
$search_to_perform = $search->getSavedSearch();
$search->getClientSideFiles();
$search_bar = $search->getHtmlSearchBar($search_to_perform);
$search_table = $search->getHtmlsearchTable();
$output = $search_bar . $search_table;
return $output;
}
/**
* Configuration page for the VisualScience module.
*
* @return string
* The page to be displayed.
*/
function visualscience_config_page() {
$config = new VisualscienceConfig();
$output = '';
if (isset($_POST['visualscience_config_form']) && $_POST['visualscience_config_csrf_token'] == $_COOKIE['csrfTokenValue']) {
$config->saveSentValues();
drupal_set_message(t('Configuration Saved !'), 'status');
}
$output .= $config->getHtmlConfigPage();
return $output;
}
/**
* Backend to get the list of users from the server.
*
* @return string
* The list of users with some additional informations(json format).
*/
function visualscience_users() {
$search = new VisualscienceSearch();
$from = intval($_GET['userId']);
$database = $search->getUsersEntries($from, variable_get('visualscience_user_sent_per_ajax_request', 1000));
echo $database;
}
/**
* Implements hook_css_alter().
*
* When using the CSS selector jQuery UI suggests,
* we don't have the expected performance(Really slow with > 10'000 checkboxes).
*/
function visualscience_css_alter(&$css) {
if (isset($css['misc/ui/jquery.ui.theme.css'])) {
$css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('module', 'visualscience') . '/css/visualscience.jquery.ui.theme.css';
}
}