1: <?php
2:
3: 4: 5:
6: class Quform_Upgrader
7: {
8: 9: 10:
11: protected $repository;
12:
13: 14: 15:
16: protected $permissions;
17:
18: 19: 20:
21: protected $uploader;
22:
23: 24: 25:
26: protected $session;
27:
28: 29: 30:
31: protected $scriptLoader;
32:
33: 34: 35: 36: 37: 38: 39:
40: public function __construct(
41: Quform_Repository $repository,
42: Quform_Permissions $permissions,
43: Quform_Uploader $uploader,
44: Quform_Session $session,
45: Quform_ScriptLoader $scriptLoader
46: ) {
47: $this->repository = $repository;
48: $this->permissions = $permissions;
49: $this->uploader = $uploader;
50: $this->session = $session;
51: $this->scriptLoader = $scriptLoader;
52: }
53:
54: 55: 56:
57: public function upgradeCheck()
58: {
59: if (get_option('quform_activated') === '1' || get_option('quform_version') != QUFORM_VERSION) {
60:
61: $this->activate();
62:
63:
64: $version = get_option('quform_version');
65:
66:
67: update_option('quform_version', QUFORM_VERSION);
68: delete_option('quform_activated');
69:
70:
71: }
72: }
73:
74: 75: 76:
77: public function activate()
78: {
79: add_option('quform_version', QUFORM_VERSION);
80:
81: $this->repository->activate();
82: $this->permissions->activate();
83: $this->uploader->activate();
84: $this->session->activate();
85: $this->scriptLoader->activate();
86: }
87:
88: 89: 90:
91: public function uninstall()
92: {
93: delete_option('quform_version');
94: }
95: }
96: