/**
  * Updates the CMS fields adding the fields defined in this extension
  * @param {FieldList} $fields Field List that new fields will be added to
  */
 public function updateSettingsFields(FieldList $fields)
 {
     $kapostRefID = $this->owner->KapostRefID;
     if (!empty($kapostRefID)) {
         if (CMSPageSettingsController::has_extension('KapostPageSettingsControllerExtension')) {
             $messageContent = _t('KapostSiteTreeExtension.KAPOST_CONTENT_WARNING_RO', '_This Page\'s content is being populated by Kapost, some fields are not editable.');
         } else {
             $messageContent = _t('KapostSiteTreeExtension.KAPOST_CONTENT_WARNING', '_This Page\'s content is being populated by Kapost.');
         }
         //Edit in kapost link
         $kapostBase = KapostAdmin::config()->kapost_base_url;
         if (!empty($kapostBase)) {
             $messageContent .= ' <a href="' . Controller::join_links($kapostBase, 'posts', $kapostRefID) . '" target="_blank">' . _t('KapostSiteTreeExtension.KAPOST_CONTENT_EDIT_LABEL', '_Click here to edit in Kapost') . '</a>';
         }
         $fields->insertBefore(new LiteralField('KapostContentWarning', '<div class="message warning">' . $messageContent . '</div>'), 'ClassName');
         //Detect Incoming Changes
         if (Permission::check('CMS_ACCESS_KapostAdmin')) {
             $incoming = KapostObject::get()->filter('KapostRefID', Convert::raw2sql($kapostRefID));
             if ($incoming->count() >= 1) {
                 $link = Controller::join_links(AdminRootController::config()->url_base, KapostAdmin::config()->url_segment, 'KapostObject/EditForm/field/KapostObject/item', $incoming->first()->ID, 'edit');
                 $messageContent = _t('KapostSiteTreeExtension.KAPOST_INCOMING', '_There are incoming changes from Kapost waiting for this page.') . ' ' . '<a href="' . $link . '" class="cms-panel-link">' . _t('KapostSiteTreeExtension.KAPOST_INCOMING_VIEW', '_Click here to view the changes') . '</a>';
                 $fields->insertBefore(new LiteralField('KapostIncomingWarning', '<div class="message warning">' . $messageContent . '</div>'), 'ClassName');
             }
         }
     }
 }
 public function init()
 {
     if (!Controller::has_curr()) {
         return;
     }
     /* @var $ctrl Controller */
     $ctrl = Controller::curr();
     /* @ var $req SS_HTTPRequest */
     $req = $ctrl->getRequest();
     // Otherwise it will get excluded if it does not have access to all subsites...
     if (class_exists('Subsite')) {
         Subsite::$disable_subsite_filter = true;
     }
     $base = AdminRootController::config()->url_base;
     $defaultPanel = AdminRootController::config()->default_panel;
     $currentSegment = $req->getURL();
     // We will fail if we are redirected to a panel without the proper permission
     if (($currentSegment == $base || $currentSegment == $base . '/pages') && $defaultPanel == 'CMSPagesController' && !Permission::check('CMS_ACCESS_CMSMain')) {
         // Instead, let's redirect to something we can access
         if (Permission::check('CMS_ACCESS')) {
             $member = Member::currentUser();
             $permissions = Permission::permissions_for_member($member->ID);
             foreach ($permissions as $permission) {
                 if (strpos($permission, 'CMS_ACCESS_') === 0) {
                     $class = str_replace('CMS_ACCESS_', '', $permission);
                     $segment = Config::inst()->get($class, 'url_segment');
                     $url = Director::absoluteBaseURL() . $base . '/' . $segment;
                     header('Location:' . $url);
                     exit;
                 }
             }
         }
     }
     if (class_exists('Subsite')) {
         Subsite::$disable_subsite_filter = false;
     }
 }
Exemplo n.º 3
0
 /**
  * Given a successful login, tell the parent frame to close the dialog
  *
  * @return SS_HTTPResponse
  */
 public function success()
 {
     // Ensure member is properly logged in
     if (!Member::currentUserID()) {
         return $this->redirectToExternalLogin();
     }
     // Get redirect url
     $controller = $this->getResponseController(_t('CMSSecurity.SUCCESS', 'Success'));
     $backURLs = array($this->getRequest()->requestVar('BackURL'), Session::get('BackURL'), Director::absoluteURL(AdminRootController::config()->url_base, true));
     foreach ($backURLs as $backURL) {
         if ($backURL && Director::is_site_url($backURL)) {
             break;
         }
     }
     // Show login
     $controller = $controller->customise(array('Content' => _t('CMSSecurity.SUCCESSCONTENT', '<p>Login success. If you are not automatically redirected ' . '<a target="_top" href="{link}">click here</a></p>', 'Login message displayed in the cms popup once a user has re-authenticated themselves', array('link' => $backURL))));
     return $controller->renderWith($this->getTemplatesFor('success'));
 }