Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
20e37bd3
Commit
20e37bd3
authored
9 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
Adding occ command to create an addressbook
parent
d8e965e5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/dav/appinfo/register_command.php
+8
-0
8 additions, 0 deletions
apps/dav/appinfo/register_command.php
apps/dav/command/createaddressbook.php
+52
-0
52 additions, 0 deletions
apps/dav/command/createaddressbook.php
with
60 additions
and
0 deletions
apps/dav/appinfo/register_command.php
0 → 100644
+
8
−
0
View file @
20e37bd3
<?php
use
OCA\DAV\Command\CreateAddressBook
;
$dbConnection
=
\OC
::
$server
->
getDatabaseConnection
();
$userManager
=
OC
::
$server
->
getUserManager
();
/** @var Symfony\Component\Console\Application $application */
$application
->
add
(
new
CreateAddressBook
(
$userManager
,
$dbConnection
));
This diff is collapsed.
Click to expand it.
apps/dav/command/createaddressbook.php
0 → 100644
+
52
−
0
View file @
20e37bd3
<?php
namespace
OCA\DAV\Command
;
use
OCA\DAV\CardDAV\CardDavBackend
;
use
OCP\IDBConnection
;
use
OCP\IUserManager
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputArgument
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
class
CreateAddressBook
extends
Command
{
/** @var IUserManager */
protected
$userManager
;
/** @var \OCP\IDBConnection */
protected
$dbConnection
;
/**
* @param IUserManager $userManager
* @param IDBConnection $dbConnection
*/
function
__construct
(
IUserManager
$userManager
,
IDBConnection
$dbConnection
)
{
parent
::
__construct
();
$this
->
userManager
=
$userManager
;
$this
->
dbConnection
=
$dbConnection
;
}
protected
function
configure
()
{
$this
->
setName
(
'dav:create-addressbook'
)
->
setDescription
(
'Create a dav addressbook'
)
->
addArgument
(
'user'
,
InputArgument
::
REQUIRED
,
'User for whom the addressbook will be created'
)
->
addArgument
(
'name'
,
InputArgument
::
REQUIRED
,
'Name of the addressbook'
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$user
=
$input
->
getArgument
(
'user'
);
if
(
!
$this
->
userManager
->
userExists
(
$user
))
{
throw
new
\InvalidArgumentException
(
"User <
$user
> in unknown."
);
}
$name
=
$input
->
getArgument
(
'name'
);
$carddav
=
new
CardDavBackend
(
$this
->
dbConnection
);
$carddav
->
createAddressBook
(
"principals/
$user
"
,
$name
,
[]);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment