本文整理汇总了PHP中QApplication::User方法的典型用法代码示例。如果您正苦于以下问题:PHP QApplication::User方法的具体用法?PHP QApplication::User怎么用?PHP QApplication::User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QApplication
的用法示例。
在下文中一共展示了QApplication::User方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Form_Create
protected function Form_Create()
{
parent::Form_Create();
if (QApplication::GetUserId() == NarroUser::ANONYMOUS_USER_ID) {
$strPassHash = QApplication::QueryString('h');
$strUsername = QApplication::QueryString('u');
if ($strPassHash && $strUsername) {
$objUser = NarroUser::LoadByUsernameAndPassword($strUsername, $strPassHash);
if ($objUser instanceof NarroUser) {
QApplication::$User = $objUser;
} else {
QApplication::Redirect('login.php');
}
} else {
QApplication::Redirect('login.php');
}
}
$this->lblMessage = new QLabel($this);
$this->lblMessage->HtmlEntities = false;
$this->txtPassword = new QTextBox($this);
$this->txtPassword->TextMode = QTextMode::Password;
$this->btnChangePassword = new QButton($this);
$this->btnChangePassword->PrimaryButton = true;
$this->btnChangePassword->Text = t('Change password');
$this->btnChangePassword->AddAction(new QClickEvent(), new QServerAction('btnChangePassword_Click'));
}
示例2: Form_Create
protected function Form_Create()
{
if (isset($_GET['logout'])) {
session_destroy();
QApplication::Redirect('word_list.php');
}
$this->lblMessage = new QLabel($this);
$this->lblMessage->HtmlEntities = false;
$this->txtOpenIdUrl = new QTextBox($this, 'username');
$this->txtOpenIdUrl->TabIndex = 1;
$this->btnLogin = new QButton($this);
$this->btnLogin->Text = 'Autentificare';
$this->btnLogin->PrimaryButton = true;
$this->btnLogin->TabIndex = 3;
$this->btnLogin->AddAction(new QClickEvent(), new QServerAction('btnLogin_Click'));
if (isset($_REQUEST['openid_mode'])) {
require_once "Zend/Auth.php";
require_once "Zend/Auth/Adapter/OpenId.php";
require_once "Zend/Auth/Storage/NonPersistent.php";
$auth = Zend_Auth::getInstance();
$auth->authenticate(new Zend_Auth_Adapter_OpenId($this->txtOpenIdUrl->Text));
if ($auth->hasIdentity()) {
require_once 'Zend/Session/Namespace.php';
$objSession = new Zend_Session_Namespace('SubmitWord');
$objSession->User = $auth->getIdentity();
QApplication::$User = $auth->getIdentity();
QApplication::Redirect('word_list.php');
} else {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = 'N-am primit nicio identitate, astea sunt datele primite: ' . var_export($auth, true);
return false;
}
}
// Instantiate the Meta DataGrid
$this->dtgWords = new WordDataGrid($this);
// Style the DataGrid (if desired)
$this->dtgWords->CssClass = 'datagrid';
$this->dtgWords->AlternateRowStyle->CssClass = 'alternate';
// Add Pagination (if desired)
$this->dtgWords->Paginator = new QPaginator($this->dtgWords);
$this->dtgWords->ItemsPerPage = 20;
$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/word_edit.php';
// Create the Other Columns (note that you can use strings for submit_word_word's properties, or you
// can traverse down QQN::submit_word_word() to display fields that are down the hierarchy)
$this->dtgWords->MetaAddColumn('WordId', 'Name=Id');
if (QApplication::$User) {
$this->dtgWords->MetaAddColumn('Word', 'Name=Cuvânt', 'HtmlEntities=false', 'Html=<?= \'<a href="' . $strEditPageUrl . '/\' . $_ITEM->WordId . \'">\' . $_ITEM->Word . \'</a>\'?>');
} else {
$this->dtgWords->MetaAddColumn('Word', 'Name=Cuvânt');
}
$this->dtgWords->MetaAddTypeColumn('StatusTypeId', 'StatusType', 'Name=Stare');
$this->dtgWords->MetaAddColumn('ProposalCount', 'Name=Propuneri');
$this->dtgWords->MetaAddColumn('LastSent', 'Name=Ultima propunere');
}
示例3:
if (array_search('--translation-lang', $argv) !== false) {
$strTargetLanguage = $argv[array_search('--translation-lang', $argv) + 1];
}
if (array_search('--user', $argv) !== false) {
$intUserId = $argv[array_search('--user', $argv) + 1];
}
$objUser = NarroUser::LoadByUserId($intUserId);
if (!$objUser instanceof NarroUser) {
NarroLogger::LogInfo(sprintf('User id=%s does not exist in the database, will try to use the anonymous user.', $intUserId));
$objUser = NarroUser::LoadAnonymousUser();
if (!$objUser instanceof NarroUser) {
NarroLogger::LogInfo(sprintf('The anonymous user id=%s does not exist in the database.', $intUserId));
return false;
}
}
QApplication::$User = $objUser;
$objProject = NarroProject::Load($intProjectId);
if (!$objProject instanceof NarroProject) {
NarroLogger::LogInfo(sprintf('Project with id=%s does not exist in the database.', $intProjectId));
return false;
}
$objLanguage = NarroLanguage::LoadByLanguageCode($strTargetLanguage);
if (!$objLanguage instanceof NarroLanguage) {
NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strTargetLanguage));
return false;
}
QApplication::$TargetLanguage = $objLanguage;
$objNarroImporter->TargetLanguage = $objLanguage;
NarroLogger::LogInfo(sprintf('Target language is %s', $objNarroImporter->TargetLanguage->LanguageName));
$objNarroImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode($strSourceLanguage);
if (!$objNarroImporter->SourceLanguage instanceof NarroLanguage) {
示例4: btnBrowserIdLogin_Click
public function btnBrowserIdLogin_Click($strFormId, $strControlId, $strAssertion)
{
// open connection
$ch = curl_init();
// set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, 'https://browserid.org/verify');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf('assertion=%s&audience=%s', $strAssertion, __HTTP_URL__));
// execute post
$result = json_decode(curl_exec($ch));
// close connection
curl_close($ch);
if ($result && property_exists($result, 'status') && $result->status == 'okay') {
$objUser = NarroUser::LoadByUsername($result->email);
if (!$objUser instanceof NarroUser) {
try {
$objUser = NarroUser::RegisterUser($result->email, $result->email, '', $result->email);
} catch (Exception $objEx) {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = sprintf(t('Failed to create an associated user for the email address "%s": %s'), $result->email, $objEx->getMessage());
return false;
}
$objUser->Reload();
QApplication::$Session->User = $objUser;
QApplication::Redirect(NarroLink::UserPreferences($objUser->UserId));
exit;
} elseif ($objUser->Password != $objHasher->HashPassword('')) {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = t('This user has a password set, please login with that instead');
return false;
}
QApplication::$Session->RegenerateId();
QApplication::$Session->User = $objUser;
QApplication::$User = $objUser;
if ($this->txtPreviousUrl) {
$strUrl = preg_replace('/([\\?\\&]l\\=)[a-z0-9\\-\\_]+/', '\\1' . QApplication::$User->GetPreferenceValueByName('Language'), $this->txtPreviousUrl);
if ($strUrl) {
QApplication::Redirect($strUrl);
} else {
QApplication::Redirect($this->txtPreviousUrl);
}
} else {
QApplication::Redirect(NarroLink::ProjectList(null, null, QApplication::$User->GetPreferenceValueByName('Language')));
}
exit;
} else {
$this->lblMessage->Text = t('BrowserID login failed');
$this->lblMessage->ForeColor = 'red';
}
}
示例5: InitializeUser
public static function InitializeUser()
{
global $argv;
if (QApplication::$Session->User) {
QApplication::$User = QApplication::$Session->User;
} elseif (is_array($argv) && array_search('--user', $argv) !== false) {
QApplication::$User = NarroUser::LoadByUserId((int) $argv[array_search('--user', $argv) + 1]);
}
if (!QApplication::$User instanceof NarroUser) {
QApplication::$User = NarroUser::LoadAnonymousUser();
QApplication::$Session->User = QApplication::$User;
}
if (!QApplication::$User instanceof NarroUser) {
// @todo add handling here
throw new Exception('Could not create an instance of NarroUser');
}
}
示例6:
// Initialize the Application and DB Connections
////////////////////////////////////////////////
QApplication::Initialize();
QApplication::InitializeDatabaseConnections();
/////////////////////////////
// Start Session Handler (if required)
/////////////////////////////
if (strstr($_SERVER['SCRIPT_NAME'], 'codegen.php') === false) {
/////////////////////////////
// Start Session Handler (if required)
/////////////////////////////
require_once 'Zend/Session.php';
Zend_Session::setOptions(array('cookie_lifetime' => 31 * 24 * 3600, 'gc_maxlifetime' => 31 * 24 * 3600));
require_once 'Zend/Session/Namespace.php';
$objSession = new Zend_Session_Namespace('SubmitWord');
QApplication::$User = $objSession->User;
}
//////////////////////////////////////////////
// Setup Internationalization and Localization (if applicable)
// Note, this is where you would implement code to do Language Setting discovery, as well, for example:
// * Checking against $_GET['language_code']
// * checking against session (example provided below)
// * Checking the URL
// * etc.
// TODO: options to do this are left to the developer
//////////////////////////////////////////////
QApplication::$CountryCode = 'ro';
QApplication::$LanguageCode = 'ro';
// Initialize I18n if QApplication::$LanguageCode is set
if (QApplication::$LanguageCode) {
QI18n::Initialize();