本文整理汇总了PHP中GitRepository::belongsTo方法的典型用法代码示例。如果您正苦于以下问题:PHP GitRepository::belongsTo方法的具体用法?PHP GitRepository::belongsTo怎么用?PHP GitRepository::belongsTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitRepository
的用法示例。
在下文中一共展示了GitRepository::belongsTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GitRepository
function permission_user_allowed_to_change($params)
{
if (!$params['allowed']) {
if (!$this->_cached_permission_user_allowed_to_change) {
if (in_array($params['permission_type'], array('PLUGIN_GIT_READ', 'PLUGIN_GIT_WRITE', 'PLUGIN_GIT_WPLUS'))) {
require_once 'GitRepository.class.php';
$repository = new GitRepository();
$repository->setId($params['object_id']);
try {
$repository->load();
//Only project admin can update perms of project repositories
//Only repo owner can update perms of personal repositories
$user = UserManager::instance()->getCurrentUser();
$this->_cached_permission_user_allowed_to_change = $repository->belongsTo($user) || $user->isMember($repository->getProjectId(), 'A');
} catch (Exception $e) {
// do nothing
}
}
}
$params['allowed'] = $this->_cached_permission_user_allowed_to_change;
}
}
示例2: testUserRepositoryDoesNotBelongToAnotherUser
public function testUserRepositoryDoesNotBelongToAnotherUser()
{
$creator = new PFUser(array('language_id' => 1));
$creator->setId(123);
$user = new PFUser(array('language_id' => 1));
$user->setId(456);
$repo = new GitRepository();
$repo->setCreator($creator);
$repo->setScope(GitRepository::REPO_SCOPE_INDIVIDUAL);
$this->assertFalse($repo->belongsTo($user));
}
示例3: GitRepository
function permission_user_allowed_to_change($params)
{
if (!$params['allowed']) {
$user = $this->getCurrentUser();
$project = $this->getProjectManager()->getProject($params['group_id']);
if ($this->getGitPermissionsManager()->userIsGitAdmin($user, $project)) {
$this->_cached_permission_user_allowed_to_change = true;
}
if (!$this->_cached_permission_user_allowed_to_change) {
if (in_array($params['permission_type'], array('PLUGIN_GIT_READ', 'PLUGIN_GIT_WRITE', 'PLUGIN_GIT_WPLUS'))) {
$repository = new GitRepository();
$repository->setId($params['object_id']);
try {
$repository->load();
//Only project admin can update perms of project repositories
//Only repo owner can update perms of personal repositories
$this->_cached_permission_user_allowed_to_change = $repository->belongsTo($user) || $this->getPermissionsManager()->userIsGitAdmin($user, $project);
} catch (Exception $e) {
// do nothing
}
}
}
$params['allowed'] = $this->_cached_permission_user_allowed_to_change;
}
}