本文整理汇总了PHP中UserCache类的典型用法代码示例。如果您正苦于以下问题:PHP UserCache类的具体用法?PHP UserCache怎么用?PHP UserCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_by_login_and_remove
/**
* Test, if a user cached by login gets removed on clear()
*/
function test_get_by_login_and_remove()
{
$UserCache = new UserCache();
$this->MockDB->expectCallCount('get_row', 2);
$this->MockDB->expect('get_row', array(new PatternExpectation('/SELECT \\*\\s+FROM T_users.*login/is'), '*', '*', '*'), 'DB select ok.');
$UserCache->get_by_login('login');
$UserCache->clear();
$UserCache->get_by_login('login');
}
示例2: getIssueGeneralInfo
/**
* Get general info of an issue
* @param Issue $issue The issue
* @param bool $isManager if true: show MgrEffortEstim column
* @param bool $displaySupport If true, display support
* @return mixed[]
*/
public static function getIssueGeneralInfo(Issue $issue, $isManager = false, $displaySupport = false)
{
$withSupport = true;
// include support in elapsed & Drift
$drift = $issue->getDrift($withSupport);
$issueGeneralInfo = array("issueId" => $issue->getId(), "issueSummary" => htmlspecialchars(preg_replace('![\\t\\r\\n]+!', ' ', $issue->getSummary())), "issueType" => $issue->getType(), "issueDescription" => htmlspecialchars($issue->getDescription()), "projectName" => $issue->getProjectName(), "categoryName" => $issue->getCategoryName(), "issueExtRef" => $issue->getTcId(), 'mantisURL' => Tools::mantisIssueURL($issue->getId(), NULL, true), 'issueURL' => Tools::mantisIssueURL($issue->getId()), 'statusName' => $issue->getCurrentStatusName(), 'priorityName' => $issue->getPriorityName(), 'severityName' => $issue->getSeverityName(), 'handlerName' => UserCache::getInstance()->getUser($issue->getHandlerId())->getName(), "issueEffortTitle" => $issue->getEffortEstim() . ' + ' . $issue->getEffortAdd(), "issueEffort" => $issue->getEffortEstim() + $issue->getEffortAdd(), "issueReestimated" => $issue->getReestimated(), "issueBacklog" => $issue->getBacklog(), "issueDriftColor" => $issue->getDriftColor($drift), "issueDrift" => round($drift, 2), "progress" => round(100 * $issue->getProgress()), 'relationships' => self::getFormattedRelationshipsInfo($issue));
if ($isManager) {
$issueGeneralInfo['issueMgrEffortEstim'] = $issue->getMgrEffortEstim();
$driftMgr = $issue->getDriftMgr($withSupport);
$issueGeneralInfo['issueDriftMgrColor'] = $issue->getDriftColor($driftMgr);
$issueGeneralInfo['issueDriftMgr'] = round($driftMgr, 2);
}
if ($withSupport) {
$issueGeneralInfo['issueElapsed'] = $issue->getElapsed();
} else {
$issueGeneralInfo['issueElapsed'] = $issue->getElapsed() - $issue->getElapsed(Jobs::JOB_SUPPORT);
}
if ($displaySupport) {
if ($isManager) {
$driftMgr = $issue->getDriftMgr(!$withSupport);
$issueGeneralInfo['issueDriftMgrSupportColor'] = $issue->getDriftColor($driftMgr);
$issueGeneralInfo['issueDriftMgrSupport'] = round($driftMgr, 2);
}
$drift = $issue->getDrift(!$withSupport);
$issueGeneralInfo['issueDriftSupportColor'] = $issue->getDriftColor($drift);
$issueGeneralInfo['issueDriftSupport'] = round($drift, 2);
}
return $issueGeneralInfo;
}
示例3: display
protected function display()
{
// Admins only
if (Tools::isConnectedUser()) {
$session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
$this->smartyHelper->assign('defaultColor', Holidays::$defaultColor);
if (isset($_POST['hol_color'])) {
$formatedDate = Tools::getSecurePOSTStringValue('date');
$timestamp = Tools::date2timestamp($formatedDate);
$hol_desc = Tools::getSecurePOSTStringValue('hol_desc');
$hol_color = Tools::getSecurePOSTStringValue('hol_color');
if (!Holidays::save($timestamp, $hol_desc, $hol_color)) {
$this->smartyHelper->assign('error', T_("Couldn't add the holiday"));
}
} elseif (isset($_POST['hol_id'])) {
$hol_id = Tools::getSecurePOSTIntValue('hol_id');
if (!Holidays::delete($hol_id)) {
$this->smartyHelper->assign('error', T_("Couldn't remove the holiday"));
}
}
$this->smartyHelper->assign('holidays', Holidays::getHolidays());
}
}
}
示例4: actionRefreshOperations
/**
* actionRefreshOperations
*
* @param int $id - task id
*/
public function actionRefreshOperations($id)
{
UserOperation::updateData();
// Reset cache
UserCache::model()->updateAll(array('status' => 0));
$this->redirect(array('view', 'id' => $id));
}
示例5: execute
/**
*
* 执行登录检查,如果错误,将返回状态代码403
*
* @access public
* @param 无
* @return void
*/
public function execute($request)
{
Logger::debug('----- ' . __CLASS__ . ' is started -----');
// 验证 SessionKey
$user_id = $request->getRequestParameter(Constants::PARAM_SESSION_KEY);
$clientSendKey = $request->getRequestParameter(Constants::PARAM_USER_ID);
$userCache = UserCache::getCacheInstance();
$serverSaveKey = $userCache->getByKey($user_id, Constants::CURRENT_SESSION_KEY);
if ($serverSaveKey !== $clientSendKey) {
Logger::debug('Stopping ' . __CLASS__ . '. caused by: Invalid session key.');
Logger::debug('server save session key: ', $serverSaveKey);
Logger::debug('client send session key: ', $clientSendKey);
$view = new JsonView();
$view->setValue('result', Constants::RESP_RESULT_ERROR);
$view->setValue('message', "session key not match");
$view->display();
throw new ForbiddenException("Session Key not match.");
}
// 登录检查
/*if( !$authorizer->loginCheck($auth_param) )
{
Logger::debug( 'Stopping ' . __CLASS__ . '. caused by: The request not authenticated.' );
throw new ForbiddenException();
}*/
Logger::debug(__CLASS__ . ' is success.');
Logger::debug('----- ' . __CLASS__ . ' is finished -----');
}
示例6: display
protected function display()
{
if (Tools::isConnectedUser()) {
// Admins only
$session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
if (NULL != Constants::$codevtt_logfile && file_exists(Constants::$codevtt_logfile)) {
$nbLinesToDisplay = 1500;
$lines = file(Constants::$codevtt_logfile);
if (count($lines) > $nbLinesToDisplay) {
$offset = count($lines) - $nbLinesToDisplay;
} else {
$offset = 0;
}
$logs = array();
for ($i = $offset; $i <= $offset + $nbLinesToDisplay, $i < count($lines); $i++) {
$logs[$i + 1] = htmlspecialchars($lines[$i], ENT_QUOTES, "UTF-8");
#echo "DEBUG $line_num - ".$logs[$line_num]."<br>";
}
$this->smartyHelper->assign('logs', $logs);
} else {
$this->smartyHelper->assign('error', T_('Sorry, logfile not found:') . ' [' . Constants::$codevtt_logfile . ']');
}
} else {
$this->smartyHelper->assign('error', T_('Sorry, you need to be in the admin-team to access this page.'));
}
} else {
$this->smartyHelper->assign('error', T_('Sorry, you need to be in the admin-team to access this page.'));
}
}
示例7: display
protected function display()
{
if (Tools::isConnectedUser()) {
// Admins only
$session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
$projectList = $this->getProjectList(false);
if (isset($_POST['projectid']) && array_key_exists($_POST['projectid'], $projectList)) {
$projectid = Tools::getSecurePOSTIntValue('projectid');
$_SESSION['projectid'] = $projectid;
} elseif (isset($_SESSION['projectid']) && array_key_exists($_SESSION['projectid'], $projectList)) {
$projectid = $_SESSION['projectid'];
} else {
$projectIds = array_keys($projectList);
if (count($projectIds) > 0) {
$projectid = $projectIds[0];
} else {
$projectid = 0;
}
}
$this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projectList, $projectid));
// display current workflow
if (0 != $projectid) {
$clone_projectid = Tools::getSecurePOSTIntValue('clone_projectid', 0);
if ($clone_projectid == $projectid || !array_key_exists($clone_projectid, $projectList)) {
$clone_projectid = 0;
}
$action = Tools::getSecurePOSTStringValue('action', '');
if ("cloneToProject" == $action) {
#echo "Clone $projectid ---> $clone_projectid<br>";
$errMsg = Project::cloneAllProjectConfig($projectid, $clone_projectid);
$this->smartyHelper->assign('msg', 'Clone to project : ' . $errMsg);
} elseif ("cloneFromProject" == $action) {
#echo "Clone $clone_projectid ---> $projectid<br>";
$errMsg = Project::cloneAllProjectConfig($clone_projectid, $projectid);
$this->smartyHelper->assign('msg', 'Clone from project : ' . $errMsg);
}
unset($projectList[$projectid]);
$this->smartyHelper->assign('cloneProjects', SmartyTools::getSmartyArray($projectList, $clone_projectid));
$proj = ProjectCache::getInstance()->getProject($projectid);
$this->smartyHelper->assign('currentProjectId', $projectid);
$this->smartyHelper->assign('defaultProjectId', $clone_projectid);
$this->smartyHelper->assign('currentProjectName', $proj->getName());
$this->smartyHelper->assign('disabled', 0 == $clone_projectid);
$projectsInfo = array();
$projectsInfo[] = $this->getProjectInfo($proj, "tabsProject");
if (0 != $clone_projectid) {
$cproj = ProjectCache::getInstance()->getProject($clone_projectid);
$this->smartyHelper->assign('defaultProjectName', $cproj->getName());
$projectsInfo[] = $this->getProjectInfo($cproj, "tabsCloneProject");
}
$this->smartyHelper->assign('projectsInfo', $projectsInfo);
}
}
}
}
示例8: display
protected function display()
{
if (Tools::isConnectedUser()) {
$session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
// Admins only
if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
$this->smartyHelper->assign('access', true);
$is_modified = Tools::getSecurePOSTStringValue('is_modified', 'false');
// init
// 'is_modified' is used because it's not possible to make a difference
// between an unchecked checkBox and an unset checkbox variable
if ("false" == $is_modified) {
$isBackup = true;
} else {
$isBackup = $_POST['cb_backup'];
}
$filename = Tools::getSecurePOSTStringValue('backup_filename', "codevtt_backup_" . date("Ymd") . ".sql");
$this->smartyHelper->assign('isBackup', $isBackup);
$this->smartyHelper->assign('filename', $filename);
if (isset($_POST['cb_backup'])) {
$result = true;
if ($isBackup) {
$result = SqlWrapper::getInstance()->sql_dump($filename) && $this->saveConfigFiles();
$this->smartyHelper->assign('backupResult', $result);
}
$this->smartyHelper->assign('stepOneResult', $result);
if ($result) {
$prjList = $this->displayProjectsToRemove();
$this->smartyHelper->assign('projects', $prjList);
}
$this->smartyHelper->assign('stepTwoResult', $result);
if ($result) {
$result = $this->removeCustomFields();
}
$this->smartyHelper->assign('stepThreeResult', $result);
if ($result) {
$result = Tools::execSQLscript2("uninstall.sql");
}
$this->smartyHelper->assign('stepFourResult', $result);
if ($result) {
$result = $this->deleteConfigFiles();
}
$this->smartyHelper->assign('stepFiveResult', $result);
if ($result) {
$result = $this->removeCustomMenuItem('CodevTT');
}
$this->smartyHelper->assign('stepSixResult', $result);
} else {
Config::setQuiet(true);
$this->smartyHelper->assign('codevReportsDir', Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports');
Config::setQuiet(false);
$this->smartyHelper->assign('is_modified', $is_modified);
}
}
}
}
示例9: login
function login($user, $password)
{
$logger = Logger::getLogger('login');
// WARN: if logger is LoggerAppenderEcho, then logs will break the login Ajax call !
try {
$appenders = $logger->getParent()->getAllAppenders();
$isLog = true;
foreach ($appenders as $appender) {
if ('LoggerAppenderEcho' === get_class($appender)) {
$isLog = false;
break;
}
}
} catch (Exception $e) {
// logs should never break application
$isLog = false;
}
$password = md5($password);
$formattedUser = SqlWrapper::sql_real_escape_string($user);
$formattedPass = SqlWrapper::sql_real_escape_string($password);
$query = "SELECT id, username, realname FROM `mantis_user_table` WHERE username = '" . $formattedUser . "' AND password = '" . $formattedPass . "' AND enabled = 1;";
$result = SqlWrapper::getInstance()->sql_query($query);
if ($result && SqlWrapper::getInstance()->sql_num_rows($result) == 1 && ($row_login = SqlWrapper::getInstance()->sql_fetch_object($result))) {
$_SESSION['userid'] = $row_login->id;
$_SESSION['username'] = $row_login->username;
$_SESSION['realname'] = $row_login->realname;
try {
$user = UserCache::getInstance()->getUser($row_login->id);
$locale = $user->getDefaultLanguage();
if (NULL != $locale) {
$_SESSION['locale'] = $locale;
}
$teamid = $user->getDefaultTeam();
if (0 != $teamid) {
$_SESSION['teamid'] = $teamid;
}
$projid = $user->getDefaultProject();
if (0 != $projid) {
$_SESSION['projectid'] = $projid;
}
} catch (Exception $e) {
if ($isLog && self::$logger->isDebugEnabled()) {
$logger->debug("could not load preferences for user {$row_login->id}");
}
}
if ($isLog) {
$ua = Tools::getBrowser();
$browserStr = $ua['name'] . ' ' . $ua['version'] . ' (' . $ua['platform'] . ')';
$logger->info('user ' . $row_login->id . ' ' . $row_login->username . ' (' . $row_login->realname . '), Team ' . $user->getDefaultTeam() . ', ' . $browserStr);
}
return TRUE;
} else {
#$error = 'login failed !';
return FALSE;
}
}
示例10: setSessionKey
public static function setSessionKey($user_id, $oldSessionKey)
{
// 生成缓存
$newSessionKey = Util::generateSessionKey($user_id);
Logger::debug('SessionKey1:' . $oldSessionKey);
Logger::debug('SessionKey2:' . $newSessionKey);
UserCache::setByKey($user_id, Constants::PREVIOUS_SESSION_KEY, $oldSessionKey);
UserCache::setByKey($user_id, Constants::CURRENT_SESSION_KEY, $newSessionKey);
return $newSessionKey;
}
示例11: getCommandIssues
/**
* @param Command $command
* @return mixed[]
*/
private static function getCommandIssues(Command $command)
{
$issueArray = array();
$issues = $command->getIssueSelection()->getIssueList();
foreach ($issues as $id => $issue) {
$driftMgr = $issue->getDriftMgr();
$driftMgrColor = $issue->getDriftColor($driftMgr);
$drift = $issue->getDrift();
$driftColor = $issue->getDriftColor($drift);
$user = UserCache::getInstance()->getUser($issue->getHandlerId());
$issueArray[$id] = array("mantisLink" => Tools::mantisIssueURL($issue->getId(), NULL, TRUE), "bugid" => Tools::issueInfoURL(sprintf("%07d\n", $issue->getId())), "extRef" => $issue->getTcId(), "project" => $issue->getProjectName(), "target" => $issue->getTargetVersion(), "status" => $issue->getCurrentStatusName(), "progress" => round(100 * $issue->getProgress()), "effortEstim" => $issue->getEffortEstim() + $issue->getEffortAdd(), "mgrEffortEstim" => $issue->getMgrEffortEstim(), "elapsed" => $issue->getElapsed(), "driftMgr" => $driftMgr, "driftMgrColor" => $driftMgrColor, "drift" => $drift, "driftColor" => $driftColor, "duration" => $issue->getDuration(), "summary" => $issue->getSummary(), "type" => $issue->getType(), "handlerName" => $user->getName());
}
return $issueArray;
}
示例12: getUserData
protected function getUserData()
{
$userId = $this->userId;
$cache = UserCache::getInstance();
$data = $cache->read($userId);
if ((ENVIRONMENT & PRODUCTION) > 0 && !$data) {
list($fp) = $cache->lock($userId);
$data = $this->_getUserData($userId);
$cache->write($fp, $data);
}
if (!$data) {
$data = $this->_getUserData($userId);
}
return Sabel_ValueObject::fromArray(array("userId" => $userId, "friends" => Follower::getFriends($userId, FRIENDS_ICON_LIMIT + 1), "friendsCount" => $data["friends"], "followersCount" => $data["followers"], "statusesCount" => $data["statuses"], "latestComment" => $data["comment"]));
}
示例13: logicsFollowRemove
protected function logicsFollowRemove($userId, $targetId, $result)
{
if ($result->isFailure() || $result->removeType !== "follow") {
return;
}
$cache = UserCache::getInstance();
list($fp, $data) = $cache->lock($userId);
if ($data) {
$data["friends"]--;
$cache->write($fp, $data);
}
list($fp, $data) = $cache->lock($targetId);
if ($data) {
$data["followers"]--;
$cache->write($fp, $data);
}
}
示例14: checkAnalyzed
/**
* fiches analyzed dont BI non renseignes
* fiches analyzed dont RAE non renseignes
* @return ConsistencyError[]
*/
public function checkAnalyzed()
{
// CoDev FDJ custom, defined in Mantis
$status_analyzed = Config::getVariableKeyFromValue(Config::id_statusNames, 'analyzed');
$status_accepted = Config::getVariableKeyFromValue(Config::id_statusNames, 'accepted');
$status_deferred = Config::getVariableKeyFromValue(Config::id_statusNames, 'deferred');
$FDJ_teamid = Config::getInstance()->getValue(Config::id_ClientTeamid);
$cerrList = array();
// select all issues which current status is 'analyzed'
$query = "SELECT * " . "FROM `mantis_bug_table` " . "WHERE status in ({$status_analyzed}, {$status_accepted}, " . Constants::$status_open . ", {$status_deferred}) ";
if (0 != count($this->projectList)) {
$formatedProjects = implode(', ', array_keys($this->projectList));
$query .= "AND project_id IN ({$formatedProjects}) ";
}
$query .= "ORDER BY last_updated DESC, bug_id DESC";
$result = SqlWrapper::getInstance()->sql_query($query);
if (!$result) {
echo "<span style='color:red'>ERROR: Query FAILED</span>";
exit;
}
while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
$issue = IssueCache::getInstance()->getIssue($row->id, $row);
if (NULL == $issue->getEffortEstim()) {
$cerr = new ConsistencyError($row->id, $row->handler_id, $row->status, $row->last_updated, T_("BI not specified: BI = Time(Analysis + Dev + Tests)"));
$cerr->severity = T_("Error");
$cerrList[] = $cerr;
}
if (is_null($issue->getBacklog())) {
$cerr = new ConsistencyError($row->bug_id, $row->handler_id, $row->status, $row->last_updated, T_("Backlog not specified: Backlog = Time(BI - Analysis)"));
$cerr->severity = T_("Error");
$cerrList[] = $cerr;
}
if ($status_analyzed == $row->status) {
$user = UserCache::getInstance()->getUser($row->handler_id);
if (!$user->isTeamMember($FDJ_teamid)) {
$cerr = new ConsistencyError($row->bug_id, $row->handler_id, $row->status, $row->last_updated, T_("Once analysed, a Task must be assigned to 'FDJ' for validation"));
$cerr->severity = T_("Error");
$cerrList[] = $cerr;
}
}
}
// check if fields correctly set
return $cerrList;
}
示例15: display
protected function display()
{
if (Tools::isConnectedUser()) {
// Admins only
$session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
if (isset($_POST['projects']) && !empty($_POST['projects'])) {
$selectedProjects = $_POST['projects'];
$result = array();
foreach ($selectedProjects as $projectid) {
$project = ProjectCache::getInstance()->getProject($projectid);
$result[$projectid] = $project->getName();
Project::prepareProjectToCodev($projectid);
}
$this->smartyHelper->assign('result', $result);
}
$this->smartyHelper->assign('projects', $this->getProjectList());
}
}
}