Exemplo n.º 1
0
                    exit;
                }
            } else {
                // Insert mode
                if (true) {
                    $file = $_FILES['user_upload'];
                    $file_comment = $data['file_comment'];
                    if (empty($group_id)) {
                        $insert_id = AnnouncementManager::add_announcement($data['title'], $data['content'], $data['users'], $file, $file_comment, null, $sendToUsersInSession);
                    } else {
                        $insert_id = AnnouncementManager::add_group_announcement($data['title'], $data['content'], array('GROUP:' . $group_id), $data['users'], $file, $file_comment, $sendToUsersInSession);
                    }
                    Display::addFlash(Display::return_message(get_lang('AnnouncementAdded'), 'success'));
                    /* MAIL FUNCTION */
                    if (isset($data['email_ann']) && $data['email_ann']) {
                        AnnouncementManager::send_email($insert_id, $sendToUsersInSession);
                    }
                    header('Location: ' . $homeUrl);
                    exit;
                }
                // end condition token
            }
        }
        $content = $form->returnForm();
        break;
}
if (!empty($_GET['remind_inactive'])) {
    $to[] = 'USER:'******'remind_inactive']);
}
if (!empty($group_id)) {
    $group_properties = GroupManager::get_group_properties($group_id);
Exemplo n.º 2
0
 /**
  * @param int $item_id
  * @param array $sentTo
  * @return int
  */
 public function store_agenda_item_as_announcement($item_id, $sentTo = array())
 {
     $table_agenda = Database::get_course_table(TABLE_AGENDA);
     $course_id = api_get_course_int_id();
     // Check params
     if (empty($item_id) or $item_id != strval(intval($item_id))) {
         return -1;
     }
     // Get the agenda item.
     $item_id = intval($item_id);
     $sql = "SELECT * FROM {$table_agenda}\n                WHERE c_id = {$course_id} AND id = " . $item_id;
     $res = Database::query($sql);
     if (Database::num_rows($res) > 0) {
         $row = Database::fetch_array($res, 'ASSOC');
         // Sending announcement
         if (!empty($sentTo)) {
             $id = AnnouncementManager::add_announcement($row['title'], $row['content'], $sentTo, null, null, $row['end_date']);
             AnnouncementManager::send_email($id);
             return $id;
         }
     }
     return -1;
 }