/**
  * View/Edit Form
  *
  */
 public function actionEditForm(array $variables = array())
 {
     $variables['brandNewForm'] = false;
     $variables['navigation'] = $this->navigation();
     if (!empty($variables['formId'])) {
         if (empty($variables['form'])) {
             $variables['form'] = craft()->formBuilder2_form->getFormById($variables['formId']);
             $variables['crumbs'] = array(array('label' => Craft::t('FormBuilder 2'), 'url' => UrlHelper::getUrl('formbuilder2')), array('label' => Craft::t('Forms'), 'url' => UrlHelper::getUrl('formbuilder2/forms')), array('label' => $variables['formId'], 'url' => UrlHelper::getUrl('formbuilder2/forms/' . $variables['formId'] . '/edit')));
             if (!$variables['form']) {
                 throw new HttpException(404);
             }
             // Get Logo Asset
             $customEmailLogo = $variables['form']->notificationSettings['templateSettings']['emailCustomLogo'];
             if ($customEmailLogo) {
                 $criteria = craft()->elements->getCriteria(ElementType::Asset);
                 $criteria->id = $customEmailLogo[0];
                 $criteria->limit = 1;
                 $elements = $criteria->find();
             } else {
                 $elements = [];
             }
             $variables['elements'] = $elements;
         }
         $variables['title'] = $variables['form']->name;
     } else {
         if (empty($variables['form'])) {
             $variables['form'] = new FormBuilder2_FormModel();
             $variables['brandNewForm'] = true;
             $variables['crumbs'] = array(array('label' => Craft::t('FormBuilder 2'), 'url' => UrlHelper::getUrl('formbuilder2')), array('label' => Craft::t('Forms'), 'url' => UrlHelper::getUrl('formbuilder2/forms')), array('label' => Craft::t('New Form'), 'url' => UrlHelper::getUrl('formbuilder2/forms/new')));
         }
         $variables['title'] = Craft::t('Create a new form');
     }
     $this->renderTemplate('formbuilder2/forms/_edit', $variables);
 }
 /**
  * Edit a Redirect.
  *
  * @param array $variables
  * @throws HttpException
  */
 public function actionEditRedirect(array $variables = array())
 {
     //Get method options
     $variables['methodOptions'] = sproutSeo()->redirects->getMethods();
     //Set title
     $variables['subTitle'] = Craft::t('Create a new redirect');
     // Now let's set up the actual redirect
     if (empty($variables['redirect'])) {
         if (!empty($variables['redirectId'])) {
             //Set title
             $variables['subTitle'] = Craft::t('Edit redirect');
             $variables['redirect'] = sproutSeo()->redirects->getRedirectById($variables['redirectId']);
             if (!$variables['redirect']) {
                 throw new HttpException(404);
             }
         } else {
             $variables['redirect'] = new SproutSeo_RedirectModel();
         }
     }
     // Set the "Continue Editing" URL
     $variables['continueEditingUrl'] = 'sproutseo/redirects/{id}';
     // Breadcrumbs
     $variables['crumbs'] = array(array('label' => Craft::t('Redirects'), 'url' => UrlHelper::getUrl('redirects')));
     $this->renderTemplate('sproutseo/redirects/_edit', $variables);
 }
 /**
  * Edit an asset source.
  *
  * @param array $variables
  *
  * @throws HttpException
  * @return null
  */
 public function actionEditSource(array $variables = array())
 {
     if (empty($variables['source'])) {
         if (!empty($variables['sourceId'])) {
             $variables['source'] = craft()->assetSources->getSourceById($variables['sourceId']);
             if (!$variables['source']) {
                 throw new HttpException(404);
             }
             $variables['sourceType'] = craft()->assetSources->populateSourceType($variables['source']);
         } else {
             $variables['source'] = new AssetSourceModel();
             $variables['sourceType'] = craft()->assetSources->getSourceType('Local');
         }
     }
     if (empty($variables['sourceType'])) {
         $variables['sourceType'] = craft()->assetSources->populateSourceType($variables['source']);
     }
     if (craft()->getEdition() == Craft::Pro) {
         $sourceTypes = craft()->assetSources->getAllSourceTypes();
         $variables['sourceTypes'] = AssetSourceTypeVariable::populateVariables($sourceTypes);
     }
     $variables['isNewSource'] = !$variables['source']->id;
     if ($variables['isNewSource']) {
         $variables['title'] = Craft::t('Create a new asset source');
     } else {
         $variables['title'] = $variables['source']->name;
     }
     $variables['crumbs'] = array(array('label' => Craft::t('Settings'), 'url' => UrlHelper::getUrl('settings')), array('label' => Craft::t('Assets'), 'url' => UrlHelper::getUrl('settings/assets')), array('label' => Craft::t('Asset Sources'), 'url' => UrlHelper::getUrl('settings/assets')));
     $variables['tabs'] = array('settings' => array('label' => Craft::t('Settings'), 'url' => '#assetsource-settings'), 'fieldlayout' => array('label' => Craft::t('Field Layout'), 'url' => '#assetsource-fieldlayout'));
     $this->renderTemplate('settings/assets/sources/_edit', $variables);
 }
 /**
  * Edit an device.
  *
  * @param array $variables
  *
  * @throws HttpException
  */
 public function actionEditDevice(array $variables = array())
 {
     if (!empty($variables['appHandle'])) {
         $variables['app'] = craft()->pushNotifications_apps->getAppByHandle($variables['appHandle']);
     } elseif (!empty($variables['appId'])) {
         $variables['app'] = craft()->pushNotifications_apps->getAppById($variables['appId']);
     }
     if (empty($variables['app'])) {
         throw new HttpException(404);
     }
     // Now let's set up the actual device
     if (empty($variables['device'])) {
         if (!empty($variables['deviceId'])) {
             $variables['device'] = craft()->pushNotifications_devices->getDeviceById($variables['deviceId']);
             if (!$variables['device']) {
                 throw new HttpException(404);
             }
         } else {
             $variables['device'] = new PushNotifications_DeviceModel();
             $variables['device']->appId = $variables['app']->id;
         }
     }
     if (!$variables['device']->id) {
         $variables['title'] = Craft::t('Create a new device');
     } else {
         $variables['title'] = $variables['device']->title;
     }
     // Breadcrumbs
     $variables['crumbs'] = array(array('label' => Craft::t('Push Notifications'), 'url' => UrlHelper::getUrl('pushnotifications')), array('label' => $variables['app']->name, 'url' => UrlHelper::getUrl('pushnotifications')));
     // Set the "Continue Editing" URL
     $variables['continueEditingUrl'] = 'pushnotifications/devices/' . $variables['app']->handle . '/{id}';
     // Render the template!
     $this->renderTemplate('pushnotifications/devices/_edit', $variables);
 }
 public function init()
 {
     parent::init();
     $user = craft()->userSession->getUser();
     if (craft()->request->isCpRequest()) {
         $allNavs = craft()->cpNav_nav->getDefaultOrUserNavs();
         if ($user) {
             if ($this->getSettings()->showQuickAddMenu && $user->can('quickAddMenu')) {
                 $this->insertJsForQuickMenuAdd($allNavs);
             }
         }
         if ($allNavs) {
             foreach ($allNavs as $nav) {
                 // Allow links to be opened in new window - insert some small JS
                 if ($nav->newWindow) {
                     $this->insertJsForNewWindow($nav);
                 }
                 // Check to ensure this page is enabled - otherwise simply redirect to first available menu item
                 if (craft()->request->path == $nav->url) {
                     if (!$nav->enabled) {
                         $enabledNavs = craft()->cpNav_nav->getAllNavsByAttributes(array('enabled' => true));
                         // We're on a page that's disabled - redirect to the first enabled one!
                         craft()->request->redirect(UrlHelper::getUrl($enabledNavs[0]->url));
                     }
                 } else {
                     if (craft()->request->path == preg_replace(sprintf('/^(https?:\\/\\/)?(%s)?\\/?%s\\//', preg_quote(craft()->getSiteUrl(''), '/'), preg_quote(craft()->config->get('cpTrigger')), '/'), '', $nav->url) && $nav->enabled && $nav->manualNav) {
                         // Add some JavaScript to correct the selected nav item for manually added navigation items.
                         // Have to do this with JavaScript for now as the nav item selection is made after the modifyCpNav hook.
                         $this->insertJsForManualNavSelection($nav);
                     }
                 }
             }
         }
     }
 }
 public function getInputHtml($name, $value)
 {
     // Include JavaScript & CSS
     craft()->templates->includeJsResource('simplemeta/simple.meta.js');
     craft()->templates->includeCssResource('simplemeta/simple.meta.css');
     // Whether any assets sources exist
     $sources = craft()->assets->findFolders();
     $variables['assetsSourceExists'] = count($sources);
     // URL to create a new assets source
     $variables['newAssetsSourceUrl'] = UrlHelper::getUrl('settings/assets/sources/new');
     if (!empty($value)) {
         $simpleMetaModel = SimpleMeta_SimpleMetaModel::populateModel($value);
     } else {
         $simpleMetaModel = new SimpleMeta_SimpleMetaModel();
         $simpleMetaModel->handle = $name;
     }
     // Set assets
     $simplemetaAssets = array('socialOGImage' => $simpleMetaModel->socialOGImageId, 'socialTwitterGalleryImages' => $simpleMetaModel->socialTwitterGalleryImagesId, 'socialTwitterPhoto' => $simpleMetaModel->socialTwitterPhotoId, 'socialTwitterProductImage' => $simpleMetaModel->socialTwitterProductImageId, 'socialTwitterSummaryImage' => $simpleMetaModel->socialTwitterSummaryImageId, 'socialTwitterSummaryLargeImage' => $simpleMetaModel->socialTwitterSummaryLargeImageId);
     foreach ($simplemetaAssets as $key => $value) {
         if ($value) {
             $asset = craft()->elements->getElementById($value);
             $variables[$key . 'Elements'] = array($asset);
             $variables[$key . 'Id'] = $asset->id;
         } else {
             $variables[$key . 'Elements'] = array();
             $variables[$key . 'Id'] = "";
         }
     }
     // Set element type
     $variables['elementType'] = craft()->elements->getElementType(ElementType::Asset);
     $data = array_merge($simpleMetaModel->getAttributes(), $variables);
     return craft()->templates->render('simplemeta/input', $data);
 }
