ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
AbandonCASAuthModeUpdateObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ilAuthUtils;
25 use ilDBConstants;
26 use ilDBInterface;
27 
29 {
30  private const string TABLE_NAME = 'usr_data';
31 
32  protected ilDBInterface $db;
33 
34  public function prepare(ilDBInterface $db): void
35  {
36  $this->db = $db;
37  }
38 
39  public function step_1(): void
40  {
41  $default_auth_mode_result = $this->db->query(
42  'SELECT value FROM settings WHERE module = ' . $this->db->quote('common', ilDBConstants::T_TEXT)
43  . ' AND keyword = ' . $this->db->quote('auth_mode', ilDBConstants::T_TEXT)
44  );
45 
46  $default_auth_mode = (int) ($this->db->fetchAssoc($default_auth_mode_result)['value'] ?? ilAuthUtils::AUTH_LOCAL);
47 
48  $this->db->manipulateF(
49  'UPDATE ' . self::TABLE_NAME . ' SET auth_mode = %s WHERE auth_mode = %s',
51  [$default_auth_mode === ilAuthUtils::AUTH_LOCAL ? 'default' : 'local', 'cas']
52  );
53  }
54 
55  public function step_2(): void
56  {
57  $settings = [
58  'cas_server',
59  'cas_port',
60  'cas_uri',
61  'cas_login_instructions',
62  'cas_active',
63  'cas_create_users',
64  'cas_allow_local',
65  'cas_user_default_role',
66  ];
67 
68  $this->db->manipulate(
69  'DELETE FROM settings WHERE module = ' . $this->db->quote('common', ilDBConstants::T_TEXT) . ' AND '
70  . $this->db->in('keyword', $settings, false, ilDBConstants::T_TEXT),
71  );
72  }
73 }
const int AUTH_LOCAL