FOSSology  4.4.0
Open Source License Compliance by Open Source Software
fo_chmod.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
10 
11 require_once("$MODDIR/lib/php/common-cli.php");
12 cli_Init();
13 
14 global $Plugins;
15 error_reporting(E_NOTICE & E_STRICT);
16 
17 $Usage = "Usage: " . basename($argv[0]) . " [options]
18  --username = user name
19  --password = password
20  --groupname = a group the user belongs to (default active group)
21  --uploadId = id of upload
22  --destgroup = group which will become admin of the upload\n";
23 
24 // TODO support much more command line options
25 
26 $opts = getopt("hc:", array("username:", "groupname:", "uploadId:", "password:", "destgroup:"));
27 if (array_key_exists('h', $opts)) {
28  print $Usage;
29  exit(0);
30 }
31 
32 if (!array_key_exists("uploadId", $opts)) {
33  echo "no uploadId supplied\n";
34  exit (1);
35 }
36 if (!array_key_exists("destgroup", $opts)) {
37  echo "no destgroup supplied\n";
38  exit (1);
39 }
40 $uploadId = $opts["uploadId"];
41 
42 $user = array_key_exists("username", $opts) ? $opts["username"] : '';
43 $group = array_key_exists("groupname", $opts) ? $opts["groupname"] : '';
44 $passwd = array_key_exists("password", $opts) ? $opts["password"] : null;
45 account_check($user, $passwd, $group);
46 
47 global $SysConf;
48 $userId = $SysConf['auth']['UserId'];
49 $groupId = $SysConf['auth']['GroupId'];
50 
52 $userDao = $GLOBALS['container']->get("dao.user");
53 $destGroupId = $userDao->getGroupIdByName($opts["destgroup"]);
54 
55 /* @var $uploadPermDao UploadPermissionDao */
56 $uploadpermDao = $GLOBALS['container']->get("dao.upload.permission");
57 $uploadpermDao->makeAccessibleToGroup($uploadId, $destGroupId);
account_check(&$user, &$passwd, &$group="")
check if this account is correct
Definition: common-auth.php:75
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...
Definition: common-cli.php:25