Esempio n. 1
0
 /**
  * getIndexPage
  *
  * Returns the page for the given type
  * defaults to the site homepage
  *
  * @access public
  * @return URL of page by index type
  */
 function getIndexPage($pIndexType = NULL)
 {
     global $userlib, $gBitUser, $gBitSystem;
     $pIndexType = !is_null($pIndexType) ? $pIndexType : $this->getConfig("bit_index");
     $url = '';
     if ($pIndexType == 'role_home') {
         // See if we have first a user assigned default group id, and second a group default system preference
         if (!$gBitUser->isRegistered() && ($role_home = $gBitUser->getHomeRole(ANONYMOUS_TEAM_ID))) {
         } elseif (@$this->verifyId($gBitUser->mInfo['default_role_id']) && ($role_home = $gBitUser->getHomeRole($gBitUser->mInfo['default_role_id']))) {
         } elseif ($this->getConfig('default_home_role') && ($role_home = $gBitUser->getHomeRole($this->getConfig('default_home_role')))) {
         }
         if (!empty($role_home)) {
             if ($this->verifyId($role_home)) {
                 $url = BIT_ROOT_URL . "index.php" . (!empty($role_home) ? "?content_id=" . $role_home : "");
                 // wiki dependence - NO bad idea
                 // } elseif( strpos( $group_home, '/' ) === FALSE ) {
                 // 	$url = BitPage::getDisplayUrl( $group_home );
             } elseif (strpos($role_home, 'http://') === FALSE) {
                 $url = BIT_ROOT_URL . $role_home;
             } else {
                 $url = $role_home;
             }
         }
     } elseif ($pIndexType == 'group_home') {
         // See if we have first a user assigned default group id, and second a group default system preference
         if (!$gBitUser->isRegistered() && ($group_home = $gBitUser->getGroupHome(ANONYMOUS_GROUP_ID))) {
         } elseif (@$this->verifyId($gBitUser->mInfo['default_group_id']) && ($group_home = $gBitUser->getGroupHome($gBitUser->mInfo['default_group_id']))) {
         } elseif ($this->getConfig('default_home_group') && ($group_home = $gBitUser->getGroupHome($this->getConfig('default_home_group')))) {
         }
         if (!empty($group_home)) {
             if ($this->verifyId($group_home)) {
                 $url = BIT_ROOT_URL . "index.php" . (!empty($group_home) ? "?content_id=" . $group_home : "");
                 // wiki dependence - NO bad idea
                 // } elseif( strpos( $group_home, '/' ) === FALSE ) {
                 // 	$url = BitPage::getDisplayUrl( $group_home );
             } elseif (strpos($group_home, 'http://') === FALSE) {
                 $url = BIT_ROOT_URL . $group_home;
             } else {
                 $url = $group_home;
             }
         }
     } elseif ($pIndexType == 'my_page' || $pIndexType == 'my_home' || $pIndexType == 'user_home') {
         // TODO: my_home is deprecated, but was the default for BWR1. remove in DILLINGER - spiderr
         if ($gBitUser->isRegistered()) {
             if (!$gBitUser->isRegistered()) {
                 $url = USERS_PKG_URL . 'login.php';
             } else {
                 if ($pIndexType == 'my_page') {
                     $url = $gBitSystem->getConfig('users_login_homepage', USERS_PKG_URL . 'my.php');
                     if ($url != USERS_PKG_URL . 'my.php' && strpos($url, 'http://') === FALSE) {
                         // the safe assumption is that a custom path is a subpath of the site
                         // append the root url unless we have a fully qualified uri
                         $url = BIT_ROOT_URL . $url;
                     }
                 } elseif ($pIndexType == 'user_home') {
                     $url = $gBitUser->getDisplayUrl();
                 } else {
                     $users_homepage = $gBitUser->getPreference('users_homepage');
                     if (isset($users_homepage) && !empty($users_homepage)) {
                         if (strpos($users_homepage, '/') === FALSE) {
                             $url = BitPage::getDisplayUrlFromHash(array('title' => $users_homepage));
                         } else {
                             $url = $users_homepage;
                         }
                     }
                 }
             }
         } else {
             $url = USERS_PKG_URL . 'login.php';
         }
     } elseif (in_array($pIndexType, array_keys($gBitSystem->mPackages))) {
         $work = strtoupper($pIndexType) . '_PKG_URL';
         if (defined("{$work}")) {
             $url = constant($work);
         }
         /* this was commented out with the note that this can send requests to inactive packages -
          * that should only happen if the admin chooses to point to an inactive pacakge.
          * commenting this out however completely breaks the custom uri home page feature, so its
          * turned back on and caviate admin - if the problem is more severe than it seems then
          * get in touch on irc and we'll work out a better solution than commenting things on and off -wjames5
          */
     } elseif (!empty($pIndexType)) {
         $url = BIT_ROOT_URL . $pIndexType;
     }
     // if no special case was matched above, default to users' my page
     if (empty($url)) {
         if ($this->isPackageActive('wiki')) {
             $url = WIKI_PKG_URL;
         } elseif (!$gBitUser->isRegistered()) {
             $url = USERS_PKG_URL . 'login.php';
         } else {
             $url = USERS_PKG_URL . 'my.php';
         }
     }
     if (strpos($url, 'http://') === FALSE) {
         $url = preg_replace("#//#", "/", $url);
     }
     return $url;
 }
