/** * @param $endpoint * @param int $timeout */ function __construct($endpoint, $timeout = 30) { $endpoint .= craft()->config->get('endpointSuffix'); $this->_endpoint = $endpoint; $this->_timeout = $timeout; $this->_model = new EtModel(array('licenseKey' => $this->_getLicenseKey(), 'requestUrl' => craft()->request->getHostInfo() . craft()->request->getUrl(), 'requestIp' => craft()->request->getIpAddress(), 'requestTime' => DateTimeHelper::currentTimeStamp(), 'requestPort' => craft()->request->getPort(), 'installedPackages' => Craft::getPackages(), 'localBuild' => CRAFT_BUILD, 'localVersion' => CRAFT_VERSION, 'userEmail' => craft()->userSession->getUser()->email, 'track' => CRAFT_TRACK)); $this->_options['useragent'] = 'craft-requests/' . \Requests::VERSION; $this->_options['timeout'] = $this->_timeout; }
/** * Gets the widget's body HTML. * * @return string */ public function getBodyHtml() { $id = $this->model->id; $js = "new Craft.GetHelpWidget({$id});"; craft()->templates->includeJs($js); craft()->templates->includeJsResource('js/GetHelpWidget.js'); craft()->templates->includeTranslations('Message sent successfully.'); $message = "Enter your message here.\n\n" . "------------------------------\n\n" . 'Craft version: ' . Craft::t('{version} build {build}', array('version' => Craft::getVersion(), 'build' => Craft::getBuild())) . "\n" . 'Packages: ' . implode(', ', Craft::getPackages()); $plugins = craft()->plugins->getPlugins(); if ($plugins) { $pluginNames = array(); foreach ($plugins as $plugin) { $pluginNames[] = $plugin->getName() . ' (' . $plugin->getDeveloper() . ')'; } $message .= "\nPlugins: " . implode(', ', $pluginNames); } return craft()->templates->render('_components/widgets/GetHelp/body', array('message' => $message)); }
/** * Returns the packages in this Craft install, as defined by the craft_info table. * * @return array */ public function getPackages() { return Craft::getPackages(); }
/** * @static * @param bool $fetch * @return array */ public static function getAlerts($path = null, $fetch = false) { $alerts = array(); $user = craft()->userSession->getUser(); if (!$user) { return $alerts; } if (craft()->updates->isUpdateInfoCached() || $fetch) { // Fetch the updates regardless of whether we're on the Updates page or not, // because the other alerts are relying on cached Elliott info $updateModel = craft()->updates->getUpdates(); if ($path != 'updates' && $user->can('performUpdates')) { if (!empty($updateModel->app->releases)) { if (craft()->updates->criticalCraftUpdateAvailable($updateModel->app->releases)) { $alerts[] = Craft::t('There’s a critical Craft update available.') . ' <a class="go" href="' . UrlHelper::getUrl('updates') . '">' . Craft::t('Go to Updates') . '</a>'; } } } // Domain mismatch? $licenseKeyStatus = craft()->et->getLicenseKeyStatus(); if ($licenseKeyStatus == LicenseKeyStatus::MismatchedDomain) { $licensedDomain = craft()->et->getLicensedDomain(); $licenseKeyPath = craft()->path->getLicenseKeyPath(); $licenseKeyFile = IOHelper::getFolderName($licenseKeyPath, false) . '/' . IOHelper::getFileName($licenseKeyPath); $message = Craft::t('The license located at {file} belongs to {domain}.', array('file' => $licenseKeyFile, 'domain' => '<a href="http://' . $licensedDomain . '" target="_blank">' . $licensedDomain . '</a>')); // Can they actually do something about it? if ($user->admin) { $action = '<a class="domain-mismatch">' . Craft::t('Transfer it to this domain?') . '</a>'; } else { $action = Craft::t('Please notify one of your site’s admins.'); } $alerts[] = $message . ' ' . $action; } // Unlicensed packages? if ($path != 'settings/packages') { $licensedPackages = craft()->et->getLicensedPackages(); $packageTrials = craft()->et->getPackageTrials(); // Could be false if not cached if (is_array($licensedPackages)) { // Look for any unlicensed licenses $unlicensedPackages = array(); foreach (Craft::getPackages() as $package) { if (!in_array($package, $licensedPackages)) { // Make sure it's not in trial if (!is_array($packageTrials) || !in_array($package, array_keys($packageTrials))) { $unlicensedPackages[] = $package; } } } if ($unlicensedPackages) { if (count($unlicensedPackages) == 1) { $message = Craft::t('The {package} package is installed, but it’s not licensed.', array('package' => Craft::t($unlicensedPackages[0]))); } else { $message = Craft::t('You have multiple unlicensed packages installed.'); } // Can they actually do something about it? if ($user->admin) { $action = '<a class="go" href="' . UrlHelper::getUrl('settings/packages') . '">' . Craft::t('Manage packages') . '</a>'; } else { $action = Craft::t('Please notify one of your site’s admins.'); } $alerts[] = $message . ' ' . $action; } } if ($packageTrials && $user->admin && !$user->hasShunned('packageTrialAlert')) { $expiringTrials = array(); $currentTime = DateTimeHelper::currentUTCDateTime(); $nextWeek = $currentTime->add(new DateInterval('P1W'))->getTimestamp(); // See if there are any package trials that expire in less than a week foreach (Craft::getPackages() as $package) { if (!empty($packageTrials[$package])) { if ($packageTrials[$package] < $nextWeek) { $expiringTrials[] = $package; } } } if ($expiringTrials) { if (count($expiringTrials) == 1) { $message = Craft::t('Your {package} trial is expiring soon.', array('package' => Craft::t($expiringTrials[0]))); } else { $message = Craft::t('You have multiple package trials expiring soon.'); } $action1 = '<a class="shun:packageTrialAlert">' . Craft::t('Remind me later') . '</a>'; $action2 = '<a class="go" href="' . UrlHelper::getUrl('settings/packages') . '">' . Craft::t('manage packages') . '</a>'; $alerts[] = $message . ' ' . $action1 . ' ' . Craft::t('or') . ' ' . $action2; } } } } return $alerts; }