|
|
|
@ -93,13 +93,14 @@ class ScheduledAnnouncement extends Model |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a Form validator Obj |
|
|
|
* Returns a Form validator Obj |
|
|
|
|
|
|
|
* @param int $id |
|
|
|
* @param string $url |
|
|
|
* @param string $url |
|
|
|
* @param string $action add, edit |
|
|
|
* @param string $action add, edit |
|
|
|
* @param array $sessionInfo |
|
|
|
* @param array $sessionInfo |
|
|
|
* |
|
|
|
* |
|
|
|
* @return FormValidator form validator obj |
|
|
|
* @return FormValidator form validator obj |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function returnSimpleForm($url, $action, $sessionInfo = []) |
|
|
|
public function returnSimpleForm($id, $url, $action, $sessionInfo = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$form = new FormValidator( |
|
|
|
$form = new FormValidator( |
|
|
|
'announcement', |
|
|
|
'announcement', |
|
|
|
@ -111,6 +112,12 @@ class ScheduledAnnouncement extends Model |
|
|
|
$form->addDateTimePicker('date', get_lang('Date')); |
|
|
|
$form->addDateTimePicker('date', get_lang('Date')); |
|
|
|
$form->addText('subject', get_lang('Subject')); |
|
|
|
$form->addText('subject', get_lang('Subject')); |
|
|
|
$form->addHtmlEditor('message', get_lang('Message')); |
|
|
|
$form->addHtmlEditor('message', get_lang('Message')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$extraField = new ExtraField('schedule_announcement'); |
|
|
|
|
|
|
|
$extra = $extraField->addElements($form, $id); |
|
|
|
|
|
|
|
$js = $extra['jquery_ready_content']; |
|
|
|
|
|
|
|
$form->addHtml("<script> $(function() { $js }); </script> "); |
|
|
|
|
|
|
|
|
|
|
|
$this->setTagsInForm($form); |
|
|
|
$this->setTagsInForm($form); |
|
|
|
|
|
|
|
|
|
|
|
$form->addCheckBox('sent', null, get_lang('MessageSent')); |
|
|
|
$form->addCheckBox('sent', null, get_lang('MessageSent')); |
|
|
|
@ -241,6 +248,12 @@ class ScheduledAnnouncement extends Model |
|
|
|
$form->addHtml('</div>'); |
|
|
|
$form->addHtml('</div>'); |
|
|
|
$form->addText('subject', get_lang('Subject')); |
|
|
|
$form->addText('subject', get_lang('Subject')); |
|
|
|
$form->addHtmlEditor('message', get_lang('Message')); |
|
|
|
$form->addHtmlEditor('message', get_lang('Message')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$extraField = new ExtraField('schedule_announcement'); |
|
|
|
|
|
|
|
$extra = $extraField->addElements($form); |
|
|
|
|
|
|
|
$js = $extra['jquery_ready_content']; |
|
|
|
|
|
|
|
$form->addHtml("<script> $(function() { $js }); </script> "); |
|
|
|
|
|
|
|
|
|
|
|
$this->setTagsInForm($form); |
|
|
|
$this->setTagsInForm($form); |
|
|
|
|
|
|
|
|
|
|
|
if ($action == 'edit') { |
|
|
|
if ($action == 'edit') { |
|
|
|
@ -252,6 +265,33 @@ class ScheduledAnnouncement extends Model |
|
|
|
return $form; |
|
|
|
return $form; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param int $id |
|
|
|
|
|
|
|
* @return string |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function getAttachmentToString($id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$file = $this->getAttachment($id); |
|
|
|
|
|
|
|
if (!empty($file) && !empty($file['value'])) { |
|
|
|
|
|
|
|
//$file = api_get_uploaded_web_url('schedule_announcement', $id, basename($file['value'])); |
|
|
|
|
|
|
|
$url = api_get_path(WEB_UPLOAD_PATH).$file['value']; |
|
|
|
|
|
|
|
return get_lang('Attachment').': '.Display::url(basename($file['value']), $url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param int $id |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function getAttachment($id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('schedule_announcement'); |
|
|
|
|
|
|
|
$attachment = $extraFieldValue->get_values_by_handler_and_field_variable($id, 'attachment'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $attachment; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param int $urlId |
|
|
|
* @param int $urlId |
|
|
|
* |
|
|
|
* |
|
|
|
@ -286,8 +326,12 @@ class ScheduledAnnouncement extends Model |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$attachments = $this->getAttachmentToString($result['id']); |
|
|
|
|
|
|
|
|
|
|
|
self::update(['id' => $result['id'], 'sent' => 1]); |
|
|
|
self::update(['id' => $result['id'], 'sent' => 1]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$subject = $result['subject']; |
|
|
|
$subject = $result['subject']; |
|
|
|
|
|
|
|
|
|
|
|
if ($users) { |
|
|
|
if ($users) { |
|
|
|
@ -354,6 +398,7 @@ class ScheduledAnnouncement extends Model |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$message = str_replace(array_keys($tags), $tags, $message); |
|
|
|
$message = str_replace(array_keys($tags), $tags, $message); |
|
|
|
|
|
|
|
$message .= $attachments; |
|
|
|
|
|
|
|
|
|
|
|
MessageManager::send_message( |
|
|
|
MessageManager::send_message( |
|
|
|
$userInfo['user_id'], |
|
|
|
$userInfo['user_id'], |
|
|
|
|