/**
  * The namedContent mechanism for our skin. Here is the catalog:
  * 
  * mainMenu - An associative array of links ('link name' => 'link url') for the header area.
  * copyright - a copyright notice, as a string.
  *
  */
 function namedContent($name, $options = NULL)
 {
     switch ($name) {
         case 'mainMenu':
             return array('Widget Examples Reference' => WFRequestController::WFURL('examples/widgets/toc'), 'Email' => WFRequestController::WFURL('examples/emailform'), 'phpinfo' => WFRequestController::WFURL('examples/phpinfo'), 'Skin Info' => WFRequestController::WFURL('examples/skininfo'));
             break;
         case 'copyright':
             return "Copyright (c) 2005 Open Development. All Rights Reserved.";
             break;
     }
 }
示例#2
0
 /**
  * The namedContent mechanism for our skin. Here is the catalog:
  * 
  * mainMenu - An associative array of links ('link name' => 'link url') for the header area.
  * copyright - a copyright notice, as a string.
  *
  */
 function namedContent($name, $options = NULL)
 {
     switch ($name) {
         case 'mainMenu':
             return array('Widget Examples Reference' => WFRequestController::WFURL('examples/widgets/toc'), 'Email' => WFRequestController::WFURL('examples/emailform'), 'phpinfo' => WFRequestController::WFURL('examples/phpinfo'), 'Skin Info' => WFRequestController::WFURL('examples/skininfo'));
             break;
         case 'copyright':
             return "© 2005-" . date('Y') . " Alan Pinstein. All Rights Reserved.";
             break;
     }
 }
示例#3
0
 /**
  *  @todo Build a resource plugin that creates the {WFLabel id="XXX"} on the fly so we can use bindings etc.
  *  @todo also eventually we will have a convention for calling certain methods to get metadata about all discoverable properties.
  */
 function browse_PageDidLoad($page, $params)
 {
     $tName = $params['objectName'];
     try {
         $tMap = $this->propelDBMap->getTable($tName);
     } catch (Exception $e) {
         header("Location: " . WFRequestController::WFURL($this->invocation()->modulePath(), 'objects'));
         exit;
     }
     $peerMethod = $tMap->getPhpName() . "Peer";
     // set up paginator; query for data
     // set up sort links
     $cols = array();
     $sortOptions = array();
     $defaultSortKeys = array();
     $dynamicWidgetIDs = array();
     $primaryKeys = array();
     foreach ($tMap->getColumns() as $col) {
         $cols[$col->getColumnName()] = $col->getPhpName();
         $sortOptions['+' . $col->getFullyQualifiedName()] = $col->getPhpName();
         $sortOptions['-' . $col->getFullyQualifiedName()] = $col->getPhpName();
         if ($col->isPrimaryKey()) {
             $defaultSortKeys[] = '+' . $col->getFullyQualifiedName();
             $primaryKeys[] = $col->getPhpName();
         }
         // create sort widget
         $sw = new WFPaginatorSortLink("sortLink_" . $col->getPhpName(), $page);
         $sw->setPaginator($this->paginator);
         $sw->setValue($col->getFullyQualifiedName());
         $dynamicWidgetIDs[$col->getPhpName()]['sortLink'] = $sw->id();
         // create label widget via WFDynamic
         $lw = new WFDynamic("label_" . $col->getPhpName(), $page);
         $lw->setWidgetClass('WFLabel');
         $lw->setArrayController($this->records);
         $lw->setSimpleBindKeyPath($col->getPhpName());
         $labelConfig = array('ellipsisAfterChars' => array('custom' => array('iterate' => false, 'value' => 50)));
         $lw->setWidgetConfig($labelConfig);
         $dynamicWidgetIDs[$col->getPhpName()]['label'] = $lw->id();
     }
     $this->paginator->setSortOptions($sortOptions);
     $this->paginator->setDefaultSortKeys($defaultSortKeys);
     $this->paginator->setDataDelegate(new WFPagedPropelQuery(new Criteria(), $peerMethod));
     $this->paginator->setPaginatorState($params['paginatorState']);
     $result = $this->paginator->currentItems();
     // set up controller
     $this->records->setClass($tMap->getPhpName());
     $this->records->setClassIdentifiers($primaryKeys);
     $this->records->setContent($result);
     $page->assign('dynamicWidgetIDs', $dynamicWidgetIDs);
     $page->assign('tableMap', $tMap);
     $page->assign('columns', $cols);
     $page->assign('objects', $result);
     $this->browseTableName = $tMap->getName();
 }