Esempio n. 7
0
 /**
  * Add additional information to the image after the model has fetched
  * an image from the database
  */
 public function afterFetch()
 {
     $this->resizedUrl = $this->getDI()->get('imageLocation') . $this->id . '_1024.jpg';
     $this->thumbUrl = $this->getDI()->get('imageLocation') . $this->id . '_thumb.jpg';
     $this->originalUrl = str_replace(UrlHelper::getUrl($this->getDI()), 'http://hack4dk.dr.dk', $this->url);
     $this->imagePageUrl = UrlHelper::getUrl($this->getDI()) . '?image_id=' . $this->id;
 }
 /**
  * Returns the URL to a specific page
  *
  * @param int $page
  *
  * @return string|null
  */
 public function getPageUrl($page)
 {
     if ($page >= 1 && $page <= $this->totalPages) {
         $path = craft()->request->getPath();
         $params = array();
         if ($page != 1) {
             $pageTrigger = craft()->config->get('pageTrigger');
             if (!is_string($pageTrigger) || !strlen($pageTrigger)) {
                 $pageTrigger = 'p';
             }
             // Is this query string-based pagination?
             if ($pageTrigger[0] === '?') {
                 $pageTrigger = trim($pageTrigger, '?=');
                 if ($pageTrigger === 'p') {
                     // Avoid conflict with the main 'p' param
                     $pageTrigger = 'pg';
                 }
                 $params = array($pageTrigger => $page);
             } else {
                 if ($path) {
                     $path .= '/';
                 }
                 $path .= $pageTrigger . $page;
             }
         }
         return UrlHelper::getUrl($path, $params);
     }
 }
 public function actionEditForm(array $variables = array())
 {
     if (!empty($variables['formId'])) {
         if (empty($variables['form'])) {
             $variables['form'] = craft()->formerly_forms->getFormById($variables['formId']);
             $variables['questions'] = craft()->formerly_forms->getQuestionsByFormId($variables['formId'], 'id');
             if (!$variables['form']) {
                 throw new HttpException(404);
             }
         }
         $variables['title'] = $variables['form']->name;
     } else {
         if (empty($variables['form'])) {
             $user = craft()->userSession->getUser();
             $form = new Formerly_FormModel();
             $form->emails = array(array('to' => '{email}', 'from' => $user->email, 'subject' => 'Thank you for your enquiry', 'body' => "<p>Hi {name},</p>\n<p>Thanks for your enquiry! We'll get back to you shortly.</p>\n<p>{$user->name}</p>"), array('to' => $user->email, 'from' => '{email}', 'subject' => 'Website enquiry', 'body' => ''));
             $questions = array('new_1' => new Formerly_QuestionModel(array('name' => 'Name', 'handle' => 'name', 'type' => Formerly_QuestionType::PlainText, 'required' => true)), 'new_2' => new Formerly_QuestionModel(array('name' => 'Email', 'handle' => 'email', 'type' => Formerly_QuestionType::Email, 'required' => true)), 'new_3' => new Formerly_QuestionModel(array('name' => 'Message', 'handle' => 'message', 'type' => Formerly_QuestionType::MultilineText, 'required' => true)));
             $variables['form'] = $form;
             $variables['questions'] = $questions;
         }
         $variables['title'] = Craft::t('New form');
     }
     $variables['crumbs'] = array(array('label' => Craft::t('Formerly'), 'url' => UrlHelper::getUrl('formerly')));
     $this->renderTemplate('formerly/forms/_edit', $variables);
 }
