define('ADMIN_SURFBAR_NOTIFY_URL_REJECTED_SUBJECT', "[Surfbar:] URL abgelehnt");
define('ADMIN_SURFBAR_NOTIFY_URL_PENDING_SUBJECT', "[Surfbar:] URL-Buchung zugestimmt");
define('ADMIN_SURFBAR_NOTIFY_URL_DEPLETED_SUBJECT', "[Surfbar:] URL automatisch angehalten");
+define('ADMIN_SURFBAR_NOTIFY_URL_EDITED_SUBJECT', "[Surfbar:'] Mitglied hat URL geändert");
define('ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT', "Problem in Surfbar-Betreff");
// Auto-generated admin subject lines
define('ADMIN_LOCKED_SURFBAR_URLS_SUBJECT', "[Surfbar:] Sperrung einer URL");
// Subject lines for members
-define('MEMBER_SURFBAR_NOTIFY_URL_UNLOCK_SUBJECT', "Ihre URL wurde in die Surfbar aufgenommen");
-define('MEMBER_SURFBAR_NOTIFY_URL_REG_SUBJECT', "Ihre URL in der Surfbar wartet auf Freischaltung");
-define('MEMBER_SURFBAR_NOTIFY_URL_MIGRATE_SUBJECT', "Ihre Mailbuchung wurde in die Surfbar migriert");
-define('MEMBER_SURFBAR_NOTIFY_URL_ACTIVE_SUBJECT', "Ihre URL wurde für die Surfbar freigegeben");
-define('MEMBER_SURFBAR_NOTIFY_URL_DELETED_SUBJECT', "Löschung Ihrer URL aus der Surfbar");
-define('MEMBER_SURFBAR_NOTIFY_URL_REJECTED_SUBJECT', "Ihre URL wurde für die Surfbar abgelehnt!");
-define('MEMBER_SURFBAR_NOTIFY_URL_PENDING_SUBJECT', "Zustimmung zur URL-Buchung in Surfbar erhalten");
-define('MEMBER_SURFBAR_NOTIFY_URL_DEPLETED_SUBJECT', "Ihre URL wurde automatisch angehalten");
+define('MEMBER_SURFBAR_NOTIFY_URL_UNLOCK_SUBJECT', "[Surfbar:] Ihre URL wurde aufgenommen");
+define('MEMBER_SURFBAR_NOTIFY_URL_REG_SUBJECT', "[Surfbar:] Ihre URL wartet auf Freischaltung");
+define('MEMBER_SURFBAR_NOTIFY_URL_MIGRATE_SUBJECT', "[Surfbar:] Ihre URL aus der Mailbuchung wurde migriert");
+define('MEMBER_SURFBAR_NOTIFY_URL_ACTIVE_SUBJECT', "[Surfbar:] Ihre URL wurde freigegeben");
+define('MEMBER_SURFBAR_NOTIFY_URL_DELETED_SUBJECT', "[Surfbar:] Löschung Ihrer URL");
+define('MEMBER_SURFBAR_NOTIFY_URL_REJECTED_SUBJECT', "[Surfbar:] Ihre URL wurde abgelehnt!");
+define('MEMBER_SURFBAR_NOTIFY_URL_PENDING_SUBJECT', "[Surfbar:] Zustimmung zur URL-Buchung erhalten");
+define('MEMBER_SURFBAR_NOTIFY_URL_DEPLETED_SUBJECT', "[Surfbar:] Ihre URL wurde automatisch angehalten");
+define('MEMBER_SURFBAR_NOTIFY_URL_EDITED_SUBJECT', "[Surfbar:] Sie haben Ihre URL geändert");
define('MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT', "[Fehler:] Bitte leiten Sie diese Mail an uns weiter!");
-define('MEMBER_SURFBAR_NOTIFY_LOW_POINTS_SUBJECT', "Ihr {!POINTS!}-Stand ist sehr niedrig!");
+define('MEMBER_SURFBAR_NOTIFY_LOW_POINTS_SUBJECT', "[Surfbar:] Ihr {!POINTS!}-Stand ist sehr niedrig!");
// Auto-generated member subject lines
-define('MEMBER_DEL_SURFBAR_URLS_SUBJECT', "Ihre URL wurde aus der Surfbar entfernt");
-define('MEMBER_EDIT_SURFBAR_URLS_SUBJECT', "Änderung Ihrer URL in der Surfbar");
-define('MEMBER_LOCKED_SURFBAR_URLS_SUBJECT', "Sperrung Ihrer URL in Surfbar, bitte AGBs beachten!");
-define('MEMBER_ACTIVE_SURFBAR_URLS_SUBJECT', "Freigabe Ihrer URL in Surfbar");
+define('MEMBER_DEL_SURFBAR_URLS_SUBJECT', "[Surfbar:] Ihre URL wurde entfernt");
+define('MEMBER_EDIT_SURFBAR_URLS_SUBJECT', "[Surfbar:] Änderung Ihrer URL durch Admin");
+define('MEMBER_LOCKED_SURFBAR_URLS_SUBJECT', "[Surfbar:] Sperrung Ihrer URL, bitte AGBs beachten!");
+define('MEMBER_ACTIVE_SURFBAR_URLS_SUBJECT', "[Surfbar:] Freigabe Ihrer URL");
// URL status
define('SURFBAR_URL_STATUS_ACTIVE', "Freigegeben");
define('MEMBER_SURFBAR_ACTION_PAUSE_TITLE', "Halten Sie die URL in der Surfbar kurz an, wenn sie gerade nicht erreichbar ist. Dies geschieht nicht automatisch.");
define('MEMBER_SURFBAR_ACTION_UNPAUSE_TITLE', "Lassen Sie die URL in der Surfbar weiterlaufen, wenn Sie dies möchten. Wir müssen die URL jedoch erneut freigeben.");
+// Internal errors
+define('MEMBER_SURFBAR_EXECUTE_ACTION_404', "Auszuführende Funktion <u>%s</u> nicht gefunden!");
+define('ADMIN_SURFBAR_NOTIFY_SUBJECT_404', "Admin-Betreffzeile %s nicht gefunden.");
+define('MEMBER_SURFBAR_NOTIFY_SUBJECT_404', "Mitglieder-Betreffzeile %s nicht gefunden.");
+
//
?>
return false;
}
+ // Secure action
+ $action = SQL_ESCAPE(htmlentities(strip_tags($formData['action']), ENT_QUOTES));
+
+ // Has it changed?
+ if ($action != $formData['action']) {
+ // Invalid data in action found
+ return false;
+ } // END - if
+
// Create the function name for selected action
- $functionName = sprintf("SURFBAR_MEMBER_%s_ACTION", strtoupper(SQL_ESCAPE($formData['action'])));
+ $functionName = sprintf("SURFBAR_MEMBER_%s_ACTION", strtoupper($action));
// Is the function there?
if (function_exists($functionName)) {
$URLs[$formData['id']]['new_status'] = $SURFBAR_CACHE['new_status'];
// Extract URL data for call-back
- $urlData = array($URLs[$formData['id']]);
+ $urlData = array(array_merge($URLs[$formData['id']], array($action => $formData)));
// Action found so execute it
$performed = call_user_func_array($functionName, $urlData);
// Show edit form or do the changes
function SURFBAR_MEMBER_EDIT_ACTION ($urlData) {
// Is the "execute" flag there?
- if (isset($urlData['execute'])) {
+ if (isset($urlData['edit']['execute'])) {
// Execute the changes
return SURFBAR_MEMBER_EXECUTE_ACTION("edit", $urlData);
} // END - if
// Show delete form or do the changes
function SURFBAR_MEMBER_DELETE_ACTION ($urlData) {
// Is the "execute" flag there?
- if (isset($urlData['execute'])) {
+ if (isset($urlData['delete']['execute'])) {
// Execute the changes
- return SURFBAR_MEMBER_EXECUTE_ACTION("del", $urlData);
+ return SURFBAR_MEMBER_EXECUTE_ACTION("delete", $urlData);
} // END - if
// Display form
- return SURFBAR_MEMBER_DISPLAY_ACTION_FORM("del", $urlData);
+ return SURFBAR_MEMBER_DISPLAY_ACTION_FORM("delete", $urlData);
}
// Display selected "action form"
function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
// All fine by default ... ;-)
return true;
}
+// Execute choosen action
+function SURFBAR_MEMBER_EXECUTE_ACTION ($action, $urlData) {
+ // By default nothing is executed
+ $executed = false;
+
+ // Is limitation "no" and "limit" is > 0?
+ if ((isset($urlData[$action]['limited'])) && ($urlData[$action]['limited'] == "N") && ((isset($urlData[$action]['limit'])) && ($urlData[$action]['limit'] > 0)) || (!isset($urlData[$action]['limit']))) {
+ // Set it to unlimited
+ $urlData[$action]['limit'] = 0;
+ } // END - if
+
+ // Construct function name
+ $functionName = sprintf("SURFBAR_MEMBER_EXECUTE_%s_ACTION", strtoupper($action));
+
+ // Is 'userid' set and not 'uid' ?
+ if ((!isset($urlData['uid'])) && (isset($urlData['userid']))) {
+ // Auto-fix this
+ $urlData['uid'] = $urlData['userid'];
+ } // END - if
+
+ // Is that function there?
+ if (function_exists($functionName)) {
+ // Execute the function
+ if (call_user_func_array($functionName, array($urlData)) == true) {
+ // Update status as well
+ $executed = SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
+ } // END - if
+ } else {
+ // Not found!
+ ADD_FATAL(sprintf(MEMBER_SURFBAR_EXECUTE_ACTION_404, $functionName));
+ }
+
+ // Return status
+ return $executed;
+}
+// "Execute edit" function: Update changed data
+function SURFBAR_MEMBER_EXECUTE_EDIT_ACTION ($urlData) {
+ // Translate URLs for testing
+ $url1 = COMPILE_CODE($urlData['url']);
+ $url2 = COMPILE_CODE($urlData['edit']['url']);
+
+ // Has the URL or limit changed?
+ if (true) {
+ //if (($urlData['views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
+ // Run the query
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_urls SET url='%s', views_allowed=%s, views_max=%s WHERE id=%s AND status='%s' LIMIT 1",
+ array($urlData['url'], $urlData['edit']['limit'], $urlData['edit']['limit'], $urlData['id'], $urlData['status']), __FILE__, __LINE__);
+
+ // Prepare new data
+ $urlData['new_url'] = $urlData['edit']['url'];
+ $urlData['new_limit'] = $urlData['edit']['limit'];
+ unset($urlData['edit']);
+
+ // Send admin notification
+ SURFBAR_NOTIFY_ADMIN("url_edited", $urlData);
+
+ // Send user notification
+ SURFBAR_NOTIFY_USER("url_edited", $urlData);
+ } // END - if
+
+ // All fine!
+ return true;
+}
//
// -----------------------------------------------------------------------------
// Self-maintenance functions
// Set default subject if following eval() wents wrong
$subject = ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
- // Prepare subject
- $subject = constant(sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
+ // Create constant name
+ $constantName = sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
strtoupper($messageType)
- ));
+ );
+
+ // Prepare subject
+ if (defined($constantName)) {
+ $subject = constant($constantName);
+ } else {
+ ADD_FATAL(ADMIN_SURFBAR_NOTIFY_SUBJECT_404, $constantName);
+ }
+
+ // Translate some data if present
+ if (isset($content['status'])) $content['status'] = SURFBAR_TRANSLATE_STATUS($content['status']);
+ if (isset($content['registered'])) $content['registered'] = MAKE_DATETIME($content['registered'], "2");
+ if (isset($content['last_locked'])) $content['last_locked'] = MAKE_DATETIME($content['last_locked'], "2");
+ if (isset($content['views_total'])) $content['views_total'] = TRANSLATE_COMMA($content['views_total']);
+ if (isset($content['views_allowed'])) $content['views_allowed'] = TRANSLATE_COMMA($content['views_allowed']);
+ if (isset($content['views_max'])) $content['views_max'] = TRANSLATE_COMMA($content['views_max']);
// Send the notification out
return SEND_ADMIN_NOTIFICATION($subject, $templateName, $content, $content['uid']);
// Set default subject if following eval() wents wrong
$subject = MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT;
- // Prepare subject
- $subject = constant(sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
+ // Create constant name
+ $constantName = sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
strtoupper($messageType)
- ));
+ );
+
+ // Prepare subject
+ if (defined($constantName)) {
+ $subject = constant($constantName);
+ } else {
+ ADD_FATAL(MEMBER_SURFBAR_NOTIFY_SUBJECT_404, $constantName);
+ }
// Load template
$mailText = LOAD_EMAIL_TEMPLATE($templateName, $content, $content['uid']);
$data = SURFBAR_GET_URL_DATA($urlId);
} // END - if
+ // Is the new status set?
+ if ((!is_string($newStatus)) || (empty($newStatus))) {
+ // Abort here, but fine!
+ return true;
+ } // END - if
+
// Is the status like prevStatus is saying?
if ($data[$urlId]['status'] != $prevStatus) {
// No, then abort here