本文整理汇总了PHP中UserDao::getKey方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDao::getKey方法的具体用法?PHP UserDao::getKey怎么用?PHP UserDao::getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDao
的用法示例。
在下文中一共展示了UserDao::getKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: linkuser
/**
* Link user view helper.
*
* @param UserDao $userDao user DAO
* @return string full name of the user, linked to their profile if it is public
*/
public function linkuser($userDao)
{
if ($userDao->getPrivacy() == MIDAS_USER_PUBLIC || isset($this->view->userDao) && $this->view->userDao->isAdmin() || isset($this->view->userDao) && $userDao->getKey() == $this->view->userDao->getKey()) {
return '<a class="userTitle" href="' . $this->view->webroot . '/user/' . htmlspecialchars($userDao->getKey(), ENT_QUOTES, 'UTF-8') . '">' . htmlspecialchars($userDao->getFullName(), ENT_QUOTES, 'UTF-8') . '</a>';
}
return htmlspecialchars($userDao->getFullName(), ENT_QUOTES, 'UTF-8');
}
示例2: getPolicy
/**
* Get policy.
*
* @param UserDao $user
* @param FolderDao $folder
* @return false|FolderpolicyuserDao
* @throws Zend_Exception
*/
public function getPolicy($user, $folder)
{
if (!$user instanceof UserDao) {
throw new Zend_Exception('Should be a user.');
}
if (!$folder instanceof FolderDao) {
throw new Zend_Exception('Should be a folder.');
}
return $this->initDao('Folderpolicyuser', $this->database->fetchRow($this->database->select()->where('folder_id = ?', $folder->getKey())->where('user_id = ?', $user->getKey())));
}
示例3: getByUser
/**
* Return all client records owned by the given user.
*
* @param UserDao $userDao
* @return array
*/
public function getByUser($userDao)
{
$sql = $this->database->select()->setIntegrityCheck(false)->where('owner_id = ?', $userDao->getKey());
$rows = $this->database->fetchAll($sql);
$daos = array();
foreach ($rows as $row) {
$daos[] = $this->initDao('Client', $row, $this->moduleName);
}
return $daos;
}
示例4: createTempToken
/**
* Create a temporary token that will be used to fetch the user's real API token later.
*
* @param UserDao $user user to create the token for
* @param TokenDao $tokenDao token DAO
* @return Mfa_ApitokenDao
* @throws Zend_Exception
*/
public function createTempToken($user, $tokenDao)
{
/** @var Mfa_ApitokenDao $newToken */
$newToken = MidasLoader::newDao('ApitokenDao', 'mfa');
$newToken->setUserId($user->getKey());
$newToken->setTokenId($tokenDao->getKey());
$newToken->setCreationDate(date('Y-m-d H:i:s'));
$this->save($newToken);
return $newToken;
}
示例5: getPolicy
/**
* Get policy.
*
* @param UserDao $user
* @param ItemDao $item
* @return false|ItempolicyuserDao
* @throws Zend_Exception
*/
public function getPolicy($user, $item)
{
if (!$user instanceof UserDao) {
throw new Zend_Exception('Should be a user.');
}
if (!$item instanceof ItemDao) {
throw new Zend_Exception('Should be an item.');
}
return $this->initDao('Itempolicyuser', $this->database->fetchRow($this->database->select()->where('item_id = ?', $item->getKey())->where('user_id = ?', $user->getKey())));
}
示例6: getByUser
/**
* Returns the LDAP user corresponding to the core user, or false if the
* user is not an LDAP user.
*
* @param UserDao $userDao core user
* @return false|Ldap_UserDao
* @throws Zend_Exception
*/
public function getByUser($userDao)
{
$sql = $this->database->select()->where('user_id = ?', $userDao->getKey());
$row = $this->database->fetchRow($sql);
$dao = $this->initDao('User', $row, 'ldap');
if ($dao) {
return $dao;
} else {
return false;
}
}
示例7: createTask
/**
* Create a task.
*
* @param UserDao $userDao
* @param string $tmpWorkDirRoot
* @return Batchmake_TaskDao
* @throws Zend_Exception
*/
public function createTask($userDao, $tmpWorkDirRoot)
{
if (!$userDao instanceof UserDao) {
throw new Zend_Exception('Error parameters.');
}
/** @var Batchmake_TaskDao $task */
$task = MidasLoader::newDao('TaskDao', 'batchmake');
$task->setUserId($userDao->getKey());
$this->save($task);
$userId = $task->getUserId();
$taskId = $task->getKey();
$subdirs = array(MIDAS_BATCHMAKE_SSP_DIR, $userId, $taskId);
// create a workDir based on the task and user
$workDir = KWUtils::createSubDirectories($tmpWorkDirRoot . '/', $subdirs);
$task->setWorkDir($workDir);
$this->save($task);
return $task;
}
示例8: create
/**
* Create and return a new oauth client owned by the given user.
*
* @param UserDao $userDao owner of the client
* @param string $name human readable name of the client
* @return Oauth_ClientDao
* @throws Zend_Exception
*/
public function create($userDao, $name)
{
if (!$userDao instanceof UserDao) {
throw new Zend_Exception('Invalid userDao');
}
if (empty($name)) {
throw new Zend_Exception('Client name must not be empty');
}
/** @var RandomComponent $randomComponent */
$randomComponent = MidasLoader::loadComponent('Random');
/** @var Oauth_ClientDao $clientDao */
$clientDao = MidasLoader::newDao('ClientDao', $this->moduleName);
$clientDao->setName($name);
$clientDao->setOwnerId($userDao->getKey());
$clientDao->setSecret($randomComponent->generateString(40));
$clientDao->setCreationDate(date('Y-m-d H:i:s'));
$this->save($clientDao);
return $clientDao;
}
示例9: createInvitation
/**
* Create an invitation record for the user into the given group.
*
* @param GroupDao $groupDao The group to invite the user to
* @param UserDao $userDao The user performing the invitation (typically the session user)
* @param UserDao $invitedUserDao The user being invited to the group
* @return false|CommunityInvitationDao
* @throws Zend_Exception
*/
public function createInvitation($groupDao, $userDao, $invitedUserDao)
{
$communityDao = $groupDao->getCommunity();
$invitations = $invitedUserDao->getInvitations();
foreach ($invitations as $invitation) {
if ($invitation->getCommunityId() == $communityDao->getKey()) {
return false;
}
}
/** @var CommunityInvitationDao $invitationDao */
$invitationDao = MidasLoader::newDao('CommunityInvitationDao');
$invitationDao->setCommunityId($communityDao->getKey());
$invitationDao->setGroupId($groupDao->getKey());
$invitationDao->setUserId($invitedUserDao->getKey());
$this->save($invitationDao);
/** @var FeedModel $feedModel */
$feedModel = MidasLoader::loadModel('Feed');
/** @var FeedpolicyuserModel $feedpolicyuserModel */
$feedpolicyuserModel = MidasLoader::loadModel('Feedpolicyuser');
$feed = $feedModel->createFeed($userDao, MIDAS_FEED_COMMUNITY_INVITATION, $invitationDao, $communityDao);
$feedpolicyuserModel->createPolicy($invitedUserDao, $feed, MIDAS_POLICY_ADMIN);
return $invitationDao;
}
示例10: create
/**
* Create and return a new oauth authorization code for the given client and user. Expires after 10 minutes
* in accordance with the recommendation in the IETF draft v31.
*
* @param UserDao $userDao resource owner (end user to authenticate via the client)
* @param Oauth_ClientDao $clientDao client that will be receiving the code
* @param array $scopes array of permission scopes (see api module constants)
* @return Oauth_CodeDao
* @throws Zend_Exception
*/
public function create($userDao, $clientDao, $scopes)
{
if (!$userDao instanceof UserDao) {
throw new Zend_Exception('Invalid userDao');
}
if (!$clientDao instanceof Oauth_ClientDao) {
throw new Zend_Exception('Invalid userDao');
}
if (!is_array($scopes)) {
throw new Zend_Exception('Scopes must be an array');
}
/** @var RandomComponent $randomComponent */
$randomComponent = MidasLoader::loadComponent('Random');
/** @var Oauth_CodeDao $codeDao */
$codeDao = MidasLoader::newDao('CodeDao', $this->moduleName);
$codeDao->setCode($randomComponent->generateString(32));
$codeDao->setScopes(JsonComponent::encode($scopes));
$codeDao->setUserId($userDao->getKey());
$codeDao->setClientId($clientDao->getKey());
$codeDao->setCreationDate(date('Y-m-d H:i:s'));
$codeDao->setExpirationDate(date('Y-m-d H:i:s', strtotime('+10 minutes')));
$this->save($codeDao);
return $codeDao;
}
示例11: getByUser
/**
* Get the user's keys.
*
* @param UserDao $userDao
* @return array
* @throws Zend_Exception
*/
public function getByUser($userDao)
{
if (!$userDao instanceof UserDao) {
throw new Zend_Exception('Error in parameter when getting Userapi from user.');
}
$rowset = $this->database->fetchAll($this->database->select()->where('user_id = ?', $userDao->getKey()));
$return = array();
foreach ($rowset as $row) {
$return[] = $this->initDao('Userapi', $row);
}
return $return;
}
示例12: addToTrend
/**
* Add a new scalar to the trend. If overwrite is true, and a scalar already exists on the trend with the same
* submit time and user, then this will replace that scalar.
*
* @param Tracker_TrendDao $trendDao trend DAO
* @param string $submitTime submit time
* @param string $producerRevision producer revision
* @param float $value scalar value
* @param UserDao $userDao user DAO
* @param bool $overwrite true if a scalar with the same trend, submit time, and user should be overwritten
* @param bool $official true if the submission containing the scalar should be official
* @param string $buildResultsUrl build results URL
* @param null|string $branch branch name
* @param null|string|array $params parameters
* @param null|string|array $extraUrls extra URLs
* @return Tracker_ScalarDao scalar DAO
*/
public function addToTrend($trendDao, $submitTime, $submissionId, $producerRevision, $value, $userDao, $overwrite = true, $official = true, $buildResultsUrl = '', $branch = '', $params = null, $extraUrls = null)
{
if ($overwrite === true) {
$scalarDao = $this->getByTrendAndTimestamp($trendDao->getKey(), $submitTime, $userDao->getKey());
if ($scalarDao !== false) {
$this->delete($scalarDao);
}
}
if (empty($params)) {
$params = null;
} elseif (is_array($params)) {
$params = json_encode($params);
}
if (empty($extraUrls)) {
$extraUrls = null;
} elseif (is_array($extraUrls)) {
$extraUrls = json_encode($extraUrls);
}
$userId = is_null($userDao) || $userDao === false ? -1 : $userDao->getKey();
/** @var Tracker_ScalarDao $scalarDao */
$scalarDao = MidasLoader::newDao('ScalarDao', $this->moduleName);
$scalarDao->setSubmissionId($submissionId);
$scalarDao->setTrendId($trendDao->getKey());
$scalarDao->setSubmitTime($submitTime);
$scalarDao->setProducerRevision($producerRevision);
$scalarDao->setValue($value);
$scalarDao->setUserId($userId);
$scalarDao->setOfficial((int) $official);
$scalarDao->setBuildResultsUrl($buildResultsUrl);
$scalarDao->setBranch(trim($branch));
$scalarDao->setParams($params);
$scalarDao->setExtraUrls($extraUrls);
$this->save($scalarDao);
return $scalarDao;
}
示例13: getFeeds
/**
* Get feeds.
*
* @param UserDao $loggedUserDao
* @param null|UserDao $userDao
* @param null|CommunityDao $communityDao
* @param int $policy
* @param int $limit
* @return array
* @throws Zend_Exception
*/
protected function getFeeds($loggedUserDao, $userDao = null, $communityDao = null, $policy = 0, $limit = 20)
{
$isAdmin = false;
if ($loggedUserDao == null) {
$userId = -1;
} elseif (!$loggedUserDao instanceof UserDao) {
throw new Zend_Exception('Should be an user.');
} else {
$userId = $loggedUserDao->getUserId();
if ($loggedUserDao->isAdmin()) {
$isAdmin = true;
}
}
if ($userDao != null && !$userDao instanceof UserDao) {
throw new Zend_Exception('Should be an user.');
}
if ($communityDao != null && !$communityDao instanceof CommunityDao) {
throw new Zend_Exception('Should be a community.');
}
$sql = $this->database->select()->setIntegrityCheck(false)->from(array('f' => 'feed'))->limit($limit);
if (!$isAdmin) {
$sql->joinLeft(array('fpu' => 'feedpolicyuser'), '
f.feed_id = fpu.feed_id AND ' . $this->database->getDB()->quoteInto('fpu.policy >= ?', $policy) . '
AND ' . $this->database->getDB()->quoteInto('fpu.user_id = ? ', $userId) . ' ', array('userpolicy' => 'fpu.policy'))->joinLeft(array('fpg' => 'feedpolicygroup'), '
f.feed_id = fpg.feed_id AND ' . $this->database->getDB()->quoteInto('fpg.policy >= ?', $policy) . '
AND ( ' . $this->database->getDB()->quoteInto('fpg.group_id = ? ', MIDAS_GROUP_ANONYMOUS_KEY) . ' OR
fpg.group_id IN (' . new Zend_Db_Expr($this->database->select()->setIntegrityCheck(false)->from(array('u2g' => 'user2group'), array('group_id'))->where('u2g.user_id = ?', $userId)) . '))', array('grouppolicy' => 'fpg.policy'))->where('(
fpu.feed_id is not null or
fpg.feed_id is not null)');
}
if ($userDao != null) {
$sql->where('f.user_id = ? ', $userDao->getKey());
}
if ($communityDao != null) {
$sql->join(array('f2c' => 'feed2community'), $this->database->getDB()->quoteInto('f2c.community_id = ? ', $communityDao->getKey()) . ' AND f.feed_id = f2c.feed_id', array());
}
$sql->order(array('f.date DESC'));
$rowset = $this->database->fetchAll($sql);
$rowsetAnalysed = array();
foreach ($rowset as $row) {
if (isset($row['userpolicy']) && $row['userpolicy'] == null) {
$row['userpolicy'] = 0;
}
if (isset($row['grouppolicy']) && $row['grouppolicy'] == null) {
$row['grouppolicy'] = 0;
}
if (!isset($rowsetAnalysed[$row['feed_id']]) || $rowsetAnalysed[$row['feed_id']]->policy < $row['userpolicy'] && $rowsetAnalysed[$row['feed_id']]->policy < $row['grouppolicy']) {
$tmpDao = $this->initDao('Feed', $row);
if (isset($row['userpolicy']) && isset($row['grouppolicy']) && $row['userpolicy'] >= $row['grouppolicy']) {
$tmpDao->policy = $row['userpolicy'];
} elseif ($isAdmin) {
$tmpDao->policy = MIDAS_POLICY_ADMIN;
} else {
$tmpDao->policy = $row['grouppolicy'];
}
$rowsetAnalysed[$row['feed_id']] = $tmpDao;
unset($tmpDao);
}
}
$this->Component->Sortdao->field = 'date';
$this->Component->Sortdao->order = 'asc';
usort($rowsetAnalysed, array($this->Component->Sortdao, 'sortByDate'));
return $rowsetAnalysed;
}
示例14: deleteByUser
/**
* Delete this to wipe the link between a google OAuth user and a core user
* record. Must call when a core user record is being deleted.
*
* @param UserDao $userDao The core user dao.
*/
public function deleteByUser($userDao)
{
$this->database->getDB()->delete('googleauth_user', 'user_id = ' . $userDao->getKey());
}
示例15: getMaxPolicy
/**
* Get the maximum policy level for the given item and user.
*
* @param int $itemId
* @param UserDao $user
* @return int|string
*/
public function getMaxPolicy($itemId, $user)
{
$maxPolicy = -1;
if ($user) {
if ($user->isAdmin()) {
return MIDAS_POLICY_ADMIN;
}
$userId = $user->getKey();
$sql = $this->database->select()->setIntegrityCheck(false)->from('itempolicyuser', array('maxpolicy' => 'max(policy)'))->where('item_id = ?', $itemId)->where('user_id = ? ', $userId);
$row = $this->database->fetchRow($sql);
if ($row != null && $row['maxpolicy'] > $maxPolicy) {
$maxPolicy = $row['maxpolicy'];
}
} else {
$userId = -1;
}
$sql = $this->database->select()->setIntegrityCheck(false)->from(array('p' => 'itempolicygroup'), array('maxpolicy' => 'max(policy)'))->where('p.item_id = ?', $itemId)->where('( ' . $this->database->getDB()->quoteInto('group_id = ?', MIDAS_GROUP_ANONYMOUS_KEY) . ' OR group_id IN (' . new Zend_Db_Expr($this->database->select()->setIntegrityCheck(false)->from(array('u2g' => 'user2group'), array('group_id'))->where('u2g.user_id = ?', $userId) . '))'));
$row = $this->database->fetchRow($sql);
if ($row != null && $row['maxpolicy'] > $maxPolicy) {
$maxPolicy = $row['maxpolicy'];
}
return $maxPolicy;
}