Skip to content

Commit e7a28ee

Browse files
committed
Planner API examples updates
1 parent 0090b26 commit e7a28ee

13 files changed

+150
-29
lines changed

examples/Planner/GetSharedTasksReport.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?php
22

33
/**
4+
* Planner Plan and Task Report
45
*
5-
* Description:
6-
* - List all groups containing Planner plans
7-
* - Identify plans accessible to the specific group
8-
* - Extract all tasks from qualifying plans
6+
* This script:
7+
* 1. Retrieves all Planner plans associated with the group
8+
* 2. Extracts all tasks for each plan with relevant details
9+
* 3. Returns structured JSON output containing plans with their tasks
910
*
10-
* Permissions:
11-
* Accessing group plans requires both Group.Read.All and Tasks.Read.All permissions.
11+
* Required Permissions:
12+
* - Group.Read.All (to read group information)
13+
* - Tasks.Read.All (to read Planner tasks)
14+
*
15+
* Note: The service principal/app registration must have these permissions granted
16+
* with admin consent in the Azure AD portal.
1217
*/
1318

1419

@@ -21,13 +26,19 @@
2126
$settings = include('../../tests/Settings.php');
2227
$client = GraphServiceClient::withClientSecret($settings['TenantName'], $settings['ClientId'], $settings['ClientSecret']);
2328

29+
$groupName = "TestSharedGroup";
2430

2531
// 1. Get the specific group
2632
$groups = $client->getGroups()
27-
->filter("displayName eq 'PlanGroup'")
33+
->filter("displayName eq '$groupName'")
2834
->get()
2935
->executeQuery();
3036

37+
if (count($groups->getData()) === 0) {
38+
throw new Exception("Group '$groupName' not found");
39+
}
40+
41+
3142
// 2. Get all plans in this group
3243
$plans = $groups[0]->getPlanner()
3344
->getPlans()

examples/Reports/getReports.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
var_dump($result->getValue());
1313

1414
$result = $client->getReports()->getOffice365ActiveUserDetail("D7")->executeQuery();
15-
var_dump($result->getValue());
15+
var_dump($result->getValue()->toJson());
1616

1717

1818

generator/GenerateModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function syncSharePointMetadataFile($fileName){
140140

141141
try {
142142

143-
$modelName = "MicrosoftGraph";
143+
$modelName = "SharePoint";
144144
if (count($argv) > 1)
145145
$modelName = $argv[1];
146146

src/EntityCollection.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@
1414
*/
1515
class EntityCollection extends ClientObjectCollection
1616
{
17+
/**
18+
* @var Entity|null
19+
*/
20+
private $parent;
21+
1722
/**
1823
* @param ClientRuntimeContext $ctx
1924
* @param ResourcePath|null $resourcePath
2025
* @param null $itemTypeName
2126
*/
22-
public function __construct(ClientRuntimeContext $ctx, ?ResourcePath $resourcePath = null, $itemTypeName = null)
27+
public function __construct(ClientRuntimeContext $ctx, ?ResourcePath $resourcePath = null, $itemTypeName = null, $parent=null)
2328
{
2429
parent::__construct($ctx, $resourcePath, $itemTypeName);
30+
$this->parent = $parent;
31+
}
32+
33+
public function getParent(){
34+
return $this->parent;
2535
}
2636

2737
/**

src/Planner/Buckets/PlannerBucket.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
namespace Office365\Planner\Buckets;
77

88
use Office365\Entity;
9+
use Office365\Planner\Tasks\PlannerTaskCollection;
10+
use Office365\Runtime\ResourcePath;
911

1012
/**
11-
* The **plannerBucket** resource represents a bucket (or "custom column") for tasks in a plan in Office 365. It is contained in a [plannerPlan](plannerplan.md) and can have a collection of [plannerTasks](plannertask.md).
13+
* The **plannerBucket** resource represents a bucket (or "custom column") for tasks in a plan in Office 365.
14+
* It is contained in a [plannerPlan](plannerplan.md) and can have a collection of [plannerTasks](plannertask.md).
1215
*/
1316
class PlannerBucket extends Entity
1417
{
@@ -63,4 +66,14 @@ public function setOrderHint($value)
6366
{
6467
$this->setProperty("OrderHint", $value, true);
6568
}
69+
70+
/**
71+
* @return PlannerTaskCollection
72+
*/
73+
public function getTasks()
74+
{
75+
return $this->getProperty("Tasks",
76+
new PlannerTaskCollection($this->getContext(),
77+
new ResourcePath("Tasks", $this->getResourcePath()), $this));
78+
}
6679
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Office365\Planner\Buckets;
4+
5+
use Office365\Entity;
6+
use Office365\EntityCollection;
7+
use Office365\Runtime\ClientRuntimeContext;
8+
use Office365\Runtime\ResourcePath;
9+
10+
class PlannerBucketCollection extends EntityCollection
11+
{
12+
public function __construct(ClientRuntimeContext $ctx, ?ResourcePath $resourcePath = null, ?Entity $parent=null)
13+
{
14+
parent::__construct($ctx, $resourcePath, PlannerBucket::class, $parent);
15+
}
16+
17+
}

src/Planner/Planner.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Office365\Planner;
77

88
use Office365\Entity;
9+
use Office365\Planner\Buckets\PlannerBucketCollection;
910
use Office365\Planner\Plans\PlannerPlanCollection;
1011
use Office365\Planner\Tasks\PlannerTaskCollection;
1112
use Office365\Runtime\ResourcePath;
@@ -31,4 +32,14 @@ public function getTasks()
3132
new PlannerTaskCollection($this->getContext(),
3233
new ResourcePath("Tasks", $this->getResourcePath()), $this));
3334
}
35+
36+
/**
37+
* @return PlannerBucketCollection
38+
*/
39+
public function getBuckets()
40+
{
41+
return $this->getProperty("Buckets",
42+
new PlannerBucketCollection($this->getContext(),
43+
new ResourcePath("Buckets", $this->getResourcePath()), $this));
44+
}
3445
}

src/Planner/Plans/PlannerPlan.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Office365\Directory\Identities\IdentitySet;
99
use Office365\Entity;
10+
use Office365\Planner\Buckets\PlannerBucketCollection;
1011
use Office365\Planner\Tasks\PlannerTaskCollection;
1112
use Office365\Runtime\Http\RequestOptions;
1213
use Office365\Runtime\ResourcePath;
@@ -92,6 +93,16 @@ public function getTasks()
9293
new ResourcePath("Tasks", $this->getResourcePath()), $this));
9394
}
9495

