1<?php
2/**
3 * This view display any error encoutered while getting the welcome message. Most of those errors are returned by the update server, and concern the update key.
4 * @var obj $errorObject the object error
5 */
6// TODO : move to the controler
7$urlNew = Yii::app()->createUrl("admin/update", array("update"=>'newKey', 'destinationBuild' => $_REQUEST['destinationBuild']));
8// We first build the error message.
9// View is right place to do this, so it's easy for further integrators to change messages.
10$buttons = 0;
11switch ($errorObject->error)
12{
13    case 'no_server_answer':
14        $title = gT('No server answer!');
15        $message = gT("We couldn't reach the server or the server didn't provide any answer. Please try again in few minutes.");
16        break;
17
18    case 'db_error':
19        $title = gT('Database error!');
20        $message = gT("ComfortUpdate encountered an error while trying to get data from your database.");
21        break;
22
23    case 'unzip_error':
24        $title = gT('Unzip error!');
25        $message = gT("ComfortUpdate couldn't unzip the update file (or the updater update file)");
26        break;
27
28    case 'zip_update_not_found':
29        $title = gT('Zip file not found!');
30        $message = gT("ComfortUpdate couldn't find the update file on your local system (or the updater update file)");
31        break;
32
33    case 'cant_zip_backup':
34        $title = gT('Zip error!');
35        $message = gT("ComfortUpdate could not zip the files for your backup");
36        break;
37
38    case 'error_while_processing_download':
39        $title = gT('Download error!');
40        $message = gT("ComfortUpdate could not download the update!");
41        break;
42
43    case 'out_of_updates':
44        $title = gT("Your update key has exceeded the maximum number updates!");
45        $message = gT("Please buy a new one!");
46        $buttons = 1;
47        break;
48
49    case 'expired':
50        $title = gT("Your update key has expired!");
51        $message = gT("Please buy a new one!");
52        $buttons = 1;
53        break;
54
55    case 'not_found':
56        $title = gT("Unknown update key!");
57        $message = gT("Your key is unknown by the update server.");
58        $buttons = 3;
59        break;
60
61    case 'key_null':
62        $title = gT("Key can't be null!");
63        $message = "";
64        $buttons = 3;
65        break;
66
67    case 'unknown_view':
68        $title = gT("The server tried to call an unknown view!");
69        $message = gT('Is your ComfortUpdate up to date?').' '.gT('Please contact the LimeSurvey team.');
70        $buttons = 3;
71        break;
72
73    case 'unknown_destination_build':
74        $title = gT("Unknown destination build!");
75        $message = gT("It seems that ComfortUpdate doesn't know the version you're trying to update to. Please restart the process.");
76        $buttons = 0;
77        break;
78
79    case 'file_locked':
80        $title = gT('Update server busy');
81        $message = gT('The update server is currently busy. This usually happens when the update files for a new version are being prepared.').'<br/>'.gT('Please be patient and try again in about 5 minutes.');
82        $buttons = 0;
83        break;
84
85    case 'server_error_creating_zip_update':
86        $title = gT('Server error!');
87        $message = gT('An error occured while creating your update package file.').' '.gT('Please contact the LimeSurvey team.');
88        $buttons = 0;
89        break;
90
91    case 'server_error_getting_checksums':
92        $title = gT('Server error!');
93        $message = gT('An error occured while getting checksums.').' '.gT('Please contact the LimeSurvey team.');
94        $buttons = 0;
95        break;
96
97    case 'cant_get_changeset':
98        $title = gT('Server error!');
99        $message = gT('An error occured while getting the changeset.').' '.gT('Please contact the LimeSurvey team.');
100        $buttons = 0;
101        break;
102
103    case 'wrong_token':
104        $title = gT('Unknown session');
105        $message = gT('Your session with the ComfortUpdate server is not valid or expired. Please restart the process.');
106        $buttons = 0;
107        break;
108
109    case 'zip_error':
110        $title = gT('Error while creating zip file');
111        $message = gT("An error occured while creating a backup of your files. Check your local system (permission, available space, etc.)");
112        break;
113
114
115    case 'no_updates_infos':
116        $title = gT("Could not retrieve update info data");
117        $message = gT("ComfortUpdate could not find the update info data.");
118        break;
119
120    case 'cant_remove_deleted_files':
121        $title = gT("Could not remove deleted files");
122        $message =  gT("ComfortUpdate couldn't remove one or more files that were deleted with the update.");
123        $message .=  $errorObject->message;
124        break;
125
126    case 'cant_remove_deleted_directory':
127        $title = gT("Could not remove the deleted directories");
128        $message =  gT("ComfortUpdate couldn't remove one or more directories that were deleted with the update.");
129        break;
130
131
132    default:
133        $title = $errorObject->error;
134        $message = gT('Unknown error.').' '.gT('Please contact the LimeSurvey team.');
135        $buttons = 0;
136        break;
137}
138?>
139
140
141<h2 class="maintitle" style="color: red;"><?php echo $title;?></h2>
142<div style="padding: 10px">
143    <?php echo $message; ?>
144</div>
145
146<div>
147
148<?php if( $buttons == 1 ): ?>
149        <a class="btn btn-default" href="https://community.limesurvey.org/comfort-update-extension/" role="button" aria-disabled="false" target="_blank">
150            <?php eT("Buy a new key"); ?>
151        </a>
152
153        <a class="btn btn-default" href="<?php echo Yii::app()->createUrl("admin/update/sa/managekey");?>" role="button" aria-disabled="false">
154            <?php eT("Enter a new key"); ?>
155        </a>
156<?php endif; ?>
157<?php if( $buttons == 3 ): ?>
158        <a class="btn btn-default" href="<?php echo Yii::app()->createUrl("admin/update/sa/managekey");?>" role="button" aria-disabled="false">
159            <?php eT("Enter a new key"); ?>
160        </a>
161<?php endif;?>
162<a class="btn btn-default" href="<?php echo Yii::app()->createUrl("admin/update"); ?>" role="button" aria-disabled="false">
163    <?php eT("Cancel"); ?>
164</a>
165</div>
166