public function websitesAction() { $auth = $this->getServiceLocator()->get('AuthService'); if (!$auth->hasIdentity()) { return $this->redirect()->toRoute('login'); } $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $error_msg = null; $success_msg = null; $PublisherWebsite = new \model\PublisherWebsite(); $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $request = $this->getRequest(); if ($request->isPost()) { $website = $request->getPost('website'); $category = $request->getPost('category'); $PublisherWebsite->WebDomain = $website; $PublisherWebsite->IABCategory = $category; $PublisherWebsite->DomainOwnerID = $this->auth->getPublisherInfoID(); $PublisherWebsite->DateCreated = date("Y-m-d H:i:s"); $PublisherWebsite->Description = ""; $PublisherWebsite->VisibilityTypeID = \util\AuthHelper::isPrivateExchangePublisher($this->auth->getPublisherInfoID()) === true ? 2 : 1; $auto_approve_websites = $this->config_handle['settings']['publisher']['auto_approve_websites']; $PublisherWebsite->AutoApprove = $auto_approve_websites == true ? 1 : 0; // Disapprove the changes if not admin. if ($this->is_super_admin || $auto_approve_websites == true) { $PublisherWebsite->ApprovalFlag = 1; } else { $PublisherWebsite->ApprovalFlag = 0; } $PublisherWebsite->IABCategory = $category; $params = array(); $params["WebDomain"] = $PublisherWebsite->WebDomain; $params["DomainOwnerID"] = $this->auth->getPublisherInfoID(); if ($PublisherWebsiteFactory->get_row($params) === null) { $PublisherWebsiteFactory->save_domain($PublisherWebsite); if ($auto_approve_websites != true || $this->config_handle['mail']['subscribe']['websites'] === true) { if ($auto_approve_websites != true) { $message = "New NginAd Website for Approval.<br /><b>" . $website . "</b><br /><br />Username: "******"New NginAd Website for Approval: " . $website; } else { $message = "New NginAd Website.<br /><b>" . $website . "</b><br /><br />Username: "******"New NginAd Website: " . $website; } $transport = $this->getServiceLocator()->get('mail.transport'); $text = new Mime\Part($message); $text->type = Mime\Mime::TYPE_HTML; $text->charset = 'utf-8'; $mimeMessage = new Mime\Message(); $mimeMessage->setParts(array($text)); $zf_message = new Message(); $zf_message->addTo($this->config_handle['mail']['admin-email']['email'], $this->config_handle['mail']['admin-email']['name'])->addFrom($this->config_handle['mail']['reply-to']['email'], $this->config_handle['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage); $transport->send($zf_message); } $success_msg = 1; } else { $error_msg = '"' . $website . '" duplicate entry.'; } } $pending_list = $PublisherWebsiteFactory->get(array('DomainOwnerID' => $this->auth->getPublisherInfoID(), 'ApprovalFlag' => 0)); $approved_list = $PublisherWebsiteFactory->get(array('DomainOwnerID' => $this->auth->getPublisherInfoID(), 'ApprovalFlag' => 1)); $denied_list = $PublisherWebsiteFactory->get(array('DomainOwnerID' => $this->auth->getPublisherInfoID(), 'ApprovalFlag' => 2)); $view = new ViewModel(array('dashboard_view' => 'account', 'pending_list' => $pending_list, 'approved_list' => $approved_list, 'denied_list' => $denied_list, 'success_msg' => $success_msg, 'error_msg' => $error_msg, 'vertical_map' => \util\DeliveryFilterOptions::$vertical_map, 'user_id' => $this->auth->getUserID(), 'user_id_list' => $this->user_id_list, 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'header_title' => 'Account Settings', 'is_super_admin' => $this->is_super_admin, 'is_domain_admin' => $this->is_domain_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID)); return $view; }
/** * Show the editing of a domain and process it. * * @return multitype:string \DashboardManager\model\PublisherWebsite |multitype:Ambigous <NULL, string> \DashboardManager\model\PublisherWebsite */ public function editdomainAction() { $error_message = null; $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $editResultObj = new \model\PublisherWebsite(); $needed_input = array('WebDomain', 'Description'); // Check to make sure the value is valid to begin with. $PublisherWebsiteID = intval($this->params()->fromRoute('param1', 0)); if ($PublisherWebsiteID > 0) { // Only modify entries that belong to the user. $parameters = array("PublisherWebsiteID" => $PublisherWebsiteID, "DomainOwnerID" => $this->PublisherInfoID); $editResultObj = $PublisherWebsiteFactory->get_row_object($parameters); $request = $this->getRequest(); // Check to make sure this entry exists for editing and make sure the user owns this entry. // Prevent the display of entries that the user does not own or have access. if (intval($editResultObj->PublisherWebsiteID) == $PublisherWebsiteID && $editResultObj->DomainOwnerID == $this->PublisherInfoID) { if ($request->isPost()) { $validate = $this->validateInput($needed_input, false); if ($validate && $editResultObj->DomainOwnerID == $this->PublisherInfoID) { $web_domain = $request->getPost("WebDomain"); $description = $request->getPost("Description"); $iab_category = $request->getPost("IABCategory"); // Check if an entry exists with the same name. A NULL means there is no duplicate. //if ($PublisherWebsiteFactory->get_row(array("WebDomain" => $web_domain)) === null): $editResultObj->WebDomain = strip_tags($web_domain); $editResultObj->Description = strip_tags($description); $editResultObj->IABCategory = strip_tags($iab_category); $editResultObj->VisibilityTypeID = \util\AuthHelper::isPrivateExchangePublisher($editResultObj->DomainOwnerID) === true ? 0 : 1; if ($this->is_super_admin || $this->is_domain_admin) { $editResultObj->VisibilityTypeID = $request->getPost("EnablePlatformConnection") == 1 ? 1 : 2; } try { $PublisherWebsiteFactory->save_domain($editResultObj); if ($this->is_domain_admin) { return $this->redirect()->toRoute('pxpublishers'); } else { return $this->redirect()->toRoute('publisher'); } } catch (\Zend\Db\Adapter\Exception\InvalidQueryException $e) { $error_msg = "ERROR: A database error has occurred, please contact customer service."; } //else: //$error_msg = "ERROR: A duplicate Web Domain may exist. Please try another."; // endif; } else { $error_message = "ERROR: Required fields are not filled in or invalid input."; } } // Valid entry, show edit. } else { $error_message = "ERROR: The specified domain entry ID was not found or you do not have permission to edit this entry."; if ($this->is_domain_admin) { return $this->redirect()->toRoute('pxpublishers'); } else { return $this->redirect()->toRoute('publisher'); } } } else { $error_message = "An invalid domain entry ID was provided."; if ($this->is_domain_admin) { return $this->redirect()->toRoute('pxpublishers'); } else { return $this->redirect()->toRoute('publisher'); } } return array('error_message' => $error_message, 'is_super_admin' => $this->is_super_admin, 'is_domain_admin' => $this->is_domain_admin, 'user_id_list' => $this->user_id_list_publisher, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID, 'true_user_name' => $this->true_user_name, 'editResultObj' => $editResultObj, 'vertical_map' => \util\DeliveryFilterOptions::$vertical_map, 'dashboard_view' => 'publisher', 'user_identity' => $this->identity(), 'header_title' => 'Edit Domain'); }