function filedepotAjaxServer_broadcastAlert($fid, $comment) { global $user; $retval = ''; $target_users = filedepot_build_notification_distribution($fid, FILEDEPOT_BROADCAST_MESSAGE); if (count($target_users) > 0) { $values = array('fid' => $fid, 'comment' => filter_xss($comment), 'target_users' => $target_users); $ret = drupal_mail('filedepot', FILEDEPOT_BROADCAST_MESSAGE, $user, language_default(), $values); if ($ret) { $filedepot = filedepot_filedepot(); $retval['retcode'] = 200; $retval['count'] = $filedepot->message; } else { $retval['retcode'] = 205; } } else { $retval['retcode'] = 205; } return $retval; }
/** * Send out notifications to all users that have subscribed to this file or file category * Will check user preferences for notification if Messenger Plugin is installed * @param string $id Key used to retrieve details depending on message type * @param string $type Message type -> * (1) FILEDEPOT_NOTIFY_NEWFILE, * (2) FILEDEPOT_NOTIFY_APPROVED, * (3) FILEDEPOT_NOTIFY_REJECT, * (4) FILEDEPOT_NOTIFY_ADMIN * @return Boolean Returns TRUE if atleast 1 message was sent out */ function filedepot_sendNotification($id, $type = 1) { global $user; /* If notifications have been disabled via the module admin settings - return TRUE */ if (variable_get('filedepot_notifications_enabled', 1) == 0) { return TRUE; } if (intval($id) > 0) { $target_users = filedepot_build_notification_distribution($id, $type); if (count($target_users) > 0) { $values = array('fid' => $id, 'target_users' => $target_users); drupal_mail('filedepot', $type, $user, language_default(), $values); } else { watchdog('filedepot', "filedepot_sendNotification (@type) - no target users", array("@type" => $type)); } } }