21 include_once ("FDL/Class.Doc.php");
23 $usage = new ApiUsage();
25 $usage->setDefinitionText("Reset profiling use when restore context from archive");
26 $user = $usage->addRequiredParameter("login", "login");
27 $password = $usage->addRequiredParameter("password", "password");
34 $dbaccess = $action->dbaccess;
35 $coreaccess = $action->dbaccess;
37 if ($dbaccess == "") {
38 print "Database not found : action->dbaccess";
42 $u = new Account($coreaccess);
43 $u->setLoginName($user);
47 $du = createDoc($dbaccess, "IUSER");
49 $du->setValue("us_login", $user);
50 $du->setValue("us_lname", $user);
51 $du->setValue("us_fname", "");
52 $du->setValue("us_passwd1", $password);
53 $du->setValue("us_passwd2", $password);
56 $err = $du->postStore();
60 printf(_("new user # %d") , $du->getRawValue("us_whatid")); // affichage de l'identifiant système
65 $g = new_Doc($dbaccess, "GDEFAULT");
67 $err = $g->insertDocument($du->initid);
72 if ($err) print "\nerreur:$err\n";
73 $uid = $du->getRawValue("us_whatid");
77 $pname = strtoupper($user . "PROFIL");
78 $pdoc = new_doc($dbaccess, $pname);
80 if (!$pdoc->isAffected()) {
81 $pdoc = createDoc($dbaccess, "PDIR");
83 $pdoc->setValue("ba_title", "profil de " . $user);
84 $pdoc->setValue("prf_desc", "profil de " . $user);
85 $pdoc->name = strtoupper($pname); // on donne un nom logique pour le retrouver après
89 $pdoc->setControl(false); // activ profil
90 printf(_("new profil %d") , $pdoc->id);
92 $perm = new DocPerm($dbaccess);
93 $perm->docid = $pdoc->id;
95 $perm->upacl = - 2 & (~(1 << 2)); // all privileges except read => read only
96 // add all privileges to user
99 // reset all profil big security
100 $err = simpleQuery($dbaccess, sprintf("update doc set profid=%d,dprofid=0", $pdoc->id) , $res);
101 $err.= simpleQuery($dbaccess, sprintf("INSERT INTO permission (id_user, id_application, id_acl) SELECT users.id as uid, id_application as appid,acl.id as aclid from acl, users where users.id=%d", $uid));
105 if ($err) print "\nerreur:$err\n";