Esempio n. 10
0
 /**
  * Returns the field's input HTML.
  *
  * @param string $name
  * @param mixed  $value
  * @return string
  */
 public function getInputHtml($name, $value)
 {
     $id = craft()->templates->formatInputId($name);
     craft()->templates->includeCssResource('twitter/css/tweet.css');
     craft()->templates->includeJsResource('twitter/js/TweetInput.js');
     craft()->templates->includeJs('new TweetInput("' . craft()->templates->namespaceInputId($id) . '");');
     $tweet = $value;
     $html = "";
     if ($tweet && isset($tweet['id_str'])) {
         $url = 'https://twitter.com/' . $tweet['user']['screen_name'] . '/status/' . $tweet['id_str'];
         if (craft()->request->isSecureConnection()) {
             $profileImageUrl = $tweet['user']['profile_image_url_https'];
         } else {
             $profileImageUrl = $tweet['user']['profile_image_url'];
         }
         if (craft()->twitter_plugin->checkDependencies()) {
             $html .= '<div class="tweet-preview">' . '<div class="tweet-image" style="background-image: url(' . $profileImageUrl . ');"></div> ' . '<div class="tweet-user">' . '<span class="tweet-user-name">' . $tweet['user']['name'] . '</span> ' . '<a class="tweet-user-screenname light" href="http://twitter.com/' . $tweet['user']['screen_name'] . '" target="_blank">@' . $tweet['user']['screen_name'] . '</a>' . '</div>' . '<div class="tweet-text">' . $tweet['text'] . '</div>' . '</div>';
         }
     } else {
         $url = $value;
         $preview = '';
     }
     if (!craft()->twitter_plugin->checkDependencies()) {
         $html .= '<p class="light">' . Craft::t("Twitter plugin is not configured properly. Please check {url} for more informations.", array('url' => Craft::t('<a href="' . UrlHelper::getUrl('twitter/settings') . '">{title}</a>', array('title' => 'Twitter plugin settings')))) . '</p>';
     }
     return '<div class="tweet">' . craft()->templates->render('_includes/forms/text', array('id' => $id, 'name' => $name, 'value' => $url, 'placeholder' => Craft::t('Enter a tweet URL or ID'))) . '<div class="spinner hidden"></div>' . $html . '</div>';
 }
 /**
  * Check requirements
  *
  * @return bool
  */
 public function checkRequirements($redirect = false)
 {
     // dependencies
     $plugin = craft()->plugins->getPlugin('analytics');
     $pluginDependencies = $plugin->getPluginDependencies();
     if (count($pluginDependencies) > 0) {
         if ($redirect) {
             $url = UrlHelper::getUrl('analytics/install');
             craft()->request->redirect($url);
         }
         return false;
     } else {
         // oauth
         $provider = craft()->oauth->getProvider('google');
         if ($provider && $provider->isConfigured()) {
             $token = craft()->analytics_oauth->getToken();
             if ($token) {
                 return true;
             } else {
                 return false;
             }
         } else {
             if ($redirect) {
                 $url = UrlHelper::getUrl('analytics/install');
                 craft()->request->redirect($url);
             }
             return false;
         }
     }
 }
