Browse Source

Fix author id

jmontoyaa 8 years ago
parent
commit
a528c98074
2 changed files with 11 additions and 3 deletions
  1. 6 1
      main/cron/import_csv.php
  2. 5 2
      main/inc/lib/AnnouncementManager.php

+ 6 - 1
main/cron/import_csv.php

@@ -1053,7 +1053,12 @@ class ImportCsv
                         $event['session_id'],
                         $subject,
                         $emailBody,
-                        ['everyone']
+                        ['everyone'],
+                        [],
+                        null,
+                        null,
+                        false,
+                        $this->defaultAdminId
                     );
 
                     if ($announcementId) {

+ 5 - 2
main/inc/lib/AnnouncementManager.php

@@ -413,6 +413,8 @@ class AnnouncementManager
      * @param string  $file_comment  Comment describing the attachment
      * @param string $end_date
      * @param bool $sendToUsersInSession
+     * @param int $authorId
+     * 
      * @return int      false on failure, ID of the announcement on success
      */
     public static function add_announcement(
@@ -424,7 +426,8 @@ class AnnouncementManager
         $file = array(),
         $file_comment = null,
         $end_date = null,
-        $sendToUsersInSession = false
+        $sendToUsersInSession = false,
+        $authorId = 0
     ) {
         if (empty($courseInfo)) {
             return false;
@@ -433,7 +436,7 @@ class AnnouncementManager
         $course_id = $courseInfo['real_id'];
         $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
 
-        $authorId = api_get_user_id();
+        $authorId = empty($authorId) ? api_get_user_id() : $authorId;
 
         if (empty($end_date)) {
             $end_date = api_get_utc_datetime();