+ // Display form
+ return SURFBAR_MEMBER_DISPLAY_ACTION_FORM("edit", $urlData);
+}
+// Show delete form or do the changes
+function SURFBAR_MEMBER_DELETE_ACTION ($urlData) {
+ // Is the "execute" flag there?
+ if (isset($urlData['execute'])) {
+ // Execute the changes
+ return SURFBAR_MEMBER_EXECUTE_ACTION("del", $urlData);
+ } // END - if
+
+ // Display form
+ return SURFBAR_MEMBER_DISPLAY_ACTION_FORM("del", $urlData);
+}
+// Display selected "action form"
+function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
+ // Translate some data
+ $urlData['registered'] = MAKE_DATETIME($urlData['registered'], "2");
+ $urlData['views_total'] = TRANSLATE_COMMA($urlData['views_total']);
+
+ // Load the form and display it
+ LOAD_TEMPLATE(sprintf("member_surfbar_%s_action_form", $action), false, $urlData);
+
+ // All fine by default ... ;-)
+ return true;
+}
+//
+// -----------------------------------------------------------------------------
+// Self-maintenance functions
+// -----------------------------------------------------------------------------
+//
+// Main function
+function SURFBAR_HANDLE_SELF_MAINTENANCE () {
+ // Handle URLs which limit has depleted so we can stop them
+ SURFBAR_HANDLE_DEPLETED_VIEWS();
+
+ // Handle low-points amounts
+ SURFBAR_HANDLE_LOW_POINTS();
+}
+// Handle URLs which limit has depleted
+function SURFBAR_HANDLE_DEPLETED_VIEWS () {
+ // Get all URLs
+ $urlArray = SURFBAR_GET_URL_DATA("0", "views_max", "id", "ASC", "id", " AND views_allowed>0 AND status='ACTIVE'");
+
+ // Do we have some entries?
+ if (count($urlArray) > 0) {
+ // Then handle all!
+ foreach ($urlArray as $id => $urlData) {
+ // Backup data
+ $data = $urlData;
+
+ // Rewrite array for next call
+ $urlData[$id] = $data;
+
+ // Handle the status
+ SURFBAR_CHANGE_STATUS($id, "ACTIVE", "DEPLETED", $urlData);
+ } // END - foreach
+ } // END - if
+}
+// Alert users which have URLs booked and are low on points amount
+function SURFBAR_HANDLE_LOW_POINTS () {
+ global $_CONFIG;
+
+ // Get all userids
+ $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS($_CONFIG['surfbar_warn_low_points']);
+
+ // "Walk" through all URLs
+ foreach ($UIDs['uid'] as $uid => $dummy) {
+ // Is the last notification far enougth away to notify again?
+ if ((time() - $UIDs['notified'][$uid]) >= $_CONFIG['surfbar_low_interval']) {
+ // Prepare content
+ $content = array(
+ 'uid' => $uid,
+ 'low' => TRANSLATE_COMMA($_CONFIG['surfbar_warn_low_points']),
+ 'points' => TRANSLATE_COMMA($UIDs['points'][$uid]),
+ 'notified' => MAKE_DATETIME($UIDs['notified'][$uid]),
+ 'interval' => CREATE_FANCY_TIME($_CONFIG['surfbar_low_interval'])
+ );
+
+ // Notify this user
+ SURFBAR_NOTIFY_USER("low_points", $content);
+
+ // Update last notified
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1",
+ array($uid), __FILE__, __LINE__);
+ } // END - if
+ } // END - foreach
+}
+//
+// -----------------------------------------------------------------------------
+// Generic functions
+// -----------------------------------------------------------------------------
+//