Esempio n. 12
0
 /**
  * Get the sections of the CP.
  *
  * @return array
  */
 public function nav($iconSize = 32)
 {
     $nav['dashboard'] = array('label' => Craft::t('Dashboard'), 'icon' => 'gauge');
     if (craft()->sections->getTotalEditableSections()) {
         $nav['entries'] = array('label' => Craft::t('Entries'), 'icon' => 'section');
     }
     $globals = craft()->globals->getEditableSets();
     if ($globals) {
         $nav['globals'] = array('label' => Craft::t('Globals'), 'url' => 'globals/' . $globals[0]->handle, 'icon' => 'globe');
     }
     if (craft()->categories->getEditableGroupIds()) {
         $nav['categories'] = array('label' => Craft::t('Categories'), 'icon' => 'categories');
     }
     if (craft()->assetSources->getTotalViewableSources()) {
         $nav['assets'] = array('label' => Craft::t('Assets'), 'icon' => 'assets');
     }
     if (craft()->getEdition() == Craft::Pro && craft()->userSession->checkPermission('editUsers')) {
         $nav['users'] = array('label' => Craft::t('Users'), 'icon' => 'users');
     }
     // Add any Plugin nav items
     $plugins = craft()->plugins->getPlugins();
     foreach ($plugins as $plugin) {
         if ($plugin->hasCpSection()) {
             $pluginHandle = $plugin->getClassHandle();
             if (craft()->userSession->checkPermission('accessPlugin-' . $pluginHandle)) {
                 $lcHandle = StringHelper::toLowerCase($pluginHandle);
                 $iconPath = craft()->path->getPluginsPath() . $lcHandle . '/resources/icon-mask.svg';
                 if (IOHelper::fileExists($iconPath)) {
                     $iconSvg = IOHelper::getFileContents($iconPath);
                 } else {
                     $iconSvg = false;
                 }
                 $nav[$lcHandle] = array('label' => $plugin->getName(), 'iconSvg' => $iconSvg);
             }
         }
     }
     if (craft()->userSession->isAdmin()) {
         $nav['settings'] = array('label' => Craft::t('Settings'), 'icon' => 'settings');
     }
     // Allow plugins to modify the nav
     craft()->plugins->call('modifyCpNav', array(&$nav));
     // Figure out which item is selected, and normalize the items
     $firstSegment = craft()->request->getSegment(1);
     if ($firstSegment == 'myaccount') {
         $firstSegment = 'users';
     }
     foreach ($nav as $handle => &$item) {
         if (is_string($item)) {
             $item = array('label' => $item);
         }
         $item['sel'] = $handle == $firstSegment;
         if (isset($item['url'])) {
             $item['url'] = UrlHelper::getUrl($item['url']);
         } else {
             $item['url'] = UrlHelper::getUrl($handle);
         }
     }
     return $nav;
 }
 public function getSettingsUrl()
 {
     if ($this->isPluginEnabled()) {
         return UrlHelper::getUrl('/golive/settings');
     } else {
         return false;
     }
 }
 /**
  * View Submission Link in Elements Table
  *
  */
 public function viewEntryLinkOnElementsTable()
 {
     $entry = craft()->formBuilder2_entry->getSubmissionById($this->id);
     // url('formbuilder2/forms/' ~ form.id ~ '/edit')
     $url = UrlHelper::getUrl('formbuilder2/entries/' . $this->id . '/edit');
     $link = '<a href="' . $url . '" class="view-submission">' . Craft::t('View Submission') . '</a>';
     $this->__set('submission', $link);
     return $this;
 }
 /**
  * Get Field Groups to add a field to.
  *
  * @return array
  */
 public function newFieldInGroup()
 {
     $commands = array();
     $groups = craft()->fields->getAllGroups();
     foreach ($groups as $group) {
         $commands[] = array('name' => $group->name, 'url' => UrlHelper::getUrl('settings/fields/new?groupId=' . $group->id));
     }
     return $commands;
 }
 /**
  * Get all available sections to add a new entry to.
  *
  * @return array
  */
 public function newEntry()
 {
     $commands = array();
     $availableSections = craft()->sections->getEditableSections();
     foreach ($availableSections as $section) {
         if ($section->type != SectionType::Single) {
             $commands[] = array('name' => $section->name, 'url' => UrlHelper::getUrl('entries/' . $section->handle . '/new'));
         }
     }
     return $commands;
 }
 /**
  * Require OAuth with configured provider
  *
  * @return bool
  */
 public function requireOauth()
 {
     $provider = craft()->oauth->getProvider('google');
     if ($provider && $provider->isConfigured()) {
         return true;
     } else {
         $url = UrlHelper::getUrl('analytics/install');
         craft()->request->redirect($url);
         return false;
     }
 }
 /**
  * View/Edit Builder
  *
  */
 public function actionCreateEditBuilder(array $variables = array())
 {
     if (!empty($variables['navigationId'])) {
         $navigationId = $variables['navigationId'];
     } else {
         craft()->userSession->setError(Craft::t('Invalid Navigation'));
     }
     $variables['title'] = 'Navigation Builder';
     $variables['crumbs'] = array(array('label' => Craft::t('Navigation Builder'), 'url' => UrlHelper::getUrl('navigationbuilder')), array('label' => Craft::t('Builder'), 'url' => UrlHelper::getUrl('navigationbuilder/builder')), array('label' => Craft::t('Primary Name'), 'url' => UrlHelper::getUrl('navigationbuilder/builder/1')));
     $this->renderTemplate('navigationbuilder/builder/_edit', $variables);
 }
