예제 #1
0
 private static function getExclusionVOs($vappliance, $vos)
 {
     $endorsed = VoAdmin::getEndorsedVos($vappliance);
     $result = array();
     foreach ($endorsed as $e) {
         foreach ($vos as $vo) {
             if (trim($vo) === trim($e["id"])) {
                 $result[] = $vo;
             }
         }
     }
     return $result;
 }
예제 #2
0
 public function contactvosAction()
 {
     $this->_helper->layout->disableLayout();
     $vappid = isset($_GET["id"]) && is_numeric($_GET["id"]) ? trim($_GET["id"]) : 0;
     $isget = $_SERVER['REQUEST_METHOD'] === "GET" ? true : false;
     $ispost = $_SERVER['REQUEST_METHOD'] === "POST" ? true : false;
     $vappliance = VoAdmin::getVAppliance($vappid);
     $vappversion = VoAdmin::getVAppVersion($vappliance);
     $user = VoAdmin::getUser($this->session->userid);
     $canmanagevas = false;
     if ($user !== null && $vappliance !== null) {
         $privs = $user->getPrivs();
         if ($privs !== null && $privs->canManageVAs($vappliance->guid)) {
             $canmanagevas = true;
         }
     }
     if ($vappid <= 0 || $vappliance === null || $user === null || $canmanagevas === false || $isget === false && $ispost === false) {
         $this->_helper->viewRenderer->setNoRender();
         header('HTTP/1.0 404 Not Found');
         header("Status: 404 Not Found");
         return;
     }
     if ($isget === true) {
         $this->view->volist = VoAdmin::getEndorsedVos($vappliance, true);
         return;
     }
     $this->_helper->viewRenderer->setNoRender();
     $notificationtype = isset($_POST["notificationtype"]) ? trim($_POST["notificationtype"]) : "";
     $subject = isset($_POST["subject"]) ? trim($_POST["subject"]) : "";
     $message = isset($_POST["message"]) ? trim($_POST["message"]) : "";
     $vos = isset($_POST["vos"]) ? $_POST["vos"] : "[]";
     $vos = json_decode($vos);
     $preview = isset($_POST["preview"]) ? trim($_POST["preview"]) : "false";
     $preview = $preview === "true" ? true : false;
     $output = array();
     if ($preview === true) {
         $result = VoContact::createVONotification($user, $vappliance, $notificationtype, $vos, $subject, $message, $output);
         if ($result !== true) {
             if ($result === false) {
                 $result = "Could not create notification";
             }
             echo "<response error='" . $result . "' ></response>";
         } else {
             echo "<response success='true'>";
             echo "<message>" . htmlentities($output["message"]) . "</message>";
             echo "<from name='" . htmlentities($output["username"]) . "' email='" . htmlentities($output["useremail"]) . "'></from>";
             if (userIsAdminOrManager($user->id) === true && isset($output["recipients"])) {
                 echo "<vorecipients>";
                 foreach ($output["recipients"] as $rec) {
                     echo "<vo id='" . htmlentities($rec["void"]) . "' name='" . htmlentities($rec["vo"]) . "' >";
                     foreach ($rec["contacts"] as $cont) {
                         echo "<contact name='" . htmlentities($cont["name"]) . "' email='" . htmlentities($cont["email"]) . "' role='" . htmlentities($cont["role"]) . "' ></contact>";
                     }
                     echo "</vo>";
                 }
                 echo "</vorecipients>";
             }
             echo "</response>";
         }
     } else {
         $result = VoContact::sendVONotification($user, $vappliance, $notificationtype, $vos, $subject, $message);
         if ($result === true) {
             echo "<response success='true'></response>";
         } else {
             if ($result === false) {
                 $result = "Could not create notification";
             }
             echo "<response error='" . $result . "' ></response>";
         }
     }
 }