Esempio n. 2
0
            // registration login, fake the cookie so the session gets updated properly.
            if (empty($_COOKIE[$gBitUser->getSiteCookieName()])) {
                $_COOKIE[$gBitUser->getSiteCookieName()] = session_id();
            }
            // login with email since login is not technically required in the form, as it can be auto generated during store
            $afterRegDefault = $newUser->login($reg['email'], $reg['password'], FALSE, FALSE);
            $url = $gBitSystem->getConfig('after_reg_url') ? BIT_ROOT_URI . $gBitSystem->getConfig('after_reg_url') : $afterRegDefault;
            // return to referring page
            if (!empty($_SESSION['returnto'])) {
                $url = $_SESSION['returnto'];
                // forward to group post-registration page
            } elseif (!empty($_REQUEST['group']) && !empty($groupInfo['after_registration_page'])) {
                if ($newUser->verifyId($groupInfo['after_registration_page'])) {
                    $url = BIT_ROOT_URI . "index.php?content_id=" . $groupInfo['after_registration_page'];
                } elseif (strpos($groupInfo['after_registration_page'], '/') === FALSE) {
                    $url = BitPage::getDisplayUrlFromHash($groupInfo['after_registration_page']);
                } else {
                    $url = $groupInfo['after_registration_page'];
                }
            }
            header('Location: ' . $url);
            exit;
        }
    } else {
        $gBitSystem->setHttpStatus(HttpStatusCodes::HTTP_BAD_REQUEST);
        $gBitSmarty->assignByRef('errors', $newUser->mErrors);
    }
    $gBitSmarty->assignByRef('reg', $reg);
} else {
    if ($gBitSystem->isFeatureActive('custom_user_fields')) {
        $fields = explode(',', $gBitSystem->getConfig('custom_user_fields'));
Esempio n. 3
0
 /**
  * Returns HTML link to display a page if it exists, or to create if not
  * @param pExistsHash the hash that was returned by LibertyContent::pageExists
  * @return the link to display the page.
  */
 public static function getPageLink($pLinkText = NULL, $pMixed = NULL, $pAnchor = NULL)
 {
     global $gBitSystem, $gBitUser;
     $ret = $pLinkText;
     if ($gBitSystem->isPackageActive('wiki')) {
         if (!empty($pMixed) && is_array($pMixed)) {
             if (is_array(current($pMixed))) {
                 $exists = $pMixed[0];
                 $multiple = TRUE;
             } else {
                 $exists = $pMixed;
                 $multiple = FALSE;
             }
             // we have a multi-demensional array (likely returned from LibertyContent::pageExists() ) - meaning we potentially have multiple pages with the same name
             if ($multiple) {
                 $desc = tra('Multiple pages with this name');
             } else {
                 $desc = empty($exists['summary']) ? $exists['title'] : $exists['summary'];
             }
             $ret = '<a title="' . htmlspecialchars($desc) . '" href="' . BitPage::getDisplayUrlFromHash($exists) . '">' . htmlspecialchars($exists['title']) . '</a>';
         } else {
             if ($gBitUser->hasPermission('p_wiki_create_page')) {
                 $ret = '<a title="' . tra("Create the page") . ': ' . htmlspecialchars($pLinkText) . '" href="' . WIKI_PKG_URL . 'edit.php?page=' . urlencode($pLinkText) . '" class="create">' . htmlspecialchars($pLinkText) . '</a>';
             } else {
                 $ret = $pLinkText;
             }
         }
     }
     return $ret;
 }