Esempio n. 19
0
 /**
  * Returns the URL to a specific page
  *
  * @param int $page
  *
  * @return string|null
  */
 public function getPageUrl($page)
 {
     if ($page >= 1 && $page <= $this->totalPages) {
         $path = craft()->request->getPath();
         if ($page != 1) {
             if ($path) {
                 $path .= '/';
             }
             $path .= craft()->config->get('pageTrigger') . $page;
         }
         return UrlHelper::getUrl($path);
     }
 }
Esempio n. 20
0
 /**
  * Edit an event.
  *
  * @param array $variables
  * @throws HttpException
  */
 public function actionEditEvent(array $variables = array())
 {
     if (!empty($variables['calendarHandle'])) {
         $variables['calendar'] = craft()->events_calendars->getCalendarByHandle($variables['calendarHandle']);
     } else {
         if (!empty($variables['calendarId'])) {
             $variables['calendar'] = craft()->events_calendars->getCalendarById($variables['calendarId']);
         }
     }
     if (empty($variables['calendar'])) {
         throw new HttpException(404);
     }
     // Now let's set up the actual event
     if (empty($variables['event'])) {
         if (!empty($variables['eventId'])) {
             $variables['event'] = craft()->events->getEventById($variables['eventId']);
             if (!$variables['event']) {
                 throw new HttpException(404);
             }
         } else {
             $variables['event'] = new Events_EventModel();
             $variables['event']->calendarId = $variables['calendar']->id;
         }
     }
     // Tabs
     $variables['tabs'] = array();
     foreach ($variables['calendar']->getFieldLayout()->getTabs() as $index => $tab) {
         // Do any of the fields on this tab have errors?
         $hasErrors = false;
         if ($variables['event']->hasErrors()) {
             foreach ($tab->getFields() as $field) {
                 if ($variables['event']->getErrors($field->getField()->handle)) {
                     $hasErrors = true;
                     break;
                 }
             }
         }
         $variables['tabs'][] = array('label' => $tab->name, 'url' => '#tab' . ($index + 1), 'class' => $hasErrors ? 'error' : null);
     }
     if (!$variables['event']->id) {
         $variables['title'] = Craft::t('Create a new event');
     } else {
         $variables['title'] = $variables['event']->title;
     }
     // Breadcrumbs
     $variables['crumbs'] = array(array('label' => Craft::t('Events'), 'url' => UrlHelper::getUrl('events')), array('label' => $variables['calendar']->name, 'url' => UrlHelper::getUrl('events')));
     // Set the "Continue Editing" URL
     $variables['continueEditingUrl'] = 'events/' . $variables['calendar']->handle . '/{id}';
     // Render the template!
     $this->renderTemplate('events/_edit', $variables);
 }
