本文整理汇总了PHP中PFUser::getProjects方法的典型用法代码示例。如果您正苦于以下问题:PHP PFUser::getProjects方法的具体用法?PHP PFUser::getProjects怎么用?PHP PFUser::getProjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFUser
的用法示例。
在下文中一共展示了PFUser::getProjects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDynamicUgroupsForUser
/**
* @param PFUser $user
* @return ProjectUGroup[]
*/
private function getDynamicUgroupsForUser(PFUser $user)
{
$project_ids = $user->getProjects();
$ugroups = array();
foreach ($project_ids as $group_id) {
$ugroups[] = new ProjectUGroup(array('ugroup_id' => ProjectUGroup::PROJECT_MEMBERS, 'group_id' => $group_id));
if ($user->isAdmin($group_id)) {
$ugroups[] = new ProjectUGroup(array('ugroup_id' => ProjectUGroup::PROJECT_ADMIN, 'group_id' => $group_id));
}
}
return $ugroups;
}
示例2: appendDynamicUGroups
/**
* Append project dynamic ugroups of user
*
* @param PFUser $user
* @param array $user_ugroups
*
* @return array the new array of user's ugroup
*/
private function appendDynamicUGroups(PFUser $user, array $user_ugroups = array())
{
$user_projects = $user->getProjects(true);
foreach ($user_projects as $user_project) {
$project_name = strtolower($user_project['unix_group_name']);
$group_id = $user_project['group_id'];
$user_ugroups[] = $this->ugroupIdToStringWithoutArobase(ProjectUGroup::PROJECT_MEMBERS, $project_name);
if ($user->isMember($group_id, 'A')) {
$user_ugroups[] = $this->ugroupIdToStringWithoutArobase(ProjectUGroup::PROJECT_ADMIN, $project_name);
}
}
return $user_ugroups;
}
示例3: fetchTrackerSwitcher
public function fetchTrackerSwitcher(PFUser $user, $separator, Project $include_project = null, Tracker $current_tracker = null)
{
$hp = Codendi_HTMLPurifier::instance();
$html = '';
//Projects/trackers
$projects = $user->getProjects(true);
if ($include_project) {
$found = false;
foreach ($projects as $data) {
if ($data['group_id'] == $include_project->getGroupId()) {
$found = true;
break;
}
}
if (!$found) {
$projects[] = array('group_id' => $include_project->getGroupId(), 'group_name' => $include_project->getPublicName());
}
}
$html .= '<strong>';
if ($current_tracker) {
$html .= $hp->purify($current_tracker->getProject()->getPublicName(), CODENDI_PURIFIER_CONVERT_HTML);
} else {
$html .= $GLOBALS['Language']->getText('plugin_tracker', 'tracker_switcher');
}
$html .= '</strong>' . $separator;
$html .= '<select id="tracker_select_tracker">';
if (!$current_tracker) {
$html .= '<option selected="selected">--</option>';
}
$factory = TrackerFactory::instance();
foreach ($projects as $data) {
if ($trackers = $factory->getTrackersByGroupId($data['group_id'])) {
foreach ($trackers as $key => $v) {
if (!$v->userCanView($user)) {
unset($trackers[$key]);
}
}
if ($trackers) {
$html .= '<optgroup label="' . $hp->purify($data['group_name'], CODENDI_PURIFIER_CONVERT_HTML) . '">';
foreach ($trackers as $t) {
$selected = $current_tracker && $t->getId() == $current_tracker->getId() ? 'selected="selected"' : '';
$html .= '<option ' . $selected . ' value="' . $t->getId() . '">';
$html .= $hp->purify($t->getName(), CODENDI_PURIFIER_CONVERT_HTML);
$html .= '</option>';
}
$html .= '</optgroup>';
}
}
}
$html .= '</select>';
return $html;
}
示例4: getUserProjectList
/**
* Generates project list of the given user
*
* @param PFUser $user
*
* @return Array
*/
function getUserProjectList($user)
{
$res = $user->getProjects();
$projects = array();
foreach ($res as $groupId) {
if ($this->isWebDAVAllowedForProject($groupId)) {
$project = $this->getWebDAVProject($groupId);
if ($project->userCanRead()) {
$projects[] = $project;
}
}
}
return $projects;
}
示例5: updateCVSWritersForGivenMember
/**
* Update CVS writers into all projects that given user belongs to
*
* @param PFUser $user member to add as committer
*
* @return Boolean
*/
public function updateCVSWritersForGivenMember($user)
{
$projects = $user->getProjects();
if (isset($projects)) {
$pm = $this->getProjectManager();
foreach ($projects as $groupId) {
$project = $pm->getProject($groupId);
if ($this->repositoryExists($project)) {
if (!$this->updateCVSwriters($groupId)) {
return false;
}
}
}
}
return true;
}