96+
/**
97+
* @return PlannerBucketCollection
98+
*/
99+
public function getBuckets()
100+
{
101+
return $this->getProperty("Buckets",
102+
new PlannerBucketCollection($this->getContext(),
103+
new ResourcePath("Buckets", $this->getResourcePath()), $this));
104+
}
105+
95106
/**
96107
* @return $this
97108
*/

src/Planner/Plans/PlannerPlanCollection.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@
99

1010
class PlannerPlanCollection extends EntityCollection {
1111

12-
/**
13-
* @var mixed|null
14-
*/
15-
private $parent;
16-
1712
public function __construct(ClientRuntimeContext $ctx, ?ResourcePath $resourcePath = null, $parent=null)
1813
{
19-
parent::__construct($ctx, $resourcePath, PlannerPlan::class);
20-
$this->parent = $parent;
14+
parent::__construct($ctx, $resourcePath, PlannerPlan::class, $parent);
2115
}
2216

2317
/**
@@ -36,12 +30,16 @@ public function create($title){
3630
return $returnType;
3731
}
3832

33+
/**
34+
* Returns the container of the plan.
35+
* @return array
36+
*/
3937
public function getContainer()
4038
{
41-
if ($this->parent === null) {
39+
if ($this->getParent() === null) {
4240
throw new \RuntimeException("Parent resource is not available");
4341
}
44-
$resourceUrl = $this->parent->getResourceUrl();
42+
$resourceUrl = $this->getParent()->getResourceUrl();
4543

4644
if (str_ends_with($resourceUrl, '/Planner')) {
4745
$resourceUrl = substr($resourceUrl, 0, -8);

src/SharePoint/AgreementsSolutionFileContext.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* Generated 2025-08-15T21:03:47+00:00 16.0.26330.12011
4+
* Generated 2025-08-17T18:16:20+00:00 16.0.26330.12012
55
*/
66
namespace Office365\SharePoint;
77

@@ -72,4 +72,28 @@ class AgreementsSolutionFileContext extends ClientValue
7272
* @var string
7373
*/
7474
public $WebUrl;
75+
/**
76+
* @var EffectiveBasePermissions
77+
*/
78+
public $EffectiveBasePermissions;
79+
/**
80+
* @var LibraryDetails
81+
*/
82+
public $FieldLibrary;
83+
/**
84+
* @var LibraryDetails
85+
*/
86+
public $ModernTemplateLibrary;
87+
/**
88+
* @var LibraryDetails
89+
*/
90+
public $ParentLibrary;
91+
/**
92+
* @var LibraryDetails
93+
*/
94+
public $SnippetLibrary;
95+
/**
96+
* @var DestinationLibraryInfo
97+
*/
98+
public $TargetLibrary;
7599
}

0 commit comments

Comments
 (0)