Esempio n. 21
0
 /**
  * @param string|null $path
  * @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();
         // Get the license key status
         $licenseKeyStatus = craft()->et->getLicenseKeyStatus();
         // Invalid license?
         if ($licenseKeyStatus == LicenseKeyStatus::Invalid) {
             $alerts[] = Craft::t('Your license key is invalid.');
         } else {
             if (craft()->hasWrongEdition()) {
                 $alerts[] = Craft::t('You’re running Craft {edition} with a Craft {licensedEdition} license.', array('edition' => craft()->getEditionName(), 'licensedEdition' => craft()->getLicensedEditionName())) . ' <a class="go edition-resolution">' . Craft::t('Resolve') . '</a>';
             }
         }
         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 nowrap" href="' . UrlHelper::getUrl('updates') . '">' . Craft::t('Go to Updates') . '</a>';
                 }
             }
         }
         // Domain mismatch?
         if ($licenseKeyStatus == LicenseKeyStatus::Mismatched) {
             $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="go 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;
         }
     }
     $allPluginAlerts = craft()->plugins->call('getCpAlerts', array($path, $fetch), true);
     foreach ($allPluginAlerts as $pluginAlerts) {
         $alerts = array_merge($alerts, $pluginAlerts);
     }
     return $alerts;
 }
 /**
  * Edit a tag.
  *
  * @param array $variables
  *
  * @throws HttpException
  */
 public function actionEditTag(array $variables = array())
 {
     if (!empty($variables['groupHandle'])) {
         $variables['group'] = craft()->tags->getTagGroupByHandle($variables['groupHandle']);
     } elseif (!empty($variables['groupId'])) {
         $variables['group'] = craft()->tags->getTagGroupById($variables['groupId']);
     }
     if (empty($variables['group'])) {
         throw new HttpException(404);
     }
     // Now let's set up the actual tag
     if (empty($variables['tag'])) {
         if (!empty($variables['tagId'])) {
             $variables['tag'] = craft()->tags->getTagById($variables['tagId'], craft()->locale->id);
             if (!$variables['tag']) {
                 throw new HttpException(404);
             }
         } else {
             $variables['tag'] = new TagModel();
             $variables['tag']->groupId = $variables['group']->id;
         }
     }
     // Tabs
     $variables['tabs'] = array();
     foreach ($variables['group']->getFieldLayout()->getTabs() as $index => $tab) {
         // Do any of the fields on this tab have errors?
         $hasErrors = false;
         if ($variables['tag']->hasErrors()) {
             foreach ($tab->getFields() as $field) {
                 if ($variables['tag']->getErrors($field->getField()->handle)) {
                     $hasErrors = true;
                     break;
                 }
             }
         }
         $variables['tabs'][] = array('label' => $tab->name, 'url' => '#tab' . ($index + 1), 'class' => $hasErrors ? 'error' : null);
     }
     if (!$variables['tag']->id) {
         $variables['title'] = Craft::t('Create a new tag');
     } else {
         $variables['title'] = $variables['tag']->title;
     }
     // Breadcrumbs
     $variables['crumbs'] = array(array('label' => Craft::t('Tag Manager'), 'url' => UrlHelper::getUrl('tagmanager')), array('label' => $variables['group']->name, 'url' => UrlHelper::getUrl('tagmanager')));
     // Set the "Continue Editing" URL
     $variables['continueEditingUrl'] = 'tagmanager/' . $variables['group']->handle . '/{id}';
     // Render the template!
     $this->renderTemplate('tagmanager/_edit', $variables);
 }
 /**
  * Looks up an asset path in the manifest and returns the asset revision's URL.
  *
  * @param string $assetPath
  *
  * @return string
  */
 public function getRevUrl($assetPath = '')
 {
     $manifest = $this->getManifest();
     if ($manifest) {
         if (substr($assetPath, 0, strlen($manifest->manifestFolder)) == $manifest->manifestFolder) {
             $assetPath = substr($assetPath, strlen($manifest->manifestFolder));
         }
         if (array_key_exists($assetPath, $manifest->manifest)) {
             $revAssetPath = $manifest->manifestFolder;
             $revAssetPath .= $manifest->manifest[$assetPath];
             return UrlHelper::getUrl($revAssetPath);
         }
     }
     return UrlHelper::getUrl($assetPath);
 }
 public function actionViewSubmission(array $variables = array())
 {
     if (!empty($variables['submissionId'])) {
         if (empty($variables['submission'])) {
             $variables['submission'] = craft()->formerly_submissions->getSubmissionById($variables['submissionId']);
             if (!$variables['submission']) {
                 throw new HttpException(404);
             }
             $form = $variables['submission']->getForm();
             $variables['crumbs'] = array(array('label' => Craft::t('Formerly'), 'url' => UrlHelper::getUrl('formerly')), array('label' => $form->name, 'url' => UrlHelper::getUrl('formerly')));
         }
     } else {
         throw new HttpException(404);
     }
     $this->renderTemplate('formerly/submissions/_view', $variables);
 }
