/** * Toggle the approval given the supplied flag to toggle. * * @param integer $flag 0 = Pending | 1 = Approved * @return boolean TRUE if successful, FALSE if failure. */ private function adApprovalToggle($flag) { $DomainID = intval($this->params()->fromRoute('param1', 0)); $PublisherAdZoneID = intval($this->params()->fromRoute('id', 0)); if (($this->is_super_admin || $this->is_domain_admin) && $DomainID > 0 && $PublisherAdZoneID > 0 && ($flag === 0 || $flag === 1 || $flag === 2)) { $DomainObj = $this->get_domain_data($DomainID, $this->PublisherInfoID); if ($DomainObj === null) { $error_message = "An invalid publishing web domain was specified for the specified user."; } else { if ($this->is_domain_admin) { if (!\util\AuthHelper::domain_user_authorized_publisher($this->auth->getUserID(), $DomainObj->DomainOwnerID)) { die("Not Authorized"); } } $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance(); $AdObject = new \model\PublisherAdZone(); $parameters = array("PublisherWebsiteID" => $DomainObj->PublisherWebsiteID, "PublisherAdZoneID" => $PublisherAdZoneID); $AdObject = $PublisherAdZoneFactory->get_row_object($parameters); if (intval($AdObject->PublisherAdZoneID) == $PublisherAdZoneID) { $AdObject->AutoApprove = 0; $AdObject->AdStatus = intval($flag); if ($PublisherAdZoneFactory->save_ads($AdObject)) { if (($flag == 1 || $flag == 2) && $this->config_handle['mail']['subscribe']['user_zones']) { $PublisherInfoFactory = \_factory\PublisherInfo::get_instance(); $params = array(); $params["PublisherInfoID"] = $DomainObj->DomainOwnerID; $PublisherInfo = $PublisherInfoFactory->get_row($params); if ($PublisherInfo !== null) { // approval, send out email $site_url = $this->config_handle['delivery']['site_url']; $exchange_name = $this->config_handle['delivery']['exchange_name']; if ($flag == 1) { $message = 'Your ' . $exchange_name . ' Publisher Ad Zone for : ' . $DomainObj->WebDomain . ' : ' . $AdObject->AdName . ' was approved.<br /><br />Please login <a href="' . $site_url . '/auth/login">here</a> with your email and password'; $subject = "Your " . $exchange_name . " Publisher Ad Zone for : " . $DomainObj->WebDomain . " was approved"; } else { $message = 'Your ' . $exchange_name . ' Publisher Ad Zone for : ' . $DomainObj->WebDomain . ' : ' . $AdObject->AdName . ' was rejected.<br /><br />Please login <a href="' . $site_url . '/auth/login">here</a> with your email and password'; $subject = "Your " . $exchange_name . " Publisher Ad Zone for : " . $DomainObj->WebDomain . " was rejected"; } $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($PublisherInfo->Email)->addFrom($this->config_handle['mail']['reply-to']['email'], $this->config_handle['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage); $transport->send($zf_message); } } return TRUE; } } } } return FALSE; }
private function userApprovalToggle($flag, $user_id, $user_type) { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } if (($this->is_super_admin || $this->is_domain_admin) && $user_id > 0 && ($flag === 1 || $flag === 0)) { if ($this->is_domain_admin) { if (!\util\AuthHelper::domain_user_authorized_publisher($this->auth->getUserID(), $user_id)) { die("Not Authorized"); } } $authUsers = new \model\authUsers(); $authUsersFactory = \_factory\authUsers::get_instance(); if ($user_type == 'publisher') { $PublisherInfoFactory = \_factory\PublisherInfo::get_instance(); $authUsers = $authUsersFactory->get_row_object(array("PublisherInfoID" => $user_id)); } if ($user_type == 'customer') { $DemandCustomerFactory = \_factory\DemandCustomerInfo::get_instance(); $authUsers = $authUsersFactory->get_row_object(array("DemandCustomerInfoID" => $user_id)); } $authUsers->user_enabled = $flag; $authUsers->user_verified = $flag; $authUsers->user_agreement_accepted = 0; if ($flag === 1) { $authUsersFactory->saveUser($authUsers); return true; } if ($flag === 0) { if ($user_type == 'publisher') { //$PublisherInfoFactory->deletePublisherInfo($user_id); } if ($user_type == 'customer') { //$DemandCustomerFactory->deleteCustomerInfo($user_id); } $authUsersFactory->deactivate_user($authUsers->user_id); return true; } } return false; }
public function approvedeniedAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } if (!$this->auth->hasIdentity()) { return $this->redirect()->toRoute('login'); } elseif (!$this->is_super_admin && !$this->is_domain_admin) { return $this->redirect()->toRoute('publisher'); } $success = false; $msg = ""; $PublisherWebsite = new \model\PublisherWebsite(); $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $PublisherInfoFactory = \_factory\PublisherInfo::get_instance(); $request = $this->getRequest(); if ($request->isPost()) { $q = $request->getPost('q'); $website_ids = $request->getPost('website_ids'); $denied_desciption = $request->getPost('description'); $website_arry = explode(",", $website_ids); foreach ($website_arry as $website_id) { if ($website_id == "d") { continue; } $website_id = intval($website_id); $params = array(); $params["PublisherWebsiteID"] = $website_id; $PublisherWebsite = $PublisherWebsiteFactory->get_row_object($params); $params = array(); $params["PublisherInfoID"] = $PublisherWebsite->DomainOwnerID; if ($this->is_domain_admin == true) { if (!\util\AuthHelper::domain_user_authorized_publisher($this->auth->getUserID(), $PublisherWebsite->DomainOwnerID)) { continue; } } $publisher_obj = $PublisherInfoFactory->get_row_object($params); $PublisherWebsite->DateUpdated = date("Y-m-d H:i:s"); if ($q == 0) { $PublisherWebsite->AutoApprove = 0; $PublisherWebsite->ApprovalFlag = 2; $PublisherWebsite->Description = $denied_desciption; $PublisherWebsiteFactory->save_domain($PublisherWebsite); $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance(); $params = array(); $params["PublisherWebsiteID"] = $website_id; $PublisherAdZoneList = $PublisherAdZoneFactory->get($params); foreach ($PublisherAdZoneList as $PublisherAdZone) { $PublisherAdZoneFactory->updatePublisherAdZonePublisherAdZoneStatus($PublisherAdZone->PublisherAdZoneID, 2); } $subject = "Website Denied " . $PublisherWebsite->WebDomain; $message = '<b>Website Denied</b> : '; $message = $message . " " . $PublisherWebsite->WebDomain; $message = $message . "<p>" . $denied_desciption . "</p>"; $this->batchmailAction($publisher_obj->Email, $subject, $message); $msg = "Websites denied successfully. And batch mails goes to publisher."; } elseif ($q == 1) { $PublisherWebsite->ApprovalFlag = 1; $PublisherWebsiteFactory->save_domain($PublisherWebsite); $subject = "Website Approved " . $PublisherWebsite->WebDomain; $message = '<b>Website Approved</b> : '; $message = $message . " " . $PublisherWebsite->WebDomain; $this->batchmailAction($publisher_obj->Email, $subject, $message); $msg = "Websites approved successfully. And batch mails goes to publisher."; } } $success = true; } $data = array('success' => $success, 'data' => array('msg' => $msg)); $this->setJsonHeader(); return $this->getResponse()->setContent(json_encode($data)); }
public static function domain_user_authorized_publisher_website($parent_id, $publisher_website_id) { $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $params = array(); $params["PublisherWebsiteID"] = $publisher_website_id; $PublisherWebsite = $PublisherWebsiteFactory->get_row($params); if (!\util\AuthHelper::domain_user_authorized_publisher($parent_id, $PublisherWebsite->DomainOwnerID)) { die("You are not authorized to perform this action: CODE 101"); } return true; }
/** * * @return Ambigous <\Zend\Http\Response, \Zend\Stdlib\ResponseInterface> */ public function changeprivateexchangepublishermarkupAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } if ($this->is_super_admin == false && $this->is_domain_admin == false) { die("You do not have permission to access this page"); } $publisher_info_id = $this->getRequest()->getQuery('markuppublisherinfoid'); $publisher_markup = $this->getRequest()->getQuery('private-exchange-publisher-markup'); if ($this->is_super_admin == false && !\util\AuthHelper::domain_user_authorized_publisher($this->auth->getUserID(), $publisher_info_id)) { die("You are not authorized to perform this action: CODE 101"); } $PrivateExchangePublisherMarkupFactory = \_factory\PrivateExchangePublisherMarkup::get_instance(); $params = array(); $params["PublisherInfoID"] = $publisher_info_id; $PrivateExchangePublisherMarkup = $PrivateExchangePublisherMarkupFactory->get_row($params); $publisher_markup = floatval($publisher_markup) / 100; if ($publisher_markup <= 0) { die("Publisher Markup can not be less than or equal to zero percent"); } if ($publisher_markup >= 1) { die("Publisher Markup can not be greater than or equal to one hundred percent"); } $publisher_markup = sprintf("%1.2f", $publisher_markup); $_PrivateExchangePublisherMarkup = new \model\PrivateExchangePublisherMarkup(); $_PrivateExchangePublisherMarkup->PublisherInfoID = $publisher_info_id; $_PrivateExchangePublisherMarkup->MarkupRate = $publisher_markup; if ($PrivateExchangePublisherMarkup != null) { $PrivateExchangePublisherMarkupFactory->updatePrivateExchangePublisherMarkup($_PrivateExchangePublisherMarkup); } else { $PrivateExchangePublisherMarkupFactory->insertPrivateExchangePublisherMarkup($_PrivateExchangePublisherMarkup); } if ($this->is_domain_admin) { return $this->redirect()->toRoute('pxpublishers'); } else { return $this->redirect()->toRoute('publisher'); } }