Parent Directory
|
Revision Log
|
Revision Graph
node/122896 fixed
| 1 | <?php |
| 2 | |
| 3 | /* ---------------------------------------------------------------------- |
| 4 | DRUPAL CONFERENCE MODULE - VERSION 1.2 |
| 5 | |
| 6 | Please read README.TXT for further informations. |
| 7 | ---------------------------------------------------------------------- */ |
| 8 | |
| 9 | /** |
| 10 | * conference_help |
| 11 | * |
| 12 | * Display help and module information |
| 13 | * |
| 14 | * @param section which section of the site we're displaying help |
| 15 | * @return help text for section |
| 16 | */ |
| 17 | function conference_help($section='') { |
| 18 | |
| 19 | $output = ''; |
| 20 | |
| 21 | switch ($section) { |
| 22 | case "admin/modules#description": |
| 23 | $output = t("Organise your conferences with drupal!"); |
| 24 | break; |
| 25 | } |
| 26 | |
| 27 | return $output; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | /** |
| 32 | * converence_perm |
| 33 | * |
| 34 | * Valid permissions for this module |
| 35 | * |
| 36 | * @return array An array of valid permissions for the onthisdate module |
| 37 | */ |
| 38 | function conference_perm() { |
| 39 | return array('administer conference', 'access conference papers and ratings'); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * conference_menu |
| 44 | * |
| 45 | * Implementation of hook_menu(). |
| 46 | */ |
| 47 | function conference_menu($may_cache) { |
| 48 | |
| 49 | $items = array(); |
| 50 | |
| 51 | // get some variables |
| 52 | $role_paper= variable_get('conference_role_paper', '-1'); |
| 53 | $role_review= variable_get('conference_role_review', '-1'); |
| 54 | $role_management= variable_get('conference_role_management', '-1'); |
| 55 | |
| 56 | // check users permissions |
| 57 | global $user; |
| 58 | $access_paper= 0; |
| 59 | $access_review= 0; |
| 60 | $access_management= 0; |
| 61 | if (array_key_exists($role_paper, $user->roles)) |
| 62 | $access_paper= 1; |
| 63 | if (array_key_exists($role_review, $user->roles)) |
| 64 | $access_review= 1; |
| 65 | if (array_key_exists($role_management, $user->roles)) |
| 66 | $access_management= 1; |
| 67 | |
| 68 | |
| 69 | // and the menu items... |
| 70 | if ($may_cache) { |
| 71 | $items[] = array('path' => 'conference/papers', |
| 72 | 'title' => t('My papers'), |
| 73 | 'callback' => 'conference_my_papers_page', |
| 74 | 'access' => $access_paper, |
| 75 | 'type' => MENU_NORMAL_ITEM); |
| 76 | $items[] = array('path' => 'conference/reviews', |
| 77 | 'title' => t('My reviews'), |
| 78 | 'callback' => 'conference_my_reviews_page', |
| 79 | 'access' => $access_review, |
| 80 | 'type' => MENU_NORMAL_ITEM); |
| 81 | $items[] = array('path' => 'conference/timelimit', |
| 82 | 'title' => t('Time limit'), |
| 83 | 'callback' => 'conference_timelimit', |
| 84 | 'access' => 1, |
| 85 | 'type' => MENU_CALLBACK); |
| 86 | $items[] = array('path' => 'conference/manage', |
| 87 | 'title' => t('Manage conference'), |
| 88 | 'callback' => 'conference_manage_assignment', |
| 89 | 'access' => $access_management, |
| 90 | 'type' => MENU_NORMAL_ITEM); |
| 91 | $items[] = array('path' => 'conference/manage/assignment', |
| 92 | 'title' => t('Assignment'), |
| 93 | 'weight' => 1, |
| 94 | 'access' => $access_management, |
| 95 | 'type' => MENU_DEFAULT_LOCAL_TASK); |
| 96 | $items[] = array('path' => 'conference/manage/assignment/edit', |
| 97 | 'title' => t('Edit assignment'), |
| 98 | 'weight' => 2, |
| 99 | 'callback' => 'conference_manage_assignment_edit', |
| 100 | 'access' => $access_management, |
| 101 | 'type' => MENU_NORMAL_ITEM); |
| 102 | $items[] = array('path' => 'conference/manage/status', |
| 103 | 'title' => t('Status'), |
| 104 | 'weight' => 1, |
| 105 | 'callback' => 'conference_manage_status', |
| 106 | 'access' => $access_management, |
| 107 | 'type' => MENU_LOCAL_TASK); |
| 108 | $items[] = array('path' => 'conference/manage/status/remind', |
| 109 | 'title' => t('Send reminder'), |
| 110 | 'weight' => 1, |
| 111 | 'callback' => 'conference_manage_status_remind', |
| 112 | 'access' => $access_management, |
| 113 | 'type' => MENU_NORMAL_ITEM); |
| 114 | $items[] = array('path' => 'conference/manage/status/exceed', |
| 115 | 'title' => t('Time limit reached'), |
| 116 | 'weight' => 1, |
| 117 | 'callback' => 'conference_manage_status_exceed', |
| 118 | 'access' => $access_management, |
| 119 | 'type' => MENU_NORMAL_ITEM); |
| 120 | $items[] = array('path' => 'admin/settings/conference', |
| 121 | 'title' => t('conference'), |
| 122 | 'callback' => 'conference_settings_page', |
| 123 | 'type' => MENU_NORMAL_ITEM); |
| 124 | $items[] = array('path' => 'conference/manage/decision', |
| 125 | 'title' => t('Decision'), |
| 126 | 'weight' => 2, |
| 127 | 'callback' => 'conference_manage_decision', |
| 128 | 'access' => $access_management, |
| 129 | 'type' => MENU_LOCAL_TASK); |
| 130 | $items[] = array('path' => 'conference/manage/decision/make', |
| 131 | 'title' => t('Make a decision'), |
| 132 | 'weight' => 2, |
| 133 | 'callback' => 'conference_manage_decision_make', |
| 134 | 'access' => $access_management, |
| 135 | 'type' => MENU_CALLBACK); |
| 136 | } |
| 137 | |
| 138 | return $items; |
| 139 | }; |
| 140 | |
| 141 | |
| 142 | /** |
| 143 | * conference_settings_page |
| 144 | * |
| 145 | * Module configuration settings |
| 146 | * |
| 147 | * @return settings HTML or deny access |
| 148 | */ |
| 149 | function conference_settings_page() { |
| 150 | |
| 151 | // ensure that only administrators can access this page |
| 152 | if (!user_access("administer conference")) { |
| 153 | return drupal_access_denied(); |
| 154 | } |
| 155 | |
| 156 | // pagetitle |
| 157 | drupal_set_title(t('Conference Settings')); |
| 158 | |
| 159 | // if there is something to do with the node_grants table |
| 160 | // call the appropriate function. |
| 161 | if ($_POST['op'] == t('Enable conference node permissions')) |
| 162 | conference_update_access(); |
| 163 | if ($_POST['op'] == t('Update permissions table')) |
| 164 | conference_update_access(); |
| 165 | if ($_POST['op'] == t('Disable conference node permissions')) |
| 166 | conference_disable_access(); |
| 167 | |
| 168 | // --- some first settings --- |
| 169 | |
| 170 | $form['conference_name']= |
| 171 | array( |
| 172 | '#type' => 'textfield', |
| 173 | '#title' => t('Conference name'), |
| 174 | '#default_value' => variable_get('conference_name', ''), |
| 175 | '#description' => t('Please name your conference.'), |
| 176 | '#weight' => -10, |
| 177 | ); |
| 178 | |
| 179 | // --- fieldset: content types --- |
| 180 | $form['ctypes'] = array('#type' => 'fieldset', |
| 181 | '#title' => t('Content types'), |
| 182 | ); |
| 183 | |
| 184 | $form['ctypes']['intro'] = array('#type' => 'item', |
| 185 | '#value' => t('Please use the content construction kit or similar modules to create a content type. After changing this settings it is <strong>necessary</strong> to update the node permissions!')); |
| 186 | |
| 187 | $node_types = node_get_types(); |
| 188 | $form['ctypes']['conference_ctype_paper'] = array( |
| 189 | '#type' => 'select', |
| 190 | '#title' => t('Content type for posting papers'), |
| 191 | '#default_value' => variable_get('conference_ctype_paper', ''), |
| 192 | '#options' => $node_types, |
| 193 | '#description' => t('This content type will only be editable and viewable by the author. Don\'t forget to <strong>allow file uploading</strong> for this content type.'), |
| 194 | '#weight' => 1, |
| 195 | ); |
| 196 | |
| 197 | $form['ctypes']['conference_expand_upload'] = array( |
| 198 | '#type' => 'checkbox', |
| 199 | '#title' => t('Expand upload fieldset in paper creation formular'), |
| 200 | '#default_value' => variable_get('conference_expand_upload', 0), |
| 201 | '#weight' => 2, |
| 202 | ); |
| 203 | |
| 204 | $node_types = node_get_types(); |
| 205 | $form['ctypes']['conference_ctype_review'] = array( |
| 206 | '#type' => 'select', |
| 207 | '#title' => t('Content type for posting reviews'), |
| 208 | '#default_value' => variable_get('conference_ctype_review', ''), |
| 209 | '#options' => $node_types, |
| 210 | '#description' => t('This content type will be editable and viewable by the author.'), |
| 211 | '#weight' => 3, |
| 212 | ); |
| 213 | |
| 214 | $form['ctypes']['conference_hide_title'] = array( |
| 215 | '#type' => 'checkbox', |
| 216 | '#title' => t('Hide title-field in review creation formular'), |
| 217 | '#default_value' => variable_get('conference_hide_title', 0), |
| 218 | '#weight' => 4, |
| 219 | ); |
| 220 | |
| 221 | $form['ctypes']['conference_default_title'] = array( |
| 222 | '#type' => 'textfield', |
| 223 | '#title' => t('Default title for reviews'), |
| 224 | '#default_value' => variable_get('conference_default_title', 'Review of %s'), |
| 225 | '#weight' => 5, |
| 226 | '#description' => t('"%s" will be substituted by the title of the referring paper. Leave blank to disable this feature.'), |
| 227 | ); |
| 228 | |
| 229 | // --- fieldset: node permissions --- |
| 230 | $form['access'] = array('#type' => 'fieldset', |
| 231 | '#title' => t('Node Permissions'), |
| 232 | ); |
| 233 | |
| 234 | $form['access']['intro'] = array('#type' => 'item', |
| 235 | '#value' => t('The conference module contains a system to manage node permissions. It is neccessary to update the permissions table after installing the module and after changing the content type settings.'), |
| 236 | '#weight' => -1, |
| 237 | ); |
| 238 | |
| 239 | switch (variable_get('conference_grants', 0)) { |
| 240 | case 0: |
| 241 | $form['access']['conference_grants_enable'] = array( |
| 242 | '#type' => 'submit', |
| 243 | '#value' => t('Enable conference node permissions'), |
| 244 | '#weight' => 1, |
| 245 | ); |
| 246 | break; |
| 247 | |
| 248 | case 1: |
| 249 | $form['access']['conference_grants_disable'] = array( |
| 250 | '#type' => 'submit', |
| 251 | '#value' => t('Disable conference node permissions'), |
| 252 | '#weight' => 1, |
| 253 | ); |
| 254 | $form['access']['conference_grants_update'] = array( |
| 255 | '#type' => 'submit', |
| 256 | '#value' => t('Update permissions table'), |
| 257 | '#weight' => 2, |
| 258 | ); |
| 259 | break; |
| 260 | |
| 261 | } |
| 262 | $form['access']['conference_grants'] = array('#type' => 'radios', |
| 263 | '#default_value' => variable_get('conference_grants', 0), |
| 264 | '#options' => $grants |
| 265 | ); |
| 266 | |
| 267 | $form['roles'] = array('#type' => 'fieldset', |
| 268 | '#title' => t('Roles'), |
| 269 | ); |
| 270 | |
| 271 | $form['roles']['intro'] = array('#type' => 'item', |
| 272 | '#value' => t('One role is dedicated to post papers, another to read papers and to post reviews. These settings doesn\'t affect the right to create the corresponding node types. Therefor please have a look at the <a href="?q=admin/access"> access control page</a>. But these settings control the visibility of the corresponding menu items, pages and blocks!')); |
| 273 | |
| 274 | $roles= user_roles(); |
| 275 | $form['roles']['conference_role_paper'] = array( |
| 276 | '#type' => 'select', |
| 277 | '#title' => t('Role dedicated to post papers'), |
| 278 | '#default_value' => variable_get('conference_role_paper', 2), |
| 279 | '#options' => $roles, |
| 280 | '#description' => t('What about "authenticated user"?'), |
| 281 | ); |
| 282 | |
| 283 | $form['roles']['conference_role_review'] = array( |
| 284 | '#type' => 'select', |
| 285 | '#title' => t('Role dedicated to read papers and to write reviews'), |
| 286 | '#default_value' => variable_get('conference_role_review', ''), |
| 287 | '#options' => $roles, |
| 288 | '#description' => t(''), |
| 289 | ); |
| 290 | $form['roles']['conference_role_management'] = array( |
| 291 | '#type' => 'select', |
| 292 | '#title' => t('Role dedicated to assign reviewers to papers and to manage the conference.'), |
| 293 | '#default_value' => variable_get('conference_role_management', ''), |
| 294 | '#options' => $roles, |
| 295 | '#description' => t(''), |
| 296 | ); |
| 297 | |
| 298 | // ---- email 1: decision ---- |
| 299 | $form['email1']= array('#type' => 'fieldset', |
| 300 | '#title' => t('Information email to author'), |
| 301 | ); |
| 302 | $form['email1']['conference_email_decision_subject']= array('#type' => 'textfield', |
| 303 | '#title' => t('Subject'), |
| 304 | '#default_value' => variable_get('conference_email_decision_subject', |
| 305 | '[%conference] Infromation about your paper.'), |
| 306 | '#description' => t('Use this variables: "%conference" for the conference name.'), |
| 307 | '#weight' => 2); |
| 308 | $form['email1']['conference_email_decision_body']= array('#type' => 'textarea', |
| 309 | '#title' => t('Content'), |
| 310 | '#default_value' => variable_get('conference_email_decisionbody', ' |
| 311 | Hello %username, |
| 312 | |
| 313 | thank you for submitting your paper "%title". The conference chair made a decision concerning that paper: |
| 314 | |
| 315 | *%decision* |
| 316 | |
| 317 | %feedback |
| 318 | |
| 319 | --- %conference% team |
| 320 | '), |
| 321 | '#cols' => 30, |
| 322 | '#rows' => 5, |
| 323 | '#description' => t('Use this variables: "%conference" for the conference name, "%username" for the authors username, "%title" for the paper title, "%decision" for the decision, "%feedback".'), |
| 324 | '#weight' => 3); |
| 325 | |
| 326 | $form['email1']['conference_email_decision_accept']= |
| 327 | array( |
| 328 | '#type' => 'textfield', |
| 329 | '#title' => t('Information text for accepting a paper'), |
| 330 | '#default_value' => variable_get('conference_email_decision_accept', |
| 331 | 'Your paper is accepted.'), |
| 332 | '#description' => t('The decision variable will be replaced by this string if necessary.'), |
| 333 | '#weight' => 4, |
| 334 | ); |
| 335 | |
| 336 | $form['email1']['conference_email_decision_modify']= |
| 337 | array( |
| 338 | '#type' => 'textfield', |
| 339 | '#title' => t('Information text for requesting a modification'), |
| 340 | '#default_value' => variable_get('conference_email_decision_modify', |
| 341 | 'Please post a modification of your paper (as a new paper)!'), |
| 342 | '#description' => t('The decision variable will be replaced by this string if necessary.'), |
| 343 | '#weight' => 5, |
| 344 | ); |
| 345 | |
| 346 | $form['email1']['conference_email_decision_reject']= |
| 347 | array( |
| 348 | '#type' => 'textfield', |
| 349 | '#title' => t('Information text for rejecting a paper'), |
| 350 | '#default_value' => variable_get('conference_email_decision_reject', |
| 351 | 'Your paper is rejected.'), |
| 352 | '#description' => t('The decision variable will be replaced by this string if necessary.'), |
| 353 | '#weight' => 6, |
| 354 | ); |
| 355 | |
| 356 | // ---- email 2: reminder |
| 357 | |
| 358 | $form['email2']= array('#type' => 'fieldset', |
| 359 | '#title' => t('Reminder email to reviewer'), |
| 360 | ); |
| 361 | $form['email2']['conference_email_reminder_subject']= array('#type' => 'textfield', |
| 362 | '#title' => t('Subject'), |
| 363 | '#default_value' => variable_get('conference_email_reminder_subject', |
| 364 | '[%conference] Reminder'), |
| 365 | '#description' => t('Use this variables: "%conference" for the conference name.'), |
| 366 | '#weight' => 2); |
| 367 | $form['email2']['conference_email_reminder_body']= array('#type' => 'textarea', |
| 368 | '#title' => t('Content'), |
| 369 | '#default_value' => variable_get('conference_email_reminder_body', ' |
| 370 | Hello %username, |
| 371 | |
| 372 | the conference chair assigned you to review the following papers: |
| 373 | |
| 374 | %papers% |
| 375 | |
| 376 | At least some of these papers have not been reviewed until now. Please don\'t forget to post your reviews in time. Thank you! |
| 377 | |
| 378 | --- %conference% team |
| 379 | '), |
| 380 | '#cols' => 30, |
| 381 | '#rows' => 5, |
| 382 | '#description' => t('Use this variables: "%conference" for the conference name, "%username" for the reviewers username, "%papers" for the list of papere.'), |
| 383 | '#weight' => 3); |
| 384 | |
| 385 | // ---- email 3: assignment |
| 386 | $form['email3']= array('#type' => 'fieldset', |
| 387 | '#title' => t('Inform reviewer about an assignment'), |
| 388 | ); |
| 389 | $form['email3']['conference_email_assignment_subject']= array('#type' => 'textfield', |
| 390 | '#title' => t('Subject'), |
| 391 | '#default_value' => variable_get('conference_email_assignment_subject', |
| 392 | '[%conference] Please review the paper "%title".'), |
| 393 | '#description' => t('Use this variables: "%conference" for the conference name, "%title" for the paper title'), |
| 394 | '#weight' => 2); |
| 395 | $form['email3']['conference_email_assignment_body']= array('#type' => 'textarea', |
| 396 | '#title' => t('Content'), |
| 397 | '#default_value' => variable_get('conference_email_assignment_body', ' |
| 398 | Hello %username, |
| 399 | |
| 400 | the conference chair assigned you to review the following paper. Please provide a review in time using our website. |
| 401 | |
| 402 | Paper title: %title |
| 403 | |
| 404 | You can use this link to download the paper: |
| 405 | |
| 406 | %download |
| 407 | |
| 408 | Thank you for your assistance! |
| 409 | |
| 410 | --- %conference team |
| 411 | '), |
| 412 | '#cols' => 30, |
| 413 | '#rows' => 5, |
| 414 | '#description' => t('Use this variables: "%conference" for the conference name, "%username" for the reviewers username, "%title" for the paper title, "%download" for the download links.'), |
| 415 | '#weight' => 3); |
| 416 | |
| 417 | if (!variable_get('conference_grants', 0)) |
| 418 | drupal_set_message(t('Please enable conference node permissions!'), 'error'); |
| 419 | |
| 420 | $output = system_settings_form('test_page', $form); |
| 421 | |
| 422 | return $output; |
| 423 | } |
| 424 | |
| 425 | |
| 426 | /** |
| 427 | * conference_update_access |
| 428 | * |
| 429 | * Update the node grants table and enable the conference node permissions |
| 430 | **/ |
| 431 | function conference_update_access() { |
| 432 | |
| 433 | // get some variables |
| 434 | $ctype_paper= variable_get('conference_ctype_paper', -1); |
| 435 | $ctype_review= variable_get('conference_ctype_review', -1); |
| 436 | $time_limit= variable_get('conference_time_limit', 0); |
| 437 | |
| 438 | // node types must be set |
| 439 | if (($ctype_paper == -1) or ($ctype_review == -1)) { |
| 440 | drupal_set_message("Please specify the content types for papers and reviews ", |
| 441 | 'error'); |
| 442 | return; |
| 443 | }; |
| 444 | |
| 445 | // delete universal view grant |
| 446 | db_query("DELETE FROM {node_access} WHERE nid = 0 AND realm = 'all'"); |
| 447 | db_query("DELETE FROM {node_access} WHERE (realm = 'conference') OR (realm = 'conference_all') OR (realm = 'conference_manage')"); |
| 448 | |
| 449 | // node type: paper, user: creator |
| 450 | // papers already assigned to a reviewer are viewable but not |
| 451 | // editable for the creator. |
| 452 | // if the conference chair made a decision concerning a paper, that |
| 453 | // paper is viewable but not editable for the creator |
| 454 | db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) ". |
| 455 | "SELECT n.nid, n.uid, 'conference', 1, 0, 0 FROM {node} n ". |
| 456 | "LEFT JOIN {conference} c ON n.nid = c.pnid ". |
| 457 | "LEFT JOIN {conference_decision} d ON d.pnid = n.nid ". |
| 458 | "WHERE n.type = '$ctype_paper' AND (c.ruid > '0' OR d.decision > '0')"); |
| 459 | // other papers are viewable and editable for the creator |
| 460 | db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) ". |
| 461 | "SELECT n.nid, n.uid, 'conference', 1, 1, 1 FROM {node} n ". |
| 462 | "LEFT JOIN {conference} c ON c.pnid = n.nid ". |
| 463 | "LEFT JOIN {conference_decision} d ON d.pnid = n.nid ". |
| 464 | "WHERE c.ruid IS NULL AND d.decision IS NULL AND n.type = '$ctype_paper'"); |
| 465 | |
| 466 | //if ($time_limit == 1) |
| 467 | // db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) SELECT nid, uid, 'conference', 1, 0, 0 FROM {node} WHERE type = '$ctype_paper'"); |
| 468 | //else |
| 469 | // db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) SELECT nid, uid, 'conference', 1, 1, 1 FROM {node} WHERE type = '$ctype_paper'"); |
| 470 | |
| 471 | // node type: paper, user: manager |
| 472 | db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) SELECT nid, 1, 'conference_manage', 1, 0, 0 FROM {node} WHERE type = '$ctype_paper'"); |
| 473 | |
| 474 | // node type: review, user: creator |
| 475 | db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) SELECT nid, uid, 'conference', 1, 1, 1 FROM {node} WHERE type = '$ctype_review'"); |
| 476 | |
| 477 | // node type: review, user: manager |
| 478 | db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) SELECT nid, 1, 'conference_manage', 1, 0, 0 FROM {node} WHERE type = '$ctype_review'"); |
| 479 | |
| 480 | // all other node types |
| 481 | db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) SELECT nid, 0, 'conference_all', 1, 0, 0 FROM {node} WHERE (type != '$ctype_paper') AND (type != '$ctype_review')"); |
| 482 | |
| 483 | // save state and print message |
| 484 | variable_set('conference_grants', 1); |
| 485 | drupal_set_message("The database has been configured and updated for conference node permissions."); |
| 486 | } |
| 487 | |
| 488 | /** |
| 489 | * confernece_disable_access |
| 490 | * |
| 491 | * Disable conference node permissions |
| 492 | */ |
| 493 | function conference_disable_access() { |
| 494 | db_query("DELETE FROM {node_access} WHERE nid = 0 AND realm = 'all'"); |
| 495 | db_query("DELETE FROM {node_access} WHERE (realm = 'conference') OR (realm = 'conference_all') OR (realm = 'conference_manage')"); |
| 496 | db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)"); |
| 497 | drupal_set_message("The default permissions table has been restored. Conference node permissions is disabled."); |
| 498 | variable_set('conference_grants', 0); |
| 499 | } |
| 500 | |
| 501 | |
| 502 | /** |
| 503 | * conference_node_grants |
| 504 | * |
| 505 | * Implementation of hook_node_grants |
| 506 | */ |
| 507 | function conference_node_grants($account, $op) { |
| 508 | |
| 509 | if (!variable_get('conference_grants', 0)) |
| 510 | return; |
| 511 | |
| 512 | $grants = array(); |
| 513 | |
| 514 | // disable default grants |
| 515 | $grants['all'] = array(-1); |
| 516 | |
| 517 | // allow all users access to node types other than papers and reviews |
| 518 | $grants['conference_all'] = array(0); |
| 519 | |
| 520 | // only creators can access papers and reviews |
| 521 | $grants['conference'] = array($account->uid); |
| 522 | |
| 523 | // manager can access everything |
| 524 | $role_management= variable_get('conference_role_management', '-1'); |
| 525 | if (array_key_exists($role_management, $account->roles)) |
| 526 | $grants['conference_manage'] = array(1); |
| 527 | |
| 528 | return $grants; |
| 529 | } |
| 530 | |
| 531 | |
| 532 | /** |
| 533 | * conference_manage_assignment |
| 534 | * |
| 535 | * List all papers with the assigned reviewers. |
| 536 | */ |
| 537 | function conference_manage_assignment () { |
| 538 | |
| 539 | // get some variables |
| 540 | $ctype_paper= variable_get('conference_ctype_paper', ''); |
| 541 | $ctype_review= variable_get('conference_ctype_review', ''); |
| 542 | $content= ''; |
| 543 | |
| 544 | // table header |
| 545 | $header= array(array(data => t('Title'), |
| 546 | field => 'n.title'), |
| 547 | array(data => t('User'), |
| 548 | field => 'n.uid'), |
| 549 | array(data => t('Date'), |
| 550 | field => 'n.created', |
| 551 | sort => 'desc'), |
| 552 | array(data => t('Reviewer'), |
| 553 | field => 'c.rnid'), |
| 554 | array(data => t('Assignment')), |
| 555 | ); |
| 556 | $rows= array(); |
| 557 | |
| 558 | // get a paged list of all papers |
| 559 | $sql= "SELECT * FROM {node} n LEFT JOIN {conference} c ON n.nid = c.pnid WHERE n.type='%s'"; |
| 560 | $sql.= tablesort_sql($header); |
| 561 | $result= pager_query($sql, 25, 5, NULL, $ctype_paper); |
| 562 | while($item= db_fetch_array($result)) { |
| 563 | |
| 564 | // get user informations |
| 565 | $p_user= user_load(array(uid => $item[uid])); |
| 566 | $r_user= $item[ruid] > 0 ? $item[ruid] : ''; |
| 567 | if ($r_user) $r_user= user_load(array(uid => $r_user)); |
| 568 | |
| 569 | // choose some operations to display |
| 570 | $op= array(); |
| 571 | if ($r_user) |
| 572 | $op[]= l(t('edit'), 'conference/manage/assignment/edit', array(), |
| 573 | 'pnid='.$item['nid'].'&ruid='.$r_user->uid); |
| 574 | $op[]= l(t('create'), 'conference/manage/assignment/edit', array(), |
| 575 | 'pnid='.$item['nid']); |
| 576 | |
| 577 | // build row |
| 578 | $rows[]= array(l($item[title], 'node/'.$item['nid']), |
| 579 | l($p_user->name, 'user/'.$p_user->uid), |
| 580 | format_date($item[created]), |
| 581 | $r_user ? l($r_user->name, 'user/'.$r_user->uid) : t('not assigned'), |
| 582 | implode(', ', $op), |
| 583 | ); |
| 584 | }; |
| 585 | |
| 586 | $content.= theme('table', $header, $rows); |
| 587 | $content.= theme('pager', NULL, 25, 5); |
| 588 | print theme('page', $content); |
| 589 | }; |
| 590 | |
| 591 | |
| 592 | /** |
| 593 | * conference_manage_assignment_edit |
| 594 | * |
| 595 | * Formular to create and edit the assignment of a paper to a reviewer |
| 596 | */ |
| 597 | function conference_manage_assignment_edit () { |
| 598 | |
| 599 | // set some variables |
| 600 | $content= ''; |
| 601 | $form= array(); |
| 602 | |
| 603 | // get some variables |
| 604 | $ctype_paper= variable_get('conference_ctype_paper', ''); |
| 605 | $role_review= variable_get('conference_role_review', '-1'); |
| 606 | |
| 607 | // get parameters: if present edit existing assignment, |
| 608 | // otherwise create new assignment. |
| 609 | $param_pnid= $_GET['pnid']; |
| 610 | $param_ruid= $_GET['ruid']; |
| 611 | |
| 612 | // create an array with all selectable paper-nodes |
| 613 | $papers= array(); |
| 614 | $rnid= 0; |
| 615 | if ($param_pnid AND $param_ruid) { |
| 616 | $result= db_query("SELECT * FROM {conference} c LEFT JOIN {node} n ON n.nid = c.pnid WHERE c.pnid = '%d' AND c.ruid = '%d'", $param_pnid, $param_ruid); |
| 617 | $item= db_fetch_array($result); |
| 618 | $papers[$item[nid]]= $item[title]; |
| 619 | $rnid= $item[rnid]; |
| 620 | } else { |
| 621 | $result= db_query("SELECT * FROM {node} n LEFT JOIN {conference} c ON n.nid = c.pnid WHERE n.type='%s'", $ctype_paper); |
| 622 | while($item= db_fetch_array($result)) |
| 623 | $papers[$item['nid']]= $item['title']; |
| 624 | if ($param_pnid) |
| 625 | $papers= array($param_pnid => $papers[$param_pnid]); |
| 626 | }; |
| 627 | |
| 628 | // form element: select paper |
| 629 | $form['pnid'] = array('#type' => 'select', |
| 630 | '#title' => t('Paper'), |
| 631 | '#options' => $papers, |
| 632 | '#weight' => 0, |
| 633 | ); |
| 634 | |
| 635 | // create an array with all reviewer-users |
| 636 | $reviewer= array(); |
| 637 | $result= db_query("SELECT * FROM {users_roles} r LEFT JOIN {users} u ON r.uid = u.uid WHERE r.rid = '%d'", |
| 638 | $role_review); |
| 639 | while($item= db_fetch_array($result)) { |
| 640 | $reviewer[$item['uid']]= $item['name']; |
| 641 | }; |
| 642 | |
| 643 | // form element: select reviewer |
| 644 | $form['ruid'] = array('#type' => 'select', |
| 645 | '#title' => t('Reviewer'), |
| 646 | '#default_value' => $param_ruid, |
| 647 | '#options' => $reviewer, |
| 648 | '#weight' => 1, |
| 649 | ); |
| 650 | |
| 651 | // if there is a review-node (update existing assingment), ask what to |
| 652 | // do with it. |
| 653 | if ($rnid) { |
| 654 | $form['update_rnid'] = array('#type' => 'radios', |
| 655 | '#title' => t('There exists a review by the assigned user for this paper.'), |
| 656 | '#default_value' => $rnid, |
| 657 | '#options' => array($rnid => t('keep this review'), |
| 658 | 0 => t('loose this review (no way to assign it again!)')), |
| 659 | '#weight' => 2, |
| 660 | ); |
| 661 | }; |
| 662 | |
| 663 | // form element: inform author by email? |
| 664 | $form['email']= array('#type' => 'fieldset', |
| 665 | '#title' => t('Inform reviewer by email'), |
| 666 | '#weight' => 3); |
| 667 | $form['email']['send']= array('#type' => 'checkbox', |
| 668 | '#title' => t('Send information email about this assignment to the reviewer'), |
| 669 | '#default_value' => 1, |
| 670 | '#weight' => 1); |
| 671 | $form['email']['subject']= array('#type' => 'textfield', |
| 672 | '#title' => t('Subject'), |
| 673 | '#default_value' => variable_get('conference_email_assignment_subject', |
| 674 | '[%conference] Please review the paper "%title".'), |
| 675 | '#description' => t('Use this variables: "%conference" for the conference name, "%title" for the paper title'), |
| 676 | '#weight' => 2); |
| 677 | $form['email']['body']= array('#type' => 'textarea', |
| 678 | '#title' => t('Content'), |
| 679 | '#default_value' => variable_get('conference_email_assignment_body', ' |
| 680 | Hello %username, |
| 681 | |
| 682 | the conference chair assigned you to review the following paper. Please provide a review in time using our website. |
| 683 | |
| 684 | Paper title: %title |
| 685 | |
| 686 | You can use this link to download the paper: |
| 687 | |
| 688 | %download |
| 689 | |
| 690 | Thank you for your assistance! |
| 691 | |
| 692 | --- %conference team |
| 693 | '), |
| 694 | '#cols' => 30, |
| 695 | '#rows' => 5, |
| 696 | '#description' => t('Use this variables: "%conference" for the conference name, "%username" for the reviewers username, "%title" for the paper title, "%download" for the download links.'), |
| 697 | '#weight' => 3); |
| 698 | $form['email']['save']= array('#type' => 'checkbox', |
| 699 | '#title' => t('Save email content and subject as default'), |
| 700 | '#default_value' => 1, |
| 701 | '#weight' => 4); |
| 702 | |
| 703 | $form['submit'] = array('#type' => 'submit', |
| 704 | '#value' => t('Submit'), |
| 705 | '#weight' => 9, |
| 706 | '#submit' => 1, |
| 707 | ); |
| 708 | if ($param_ruid AND $param_pnid) { |
| 709 | $form['delete'] = array('#type' => 'submit', |
| 710 | '#value' => t('Delete'), |
| 711 | '#weight' => 10, |
| 712 | ); |
| 713 | $form['update_ruid'] = array('#type' => 'hidden', |
| 714 | '#value' => $param_ruid, |
| 715 | '#weight' => 8); |
| 716 | }; |
| 717 | |
| 718 | $content.= drupal_get_form('conference_manage_assignment_edit', $form); |
| 719 | |
| 720 | print theme('page', $content); |
| 721 | }; |
| 722 | |
| 723 | function conference_manage_assignment_edit_submit ($form_id, $form_values) { |
| 724 | |
| 725 | $op = isset($_POST['op']) ? $_POST['op'] : ''; |
| 726 | |
| 727 | // DELETE assignment |
| 728 | if ($op == t('Delete')) { |
| 729 | db_query("DELETE FROM {conference} WHERE pnid = '%d' AND ruid = '%d' LIMIT 1", |
| 730 | $form_values['pnid'], $form_values['update_ruid']); |
| 731 | db_query("UPDATE {node_access} SET grant_view = '1', grant_update = '1', grant_delete = '1' ". |
| 732 | "WHERE nid = '%d' AND realm = 'conference'", $form_values['pnid']); |
| 733 | drupal_set_message(t('The assignment has been deleted.')); |
| 734 | drupal_goto('conference/manage/assignment'); |
| 735 | return; |
| 736 | }; |
| 737 | |
| 738 | $form['email']['save']= array('#type' => 'checkbox', |
| 739 | '#title' => t('Save email content and subject as default'), |
| 740 | '#default_value' => 1, |
| 741 | '#weight' => 4); |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | $form['emails'] = array('#type' => 'fieldset', |
| 747 | '#title' => t('Emails'), |
| 748 | ); |
| 749 | |
| 750 | $form['emails']['conference_reminder_subject']= |
| 751 | array( |
| 752 | '#type' => 'textfield', |
| 753 | '#title' => t('Subject of reminder email'), |
| 754 | '#default_value' => variable_get('conference_reminder_subject', |
| 755 | 'Reminder'), |
| 756 | '#description' => t('Possible variables: %conference%'), |
| 757 | '#weight' => 1, |
| 758 | ); |
| 759 | |
| 760 | $form['emails']['conference_reminder_content']= |
| 761 | array( |
| 762 | '#type' => 'textarea', |
| 763 | '#title' => t('Reminder email'), |
| 764 | '#default_value' => variable_get('conference_reminder_content', ' |
| 765 | Hello %username%, |
| 766 | |
| 767 | the conference chair of "%conference%" assigned you to review the following papers: |
| 768 | |
| 769 | %papers% |
| 770 | |
| 771 | At least some of these papers have not been reviewed until now. Please don\'t forget to post your reviews in time. Thank you! |
| 772 | |
| 773 | --- %conference% team |
| 774 | '), |
| 775 | '#cols' => 30, |
| 776 | '#rows' => 5, |
| 777 | '#description' => t('Possible variables: %username%, %conference%, %papers%'), |
| 778 | '#weight' => 2, |
| 779 | ); |
| 780 | |
| 781 | $form['emails']['conference_briefing_subject']= |
| 782 | array( |
| 783 | '#type' => 'textfield', |
| 784 | '#title' => t('Subject of information email'), |
| 785 | '#default_value' => variable_get('conference_briefing_subject', |
| 786 | 'Briefing'), |
| 787 | '#description' => t('Possible variables: %conference%'), |
| 788 | '#weight' => 3, |
| 789 | ); |
| 790 | |
| 791 | $form['emails']['conference_briefing_content']= |
| 792 | array( |
| 793 | '#type' => 'textarea', |
| 794 | '#title' => t('Information email'), |
| 795 | '#default_value' => variable_get('conference_briefing_content', ' |
| 796 | Hello %username%, |
| 797 | |
| 798 | thank you for submitting your paper "%paper%". The conference chair made a decision concerning that paper: |
| 799 | |
| 800 | *%decision%* |
| 801 | |
| 802 | %feedback% |
| 803 | |
| 804 | --- %conference% team |
| 805 | '), |
| 806 | '#cols' => 30, |
| 807 | '#rows' => 5, |
| 808 | '#description' => t('Possible variables: %username%, %conference%, %paper%, %decision%, %feedback%'), |
| 809 | '#weight' => 4, |
| 810 | ); |
| 811 | |
| 812 | $form['emails']['conference_briefing_accept']= |
| 813 | array( |
| 814 | '#type' => 'textfield', |
| 815 | '#title' => t('Information text for accepting a paper'), |
| 816 | '#default_value' => variable_get('conference_briefing_accept', |
| 817 | 'Your paper is accepted.'), |
| 818 | '#description' => t('The decision variable will be replaced by this string if necessary.'), |
| 819 | '#weight' => 5, |
| 820 | ); |
| 821 | |
| 822 | $form['emails']['conference_briefing_review']= |
| 823 | array( |
| 824 | '#type' => 'textfield', |
| 825 | '#title' => t('Information text for requesting a modification'), |
| 826 | '#default_value' => variable_get('conference_briefing_review', |
| 827 | 'Please post a modification of your paper (as a new paper)!'), |
| 828 | '#description' => t('The decision variable will be replaced by this string if necessary.'), |
| 829 | '#weight' => 6, |
| 830 | ); |
| 831 | |
| 832 | $form['emails']['conference_briefing_reject']= |
| 833 | array( |
| 834 | '#type' => 'textfield', |
| 835 | '#title' => t('Information text for rejecting a paper'), |
| 836 | '#default_value' => variable_get('conference_briefing_reject', |
| 837 | 'Your paper is rejected.'), |
| 838 | '#description' => t('The decision variable will be replaced by this string if necessary.'), |
| 839 | '#weight' => 7, |
| 840 | ); |
| 841 | |
| 842 | // EDIT/CREATE assingment |
| 843 | |
| 844 | // at first: if there is already an assignment for this paper-nid (pnid) |
| 845 | // and this review-uid (ruid), *do nothing* ! |
| 846 | $result= db_query("SELECT * FROM {conference} WHERE pnid = '%d' AND ruid = '%d'", |
| 847 | $form_values['pnid'], $form_values['ruid']); |
| 848 | if ($item= db_fetch_array($result)) { |
| 849 | drupal_set_message(t('The paper you selected is already assigned to this reviewer. Nothing '. |
| 850 | 'done.')); |
| 851 | drupal_goto('conference/manage/assignment'); |
| 852 | return; |
| 853 | }; |
| 854 | |
| 855 | if ($form_values['update_ruid']) { |
| 856 | $rnid= isset($form_values[update_rnid]) ? $form_values[update_rnid] : 0; |
| 857 | db_query("UPDATE {conference} SET ruid = '%d', rnid = '%d' WHERE pnid = '%d' AND ruid = '%d'", |
| 858 | $form_values['ruid'], $rnid, $form_values['pnid'], $form_values['update_ruid']); |
| 859 | drupal_set_message(t('Your assignment has been updated.')); |
| 860 | } else { |
| 861 | |
| 862 | db_query("INSERT INTO {conference} (pnid, ruid, rnid, comment1, comment2, status) ". |
| 863 | "VALUES ('%d', '%d', 0, '', '', 0)", |
| 864 | $form_values['pnid'], $form_values['ruid']); |
| 865 | drupal_set_message(t('Your assignment has been saved.')); |
| 866 | }; |
| 867 | |
| 868 | if ($form_values['send'] == 1) { |
| 869 | conference_send_mail($form_values['subject'], |
| 870 | $form_values['body'], |
| 871 | array('ruid' => $form_values['ruid'], |
| 872 | 'pnid' => $form_values['pnid'])); |
| 873 | if ($form_values['save'] == 1) { |
| 874 | variable_set('conference_email_assignment_subject', $form_values['subject']); |
| 875 | variable_set('conference_email_assignment_body', $form_values['body']); |
| 876 | }; |
| 877 | }; |
| 878 | |
| 879 | db_query("UPDATE {node_access} SET grant_view = '1', grant_update = '0', grant_delete = '0' ". |
| 880 | "WHERE nid = '%d' AND realm = 'conference'", $form_values['pnid']); |
| 881 | drupal_goto('conference/manage/assignment'); |
| 882 | } |
| 883 | |
| 884 | |
| 885 | function conference_manage_assignment_edit_delete ($form_id, $form_values) { |
| 886 | |
| 887 | print_r($form_values); |
| 888 | |
| 889 | }; |
| 890 | /** |
| 891 | * conference_manage_status |
| 892 | * |
| 893 | * Show the review status of all papers. |
| 894 | */ |
| 895 | function conference_manage_status () { |
| 896 | |
| 897 | // get some variables |
| 898 | $ctype_paper= variable_get('conference_ctype_paper', ''); |
| 899 | $ctype_review= variable_get('conference_ctype_review', ''); |
| 900 | |
| 901 | // set some variables |
| 902 | $content= ''; |
| 903 | |
| 904 | // intro |
| 905 | $content.= '<p>'.t('The following table only contains papers that are assignend to a reviewer:').'</p>'; |
| 906 | |
| 907 | // table header |
| 908 | $header= array(array(data => t('Title'), |
| 909 | field => 'n.title'), |
| 910 | array(data => t('User'), |
| 911 | field => 'n.uid'), |
| 912 | array(data => t('Assignment'), |
| 913 | field => 'c.ruid'), |
| 914 | array(data => t('Review'), |
| 915 | field => 'c.rnid', |
| 916 | sort => 'desc'), |
| 917 | ); |
| 918 | $rows= array(); |
| 919 | |
| 920 | // get a paged list of all papers |
| 921 | $sql= "SELECT * FROM {node} n LEFT JOIN {conference} c ON n.nid = c.pnid WHERE n.type='%s' AND c.ruid > 0"; |
| 922 | $sql.= tablesort_sql($header); |
| 923 | $result= pager_query($sql, 25, 7, NULL, $ctype_paper); |
| 924 | while($item= db_fetch_array($result)) { |
| 925 | |
| 926 | // get user informations |
| 927 | $p_user= user_load(array(uid => $item[uid])); |
| 928 | $r_user= $item[ruid] > 0 ? $item[ruid] : ''; |
| 929 | if ($r_user) $r_user= user_load(array(uid => $r_user)); |
| 930 | |
| 931 | // build row |
| 932 | $rows[]= array(l($item[title], 'node/'.$item['nid']), |
| 933 | l($p_user->name, 'user/'.$p_user->uid), |
| 934 | $r_user ? l($r_user->name, 'user/'.$r_user->uid) : t('not assigned'), |
| 935 | $item[rnid] ? l(t('show'), 'node/'.$item[rnid]) : t('not reviewed'), |
| 936 | ); |
| 937 | }; |
| 938 | |
| 939 | $content.= theme('table', $header, $rows); |
| 940 | $content.= theme('pager', NULL, 25, 7); |
| 941 | |
| 942 | // foot |
| 943 | $content.= '<h3>Control conference</h3><ul>'; |
| 944 | $content.= '<li>'.t(l('Send reminder', 'conference/manage/status/remind')).' to all '. |
| 945 | 'reviewers with outstanding reviews.'.'</li>'; |
| 946 | $content.= '<li>'.t(l('Time limit reached', 'conference/manage/status/exceed')). |
| 947 | ': stop accepting papers.</li>'; |
| 948 | $content.= '</ul>'; |
| 949 | |
| 950 | print theme('page', $content); |
| 951 | }; |
| 952 | |
| 953 | |
| 954 | function conference_manage_status_remind () { |
| 955 | |
| 956 | // some requirements |
| 957 | if (!variable_get('conference_reminder_subject', '') or |
| 958 | !variable_get('conference_reminder_content', '')) { |
| 959 | drupal_set_message(t('You did not enter the content or the subject '. |
| 960 | 'of the reminder email. Please visit the '. |
| 961 | l('conference settings', 'admin/settigs/conference'). |
| 962 | '.'), 'error'); |
| 963 | }; |
| 964 | |
| 965 | // set some variables |
| 966 | $content= ''; |
| 967 | $form= array(); |
| 968 | |
| 969 | // get some variables |
| 970 | $ctype_paper= variable_get('conference_ctype_paper', ''); |
| 971 | $role_review= variable_get('conference_role_review', '-1'); |
| 972 | |
| 973 | // form element: intro |
| 974 | |
| 975 | $form['intro']= array('#type' => 'item', |
| 976 | '#value' => t('The following form sends reminder emails '. |
| 977 | 'to all reviewers with outstanding reviews'), |
| 978 | '#weight' => 0); |
| 979 | |
| 980 | // get all users with unreviewed papers |
| 981 | $users= array(); |
| 982 | $users_default_value= array(); |
| 983 | $result= db_query("SELECT * FROM {conference} c LEFT JOIN {users} u ON c.ruid = u.uid WHERE rnid = '0' AND ruid > 0"); |
| 984 | while ($item= db_fetch_array($result)) { |
| 985 | if (!array_key_exists($item['name'], $users)) { |
| 986 | $users[$item[uid]]= $item[name]; |
| 987 | $users_default_value[]= $item[uid]; |
| 988 | }; |
| 989 | }; |
| 990 | |
| 991 | // email content and subject |
| 992 | $form['email']= array('#type' => 'fieldset', |
| 993 | '#title' => t('Reminder email'), |
| 994 | '#weight' => 3); |
| 995 | $form['email']['subject']= array('#type' => 'textfield', |
| 996 | '#title' => t('Subject'), |
| 997 | '#default_value' => variable_get('conference_email_reminder_subject', |
| 998 | '[%conference] Reminder'), |
| 999 | '#description' => t('Use this variables: "%conference" for the conference name.'), |
| 1000 | '#weight' => 2); |
| 1001 | $form['email']['body']= array('#type' => 'textarea', |
| 1002 | '#title' => t('Content'), |
| 1003 | '#default_value' => variable_get('conference_email_reminder_body', ' |
| 1004 | Hello %username, |
| 1005 | |
| 1006 | the conference chair assigned you to review the following papers: |
| 1007 | |
| 1008 | %papers% |
| 1009 | |
| 1010 | At least some of these papers have not been reviewed until now. Please don\'t forget to post your reviews in time. Thank you! |
| 1011 | |
| 1012 | --- %conference% team |
| 1013 | '), |
| 1014 | '#cols' => 30, |
| 1015 | '#rows' => 5, |
| 1016 | '#description' => t('Use this variables: "%conference" for the conference name, "%username" for the reviewers username, "%papers" for the list of papere.'), |
| 1017 | '#weight' => 3); |
| 1018 | $form['email']['save']= array('#type' => 'checkbox', |
| 1019 | '#title' => t('Save email content and subject as default'), |
| 1020 | '#default_value' => 1, |
| 1021 | '#weight' => 4); |
| 1022 | |
| 1023 | |
| 1024 | // form element: select users |
| 1025 | $form['users'] = array('#type' => 'checkboxes', |
| 1026 | '#title' => t('Send to users'), |
| 1027 | '#options' => $users, |
| 1028 | '#default_value' => $users_default_value, |
| 1029 | '#weight' => 1, |
| 1030 | ); |
| 1031 | |
| 1032 | $form['submit']= array('#type' => 'submit', |
| 1033 | '#value' => t('send'), |
| 1034 | '#weight' => 10); |
| 1035 | |
| 1036 | $content.= drupal_get_form('conference_manage_status_remind', $form); |
| 1037 | |
| 1038 | print theme('page', $content); |
| 1039 | } |
| 1040 | |
| 1041 | |
| 1042 | function conference_manage_status_remind_submit ($form_id, $form_values) { |
| 1043 | |
| 1044 | // get some variables |
| 1045 | $reminder_subject= $form_values[subject]; |
| 1046 | $reminder_content= $form_values[body]; |
| 1047 | if ($form_values[save] == 1) { |
| 1048 | variable_set('conference_email_reminder_subject', $reminder_subject); |
| 1049 | variable_set('conference_email_reminder_body', $reminder_content); |
| 1050 | }; |
| 1051 | |
| 1052 | // some requirements |
| 1053 | if (!$reminder_subject and !$reminder_content) { |
| 1054 | drupal_set_message(t('Nothing done.'), 'error'); |
| 1055 | return; |
| 1056 | }; |
| 1057 | |
| 1058 | foreach ($form_values[users] as $uid) { |
| 1059 | |
| 1060 | conference_send_mail($reminder_subject, $reminder_content, |
| 1061 | array('ruid' => $uid)); |
| 1062 | }; |
| 1063 | drupal_goto('conference/manage/status'); |
| 1064 | } |
| 1065 | |
| 1066 | /** |
| 1067 | * conference_manage_status_exceed |
| 1068 | * |
| 1069 | * Show the review status of all papers. |
| 1070 | */ |
| 1071 | function conference_manage_status_exceed () { |
| 1072 | |
| 1073 | // set some variables |
| 1074 | $content= ''; |
| 1075 | $form= array(); |
| 1076 | |
| 1077 | $form[limit]= array('#type' => 'checkbox', |
| 1078 | '#title' => t('Time limit to post and edit papers is exceeded.'), |
| 1079 | '#default_value' => variable_get('conference_time_limit', '0'), |
| 1080 | '#weight' => 0); |
| 1081 | |
| 1082 | $form[message]= array('#type' => 'textarea', |
| 1083 | '#title' => t('Message to display instead of the creation formular'), |
| 1084 | '#default_value' => variable_get('conference_time_message', ' |
| 1085 | Regrettably, we are not able to accept papers anymore. The time limit is exceeded. |
| 1086 | '), |
| 1087 | '#weight' => 1); |
| 1088 | $form[submit]= array('#type' => 'submit', |
| 1089 | '#value' => t('Submit'), |
| 1090 | '#weight' => 2); |
| 1091 | |
| 1092 | $content.= drupal_get_form('conference_manage_status_exceed', $form); |
| 1093 | |
| 1094 | print theme('page', $content); |
| 1095 | } |
| 1096 | |
| 1097 | function conference_manage_status_exceed_submit ($form_id, $form_values) { |
| 1098 | |
| 1099 | variable_set('conference_time_limit', $form_values[limit]); |
| 1100 | variable_set('conference_time_message', $form_values[message]); |
| 1101 | drupal_set_message(t('Status saved.')); |
| 1102 | drupal_goto('conference/manage/status/exceed'); |
| 1103 | } |
| 1104 | |
| 1105 | |
| 1106 | /** |
| 1107 | * conference_timelimit_reached |
| 1108 | * |
| 1109 | * If the time limit is reached noone can post papers anymore. But |
| 1110 | * there is a exception: if the conference chair requested a modification |
| 1111 | * of the useres paper, it must be possible for thoses users to post a |
| 1112 | * new paper. This function decides for a uid, if the time limit is |
| 1113 | * "reached". |
| 1114 | * |
| 1115 | * @uid user id |
| 1116 | */ |
| 1117 | function conference_timelimit_reached ($uid= 0) { |
| 1118 | } |
| 1119 | |
| 1120 | function conference_timelimit () { |
| 1121 | |
| 1122 | drupal_set_title(variable_get('conference_name', 'Conference')); |
| 1123 | $content.= '<p>'; |
| 1124 | $content.= variable_get('conference_time_message', ''); |
| 1125 | $content.= '</p>'; |
| 1126 | print theme('page', $content); |
| 1127 | |
| 1128 | }; |
| 1129 | |
| 1130 | |
| 1131 | /** |
| 1132 | * conference_manage_decision |
| 1133 | * |
| 1134 | * Show the review status of all papers. |
| 1135 | */ |
| 1136 | function conference_manage_decision () { |
| 1137 | |
| 1138 | // get some variables |
| 1139 | $ctype_paper= variable_get('conference_ctype_paper', ''); |
| 1140 | $ctype_review= variable_get('conference_ctype_review', ''); |
| 1141 | |
| 1142 | // set some variables |
| 1143 | $content= ''; |
| 1144 | |
| 1145 | // intro |
| 1146 | $content.= '<p>'.t('The following table contains all submited papers').':</p>'; |
| 1147 | |
| 1148 | // table header |
| 1149 | $header= array(array(data => t('Title'), |
| 1150 | field => 'n.title'), |
| 1151 | array(data => t('User'), |
| 1152 | field => 'n.uid'), |
| 1153 | array(data => t('Assignment'), |
| 1154 | field => 'c.ruid'), |
| 1155 | array(data => t('Decision'), |
| 1156 | field => 'd.decision', |
| 1157 | sort => 'asc'), |
| 1158 | ); |
| 1159 | $rows= array(); |
| 1160 | |
| 1161 | // get a paged list of all papers |
| 1162 | $sql= "SELECT * FROM {node} n LEFT JOIN {conference} c ON n.nid = c.pnid LEFT JOIN {conference_decision} d ON n.nid = d.pnid WHERE n.type='%s'"; |
| 1163 | $sql.= tablesort_sql($header); |
| 1164 | $result= pager_query($sql, 25, 3, NULL, $ctype_paper); |
| 1165 | while($item= db_fetch_array($result)) { |
| 1166 | |
| 1167 | // get user informations |
| 1168 | $p_user= user_load(array(uid => $item[uid])); |
| 1169 | $r_user= $item[ruid] > 0 ? $item[ruid] : ''; |
| 1170 | if ($r_user) $r_user= user_load(array(uid => $r_user)); |
| 1171 | |
| 1172 | $op= ''; |
| 1173 | if ($item[decision] == 0) |
| 1174 | $op= l(t('make'), 'conference/manage/decision/make/'.$item[nid]); |
| 1175 | if ($item[decision] == 1) |
| 1176 | $op= '<span style="color: green;">'.t('accepted').'</span>'. |
| 1177 | ' ('.l(t('change'), 'conference/manage/decision/make/'.$item[nid]).')'; |
| 1178 | if ($item[decision] == 2) |
| 1179 | $op= '<span style="color: orange;">'.t('modification requested').'</span>'. |
| 1180 | ' ('.l(t('change'), 'conference/manage/decision/make/'.$item[nid]).')'; |
| 1181 | if ($item[decision] == 3) |
| 1182 | $op= '<span style="color: red;">'.t('rejected').'</span>'. |
| 1183 | ' ('.l(t('change'), 'conference/manage/decision/make/'.$item[nid]).')'; |
| 1184 | |
| 1185 | // build row |
| 1186 | $rows[]= array(l($item[title], 'node/'.$item['nid']), |