本文整理汇总了PHP中QQN::NarroUser方法的典型用法代码示例。如果您正苦于以下问题:PHP QQN::NarroUser方法的具体用法?PHP QQN::NarroUser怎么用?PHP QQN::NarroUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQN
的用法示例。
在下文中一共展示了QQN::NarroUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: btnRecoverPassword_Click
public function btnRecoverPassword_Click($strFormId, $strControlId, $strParameter)
{
if ($this->txtEmail->Text) {
$objUser = NarroUser::QuerySingle(QQ::Equal(QQN::NarroUser()->Email, $this->txtEmail->Text));
} elseif ($this->txtUsername->Text) {
$objUser = NarroUser::QuerySingle(QQ::Equal(QQN::NarroUser()->Username, $this->txtUsername->Text));
} else {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = t('Please enter a username or email to continue.');
return false;
}
if ($objUser instanceof NarroUser) {
if ($objUser->UserId == NarroUser::ANONYMOUS_USER_ID) {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = t('Hey, the anonymous user doesn\'t have a password. What are you trying to do?');
return false;
}
$objMessage = new QEmailMessage();
$objMessage->From = sprintf('%s <%s>', __FROM_EMAIL_NAME__, __FROM_EMAIL_ADDRESS__);
$objMessage->To = sprintf('%s <%s>', $objUser->Username, $objUser->Email);
$objMessage->Subject = sprintf('Password recovery for "%s" on "%s"', $objUser->Username, $_SERVER['HTTP_HOST']);
$objMessage->Body = sprintf('Somebody, probably you, requested a password recovery for "%s" on "%s". To change your password, please follow this link: %s', $objUser->Username, $_SERVER['HTTP_HOST'], (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . sprintf('/change_password.php?l=%s&u=%s&h=%s', QApplication::$TargetLanguage->LanguageCode, $objUser->Username, $objUser->Password));
try {
QEmailServer::Send($objMessage);
$this->lblMessage->ForeColor = 'green';
$this->lblMessage->Text = t('You should have a new email message with instructions. Check your spam/bulk directory too.');
} catch (Exception $objEx) {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = t('Failed to send email. This may be a server issue. Please try again later.');
return false;
}
} else {
$this->lblMessage->ForeColor = 'red';
$this->lblMessage->Text = t('Bad username or/and email');
}
}
示例2: dtgUser_Bind
public function dtgUser_Bind()
{
if ($this->txtSearch->Text != '') {
$objSearchCondition = QQ::OrCondition(QQ::Like(QQN::NarroUser()->RealName, sprintf('%%%s%%', $this->txtSearch->Text)), QQ::Like(QQN::NarroUser()->Username, sprintf('%%%s%%', $this->txtSearch->Text)), QQ::Like(QQN::NarroUser()->Email, sprintf('%%%s%%', $this->txtSearch->Text)));
} else {
$objSearchCondition = QQ::All();
}
// Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll()
// Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
$this->dtgUser->TotalItemCount = NarroUser::QueryCount($objSearchCondition);
// Setup the $objClauses Array
$objClauses = array();
// If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
// the OrderByClause to the $objClauses array
if ($objClause = $this->dtgUser->OrderByClause) {
array_push($objClauses, $objClause);
}
// Add the LimitClause information, as well
if ($objClause = $this->dtgUser->LimitClause) {
array_push($objClauses, $objClause);
}
// Set the DataSource to be the array of all NarroUser objects, given the clauses above
$this->dtgUser->DataSource = NarroUser::QueryArray($objSearchCondition, $objClauses);
QApplication::ExecuteJavaScript('highlight_datagrid();');
}
示例3: LoadByRealName
/**
* Load a single NarroUser object,
* by RealName Index(es)
* @param string $strRealName
* @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
* @return NarroUser
*/
public static function LoadByRealName($strRealName, $objOptionalClauses = null)
{
return NarroUser::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroUser()->RealName, $strRealName)), $objOptionalClauses);
}
示例4: RegisterUser
public static function RegisterUser($strUsername, $strEmail, $strPassword, $strRealName)
{
$objMaxUser = NarroUser::LoadAll(QQ::Clause(QQ::LimitInfo(1, 0), QQ::OrderBy(QQN::NarroUser()->UserId, false)));
$objUser = new NarroUser();
$objUser->UserId = $objMaxUser[0]->UserId + 1;
$objUser->Username = $strUsername;
if ($strRealName) {
$objUser->RealName = $strRealName;
}
$objUser->Email = $strEmail;
require_once __NARRO_INCLUDES__ . '/PasswordHash.class.php';
$objHasher = new PasswordHash(8, FALSE);
$objUser->Password = $objHasher->HashPassword($strPassword);
try {
$objUser->Save();
} catch (Exception $objEx) {
throw $objEx;
}
/**
* set up default roles
*/
$objUserRole = new NarroUserRole();
if ($objUser->UserId == 1) {
$objUserRole->RoleId = 5;
} else {
$objUserRole->RoleId = 2;
}
$objUserRole->UserId = $objUser->UserId;
$objUserRole->Save();
return NarroUser::LoadByUsernameAndPassword($strUsername, md5($strPassword));
}
示例5: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case "TranslationPath":
if (file_exists($mixValue)) {
$this->strTranslationPath = $mixValue;
} else {
if (!file_exists(dirname($mixValue))) {
throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" does not exist', $mixValue, dirname($mixValue)));
}
if (!is_writable(dirname($mixValue))) {
throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" is not writable', $mixValue, dirname($mixValue)));
}
chmod(dirname($mixValue), 0777);
if (mkdir($mixValue, 0777, true)) {
$this->strTranslationPath = $mixValue;
} else {
throw new Exception(sprintf(t('TranslationPath "%s" does not exist.'), $mixValue));
}
NarroUtils::RecursiveChmod($mixValue);
}
break;
case "TemplatePath":
if (file_exists($mixValue)) {
$this->strTemplatePath = $mixValue;
} else {
if (!file_exists(dirname($mixValue))) {
throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" does not exist', $mixValue, dirname($mixValue)));
}
if (!is_writable(dirname($mixValue))) {
throw new Exception(sprintf('Cannot create "%s" because the parent directory "%s" is not writable', $mixValue, dirname($mixValue)));
}
chmod(dirname($mixValue), 0777);
if (mkdir($mixValue, 0777, true)) {
$this->strTranslationPath = $mixValue;
} else {
throw new Exception(sprintf(t('TranslationPath "%s" does not exist.'), $mixValue));
}
NarroUtils::RecursiveChmod($mixValue);
}
break;
case "User":
if ($mixValue instanceof NarroUser) {
$this->objUser = $mixValue;
} else {
throw new Exception(t('User should be set with an instance of NarroUser'));
}
break;
case "Project":
if ($mixValue instanceof NarroProject) {
$this->objProject = $mixValue;
} else {
throw new Exception(t('Project should be set with an instance of NarroProject'));
}
break;
case "TargetLanguage":
if ($mixValue instanceof NarroLanguage) {
$this->objTargetLanguage = $mixValue;
} else {
throw new Exception(t('TargetLanguage should be set with an instance of NarroLanguage'));
}
break;
case "SourceLanguage":
if ($mixValue instanceof NarroLanguage) {
$this->objSourceLanguage = $mixValue;
} else {
throw new Exception(t('SourceLanguage should be set with an instance of NarroLanguage'));
}
break;
case "Approve":
try {
$this->blnApprove = QType::Cast($mixValue, QType::Boolean);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "SkipUntranslated":
try {
$this->blnSkipUntranslated = QType::Cast($mixValue, QType::Boolean);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "ApproveAlreadyApproved":
try {
$this->blnApproveAlreadyApproved = QType::Cast($mixValue, QType::Boolean);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "CheckEqual":
try {
$this->blnCheckEqual = QType::Cast($mixValue, QType::Boolean);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
//.........这里部分代码省略.........
示例6: ResolveContentItem
/**
* Used internally by the Meta-based Add Column tools.
*
* Given a QQNode or a Text String, this will return a NarroUser-based QQNode.
* It will also verify that it is a proper NarroUser-based QQNode, and will throw an exception otherwise.
*
* @param mixed $mixContent
* @return QQNode
*/
protected function ResolveContentItem($mixContent)
{
if ($mixContent instanceof QQNode) {
if (!$mixContent->_ParentNode) {
throw new QCallerException('Content QQNode cannot be a Top Level Node');
}
if ($mixContent->_RootTableName == 'narro_user') {
if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
$objCurrentNode = $mixContent;
while ($objCurrentNode = $objCurrentNode->_ParentNode) {
if (!$objCurrentNode instanceof QQNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
}
return $mixContent;
} else {
throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "narro_user".');
}
} else {
if (is_string($mixContent)) {
switch ($mixContent) {
case 'UserId':
return QQN::NarroUser()->UserId;
case 'Username':
return QQN::NarroUser()->Username;
case 'Password':
return QQN::NarroUser()->Password;
case 'Email':
return QQN::NarroUser()->Email;
case 'RealName':
return QQN::NarroUser()->RealName;
case 'Data':
return QQN::NarroUser()->Data;
default:
throw new QCallerException('Simple Property not found in NarroUserDataGrid content: ' . $mixContent);
}
} else {
if ($mixContent instanceof QQAssociationNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
} else {
throw new QCallerException('Invalid Content type');
}
}
}
}
示例7: __construct
public function __construct($strDate, $objParentObject, NarroProject $objProject = null, $strControlId = null)
{
// Call the Parent
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
$this->strTemplate = dirname(__FILE__) . '/' . __CLASS__ . '.tpl.php';
$this->blnAutoRenderChildren = true;
// Tabs
$this->tabTop = new QTabs($this);
$pnlTranslators = new NarroUserDataGrid($this->tabTop);
$pnlTranslators->CssClass = 'datagrid';
$colUsername = $pnlTranslators->MetaAddColumn(QQN::NarroUser()->Username);
$colUsername->HtmlEntities = false;
$colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
$colCnt = new QDataGridColumn(t('Translations'));
$colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
$pnlTranslators->SortColumnIndex = 1;
$pnlTranslators->ShowHeader = false;
$pnlTranslators->SortDirection = 1;
$pnlTranslators->AddColumn($colCnt);
$pnlTranslators->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroSuggestionAsUser->Created, $strDate), QQ::Equal(QQN::NarroUser()->NarroSuggestionAsUser->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID), $objProject ? QQ::Equal(QQN::NarroUser()->NarroSuggestionAsUser->Text->NarroContextAsText->ProjectId, $objProject->ProjectId) : QQ::All());
$pnlTranslators->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroSuggestionAsUser->SuggestionId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
$pnlReviewers = new NarroUserDataGrid($this->tabTop);
$pnlReviewers->CssClass = 'datagrid';
$colUsername = $pnlReviewers->MetaAddColumn(QQN::NarroUser()->Username);
$colUsername->HtmlEntities = false;
$colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
$colCnt = new QDataGridColumn(t('Reviewers'));
$colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
$pnlReviewers->SortColumnIndex = 1;
$pnlReviewers->ShowHeader = false;
$pnlReviewers->SortDirection = 1;
$pnlReviewers->AddColumn($colCnt);
$pnlReviewers->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroContextInfoAsValidatorUser->Modified, $strDate), QQ::Equal(QQN::NarroUser()->NarroContextInfoAsValidatorUser->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID), $objProject ? QQ::Equal(QQN::NarroUser()->NarroContextInfoAsValidatorUser->Context->ProjectId, $objProject->ProjectId) : QQ::All());
$pnlReviewers->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroContextInfoAsValidatorUser->ValidSuggestionId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
$pnlVoters = new NarroUserDataGrid($this->tabTop);
$pnlVoters->CssClass = 'datagrid';
$colUsername = $pnlVoters->MetaAddColumn(QQN::NarroUser()->Username);
$colUsername->HtmlEntities = false;
$colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
$colCnt = new QDataGridColumn(t('Reviewers'));
$colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
$pnlVoters->SortColumnIndex = 1;
$pnlVoters->ShowHeader = false;
$pnlVoters->SortDirection = 1;
$pnlVoters->AddColumn($colCnt);
$pnlVoters->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroSuggestionVoteAsUser->Created, $strDate), QQ::Equal(QQN::NarroUser()->NarroSuggestionVoteAsUser->Suggestion->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID), $objProject ? QQ::Equal(QQN::NarroUser()->NarroSuggestionVoteAsUser->Suggestion->Text->NarroContextAsText->ProjectId, $objProject->ProjectId) : QQ::All());
$pnlVoters->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroSuggestionVoteAsUser->SuggestionId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
$pnlComments = new NarroUserDataGrid($this->tabTop);
$pnlComments->CssClass = 'datagrid';
$colUsername = $pnlComments->MetaAddColumn(QQN::NarroUser()->Username);
$colUsername->HtmlEntities = false;
$colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
$colCnt = new QDataGridColumn(t('Reviewers'));
$colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
$pnlComments->SortColumnIndex = 1;
$pnlComments->ShowHeader = false;
$pnlComments->SortDirection = 1;
$pnlComments->AddColumn($colCnt);
$pnlComments->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroTextCommentAsUser->Created, $strDate), QQ::Equal(QQN::NarroUser()->NarroTextCommentAsUser->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID));
$pnlComments->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroTextCommentAsUser->TextCommentId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
$this->tabTop->Headers = array(t('Translators'), t('Reviewers'), t('Voters'), t('Comments'));
}