Skip to content

Commit f1fc232

Browse files
committed
added file from server (last modified 2016-12-15)
1 parent e568863 commit f1fc232

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

addCCIDUser.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2015 Creative Commons Corportation
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along
16+
* with this program; if not, write to the Free Software Foundation, Inc.,
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18+
* http://www.gnu.org/copyleft/gpl.html
19+
*/
20+
21+
require_once __DIR__ . '/Maintenance.php';
22+
23+
class AddCCIDUser extends Maintenance {
24+
25+
public function __construct() {
26+
parent::__construct();
27+
$this->mDescription = "Create a new CCID user account.";
28+
29+
$this->addArg( "global", "CCID global identifier of new user" );
30+
$this->addArg( "email", "CCID email of new user" );
31+
}
32+
33+
public function execute() {
34+
global $CASAuth;
35+
36+
if (! isset( $CASAuth )) {
37+
$this->error('$CASAuth not set in LocalSettings.php', true);
38+
}
39+
40+
$nickname = $global = $this->getArg( 0 );
41+
$casuid = $email = $this->getArg( 1 );
42+
$ccid_name = 'CCID-' . $global;
43+
44+
$u = User::newFromName( $ccid_name );
45+
// Create a new account if the user does not exists
46+
if ($u->getID() != 0) {
47+
$this->error("User already exists", true);
48+
exit(1);
49+
} else {
50+
//$nickname = $attr['nickname'];
51+
// Create the user
52+
$u->addToDatabase();
53+
$u->setRealName($nickname);
54+
$u->setEmail($casuid);
55+
$u->confirmEmail();
56+
$u->setPassword( md5($casuid.$CASAuth["PwdSecret"]) ); //PwdSecret is used to salt the casuid, which is then used to create an md5 hash which becomes the password
57+
$u->setToken();
58+
$u->saveSettings();
59+
// Update user count
60+
$ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
61+
$ssUpdate->doUpdate();
62+
}
63+
}
64+
}
65+
66+
$maintClass = "AddCCIDUser";
67+
require_once RUN_MAINTENANCE_IF_MAIN;

0 commit comments

Comments
 (0)