FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
fo_chmod.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2015 Siemens AG
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***********************************************************/
18 
21 
22 require_once("$MODDIR/lib/php/common-cli.php");
23 cli_Init();
24 
25 global $Plugins;
26 error_reporting(E_NOTICE & E_STRICT);
27 
28 $Usage = "Usage: " . basename($argv[0]) . " [options]
29  --username = user name
30  --password = password
31  --groupname = a group the user belongs to (default active group)
32  --uploadId = id of upload
33  --destgroup = group which will become admin of the upload\n";
34 
35 // TODO support much more command line options
36 
37 $opts = getopt("hc:", array("username:", "groupname:", "uploadId:", "password:", "destgroup:"));
38 if (array_key_exists('h', $opts)) {
39  print $Usage;
40  exit(0);
41 }
42 
43 if (!array_key_exists("uploadId", $opts)) {
44  echo "no uploadId supplied\n";
45  exit (1);
46 }
47 if (!array_key_exists("destgroup", $opts)) {
48  echo "no destgroup supplied\n";
49  exit (1);
50 }
51 $uploadId = $opts["uploadId"];
52 
53 $user = array_key_exists("username", $opts) ? $opts["username"] : '';
54 $group = array_key_exists("groupname", $opts) ? $opts["groupname"] : '';
55 $passwd = array_key_exists("password", $opts) ? $opts["password"] : null;
56 account_check($user, $passwd, $group);
57 
58 global $SysConf;
59 $userId = $SysConf['auth']['UserId'];
60 $groupId = $SysConf['auth']['GroupId'];
61 
63 $userDao = $GLOBALS['container']->get("dao.user");
64 $destGroupId = $userDao->getGroupIdByName($opts["destgroup"]);
65 
66 /* @var $uploadPermDao UploadPermissionDao */
67 $uploadpermDao = $GLOBALS['container']->get("dao.upload.permission");
68 $uploadpermDao->makeAccessibleToGroup($uploadId, $destGroupId);
account_check(&$user, &$passwd, &$group="")
check if this account is correct
Definition: common-auth.php:87
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...
Definition: common-cli.php:36