]> git.mjollnir.org Git - moodle.git/commitdiff
Draft beginning of new messaging system that Martin and Shane are working on.
authormoodler <moodler>
Thu, 16 Dec 2004 12:40:36 +0000 (12:40 +0000)
committermoodler <moodler>
Thu, 16 Dec 2004 12:40:36 +0000 (12:40 +0000)
message/index.php [new file with mode: 0644]
message/lib.php [new file with mode: 0644]
message/search.html [new file with mode: 0644]

diff --git a/message/index.php b/message/index.php
new file mode 100644 (file)
index 0000000..c1a0f7d
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/// main interface window for messaging
+
+require('../config.php');
+require('lib.php');
+
+$tab = optional_param('tab', 'contacts');
+$ftab = 'message_print_'.$tab;
+
+
+
+
+
+print_header(get_string('messaging').' - '.$SITE->fullname);
+
+?>
+
+<table cellspacing="2" cellpadding="2" border="0" bgcolor="#ffffff" align="center" width="80%">
+<tr>
+    <th class="message_tab_selected"><a href="<?php echo $ME ?>?tab=contacts">contacts</a></th>
+    <th class="message_tab"><a href="<?php echo $ME ?>?tab=search">search</a></th>
+    <th class="message_tab"><a href="<?php echo $ME ?>?tab=settings">settings</a></th>
+</tr>
+<tr>
+    <td colspan="3">
+        <?php if (function_exists($ftab)) $ftab(); ?>
+    </td>
+</tr>
+</table>
+
+
+</body>
+</html>
diff --git a/message/lib.php b/message/lib.php
new file mode 100644 (file)
index 0000000..326dbfb
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/// library functions for messaging
+
+/// todo: add some functions
+
+
+function message_print_contacts() {
+    global $USER;
+    $contacts = get_records('message_contacts', 'userid', $USER->id, '', 'id, contactid');
+    echo 'contacts';
+}
+
+function message_print_search() {
+    global $USER;
+    
+    if ($frm = data_submitted()) {
+    
+        message_print_search_results($frm);
+        
+    } else {
+    /// todo make the following queries more efficient
+        if ($teachers = get_records('user_teachers', 'userid', $USER->id, '', 'id, course')) {
+        
+            $courses = get_courses('all', 'c.sortorder ASC', 'c.id, c.shortname');
+            $cs = '<select name="courseselect">';
+            foreach ($teachers as $tcourse) {
+                $cs .= "<option value=\"$tcourse->course\">".$courses[$tcourse->course]->shortname."</option>\n";
+            }
+            $cs .= '</select>';
+        }
+        
+        include('search.html');
+    }
+}
+
+function message_print_settings() {
+    if ($frm = data_submitted()) {
+        echo 'settings submitted - quick do something';
+    } else {
+        echo 'settings form';
+    }
+}
+
+function message_print_search_results($frm) {
+    if (!empty($frm->personsubmit)) {
+        echo 'searched for person';
+    } else if (!empty($frm->keywordssubmit)) {
+        echo 'searched for keywords';
+    }
+
+    print_single_button($ME, array( 'tab' => 'search'), get_string('newsearch') );
+}
+
+?>
diff --git a/message/search.html b/message/search.html
new file mode 100644 (file)
index 0000000..0981c63
--- /dev/null
@@ -0,0 +1,42 @@
+<form name="personsearch" action="<?php echo $ME ?>" method="post">
+<input type="hidden" name="tab" value="search" />
+
+<table cellpadding="5" align="center">
+
+
+    <tr>
+        <td colspan="3"><strong><?php print_string('searchforperson') ?></strong></td>
+    </tr>
+    <tr>
+        <td align="right"><?php print_string('name') ?>:</td>
+        <td><input type="text" name="name" size="20" alt="<?php print_string('name')?>" /></td>
+        <td><input type="submit" name="personsubmit" value="<?php print_string('search') ?>" /></td>
+    </tr>
+    <tr>
+        <td colspan="3"><input type="checkbox" name="mycourses" alt="<?php print_string('onlyinmycourses') ?>" /><?php print_string('onlyinmycourses') ?></td>
+    </tr>
+    
+    <tr><td colspan="3"><hr /></td></tr>
+
+    <tr>
+        <td colspan="3"><strong><?php print_string('searchformessage') ?></strong></td>
+    </tr>
+    <tr>
+        <td align="right"><?php print_string('keywords') ?>:</td>
+        <td><input type="text" name="name" size="20" alt="<?php print_string('keywords')?>" /></td>
+        <td><input type="submit" name="keywordssubmit" value="<?php print_string('search') ?>" /></td>
+    </tr>
+    <tr><td colspan="3"><input type="radio" name="keywordsoption" alt="<?php print_string('onlytome') ?>" /><?php print_string('onlytome') ?></td></tr>
+    <tr><td colspan="3"><input type="radio" name="keywordsoption" alt="<?php print_string('onlyfromme') ?>" /><?php print_string('onlyfromme') ?></td></tr>
+    <tr><td colspan="3"><input type="radio" name="keywordsoption" alt="<?php print_string('allmine') ?>" /><?php print_string('allmine') ?></td></tr>
+    
+    <?php if (isadmin()) { ?>
+    <tr><td colspan="3"><input type="radio" name="keywordsoption" alt="<?php print_string('allusers') ?>" /><?php print_string('allusers') ?></td></tr>
+    <?php } ?>
+    
+    <tr><td colspan="3"><input type="radio" name="keywordsoption" alt="<?php print_string('allstudents') ?>" /><?php print_string('allstudents'); ?><?php echo $cs; ?></td></tr>
+
+    
+</table>
+
+</form>