Esempio n. 25
0
 /**
  * common tasks for all actions
  */
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $this->course_id = $args[0];
     if (!in_array($action, words('apply claim delete order_down order_up'))) {
         $this->redirect($this->url_for('/apply/' . $action));
         return false;
     }
     if (!get_object_type($this->course_id, array('sem'))) {
         throw new Trails_Exception(400);
     }
     $course = Seminar::GetInstance($this->course_id);
     $enrolment_info = $course->getEnrolmentInfo($GLOBALS['user']->id);
     //Ist bereits Teilnehmer/Admin/freier Zugriff -> gleich weiter
     if ($enrolment_info['enrolment_allowed'] && (in_array($enrolment_info['cause'], words('root courseadmin member')) || $enrolment_info['cause'] == 'free_access' && $GLOBALS['user']->id == 'nobody')) {
         $redirect_url = UrlHelper::getUrl('seminar_main.php', array('auswahl' => $this->course_id));
         if (Request::isXhr()) {
             $this->response->add_header('X-Location', $redirect_url);
             $this->render_nothing();
         } else {
             $this->redirect($redirect_url);
         }
         return false;
     }
     //Grundsätzlich verboten
     if (!$enrolment_info['enrolment_allowed']) {
         throw new AccessDeniedException($enrolment_info['description']);
     }
     PageLayout::setTitle($course->getFullname() . " - " . _("Veranstaltungsanmeldung"));
     PageLayout::addSqueezePackage('enrolment');
     if (Request::isXhr()) {
         $this->set_layout(null);
         $this->response->add_header('X-No-Buttons', 1);
         $this->response->add_header('X-Title', PageLayout::getTitle());
         $request = Request::getInstance();
         foreach ($request as $key => $value) {
             $request[$key] = studip_utf8decode($value);
         }
     } else {
         $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
     }
     $this->set_content_type('text/html;charset=windows-1252');
     if (Request::submitted('cancel')) {
         $this->redirect(URLHelper::getURL('dispatch.php/course/details/', array('sem_id' => $this->course_id)));
     }
 }
 public function actionSso()
 {
     craft()->log->removeRoute('WebLogRoute');
     craft()->log->removeRoute('ProfileLogRoute');
     if ($this->ssoEnabled) {
         $customerId = 0;
         $auth_token = '';
         $redirect_url = '';
         $fcsid = craft()->request->getParam("fcsid", "");
         $timestamp = craft()->request->getParam("timestamp", 0) + 60 * 30;
         // valid for 30 minutes
         if (!craft()->userSession->isLoggedIn()) {
             // No member
             if ($this->ssoRequireLogin) {
                 // No guest checkouts allowed, redirect to the sites login page
                 $redirect_url = UrlHelper::getUrl(craft()->config->getLoginPath());
             }
         } else {
             $user = craft()->userSession->getUser();
             $customerId = craft()->foxyCart->getCustomerId($user);
             if ($user && !$customerId) {
                 // Member doesn't have a FoxyCart customer id, see if the member exists on FoxyCart
                 $xml = craft()->foxyCart->api("customer_get", array("customer_email" => $user->email));
                 if ($xml !== false) {
                     $customerId = (string) $xml->customer_id;
                 }
                 if (!$customerId || !$xml) {
                     // Member doesn't exist, create one for FoxyCart
                     $customerId = craft()->foxyCart->updateFoxyCartCustomer($user);
                 }
                 if (!$customerId) {
                     FoxyCartPlugin::log("[sso] User creation failed.", LogLevel::Error);
                     // TODO: What should happen here? A user is logged in, but everything failed to get their current customerId? Would that even happen?
                 } else {
                     // Update the current user's customerId as retrieved from FoxyCart
                     craft()->foxyCart->saveCustomerId($user, $customerId);
                 }
             }
         }
         $auth_token = sha1($customerId . '|' . $timestamp . '|' . $this->apikey);
         $redirect_url = $redirect_url != '' ? $redirect_url : 'https://' . $this->storedomain . '/checkout?fc_auth_token=' . $auth_token . '&fc_customer_id=' . $customerId . '&timestamp=' . $timestamp . '&fcsid=' . $fcsid;
         craft()->request->redirect($redirect_url);
     }
 }
