本文整理汇总了PHP中Session::getUserID方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getUserID方法的具体用法?PHP Session::getUserID怎么用?PHP Session::getUserID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::getUserID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstructor
public function testConstructor()
{
$factory = new \Jackalope\Factory();
$repository = $this->getMock('Jackalope\\Repository', array(), array($factory), '', false);
$workspaceName = 'asdfads';
$userID = 'abcd';
$cred = new \PHPCR\SimpleCredentials($userID, 'xxxx');
$cred->setAttribute('test', 'toast');
$cred->setAttribute('other', 'value');
$transport = new Transport\Davex\Client($factory, 'http://example.com');
$s = new Session($factory, $repository, $workspaceName, $cred, $transport);
$this->assertSame($repository, $s->getRepository());
$this->assertSame($userID, $s->getUserID());
$this->assertSame(array('test', 'other'), $s->getAttributeNames());
$this->assertSame('toast', $s->getAttribute('test'));
$this->assertSame('value', $s->getAttribute('other'));
}
示例2: getProjectsByUserID
public static function getProjectsByUserID($userID = null, $limit = null)
{
if ($userID === null) {
return null;
}
$loggedInUserID = Session::getUserID();
$query = " SELECT pu.project_id AS id FROM " . self::DB_TABLE . " pu";
$query .= " INNER JOIN " . Project::DB_TABLE . " p ON";
$query .= " pu.project_id = p.id";
$query .= " WHERE pu.user_id = " . $userID;
$query .= " AND pu.relationship != " . self::BANNED;
// only show private projects if logged-in user is also a member
if (!empty($loggedInUserID)) {
$query .= " AND (p.private = 0";
$query .= " OR pu.project_id IN (";
$query .= " SELECT project_id FROM " . self::DB_TABLE;
$query .= " WHERE user_id = " . $loggedInUserID;
$query .= " AND relationship != " . self::BANNED;
$query .= " ))";
} else {
$query .= " AND p.private = 0";
}
$query .= " ORDER BY p.title ASC";
if (!empty($limit)) {
$query .= " LIMIT " . $limit;
}
$db = Db::instance();
$result = $db->lookup($query);
if (!mysql_num_rows($result)) {
return array();
}
$projects = array();
while ($row = mysql_fetch_assoc($result)) {
$projects[$row['id']] = Project::load($row['id']);
}
return $projects;
}
示例3: handleSessions
/**
* Handles the session
* @return User/null if null, then no user is logged in
*/
function handleSessions()
{
if (isset($_SESSION['orongo-id']) && isset($_SESSION['orongo-session-id'])) {
$externID = Security::escapeSQL($_SESSION['orongo-id']);
$externSession = Security::escapeSQL($_SESSION['orongo-session-id']);
if (Session::isGoodSessionID($externSession)) {
$sessionUserID = Session::getUserID($externSession);
if ($sessionUserID == $externID) {
try {
$user = new User($externID);
return $user;
} catch (Exception $e) {
if ($e->getCode() == USER_NOT_EXIST) {
header("Location: orongo-logout.php");
exit;
} else {
header('HTTP/1.1 500 Internal Server Error');
exit;
}
}
} else {
Session::delete($externSession);
session_destroy();
header("Location: orongo-logout.php");
exit;
}
} else {
Session::delete($externSession);
session_destroy();
header("Location: orongo-logout.php");
exit;
}
} else {
return null;
}
}
示例4:
include_once TEMPLATE_PATH . '/site/helper/format.php';
$project = $SOUP->get('project');
$task = $SOUP->get('task');
$joined = $SOUP->get('accepted');
$id = $SOUP->get('id', 'contributors');
$hasJoinedTask = $SOUP->get('hasJoinedTask', false);
// can user join or leave task?
$hasLeavePermission = false;
$hasJoinPermission = false;
if ($task->getStatus()) {
$openTask = true;
} else {
$openTask = false;
}
if (Session::isLoggedIn() && !$project->isBanned(Session::getUserID())) {
if ($hasJoinedTask) {
$hasLeavePermission = true;
} else {
$hasJoinPermission = true;
}
}
// num joined
$numJoined = $task->getNumAccepted();
// num needed
$numNeeded = $task->getNumNeeded();
if (empty($numNeeded)) {
$numNeeded = '∞ people';
} else {
$numNeeded = $numNeeded - $numJoined;
if ($numNeeded < 0) {
示例5: Soup
<?php
require_once "../../global.php";
$soup = new Soup();
if (Session::isLoggedIn()) {
$projects = Project::getPublicProjects(Session::getUserID());
} else {
$projects = Project::getPublicProjects();
}
$soup->set('projects', $projects);
$soup->render('site/page/find');
示例6:
<?php
include_once TEMPLATE_PATH . '/site/helper/format.php';
$project = $SOUP->get('project');
$accepted = $SOUP->get('accepted');
$update = $SOUP->get('update');
$updates = $SOUP->get('updates');
$uploads = $SOUP->get('uploads');
$task = $SOUP->get('task', null);
$comments = $SOUP->get('comments');
// only update creator may edit or create
$hasPermission = Session::isAdmin() || $update->getCreatorID() == Session::getUserID();
$fork = $SOUP->fork();
$fork->set('title', 'Contribution');
$fork->set('id', 'update');
$fork->set('editable', $hasPermission);
$fork->set('editLabel', 'Edit');
$fork->startBlockSet('body');
?>
<?php
if ($hasPermission) {
?>
<script type="text/javascript">
$(document).ready(function(){
$('#selStatus').val('<?php
echo $accepted->getStatus();
?>
');
示例7: formatUserLink
if ($creator->getNotifyDiscussionStarted()) {
// compose email
$body = "<p>" . formatUserLink(Session::getUserID()) . ' replied to your discussion <a href="' . Url::discussion($discussionID) . '">' . $discussion->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>';
$body .= "<blockquote>" . formatDiscussionReply($message) . "</blockquote>";
$email = array('to' => $creator->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New reply to your discussion in ' . $project->getTitle(), 'message' => $body);
// send email
Email::send($email);
}
}
// others who replied to discussion
$repliers = $discussion->getDistinctRepliers();
foreach ($repliers as $r) {
if ($r->getID() != Session::getUserID()) {
// don't email yourself
if ($r->getNotifyDiscussionReply()) {
// compose email
$body = "<p>" . formatUserLink(Session::getUserID()) . ' replied to the discussion <a href="' . Url::discussion($discussionID) . '">' . $discussion->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>';
$body .= "<blockquote>" . formatDiscussionReply($message) . "</blockquote>";
$email = array('to' => $r->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New reply to a discussion in ' . $project->getTitle(), 'message' => $body);
// send email
Email::send($email);
}
}
}
$json = array('success' => '1');
Session::setMessage("You replied to the discussion.");
echo json_encode($json);
} else {
$json = array('error' => 'Invalid action.');
exit(json_encode($json));
}
示例8: saveToDatabase
public static function saveToDatabase($originalName = null, $storedName = null, $itemType = null, $itemID = null, $projectID = null)
{
// all but projectID required
if ($originalName == null || $storedName == null || $itemType == null || $itemID == null) {
return null;
}
// get extension
$ext = pathinfo($originalName, PATHINFO_EXTENSION);
$storedName .= '.' . $ext;
// temp variable for absolute path
$absPath = UPLOAD_PATH . '/' . $storedName;
// get file size
$size = filesize($absPath);
// get mime type
$mime = getMimeType($absPath);
// get height and width (if image)
$imgSize = getimagesize($absPath);
if ($imgSize) {
$height = $imgSize[1];
$width = $imgSize[0];
} else {
$height = null;
$width = null;
}
// store in db
$upload = new Upload(array('creator_id' => Session::getUserID(), 'original_name' => $originalName, 'stored_name' => $storedName, 'mime' => $mime, 'size' => $size, 'height' => $height, 'width' => $width, 'item_type' => $itemType, 'item_id' => $itemID, 'project_id' => $projectID));
$upload->save();
return $upload->getID();
}
示例9: array
<?php
require_once "../../global.php";
$user = User::load(Session::getUserID());
$action = Filter::text($_POST['action']);
if ($action == 'theme') {
// get the new theme
$themeID = Filter::numeric($_POST['themeID']);
$theme = Theme::load($themeID);
// validate the theme
if (empty($theme)) {
$json = array('error' => 'That theme does not exist.');
exit(json_encode($json));
}
// save the new theme
$user->setThemeID($theme->getID());
$user->save();
// send us back
Session::setMessage("Theme changed.");
$json = array('success' => '1');
echo json_encode($json);
} elseif ($action == 'notification') {
$notificationType = Filter::alphanum($_POST['notificationType']);
$notificationValue = Filter::alphanum($_POST['notificationValue']);
// convert checkbox value to database-friendly 1 or 0
$value = $notificationValue == 'notify' ? 1 : 0;
// figure out which User setter to use based on notification type
switch ($notificationType) {
case 'chkCommentTaskLeading':
$user->setNotifyCommentTaskLeading($value);
break;
示例10: array
$hasJoinedTask = $SOUP->get('hasJoinedTask', false);
$updates = $task->getUpdates();
//$uploads = $SOUP->get('uploads');
$fork = $SOUP->fork();
$fork->set('project', $project);
$fork->set('pageTitle', $project->getTitle());
$fork->set('headingURL', Url::project($project->getID()));
$fork->set('selected', "tasks");
$fork->set('breadcrumbs', Breadcrumbs::task($task->getID()));
$fork->startBlockSet('body');
?>
<td class="left">
<?php
$SOUP->render('project/partial/task', array());
?>
</td>
<td class="right">
<?php
if ($hasJoinedTask && !$project->isBanned(Session::getUserID())) {
$SOUP->render('project/partial/contribs', array('updates' => $updates));
$SOUP->render('project/partial/taskContributors', array());
} else {
$SOUP->render('project/partial/taskContributors', array());
$SOUP->render('project/partial/contribs', array('updates' => $updates));
}
?>
<?php
$SOUP->render('site/partial/activity', array('title' => "Recent Activity", 'size' => 'small', 'events' => $events, 'olderURL' => Url::activityTasks($project->getID()), 'class' => 'subtle'));
示例11: formatRules
<?php
include_once TEMPLATE_PATH . '/site/helper/format.php';
$project = $SOUP->get('project');
// admin, trusted, creator may edit
$hasPermission = Session::isAdmin() || $project->isTrusted(Session::getUserID()) || $project->isCreator(Session::getUserID());
$formattedRules = formatRules($project->getRules());
$fork = $SOUP->fork();
$fork->set('title', "Rules");
$fork->set('id', "rules");
$fork->set('editable', $hasPermission);
//$fork->set('editLabel', 'Edit Rules');
$fork->startBlockSet('body');
?>
<?php
if ($hasPermission) {
?>
<script type="text/javascript">
$(document).ready(function(){
$("#btnSaveRules").mousedown(function(){
buildPost({
'processPage':'<?php
echo Url::detailsProcess($project->getID());
?>
',
'info':
{
'action':'rules',
'rules':$("#txtRules").val()
示例12: initializeUploader
?>
function initializeUploader() {
var uploadButtonID = 'btnUploadPicture';
// // clear file list
// $('#filelist').html('');
var uploader = new plupload.Uploader({
runtimes : 'flash,html5,gears,silverlight,browserplus',
browse_button : uploadButtonID,
max_file_size : '500kb',
chunk_size : '100kb',
url : '<?php
echo Url::userPictureProcess(Session::getUserID());
?>
',
unique_names : true,
//resize : {width : 320, height : 240, quality : 90},
flash_swf_url : '<?php
echo Url::base();
?>
/lib/plupload/js/plupload.flash.swf',
silverlight_xap_url : '<?php
echo Url::base();
?>
/lib/plupload/js/plupload.silverlight.xap',
filters : [
{title : "Allowed files", extensions : "jpg,jpeg,gif,png"}
]
示例13: markAllRead
public function markAllRead()
{
$dateRead = date("Y-m-d H:i:s");
// get it once for consistency
// mark replies as read
$replies = $this->getReplies();
if (!empty($replies)) {
foreach ($replies as $reply) {
if ($reply->getDateRead() == null && $reply->getRecipientID() == Session::getUserID()) {
$reply->setDateRead($dateRead);
$reply->save();
}
}
}
}
示例14: chatHeartbeat
function chatHeartbeat($slug, $pageId)
{
//Add check for open chat boxes in order to keep track of multiple windows
if (empty($_SESSION['openChatBoxes']["{$pageId}"])) {
$_SESSION['openChatBoxes']["{$pageId}"] = 0;
$lastRecord = 0;
} else {
$lastRecord = $_SESSION['openChatBoxes']["{$pageId}"];
}
//**JAG check that SLUG is not null
$project = Project::getProjectFromSlug($slug);
$projectName = $project->getTitle();
//This line is used to track whether we are switching between projects and need to close down chat rooms
$_SESSION['lastProjectID'] = $project->getID();
//signed in user
$userId = Session::getUserID();
$chatBoxes = array();
$chats = Chat::getChats($slug, $lastRecord);
$numRows = count($chats);
$rowIndex = 0;
$items = '';
if (is_array($chats)) {
foreach ($chats as $row => $chat) {
$rowIndex++;
if (!isset($_SESSION['openChatBoxes'][$chat['recipient']]) && isset($_SESSION['chatHistory'][$chat['recipient']])) {
$items = $_SESSION['chatHistory'][$chat['recipient']];
}
//Grab username if available (should always be available)
$chatFrom = User::load($chat['sender'])->getUsername();
$chat['message'] = sanitize($chat['message']);
$message = str_replace('"', '\\"', formatParagraphs($chat['message'], true));
//Since chatHeartbeat always returns records greater than the stored last id, the only time that
// the returned id of a search will match the stored last id will be on the first post in an empty
// chat room
if ($chat['id'] !== $lastRecord) {
$items .= <<<EOD
\t\t\t\t\t {
\t\t\t"s": "0",
\t\t\t"f": "{$chatFrom}",
\t\t\t"m": "{$message}",
"r": "{$chat['id']}",
"t": "{$projectName}"
\t },
EOD;
}
if (!isset($_SESSION['chatHistory'][$chat['recipient']])) {
$_SESSION['chatHistory'][$chat['recipient']] = '';
}
$_SESSION['chatHistory'][$chat['recipient']] .= <<<EOD
\t\t\t\t\t\t {
\t\t\t"s": "0",
\t\t\t"f": "{$chatFrom}",
\t\t\t"m": "{$message}",
"r": "{$chat['id']}",
"t": "{$projectName}"
\t },
EOD;
$_SESSION['openChatBoxes'][$chat['recipient']] = $chat['sent'];
unset($_SESSION['tsChatBoxes'][$chat['recipient']]);
if ($numRows == $rowIndex && $numRows > 0) {
$_SESSION['openChatBoxes']["{$pageId}"] = $chat['id'];
}
}
}
//Update user record with heart beat (used to tell logged in members)
Chat::updateUserLocation($userId, $project->getID());
if ($items != '') {
$items = substr($items, 0, -1);
}
header('Content-type: application/json');
?>
{
"items": [
<?php
echo $items;
?>
]
}
<?php
exit(0);
}
示例15: Soup
<?php
require_once "../../global.php";
$soup = new Soup();
if (Session::isLoggedIn()) {
// dashboard
$yourProjects = ProjectUser::getProjectsByUserID(Session::getUserID());
$publicProjects = Project::getPublicProjects(Session::getUserID(), 10);
// projects to join
//$user = User::load(Session::getUserID());
$events = Event::getDashboardEvents(Session::getUserID(), 10);
// $updates = Update::getByUserID($user->getID());
// $discussions = Discussion::getByUserID($user->getID());
$invitations = Invitation::getByUserID(Session::getUserID());
$unrespondedInvites = Invitation::getByUserID(Session::getUserID(), null, false);
$yourTasks = Task::getYourTasks(Session::getUserID());
$soup->set('yourProjects', $yourProjects);
$soup->set('publicProjects', $publicProjects);
//$soup->set('user', $user);
$soup->set('events', $events);
// $soup->set('updates', $updates);
// $soup->set('discussions', $discussions);
$soup->set('invitations', $invitations);
$soup->set('unrespondedInvites', $unrespondedInvites);
$soup->set('tasks', $yourTasks);
$soup->render('site/page/dashboard');
} else {
// home page
$events = Event::getHomeEvents(10);
$soup->set('events', $events);
$soup->render('site/page/home');