GetName() public static méthode

public static GetName ( $const )
 public function xListEnvironmentsAction()
 {
     $this->request->defineParams(array('sort' => array('type' => 'json')));
     if ($this->user->getType() == Scalr_Account_User::TYPE_ACCOUNT_OWNER) {
         $sql = "SELECT\n\t\t\t\tid,\n\t\t\t\tname,\n\t\t\t\tdt_added AS dtAdded,\n\t\t\t\tis_system AS isSystem,\n\t\t\t\tstatus\n\t\t\t\tFROM client_environments\n\t\t\t\tWHERE client_id = ? AND :FILTER:\n\t\t\t\tGROUP BY id\n\t\t\t";
         $params = array($this->user->getAccountId());
     } else {
         $sql = "SELECT\n\t\t\t\tclient_environments.id,\n\t\t\t\tclient_environments.name,\n\t\t\t\tclient_environments.dt_added AS dtAdded,\n\t\t\t\tclient_environments.is_system AS isSystem,\n\t\t\t\tclient_environments.status\n\t\t\t\tFROM client_environments\n\t\t\t\tJOIN account_team_envs ON client_environments.id = account_team_envs.env_id\n\t\t\t\tJOIN account_team_users ON account_team_envs.team_id = account_team_users.team_id\n\t\t\t\tWHERE client_environments.client_id = ? AND account_team_users.permissions = ? AND account_team_users.user_id = ? AND :FILTER:\n\t\t\t\tGROUP BY client_environments.id\n\t\t\t";
         $params = array($this->user->getAccountId(), Scalr_Account_Team::PERMISSIONS_OWNER, $this->user->id);
     }
     $response = $this->buildResponseFromSql($sql, array('id', 'name', 'dtAdded', 'status'), array(), $params);
     foreach ($response['data'] as &$row) {
         foreach (Scalr_Environment::init()->loadById($row['id'])->getEnabledPlatforms() as $platform) {
             $row['platforms'][] = SERVER_PLATFORMS::GetName($platform);
         }
         $row['platforms'] = implode(', ', $row['platforms']);
         $row['dtAdded'] = Scalr_Util_DateTime::convertTz($row['dtAdded']);
     }
     $this->response->data($response);
 }
Exemple #2
0
 public function xListEnvironmentsAction()
 {
     $this->request->defineParams(array('sort' => array('type' => 'json')));
     $selectStmt = "SELECT e.id, e.name, e.dt_added AS dtAdded, e.status";
     if ($this->user->isAccountOwner()) {
         $sql = "\n                {$selectStmt}\n                FROM client_environments e\n                WHERE e.client_id = ? AND :FILTER:\n                GROUP BY e.id\n            ";
         $params = array($this->user->getAccountId());
     } else {
         $sql = "\n                {$selectStmt}\n                FROM client_environments e\n                JOIN account_team_envs te ON e.id = te.env_id\n                JOIN account_team_users tu ON te.team_id = tu.team_id\n                WHERE e.client_id = ? AND tu.user_id = ? AND :FILTER:\n                GROUP BY e.id\n            ";
         $params = array($this->user->getAccountId(), $this->user->id);
     }
     $response = $this->buildResponseFromSql($sql, array('id', 'name', 'dtAdded', 'status'), array(), $params);
     foreach ($response['data'] as &$row) {
         $row['platforms'] = array();
         foreach (Scalr_Environment::init()->loadById($row['id'])->getEnabledPlatforms() as $platform) {
             $row['platforms'][] = SERVER_PLATFORMS::GetName($platform);
         }
         $row['platforms'] = implode(', ', $row['platforms']);
         $row['dtAdded'] = Scalr_Util_DateTime::convertTz($row['dtAdded']);
     }
     $this->response->data($response);
 }
Exemple #3
0
 /**
  * Raises onCloudAdd notification event
  *
  * @param   string              $platform    A platform name.
  * @param   \Scalr_Environment  $environment An environment object which cloud is created in.
  * @param   \Scalr_Account_User $user        An user who has created platform.
  */
 public function onCloudAdd($platform, $environment, $user)
 {
     $container = \Scalr::getContainer();
     $analytics = $container->analytics;
     //Nothing to do in case analytics is disabled
     if (!$analytics->enabled) {
         return;
     }
     if (!$environment instanceof \Scalr_Environment) {
         $environment = \Scalr_Environment::init()->loadById($environment);
     }
     $pm = PlatformFactory::NewPlatform($platform);
     //Check if there are some price for this platform and endpoint url
     if (($endpointUrl = $pm->hasCloudPrices($environment)) === true) {
         return;
     }
     //Disabled or badly configured environment
     if ($endpointUrl === false && !in_array($platform, [\SERVER_PLATFORMS::EC2, \SERVER_PLATFORMS::GCE])) {
         return;
     }
     //Send a message to financial admin if there are not any price for this cloud
     $baseUrl = rtrim($container->config('scalr.endpoint.scheme') . "://" . $container->config('scalr.endpoint.host'), '/');
     //Disable notifications for hosted Scalr
     if (!\Scalr::isAllowedAnalyticsOnHostedScalrAccount($environment->clientId)) {
         return;
     }
     $emails = $this->getFinancialAdminEmails();
     //There isn't any financial admin
     if (empty($emails)) {
         return;
     }
     $emails = array_map(function ($email) {
         return '<' . trim($email, '<>') . '>';
     }, $emails);
     try {
         $res = $container->mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/analytics_on_cloud_add.eml.php', ['isPublicCloud' => $platform == \SERVER_PLATFORMS::EC2, 'userEmail' => $user->getEmail(), 'cloudName' => \SERVER_PLATFORMS::GetName($platform), 'linkToPricing' => $baseUrl . '/#/analytics/pricing?platform=' . urlencode($platform) . '&url=' . urlencode($endpointUrl === false ? '' : $analytics->prices->normalizeUrl($endpointUrl))], join(',', $emails));
     } catch (\Exception $e) {
     }
 }
Exemple #4
0
 /**
  * Get information about role
  */
 public function infoAction()
 {
     $this->request->restrictAccess(Acl::RESOURCE_FARMS_ROLES);
     $this->request->defineParams(array('roleId' => array('type' => 'int')));
     $roleId = $this->getParam('roleId');
     $dbRole = DBRole::loadById($roleId);
     if ($dbRole->envId != 0) {
         $this->user->getPermissions()->validate($dbRole);
     }
     $dbRole->groupName = $dbRole->getCategoryName();
     $dbRole->behaviorsList = implode(", ", $dbRole->getBehaviors());
     foreach ($dbRole->getSoftwareList() as $soft) {
         $dbRole->softwareList[] = "{$soft['name']} {$soft['version']}";
     }
     if ($dbRole->softwareList) {
         $dbRole->softwareList = implode(", ", $dbRole->softwareList);
     } else {
         $dbRole->softwareList = "";
     }
     $dbRole->tagsString = implode(", ", $dbRole->getTags());
     $dbRole->platformsList = array();
     foreach ($dbRole->getPlatforms() as $platform) {
         $dbRole->platformsList[] = array('name' => SERVER_PLATFORMS::GetName($platform), 'locations' => implode(", ", $dbRole->getCloudLocations($platform)));
     }
     $this->response->page('ui/roles/info.js', array('name' => $dbRole->name, 'info' => get_object_vars($dbRole)));
 }