示例#4
0
 function promptLogin_doLogin_Action($page)
 {
     $ac = WFAuthorizationManager::sharedAuthorizationManager();
     $ok = $ac->login($page->outlet('username')->value(), $page->outlet('password')->value());
     if ($ok) {
         if ($page->outlet('continueURL')->value()) {
             header("Location: " . base64_decode($page->outlet('continueURL')->value()));
         } else {
             header("Location: " . WFRequestController::WFURL('login', 'showLoginSuccess'));
         }
         exit;
     } else {
         $page->addError(new WFError("Login username or password is not valid."));
     }
 }
示例#5
0
 /**
  *  Execute the checking of security clearance for the user and the module.
  *
  *  NOTE: This function may issue an HTTP 302 and redirect the user to the login page, then halt script execution.
  *
  *  @throws WFException if anything unexpected happens.
  */
 private function runSecurityCheck()
 {
     try {
         // check security, but only for the root invocation
         if ($this->invocation->isRootInvocation()) {
             $authInfo = WFAuthorizationManager::sharedAuthorizationManager()->authorizationInfo();
             $access = $this->checkSecurity($authInfo);
             if (!in_array($access, array(WFAuthorizationManager::ALLOW, WFAuthorizationManager::DENY, WFAuthorizationManager::PROMPT))) {
                 throw new WFException("Unexpected return code from checkSecurity.");
             }
             // if access is denied, see if there is a logged in user. If so, then DENY. If not, then allow login.
             if ($access == WFAuthorizationManager::DENY) {
                 if ($authInfo->isLoggedIn()) {
                     // if no one is logged in, allow login, otherwise deny.
                     throw new WFAuthorizationException("Access denied.", WFAuthorizationException::DENY);
                 } else {
                     // if no one is logged in, allow login, otherwise deny.
                     throw new WFAuthorizationException("Try logging in.", WFAuthorizationException::TRY_LOGIN);
                 }
             } else {
                 if ($access == WFAuthorizationManager::PROMPT) {
                     if (!$authInfo->isLoggedIn()) {
                         throw new WFException("WFAuthorizationManager::PROMPT is not a valid response when no one is logged in.");
                     } else {
                         // if no one is logged in, allow login, otherwise deny.
                         throw new WFAuthorizationException("Please re-login to access this secure area.", WFAuthorizationException::TRY_PROMPT);
                     }
                 }
             }
         }
     } catch (WFAuthorizationException $e) {
         if (php_sapi_name() === 'cli') {
             throw new WFException($e->getMessage());
         }
         if (WFRequestController::sharedRequestController()->isAjax()) {
             throw new WFRequestController_HTTPException("Not authorized.", 403);
         }
         switch ($e->getCode()) {
             case WFAuthorizationException::TRY_PROMPT:
                 WFAuthorizationManager::sharedAuthorizationManager()->doLoginRedirect($_SERVER['REQUEST_URI'], true);
                 break;
             case WFAuthorizationException::TRY_LOGIN:
                 WFAuthorizationManager::sharedAuthorizationManager()->doLoginRedirect($_SERVER['REQUEST_URI']);
                 break;
             case WFAuthorizationException::DENY:
                 header("Location: " . WFRequestController::WFURL('login', 'notAuthorized'));
                 exit;
                 break;
         }
     }
 }
示例#6
0
 /**
  *  The message to display to a use on unsuccessful login.
  *
  *  Will call the login delegate method.
  *
  *  @param string The username that the attempted login was for.
  *  @return mixed string: The message to display on failed login. array of strings; Multiple messages to display (as list items). DEFAULT: string:"Login username or password is not valid."
  *  @see WFAuthorizationDelegate::loginFailedMessage()
  */
 function loginFailedMessage($username)
 {
     if (!$this->authorizationDelegate) {
         throw new Exception("WFAuthorizationDelegate required for loginFailedMessage.");
     }
     $loginFailedMessage = 'Login failed for ' . $this->usernameLabel() . ' "' . $username . '". Please check your ' . $this->usernameLabel() . ' and password and try again.';
     if ($this->shouldEnableForgottenPasswordReset()) {
         $loginFailedMessage .= " If you have forgotten your password, <a href=\"" . WFRequestController::WFURL('login', 'doForgotPassword') . '/' . $username . "\">click here</a>.";
     }
     if (method_exists($this->authorizationDelegate, 'loginFailedMessage')) {
         $loginFailedMessage = $this->authorizationDelegate->loginFailedMessage($username);
     }
     return $loginFailedMessage;
 }
示例#7
0
文件: login.php 项目: ardell/phocoa
 function doForgotPassword_PageDidLoad($page, $params)
 {
     // IE sometimes lower-cases URLs for some reason. Help it out.
     if (!$page->hasOutlet('username')) {
         throw new WFRequestController_RedirectException(WFRequestController::WFURL($page->module()->moduleName(), 'doForgotPassword'));
     }
     $ac = WFAuthorizationManager::sharedAuthorizationManager();
     $page->outlet('username')->setValue($params['username']);
     $page->assign('usernameLabel', $ac->usernameLabel());
 }