rcas   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 55
ccs 0
cts 41
cp 0
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUser() 0 7 2
A setUser() 0 43 4
1
<?php
2
	class rcas {
3
4
		function getUser($prefix) {
5
		global $AR;
6
			if (substr($AR->user->data->login, 0, strlen($prefix)) == $prefix) {
7
				return $AR->user;
8
			} else {
9
			}
10
		}
11
12
	 	function setUser($login, $userInfo = Array()) {
13
		global $AR, $store;
14
			pobject::pushContext(Array("scope" => "php"));
15
			$result = mod_auth_default::getUser($login, $this->config["ar:userDir"]);
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
			if ($result === LD_ERR_ACCESS) {
17
				$aLogin     = 'admin'; // FIXME: make this configurable
18
19
				$AR->user   = current($store->call("system.get.phtml", "", $store->find("/system/users/", "login.value='$aLogin' and object.implements='puser'")));
20
21
				$user_dir   = $this->config["ar:userDir"];
22
				$user_profile = $this->config["ar:userProfile"];
23
24
				$data = Array();
25
				$data["arNewFilename"] = "$user_dir$login/";
26
27
				$data["name"] = $login;
28
				$data["newpass1"] = '!';
29
				$data["newpass2"] = '!';
30
				$data["profile"] = $user_profile;
31
				$data["setowner"] = true;
32
				$data["email"] = $userInfo["email"];
33
34
				foreach ($userInfo as $key => $value) {
35
					$data["custom"]["none"][$key] = $value;
36
				}
37
38
				$userType = $this->config["ar:userType"] ? $this->config["ar:userType"] : "puser";
39
40
				$user = $store->newobject(
41
							"$user_dir$login/",
42
							"$user_dir",
43
							$userType,
44
							new baseObject);
45
46
				$user->arIsNewObject = true;
47
				$user->call('system.save.data.phtml', $data);
48
				$AR->user = $user;
49
			}
50
			ldSetCredentials($login, $this->config["ar:userDir"]);
51
			// unbecome system user
52
			pobject::popContext();
53
			return $AR->user;
54
		}
55
56
	}
57
58
	class pinp_rcas {
59
60
		function _init($module, $config = Array()) {
61
			global $ariadne;
62
			require_once($ariadne.'/modules/mod_rcas/'.basename($module).".php");
63
			$className = "rcas_$module";
64
			return new $className($config);
65
		}
66
67
	}
68