Browse Source

EventEmailTemplate functions moved in the events.lib.php see #4685

Julio Montoya 12 years ago
parent
commit
59a9e6ec01
1 changed files with 51 additions and 0 deletions
  1. 51 0
      main/inc/lib/events.lib.inc.php

+ 51 - 0
main/inc/lib/events.lib.inc.php

@@ -1405,3 +1405,54 @@ function event_course_login($course_code, $user_id, $session_id) {
     //Course catalog stats modifications see #4191
     CourseManager::update_course_ranking(null, null, null, null, true, false);
 }
+
+
+
+/* 
+ * 
+ * Filter EventEmailTemplate Filters see the main/inc/conf/events.conf.dist.php
+ * 
+ */
+
+/**
+ * user_registration - send_mail filter
+ * @param array $values (passing by reference)
+ * @return boolean 
+ */
+function user_registration_event_send_mail_filter_func(&$values) {
+    return true;
+}
+
+/**
+ * For the sake of genericity, this function is a switch.
+ * It's called by EventsDispatcher and fires the good function
+ * with the good require_once.
+ * 
+ * @param string $event_name
+ * @param array $params 
+ */
+function event_send_mail($event_name, $params) {    
+    EventsMail::send_mail($event_name, $params);
+}
+
+/**
+ * Internal function checking if the mail was already sent from that user to that user
+ * @param string $event_name
+ * @param int $user_from
+ * @param int $user_to
+ * @return boolean 
+ */
+function check_if_mail_already_sent($event_name, $user_from, $user_to = null) {
+    if ($user_to == null) {
+        $sql = 'SELECT COUNT(*) as total FROM ' . Database::get_main_table(TABLE_EVENT_SENT) . ' 
+                WHERE user_from = '.$user_from.' AND event_type_name = "'.$event_name.'"';
+    } else {
+        $sql = 'SELECT COUNT(*) as total FROM ' . Database::get_main_table(TABLE_EVENT_SENT) . ' 
+                WHERE user_from = '.$user_from.' AND user_to = '.$user_to.' AND event_type_name = "'.$event_name.'"';
+    }    
+    $result = Database::store_result(Database::query($sql), 'ASSOC');
+    return $result[0]["total"];
+}
+
+
+/*  End of filters   */