Esempio n. 27
0
 /**
  * Get the sections of the CP.
  *
  * @return array
  */
 public function nav()
 {
     $nav['dashboard'] = array('name' => Craft::t('Dashboard'));
     if (craft()->sections->getTotalEditableSections()) {
         $nav['entries'] = array('name' => Craft::t('Entries'));
     }
     $globals = craft()->globals->getEditableSets();
     if ($globals) {
         $nav['globals'] = array('name' => Craft::t('Globals'), 'url' => 'globals/' . $globals[0]->handle);
     }
     if (craft()->categories->getEditableGroupIds()) {
         $nav['categories'] = array('name' => Craft::t('Categories'));
     }
     if (craft()->assetSources->getTotalViewableSources()) {
         $nav['assets'] = array('name' => Craft::t('Assets'));
     }
     if (craft()->getEdition() == Craft::Pro && craft()->userSession->checkPermission('editUsers')) {
         $nav['users'] = array('name' => Craft::t('Users'));
     }
     // Add any Plugin nav items
     $plugins = craft()->plugins->getPlugins();
     foreach ($plugins as $plugin) {
         if ($plugin->hasCpSection()) {
             if (craft()->userSession->checkPermission('accessPlugin-' . $plugin->getClassHandle())) {
                 $lcHandle = StringHelper::toLowerCase($plugin->getClassHandle());
                 $nav[$lcHandle] = array('name' => $plugin->getName());
             }
         }
     }
     $firstSegment = craft()->request->getSegment(1);
     if ($firstSegment == 'myaccount') {
         $firstSegment = 'users';
     }
     foreach ($nav as $handle => &$item) {
         $item['sel'] = $handle == $firstSegment;
         if (isset($item['url'])) {
             $item['url'] = UrlHelper::getUrl($item['url']);
         } else {
             $item['url'] = UrlHelper::getUrl($handle);
         }
     }
     return $nav;
 }
Esempio n. 28
0
 public function getCpTabs()
 {
     $settings = $this->getPlugin()->settings;
     $tabs = array();
     if ($settings['enabledTabs']) {
         if (in_array('feeds', (array) $settings['enabledTabs']) || $settings['enabledTabs'] == '*') {
             $tabs['feeds'] = array('label' => Craft::t('Feeds'), 'url' => UrlHelper::getUrl('feedme'));
         }
         if (in_array('logs', (array) $settings['enabledTabs']) || $settings['enabledTabs'] == '*') {
             $tabs['logs'] = array('label' => Craft::t('Logs'), 'url' => UrlHelper::getUrl('feedme/logs'));
         }
         if (in_array('help', (array) $settings['enabledTabs']) || $settings['enabledTabs'] == '*') {
             $tabs['help'] = array('label' => Craft::t('Help'), 'url' => UrlHelper::getUrl('feedme/help'));
         }
         if (in_array('settings', (array) $settings['enabledTabs']) || $settings['enabledTabs'] == '*') {
             $tabs['settings'] = array('label' => Craft::t('Settings'), 'url' => UrlHelper::getUrl('settings/plugins/feedme'));
         }
     }
     return $tabs;
 }
Esempio n. 29
0
 /**
  * Get navigations by a given command.
  *
  * @param array $variables
  *
  * @return array
  */
 public function getNavigationsByCommand($variables)
 {
     // We need to know which type
     if (!isset($variables['command'])) {
         return false;
     }
     // Do we have any navigations?
     $navigations = $this->getNavigations();
     if (!$navigations) {
         craft()->amCommand->setReturnMessage(Craft::t('There are no navigations yet.'));
         return false;
     }
     // Return commands based on given command type
     $commands = array();
     $commandType = $variables['command'] == 'settings' ? 'edit' : 'build';
     foreach ($navigations as $navigation) {
         $commands[] = array('name' => $navigation->name, 'url' => UrlHelper::getUrl('amnav/' . $commandType . '/' . $navigation->id));
     }
     return $commands;
 }
 /**
  * Edit a form.
  *
  * @param array $variables
  * @throws HttpException
  * @throws Exception
  */
 public function actionEdit(array $variables = array())
 {
     $variables['brandNewForm'] = false;
     if (!empty($variables['formId'])) {
         if (empty($variables['form'])) {
             $variables['form'] = craft()->applications_forms->getFormById($variables['formId']);
             if (!$variables['form']) {
                 throw new HttpException(404);
             }
         }
         $variables['title'] = $variables['form']->name;
     } else {
         if (empty($variables['form'])) {
             $variables['form'] = new Applications_FormModel();
             $variables['brandNewForm'] = true;
         }
         $variables['title'] = Craft::t('Create a new form');
     }
     $variables['crumbs'] = array(array('label' => Craft::t('Applications'), 'url' => UrlHelper::getUrl('applications')), array('label' => Craft::t('Forms'), 'url' => UrlHelper::getUrl('applications/forms')));
     $this->renderTemplate('applications/forms/_edit', $variables);
 }