Descriptor == "AR") && ($keys[$i]->isLicensed == 1)) { $showAR = 1; } } class CNotification { var $guid; var $alertlevel; var $emailaddress; var $enabled; var $active; var $systemAccount; var $accountName; var $comment; function CNotification($aGuid, $aAlertlevel, $aEmailaddress, $aAccountName, $aEnabled=true, $aSystemAccount=false, $aComment="" ) { $this->guid = $aGuid; $this->alertlevel = $aAlertlevel; $this->emailaddress = $aEmailaddress; $this->enabled = $aEnabled; $this->active = $aActive; $this->systemAccount = $aSystemAccount; $this->accountName = $aAccountName; $this->comment = $aComment; } }; $returnMessage="No method"; //Process data for actions if($_SERVER['REQUEST_METHOD']=='POST') { $url = $_REQUEST['url']; $isChecked = $_REQUEST['ischeck']; $method = $_REQUEST['method']; $email = $_REQUEST['emailaddr']; $du = $_REQUEST['du']; $mu = $_REQUEST['mu']; $ms = $_REQUEST['ms']; $mi = $_REQUEST['mi']; $day = $_REQUEST['day']; $hour = $_REQUEST['hour']; $ampm = $_REQUEST['ampm']; $ARguidToMod = $_REQUEST['ARguidToMod']; if(strcmp($method,"removeNotification")==0) { if($showAR) { $tempAR = get_ar_notifications($user); foreach($tempAR as $temp) { error_log("temp = ".$temp->emailaddress." email address to delete = ".$email); if(strcmp($temp->emailaddress, $email) == 0) { error_log("Found email address to delete, removing the AR notification."); delete_ar_notification($user, $temp->emailaddress, $temp->sendDriveUtilization, $temp->sendMediaIntegrity, $temp->sendMediaUsage, $temp->sendMediaSecurity); } } } error_log("Removing the email notification now."); delete_notification($user, $_REQUEST['guid']); if(get_snmp_audit_logging_enabled($user) == '1') { error_log("send_snmp_audit_logging_partition_config_changed_trap"); send_snmp_audit_logging_library_config_changed_trap($user, "A library configuration setting has been changed from the Web UI"); } $returnMessage="The selected email notification was successfully removed."; } else if(strcmp($method,"addNotification")==0) { if($showAR) { $hour = intval($hour); $hour = $hour + 1; $ampm = intval($ampm); // midnight if($hour == 12 && $ampm == 0) { $hour = 0; } // noon if($hour == 12 && $ampm == 1) { $hour = 12; } if(!($hour == 12 || $hour == 0) && $ampm == 1) { $hour = $hour + 12; } if($du == "true") { $du = 1; } else { $du = 0; } if($mi == "true") { $mi = 1; } else { $mi = 0; } if($mu == "true") { $mu = 1; } else { $mu = 0; } if($ms == "true") { $ms = 1; } else { $ms = 0; } // Only if a Report is Selected create the AR notification object if( $du == 1 || $mi == 1 || $mu == 1 || $ms == 1) { create_ar_notification($user, $du, $mi, $mu, $ms, $_REQUEST['emailaddr'], "", intval($day), $hour); error_log("Creating AR Notification for email address: ".$_REQUEST['emailaddr']."\n"); error_log("send_snmp_audit_logging_partition_config_changed_trap"); send_snmp_audit_logging_library_config_changed_trap($user, "A library configuration setting has been changed from the Web UI"); } } // Check alert level 1=low, 2=medium, 3=high, 4=none if( (int)$_REQUEST['alertlevel'] == 4 ) //Create Ras Email notification that is set as disabled, and set default value to 1 since 4 cant be used { // Create the notification with an alert level of 1 maybe 4 // Then get all notifications and modify it to disabled // Create the email notification $notification = new CNotification( 0, 4, $_REQUEST['emailaddr'], '', false, false, '' ); error_log( "My notification = ". print_r($notification, true ) ); add_notification($user, $notification); // Get all notifications $notifications = get_notifications($user); foreach( $notifications as $notif) { if (strcmp($notif->emailaddress, $_REQUEST['emailaddr']) == 0) { break; } } error_log("notification inside list after finding it"); error_log(print_r($notif, true)); error_log("notif -> email address : ".$notif->emailaddress); $notification = new CNotification($notif->guid, $notif->alertLevel, $notif->emailaddress, '', false, false, ""); error_log("Notification settings: ".print_r($notification,true)); update_notification($user, $notification); error_log("send_snmp_audit_logging_partition_config_changed_trap"); send_snmp_audit_logging_library_config_changed_trap($user, "A library configuration setting has been changed from the Web UI"); error_log("Update notifcation to disabled"); $notifications = get_notifications($user); foreach( $notifications as $notif) { if (strcmp($notif->emailaddress, $_REQUEST['emailaddr']) == 0) { error_log("Updated notif below:\n".print_r($notif, true)); break; } } } else { error_log("Set the notification to enabled for ".$_REQUEST['emailaddr']); $notification = new CNotification(0, (int)$_REQUEST['alertlevel'], $_REQUEST['emailaddr'], '', true, false, ""); add_notification($user, $notification); error_log("send_snmp_audit_logging_partition_config_changed_trap"); send_snmp_audit_logging_library_config_changed_trap($user, "A library configuration setting has been changed from the Web UI"); } $returnMessage= "A new email address has been successfully added. $notification->emailaddress will now receive email notifications."; } else if(strcmp($method,"modifyNotification")==0) { if($showAR) { $hour = intval($hour); $hour = $hour + 1; $ampm = intval($ampm); // midnight if($hour == 12 && $ampm == 0) { $hour = 0; } // noon if($hour == 12 && $ampm == 1) { $hour = 12; } if(!($hour == 12 || $hour == 0) && $ampm == 1) { $hour = $hour + 12; } if($du == "true") { $du = 1; } else { $du = 0; } if($mi == "true") { $mi = 1; } else { $mi = 0; } if($mu == "true") { $mu = 1; } else { $mu = 0; } if($ms == "true") { $ms = 1; } else { $ms = 0; } $tempAR = get_ar_notifications($user); $AR_exist = 0; // 0=Does not Exist, 1=Exist foreach($tempAR as $temp) { if(strcmp($temp->emailaddress, $email) == 0) { $AR_exist = 1; break; } } if ( !$AR_exist && ( $du == 1 || $mi == 1 || $mu == 1 || $ms == 1) ) // AR Notification does NOT exist and at least one AR item selected - Create AR { create_ar_notification($user, $du, $mi, $mu, $ms, $_REQUEST['emailaddr'], "", intval($day), $hour); error_log("Called from Modify to perform action Create AR"); } else if( $AR_exist && ( $du != 1 && $mi != 1 && $mu != 1 && $ms != 1)) //Does exist and no AR items are selected - Delete AR { delete_ar_notification($user, $temp->emailaddress, $temp->sendDriveUtilization, $temp->sendMediaIntegrity, $temp->sendMediaUsage, $temp->sendMediaSecurity); error_log("Called from Modify to perform action delete AR"); } else if( $AR_exist ) // Does exist - Modify AR { modify_ar_notification($user, $du, $mi, $mu, $ms, $_REQUEST['emailaddr'], "", intval($day), $hour, intval($ARguidToMod)); error_log("Called from Modify to perform action modify AR"); } else { error_log("No modifications to AR notification."); } } $enabled = true; $alert_level = (int)$_REQUEST['alertlevel']; if( $alert_level == 4 ) { $enabled = false; // Alert Level is 4 so disable the email notification } $notification = new CNotification($_REQUEST['guid'], $alert_level, $_REQUEST['emailaddr'], '', $enabled, false, ""); error_log("Notification settings: ".print_r($notification,true)); update_notification($user, $notification); error_log("send_snmp_audit_logging_partition_config_changed_trap"); send_snmp_audit_logging_library_config_changed_trap($user, "A library configuration setting has been changed from the Web UI"); $returnMessage="The properties of the selected email address have been successfully modified."; } else if(strcmp($method, "testNotificationEmail") == 0) { // declare variables $emailAddr = $_REQUEST['emailaddr']; if (!send_test_email($user, $emailAddr)) { $returnMessage = "Test email was successfully sent to "; $returnMessage .= $emailAddr; $returnMessage .= "."; } else { $returnMessage = "Test email was unsuccessfully sent to "; $returnMessage .= $emailAddr; $returnMessage .= "."; $errorCode = 0x37; } } } ?>