public function findbyadminAction() { $data = array("app_ids" => array(), "is_allowed_to_add_pages" => array()); $application = new Application_Model_Application(); if (!Siberian_Version::is("sae")) { $applications = $application->findAllByAdmin($this->getRequest()->getParam("admin_id")); } else { $applications = array(Application_Model_Application::getInstance()); } foreach ($applications as $application) { $data["app_ids"][] = $application->getId(); if ($application->getIsAllowedToAddPages()) { $data["is_allowed_to_add_pages"][] = $application->getId(); } } $this->_sendHtml($data); }
public function deleteAction() { if ($app_id = $this->getRequest()->getParam('app_id')) { try { $application = new Application_Model_Application(); $application->find($app_id); if (!$application->getId()) { throw new Exception($this->_("This application does not exist")); } $application->delete(); $html = array('success' => 1, 'app_id' => $app_id); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }
public function setaddpageAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data["admin_id"]) or empty($data["app_id"])) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin = new Admin_Model_Admin(); $admin->find($data["admin_id"]); $application = new Application_Model_Application(); $application->find($data["app_id"]); if (!$admin->getId() or !$application->getId()) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin->setIsAllowedToAddPages(!empty($data["can_add_page"]))->save(); $data = array("success" => 1, "message" => $this->_("Data saved successfully.")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function setpermissionstoadminAction() { if ($data = $this->getRequest()->getPost()) { try { if (empty($data["admin_id"]) or empty($data["app_id"])) { throw new Exception($this->_("1An error occurred while saving. Please try again later.")); } $admin = new Admin_Model_Admin(); $admin->find($data["admin_id"]); if (($admin->getId() or $admin->getParentId()) and ($admin->getId() != $this->getAdmin()->getId() and $admin->getParentId() != $this->getAdmin()->getId())) { $this->getSession()->addError("This administrator does not exist"); } $application = new Application_Model_Application(); $application->find($data["app_id"]); if (!$application->getId()) { throw new Exception($this->_("2An error occurred while saving. Please try again later.")); } if (!$application->hasAsAdmin($this->getAdmin()->getId())) { throw new Exception($this->_("3An error occurred while saving. Please try again later.")); } $admin->setIsAllowedToAddPages(!empty($data["is_selected"])); $application->addAdmin($admin); $data = array("success" => 1); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
private function __checkKeyAndDomain($data, $application) { if (isset($data["key"]) and (!$application->getId() or $application->getKey() != $data["key"])) { $module_names = array_map('strtolower', Zend_Controller_Front::getInstance()->getDispatcher()->getSortedModuleDirectories()); if (in_array($data["key"], $module_names)) { throw new Exception($this->_("Your application key \"%s\" is not valid.", $data["key"])); } $app_tester = new Application_Model_Application(); $app_tester->find($data["key"], "key"); if ($app_tester->getId() and $app_tester->getId() != $application->getId()) { throw new Exception($this->_("The key is already used by another application.")); } } if (!empty($data["domain"]) and $application->getDomain() != $data["domain"]) { $data["domain"] = str_replace(array("http://", "https://"), "", $data["domain"]); $tmp_url = str_replace(array("http://", "https://"), "", $this->getRequest()->getBaseUrl()); $tmp_url = current(explode("/", $tmp_url)); $tmp_domain = explode("/", $data["domain"]); $domain = current($tmp_domain); if (preg_match('/^(www.)?(' . $domain . ')/', $tmp_url)) { throw new Exception($this->_("You can't use this domain.")); } else { $domain_folder = next($tmp_domain); $module_names = array_map('strtolower', Zend_Controller_Front::getInstance()->getDispatcher()->getSortedModuleDirectories()); if (in_array($domain_folder, $module_names)) { throw new Exception($this->_("Your domain key \"%s\" is not valid.", $domain_folder)); } } if (!Zend_Uri::check("http://" . $data["domain"])) { throw new Exception($this->_("Please enter a valid URL")); } $app_tester = new Application_Model_Application(); $app_tester->find($data["domain"], "domain"); if ($app_tester->getId() and $app_tester->getId() != $application->getId()) { throw new Exception("The domain is already used by another application."); } } }
public function downloadsourceAction() { if ($data = $this->getRequest()->getParams()) { try { $application = new Application_Model_Application(); if (empty($data['app_id']) or empty($data['device_id'])) { throw new Exception($this->_('This application does not exist')); } $application->find($data['app_id']); if (!$application->getId()) { throw new Exception($this->_('This application does not exist')); } $device = $application->getDevice($data["device_id"]); $device->setApplication($application); $device->setDownloadType($this->getRequest()->getParam("type"))->setExcludeAds($this->getRequest()->getParam("no_ads")); $zip = $device->getResources(); if ($this->getRequest()->getParam("type") != "apk") { $path = explode('/', $zip); end($path); $this->_download($zip, current($path), 'application/octet-stream'); } else { die; } } catch (Exception $e) { Zend_Registry::get("logger")->sendException("Error When Generating Android: \n" . print_r($e, true), "source_generator_", false); if ($application->getId()) { $this->_redirect('application/backoffice_view', array("app_id" => $application->getId())); } else { $this->_redirect('application/backoffice_list'); } } } }