本文整理汇总了PHP中wcf\system\WCF::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP WCF::getUser方法的具体用法?PHP WCF::getUser怎么用?PHP WCF::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\system\WCF
的用法示例。
在下文中一共展示了WCF::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* @see \wcf\form\IForm::validate()
*/
public function validate()
{
AbstractForm::validate();
if (empty($this->masterPassword)) {
throw new UserInputException('masterPassword');
}
// check password security
if (mb_strlen($this->masterPassword) < 12) {
throw new UserInputException('masterPassword', 'notSecure');
}
// digits
if (!Regex::compile('\\d')->match($this->masterPassword)) {
throw new UserInputException('masterPassword', 'notSecure');
}
// latin characters (lower-case)
if (!Regex::compile('[a-z]')->match($this->masterPassword)) {
throw new UserInputException('masterPassword', 'notSecure');
}
// latin characters (upper-case)
if (!Regex::compile('[A-Z]')->match($this->masterPassword)) {
throw new UserInputException('masterPassword', 'notSecure');
}
// password equals username
if ($this->masterPassword == WCF::getUser()->username) {
throw new UserInputException('masterPassword', 'notSecure');
}
// confirm master password
if (empty($this->confirmMasterPassword)) {
throw new UserInputException('confirmMasterPassword');
}
if ($this->confirmMasterPassword != $this->masterPassword) {
throw new UserInputException('confirmMasterPassword', 'notEqual');
}
}
示例2: __construct
/**
* Creates a new ViewableUserActivityEventList object.
*/
public function __construct()
{
parent::__construct();
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
}
示例3: fireEvent
/**
* Adds a new user activity point event.
*
* @param string $objectType
* @param integer $objectID
* @param integer $userID
* @param array<mixed> $additionalData
*/
public function fireEvent($objectType, $objectID, $userID = null, array $additionalData = array())
{
$objectTypeObj = $this->getObjectTypeByName($objectType);
if ($objectTypeObj === null) {
throw new SystemException("Object type '" . $objectType . "' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'");
}
if ($userID === null) {
$userID = WCF::getUser()->userID;
}
if (!$userID) {
throw new SystemException("Cannot fire user activity point events for guests");
}
// update user_activity_point
$sql = "INSERT INTO\t\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\t\t(userID, objectTypeID, activityPoints, items)\n\t\t\tVALUES\t\t\t(?, ?, ?, 1)\n\t\t\tON DUPLICATE KEY\n\t\t\tUPDATE\t\t\tactivityPoints = activityPoints + VALUES(activityPoints),\n\t\t\t\t\t\titems = items + 1";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($userID, $objectTypeObj->objectTypeID, $objectTypeObj->points));
$sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tactivityPoints = activityPoints + ?\n\t\t\tWHERE\tuserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($objectTypeObj->points, $userID));
// update user ranks
$this->updateUserRanks(array($userID));
// check if the user will be automatically added to new user groups
// because of the new activity points
UserGroupAssignmentHandler::getInstance()->checkUsers(array($userID));
}
示例4: init
/**
* @see \wcf\system\dashboard\box\IDashboardBox::init()
*/
public function init(DashboardBox $box, IPage $page)
{
parent::init($box, $page);
if (WCF::getUser()->userID && MODULE_PAID_SUBSCRIPTION) {
// get available subscriptions
$this->subscriptions = PaidSubscriptionCacheBuilder::getInstance()->getData();
// get purchased subscriptions
$userSubscriptionList = new PaidSubscriptionUserList();
$userSubscriptionList->getConditionBuilder()->add('userID = ?', array(WCF::getUser()->userID));
$userSubscriptionList->getConditionBuilder()->add('isActive = ?', array(1));
$userSubscriptionList->readObjects();
// remove purchased subscriptions
foreach ($userSubscriptionList as $userSubscription) {
if (isset($this->subscriptions[$userSubscription->subscriptionID])) {
$userSubscription->setSubscription($this->subscriptions[$userSubscription->subscriptionID]);
unset($this->subscriptions[$userSubscription->subscriptionID]);
}
}
// remove excluded subscriptions
foreach ($userSubscriptionList as $userSubscription) {
if ($userSubscription->getSubscription()->excludedSubscriptionIDs) {
foreach (explode(',', $userSubscription->getSubscription()->excludedSubscriptionIDs) as $subscriptionID) {
if (isset($this->subscriptions[$subscriptionID])) {
unset($this->subscriptions[$subscriptionID]);
}
}
}
}
}
$this->fetched();
}
示例5: execute
/**
* @see \wcf\system\event\listener\IParameterizedEventListener::execute()
*/
public function execute($eventObj, $className, $eventName, array &$parameters)
{
if (WCF::getUser()->userID && WCF::getSession()->getPermission('admin.general.canUseAcp') && !defined(get_class($eventObj) . '::DO_NOT_LOG')) {
// try to find existing session log
$sql = "SELECT\tsessionLogID\n\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_log\n\t\t\t\tWHERE\tsessionID = ?\n\t\t\t\t\tAND lastActivityTime >= ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(WCF::getSession()->sessionID, TIME_NOW - SESSION_TIMEOUT));
$row = $statement->fetchArray();
if (!empty($row['sessionLogID'])) {
$sessionLogID = $row['sessionLogID'];
$sessionLogEditor = new ACPSessionLogEditor(new ACPSessionLog(null, array('sessionLogID' => $sessionLogID)));
$sessionLogEditor->update(array('lastActivityTime' => TIME_NOW));
} else {
// create new session log
$sessionLog = ACPSessionLogEditor::create(array('sessionID' => WCF::getSession()->sessionID, 'userID' => WCF::getUser()->userID, 'ipAddress' => UserUtil::getIpAddress(), 'hostname' => @gethostbyaddr(WCF::getSession()->ipAddress), 'userAgent' => WCF::getSession()->userAgent, 'time' => TIME_NOW, 'lastActivityTime' => TIME_NOW));
$sessionLogID = $sessionLog->sessionLogID;
}
// format request uri
$requestURI = WCF::getSession()->requestURI;
// remove directories
$URIComponents = explode('/', $requestURI);
$requestURI = array_pop($URIComponents);
// remove session url
$requestURI = preg_replace('/(?:\\?|&)s=[a-f0-9]{40}/', '', $requestURI);
// save access
ACPSessionAccessLogEditor::create(array('sessionLogID' => $sessionLogID, 'ipAddress' => UserUtil::getIpAddress(), 'time' => TIME_NOW, 'requestURI' => $requestURI, 'requestMethod' => WCF::getSession()->requestMethod, 'className' => get_class($eventObj)));
}
}
示例6: readFormParameters
/**
* @see \wcf\form\IForm::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (!WCF::getUser()->userID && isset($_POST['accept'])) {
$this->accept = true;
}
}
示例7: getConversationCount
/**
* Returns the number of conversations for given user.
*
* @param integer $userID
* @return integer
*/
public function getConversationCount($userID = null)
{
if ($userID === null) {
$userID = WCF::getUser()->userID;
}
if (!isset($this->conversationCount[$userID])) {
$this->conversationCount[$userID] = 0;
// load storage data
UserStorageHandler::getInstance()->loadStorage(array($userID));
// get ids
$data = UserStorageHandler::getInstance()->getStorage(array($userID), 'conversationCount');
// cache does not exist or is outdated
if ($data[$userID] === null) {
$conditionBuilder1 = new PreparedStatementConditionBuilder();
$conditionBuilder1->add('conversation_to_user.participantID = ?', array($userID));
$conditionBuilder1->add('conversation_to_user.hideConversation IN (0,1)');
$conditionBuilder2 = new PreparedStatementConditionBuilder();
$conditionBuilder2->add('conversation.userID = ?', array($userID));
$conditionBuilder2->add('conversation.isDraft = 1');
$sql = "SELECT (SELECT\tCOUNT(*)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation_to_user conversation_to_user\n\t\t\t\t\t\t" . $conditionBuilder1->__toString() . ")\n\t\t\t\t\t\t+\n\t\t\t\t\t\t(SELECT\tCOUNT(*)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation conversation\n\t\t\t\t\t\t" . $conditionBuilder2->__toString() . ") AS count";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array_merge($conditionBuilder1->getParameters(), $conditionBuilder2->getParameters()));
$row = $statement->fetchArray();
$this->conversationCount[$userID] = $row['count'];
// update storage data
UserStorageHandler::getInstance()->update($userID, 'conversationCount', serialize($this->conversationCount[$userID]));
} else {
$this->conversationCount[$userID] = unserialize($data[$userID]);
}
}
return $this->conversationCount[$userID];
}
示例8: __construct
public function __construct()
{
parent::__construct();
// accessible news categories
$accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs();
if (!empty($accessibleCategoryIDs)) {
$this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM cms' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs));
} else {
$this->getConditionBuilder()->add('1=0');
}
//get default settings
if (!WCF::getSession()->getPermission('mod.cms.news.canModerateNews')) {
$this->getConditionBuilder()->add('news.isDisabled = 0');
}
if (!WCF::getSession()->getPermission('mod.cms.news.canModerateNews')) {
$this->getConditionBuilder()->add('news.isDeleted = 0');
}
//can view delayed news
if (!WCF::getSession()->getPermission('user.cms.news.canViewDelayedNews')) {
$this->getConditionBuilder()->add('news.isDisabled = ?', array(0));
}
// language Filter
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$this->getConditionBuilder()->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
}
示例9: initAuth
/**
* Does the user authentication.
*/
protected function initAuth() {
// this is a work-around since neither RequestHandler
// nor RouteHandler are populated right now
$pathInfo = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : '';
if (empty($pathInfo) || !preg_match('~^/(ACPCaptcha|Login|Logout)/~', $pathInfo)) {
if (WCF::getUser()->userID == 0) {
// build redirect path
$application = ApplicationHandler::getInstance()->getActiveApplication();
$path = $application->getPageURL() . 'acp/index.php/Login/' . SID_ARG_1ST;
HeaderUtil::redirect($path);
exit;
}
else {
// work-around for AJAX-requests within ACP
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
try {
WCF::getSession()->checkPermissions(array('admin.general.canUseAcp'));
}
catch (PermissionDeniedException $e) {
throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS, $e->getTraceAsString());
}
}
else {
WCF::getSession()->checkPermissions(array('admin.general.canUseAcp'));
}
}
}
}
示例10: __construct
/**
* Creates a new UnreadNewsList object.
*/
public function __construct()
{
parent::__construct();
$this->getConditionBuilder()->add("news.time > ?", array(VisitTracker::getInstance()->getVisitTime('de.voolia.news.entry')));
$this->getConditionBuilder()->add("tracked_visit.visitTime IS NULL");
$this->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")";
}
示例11: upload
/**
* Handles uploaded files.
*/
public function upload()
{
// save files
$files = $this->parameters['__files']->getFiles();
$file = $files[0];
try {
if (!$file->getValidationErrorType()) {
$data = array('userID' => WCF::getUser()->userID ?: null, 'filename' => $file->getFilename(), 'fileType' => $file->getMimeType(), 'fileHash' => sha1_file($file->getLocation()), 'filesize' => $file->getFilesize(), 'uploadTime' => TIME_NOW);
// save file
$upload = FileUploadEditor::create($data);
// move uploaded file
if (@copy($file->getLocation(), $upload->getLocation())) {
@unlink($file->getLocation());
// return result
return array('uploadID' => $upload->uploadID, 'filename' => $upload->filename, 'filesize' => $upload->filesize, 'formattedFilesize' => FileUtil::formatFilesize($upload->filesize));
} else {
// moving failed; delete file
$editor = new FileUploadEditor($upload);
$editor->delete();
throw new UserInputException('fileUpload', 'uploadFailed');
}
}
} catch (UserInputException $e) {
$file->setValidationErrorType($e->getType());
}
return array('errorType' => $file->getValidationErrorType());
}
示例12: readData
/**
* @see \wcf\page\AbstractPage::readData()
*/
public function readData()
{
parent::readData();
// get available subscriptions
$this->subscriptions = PaidSubscriptionCacheBuilder::getInstance()->getData();
// get user subscriptions
$this->userSubscriptionList = new PaidSubscriptionUserList();
$this->userSubscriptionList->getConditionBuilder()->add('userID = ?', array(WCF::getUser()->userID));
$this->userSubscriptionList->getConditionBuilder()->add('isActive = ?', array(1));
$this->userSubscriptionList->readObjects();
foreach ($this->userSubscriptionList as $userSubscription) {
if (isset($this->subscriptions[$userSubscription->subscriptionID])) {
$userSubscription->setSubscription($this->subscriptions[$userSubscription->subscriptionID]);
unset($this->subscriptions[$userSubscription->subscriptionID]);
}
}
foreach ($this->userSubscriptionList as $userSubscription) {
if ($userSubscription->getSubscription()->excludedSubscriptionIDs) {
foreach (explode(',', $userSubscription->getSubscription()->excludedSubscriptionIDs) as $subscriptionID) {
if (isset($this->subscriptions[$subscriptionID])) {
unset($this->subscriptions[$subscriptionID]);
}
}
}
}
}
示例13: __construct
/**
* Creates the AccessibleNewsList object.
*/
public function __construct()
{
parent::__construct();
// accessible news categories
$accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs();
if (!empty($accessibleCategoryIDs)) {
$this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs));
} else {
$this->getConditionBuilder()->add('1=0');
}
// default conditions
if (!WCF::getSession()->getPermission('mod.news.canReadDeactivatedNews')) {
$this->getConditionBuilder()->add('news.isActive = 1');
}
if (!WCF::getSession()->getPermission('mod.news.canReadDeletedNews')) {
$this->getConditionBuilder()->add('news.isDeleted = 0');
}
if (!WCF::getSession()->getPermission('mod.news.canReadFutureNews')) {
if (WCF::getUser()->userID) {
$this->getConditionBuilder()->add('(news.isPublished = 1 OR news.userID = ?)', array(WCF::getUser()->userID));
} else {
$this->getConditionBuilder()->add('news.isPublished = 1');
}
}
// apply language filter
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$this->getConditionBuilder()->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
}
示例14: execute
/**
* @see \wcf\system\event\listener\IParameterizedEventListener::execute()
*/
public function execute($eventObj, $className, $eventName, array &$parameters)
{
if (!MODULE_CONVERSATION || !MODULE_JCOINS || JCOINS_RECEIVECOINS_ADDCONVERSATIONREPLY == 0) {
return;
}
if ($eventObj->getActionName() != 'create' && $eventObj->getActionName() != 'quickReply') {
return;
}
// catch 3rdparty plugins, which creates Conversations without an logged in user
if (WCF::getUser()->userID == 0) {
return;
}
$parameters = $eventObj->getParameters();
if (isset($parameters['isFirstPost'])) {
return;
}
if ($eventObj->getActionName() == 'create') {
$return = $eventObj->getReturnValues();
$conversation = $return['returnValues']->getConversation();
$this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('reason' => 'wcf.jcoins.statement.conversationreplyadd.recive', 'sum' => JCOINS_RECEIVECOINS_ADDCONVERSATIONREPLY, 'additionalData' => array('title' => $conversation->subject), 'link' => $return['returnValues']->getLink()), 'changeBalance' => 1));
$this->statementAction->validateAction();
$this->statementAction->executeAction();
} else {
$conversation = new \wcf\data\conversation\Conversation(isset($parameters['objectID']) ? intval($parameters['objectID']) : 0);
$this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('reason' => 'wcf.jcoins.statement.conversationadd.recive', 'sum' => JCOINS_RECEIVECOINS_CREATECONVERSATION, 'additionalData' => array('title' => $conversation->subject), 'link' => \wcf\system\request\LinkHandler::getInstance()->getLink('Conversation', array('object' => $conversation))), 'changeBalance' => 1));
$this->statementAction->validateAction();
$this->statementAction->executeAction();
}
}
示例15: checkAccessToken
/**
* Validates the access-token and performs the login.
*/
protected function checkAccessToken() {
if (isset($_REQUEST['at'])) {
list($userID, $token) = explode('-', StringUtil::trim($_REQUEST['at']));
if (WCF::getUser()->userID) {
if ($userID == WCF::getUser()->userID && PasswordUtil::secureCompare(WCF::getUser()->accessToken, $token)) {
// everything is fine, but we are already logged in
return;
}
else {
// token is invalid
throw new IllegalLinkException();
}
}
else {
$user = new User($userID);
if (PasswordUtil::secureCompare($user->accessToken, $token)) {
// token is valid -> change user
SessionHandler::getInstance()->changeUser($user, true);
}
else {
// token is invalid
throw new IllegalLinkException();
}
}
}
}