| 1 |
<?php |
|---|
| 2 |
/* |
|---|
| 3 |
*Name : navigation.php |
|---|
| 4 |
*Author : Michael Yara |
|---|
| 5 |
*Created : June 15, 2008 |
|---|
| 6 |
*Last Updated : May 7, 2009 |
|---|
| 7 |
*History : 0.2 Beta |
|---|
| 8 |
*Purpose : Contains functions used to navigate through different modes of the CLI. |
|---|
| 9 |
*Copyright : 2008 HEHE Enterprises, LLC |
|---|
| 10 |
*/ |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
/*############################################### |
|---|
| 14 |
* Moves CLI to server mode |
|---|
| 15 |
* Takes: nothing |
|---|
| 16 |
* Returns: true if successful or false if not |
|---|
| 17 |
*/ |
|---|
| 18 |
function moveToServer() { |
|---|
| 19 |
|
|---|
| 20 |
//Move to server |
|---|
| 21 |
return checkAndSetErrorNone("server"); |
|---|
| 22 |
} |
|---|
| 23 |
|
|---|
| 24 |
/*############################################### |
|---|
| 25 |
* Moves CLI to location mode |
|---|
| 26 |
* Takes: location name |
|---|
| 27 |
* Returns: true if successful or false if not |
|---|
| 28 |
*/ |
|---|
| 29 |
function moveToLocation($location) { |
|---|
| 30 |
global $IN_LOCATION; |
|---|
| 31 |
|
|---|
| 32 |
//Move to location |
|---|
| 33 |
$moved = checkAndSetErrorNone("location $location"); |
|---|
| 34 |
$IN_LOCATION = $moved; |
|---|
| 35 |
return $moved; |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
/*############################################### |
|---|
| 39 |
* Moves CLI to tenant mode |
|---|
| 40 |
* Takes: location name, tenant name |
|---|
| 41 |
* Returns: true if successful or false if not |
|---|
| 42 |
*/ |
|---|
| 43 |
function moveToTenant($location, $tenant) { |
|---|
| 44 |
global $IN_LOCATION, $IN_TENANT; |
|---|
| 45 |
|
|---|
| 46 |
//Move to location |
|---|
| 47 |
if(!$IN_LOCATION) { |
|---|
| 48 |
if(!moveToLocation($location)) { |
|---|
| 49 |
return false; |
|---|
| 50 |
} |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
//Move to tenant |
|---|
| 54 |
$moved = checkAndSetErrorNone("tenant $tenant"); |
|---|
| 55 |
$IN_TENANT = $moved; |
|---|
| 56 |
return $moved; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
/*############################################### |
|---|
| 60 |
* Moves CLI to extension mode |
|---|
| 61 |
* Takes: location name, tenant name, extension name |
|---|
| 62 |
* Returns: true if successful or an error if not |
|---|
| 63 |
*/ |
|---|
| 64 |
function moveToExtension($location, $tenant, $extension) { |
|---|
| 65 |
global $IN_TENANT; |
|---|
| 66 |
|
|---|
| 67 |
//Move to tenant |
|---|
| 68 |
if(!$IN_TENANT) { |
|---|
| 69 |
if(!moveToTenant($location, $tenant)) { |
|---|
| 70 |
return false; |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
//Move to extension |
|---|
| 75 |
return checkAndSetErrorNone("extension $extension"); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
/*############################################### |
|---|
| 79 |
* Moves CLI to profile mode |
|---|
| 80 |
* Takes: location name, tenant name, profile name |
|---|
| 81 |
* Returns: true if successful or an error if not |
|---|
| 82 |
*/ |
|---|
| 83 |
function moveToProfile($location, $tenant, $profile) { |
|---|
| 84 |
global $IN_TENANT; |
|---|
| 85 |
|
|---|
| 86 |
//Move to tenant |
|---|
| 87 |
if(!$IN_TENANT) { |
|---|
| 88 |
if(!moveToTenant($location, $tenant)) { |
|---|
| 89 |
return false; |
|---|
| 90 |
} |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
//Move to profile |
|---|
| 94 |
return checkAndSetErrorNone("profile $profile"); |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
/*############################################### |
|---|
| 98 |
* Moves CLI to queue mode |
|---|
| 99 |
* Takes: location name, tenant name, queue name |
|---|
| 100 |
* Returns: true if successful or an error if not |
|---|
| 101 |
*/ |
|---|
| 102 |
function moveToQueue($location, $tenant, $queue) { |
|---|
| 103 |
global $IN_TENANT; |
|---|
| 104 |
|
|---|
| 105 |
//Move to tenant |
|---|
| 106 |
if(!$IN_TENANT) { |
|---|
| 107 |
if(!moveToTenant($location, $tenant)) { |
|---|
| 108 |
return false; |
|---|
| 109 |
} |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
//Move to queue |
|---|
| 113 |
return checkAndSetErrorNone("queue $queue"); |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
/*############################################### |
|---|
| 117 |
* Moves CLI to conference room mode |
|---|
| 118 |
* Takes: location name, tenant name, room name |
|---|
| 119 |
* Returns: true if successful or an error if not |
|---|
| 120 |
*/ |
|---|
| 121 |
function moveToConferenceRoom($location, $tenant, $room) { |
|---|
| 122 |
global $IN_TENANT; |
|---|
| 123 |
|
|---|
| 124 |
//Move to tenant |
|---|
| 125 |
if(!$IN_TENANT) { |
|---|
| 126 |
if(!moveToTenant($location, $tenant)) { |
|---|
| 127 |
return false; |
|---|
| 128 |
} |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
//Move to conference room |
|---|
| 132 |
return checkAndSetErrorNone("meetme $room"); |
|---|
| 133 |
} |
|---|
| 134 |
|
|---|
| 135 |
/*############################################### |
|---|
| 136 |
* Moves CLI to status mode |
|---|
| 137 |
* Takes: location name, tenant name, status name |
|---|
| 138 |
* Returns: true if successful or an error if not |
|---|
| 139 |
*/ |
|---|
| 140 |
function moveToStatus($location, $tenant, $status) { |
|---|
| 141 |
|
|---|
| 142 |
//Move to tenant |
|---|
| 143 |
if(!moveToTenant($location, $tenant)) { |
|---|
| 144 |
return false; |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
//Move to status |
|---|
| 148 |
return checkAndSetErrorNone("status $status"); |
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
/*############################################### |
|---|
| 152 |
* Moves CLI to permission group mode |
|---|
| 153 |
* Takes: location name, tenant name, group name |
|---|
| 154 |
* Returns: true if successful or an error if not |
|---|
| 155 |
*/ |
|---|
| 156 |
function moveToPermissionGroup($location, $tenant, $group) { |
|---|
| 157 |
|
|---|
| 158 |
//Move to tenant |
|---|
| 159 |
if(!moveToTenant($location, $tenant)) { |
|---|
| 160 |
return false; |
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
//Move to permission group |
|---|
| 164 |
return checkAndSetErrorNone("permgroup $group"); |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
/*############################################### |
|---|
| 168 |
* Moves CLI to default local permission mode |
|---|
| 169 |
* Takes: nothing |
|---|
| 170 |
* Returns: true if successful or an error if not |
|---|
| 171 |
*/ |
|---|
| 172 |
function moveToDefaultLocalPermission() { |
|---|
| 173 |
|
|---|
| 174 |
//Move to server |
|---|
| 175 |
if(!moveToServer()) { |
|---|
| 176 |
return false; |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
//Move to default local permissions |
|---|
| 180 |
return checkAndSetErrorNone("permission local"); |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
/*############################################### |
|---|
| 184 |
* Moves CLI to default remote permission mode |
|---|
| 185 |
* Takes: nothing |
|---|
| 186 |
* Returns: true if successful or an error if not |
|---|
| 187 |
*/ |
|---|
| 188 |
function moveToDefaultRemotePermission() { |
|---|
| 189 |
|
|---|
| 190 |
//Move to server |
|---|
| 191 |
if(!moveToServer()) { |
|---|
| 192 |
return false; |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
//Move to default remote permissions |
|---|
| 196 |
return checkAndSetErrorNone("permission remote"); |
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
/*############################################### |
|---|
| 200 |
* Moves CLI to default queue permission mode |
|---|
| 201 |
* Takes: nothing |
|---|
| 202 |
* Returns: true if successful or an error if not |
|---|
| 203 |
*/ |
|---|
| 204 |
function moveToDefaultQueuePermission() { |
|---|
| 205 |
|
|---|
| 206 |
//Move to server |
|---|
| 207 |
if(!moveToServer()) { |
|---|
| 208 |
return false; |
|---|
| 209 |
} |
|---|
| 210 |
|
|---|
| 211 |
//Move to default queue permissions |
|---|
| 212 |
return checkAndSetErrorNone("permission queue"); |
|---|
| 213 |
} |
|---|
| 214 |
|
|---|
| 215 |
/*############################################### |
|---|
| 216 |
* Moves CLI to default park permission mode |
|---|
| 217 |
* Takes: nothing |
|---|
| 218 |
* Returns: true if successful or an error if not |
|---|
| 219 |
*/ |
|---|
| 220 |
function moveToDefaultParkPermission() { |
|---|
| 221 |
|
|---|
| 222 |
//Move to server |
|---|
| 223 |
if(!moveToServer()) { |
|---|
| 224 |
return false; |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
//Move to default park permissions |
|---|
| 228 |
return checkAndSetErrorNone("permission park"); |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
/*############################################### |
|---|
| 232 |
* Moves CLI to default conference room permission mode |
|---|
| 233 |
* Takes: nothing |
|---|
| 234 |
* Returns: true if successful or an error if not |
|---|
| 235 |
*/ |
|---|
| 236 |
function moveToDefaultConferenceRoomPermission() { |
|---|
| 237 |
|
|---|
| 238 |
//Move to server |
|---|
| 239 |
if(!moveToServer()) { |
|---|
| 240 |
return false; |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
//Move to default conference room permissions |
|---|
| 244 |
return checkAndSetErrorNone("permission meetme"); |
|---|
| 245 |
} |
|---|
| 246 |
|
|---|
| 247 |
/*############################################### |
|---|
| 248 |
* Moves CLI to local permission override mode |
|---|
| 249 |
* Takes: location name, tenant name, profile name |
|---|
| 250 |
* Returns: true if successful or an error if not |
|---|
| 251 |
*/ |
|---|
| 252 |
function moveToLocalOverridePermission($location, $tenant, $profile) { |
|---|
| 253 |
|
|---|
| 254 |
//Move to profile |
|---|
| 255 |
if(!moveToProfile($location, $tenant, $profile)) { |
|---|
| 256 |
return false; |
|---|
| 257 |
} |
|---|
| 258 |
|
|---|
| 259 |
//Move to local permission override |
|---|
| 260 |
return checkAndSetErrorNone("permission local"); |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
/*############################################### |
|---|
| 264 |
* Moves CLI to park permission override mode |
|---|
| 265 |
* Takes: location name, tenant name, profile name |
|---|
| 266 |
* Returns: true if successful or an error if not |
|---|
| 267 |
*/ |
|---|
| 268 |
function moveToParkOverridePermission($location, $tenant, $profile) { |
|---|
| 269 |
|
|---|
| 270 |
//Move to profile |
|---|
| 271 |
if(!moveToProfile($location, $tenant, $profile)) { |
|---|
| 272 |
return false; |
|---|
| 273 |
} |
|---|
| 274 |
|
|---|
| 275 |
//Move to park permission override |
|---|
| 276 |
return checkAndSetErrorNone("permission park"); |
|---|
| 277 |
} |
|---|
| 278 |
|
|---|
| 279 |
/*############################################### |
|---|
| 280 |
* Moves CLI to remote permission override mode |
|---|
| 281 |
* Takes: location name, tenant name, profile name, extension name |
|---|
| 282 |
* Returns: true if successful or an error if not |
|---|
| 283 |
*/ |
|---|
| 284 |
function moveToRemoteOverridePermission($location, $tenant, $profile, $extension) { |
|---|
| 285 |
|
|---|
| 286 |
//Move to profile |
|---|
| 287 |
if(!moveToProfile($location, $tenant, $profile)) { |
|---|
| 288 |
return false; |
|---|
| 289 |
} |
|---|
| 290 |
|
|---|
| 291 |
//Move to remote permission override |
|---|
| 292 |
return checkAndSetErrorNone("permission remote $extension"); |
|---|
| 293 |
} |
|---|
| 294 |
|
|---|
| 295 |
/*############################################### |
|---|
| 296 |
* Moves CLI to queue permission override mode |
|---|
| 297 |
* Takes: location name, tenant name, profile name, queue name |
|---|
| 298 |
* Returns: true if successful or an error if not |
|---|
| 299 |
*/ |
|---|
| 300 |
function moveToQueueOverridePermission($location, $tenant, $profile, $queue) { |
|---|
| 301 |
|
|---|
| 302 |
//Move to profile |
|---|
| 303 |
if(!moveToProfile($location, $tenant, $profile)) { |
|---|
| 304 |
return false; |
|---|
| 305 |
} |
|---|
| 306 |
|
|---|
| 307 |
//Move to queue permission override |
|---|
| 308 |
return checkAndSetErrorNone("permission queue $queue"); |
|---|
| 309 |
} |
|---|
| 310 |
|
|---|
| 311 |
/*############################################### |
|---|
| 312 |
* Moves CLI to conference room permission override mode |
|---|
| 313 |
* Takes: location name, tenant name, profile name, queue name |
|---|
| 314 |
* Returns: true if successful or an error if not |
|---|
| 315 |
*/ |
|---|
| 316 |
function moveToConferenceRoomOverridePermission($location, $tenant, $profile, $room) { |
|---|
| 317 |
|
|---|
| 318 |
//Move to profile |
|---|
| 319 |
if(!moveToProfile($location, $tenant, $profile)) { |
|---|
| 320 |
return false; |
|---|
| 321 |
} |
|---|
| 322 |
|
|---|
| 323 |
//Move to conference room permission override |
|---|
| 324 |
return checkAndSetErrorNone("permission meetme $room"); |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
/*############################################### |
|---|
| 328 |
* Moves CLI to local group permission mode |
|---|
| 329 |
* Takes: location name, tenant name, permission group name |
|---|
| 330 |
* Returns: true if successful or an error if not |
|---|
| 331 |
*/ |
|---|
| 332 |
function moveToLocalGroupPermission($location, $tenant, $group) { |
|---|
| 333 |
|
|---|
| 334 |
//Move to permission group |
|---|
| 335 |
if(!moveToPermissionGroup($location, $tenant, $group)) { |
|---|
| 336 |
return false; |
|---|
| 337 |
} |
|---|
| 338 |
|
|---|
| 339 |
//Move to group local permission |
|---|
| 340 |
return checkAndSetErrorNone("permission local"); |
|---|
| 341 |
} |
|---|
| 342 |
|
|---|
| 343 |
/*############################################### |
|---|
| 344 |
* Moves CLI to park group permission mode |
|---|
| 345 |
* Takes: location name, tenant name, permission group name |
|---|
| 346 |
* Returns: true if successful or an error if not |
|---|
| 347 |
*/ |
|---|
| 348 |
function moveToParkGroupPermission($location, $tenant, $group) { |
|---|
| 349 |
|
|---|
| 350 |
//Move to permission group |
|---|
| 351 |
if(!moveToPermissionGroup($location, $tenant, $group)) { |
|---|
| 352 |
return false; |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
//Move to group park permission |
|---|
| 356 |
return checkAndSetErrorNone("permission park"); |
|---|
| 357 |
} |
|---|
| 358 |
|
|---|
| 359 |
/*############################################### |
|---|
| 360 |
* Moves CLI to remote group permission mode |
|---|
| 361 |
* Takes: location name, tenant name, permission group name, extension name |
|---|
| 362 |
* Returns: true if successful or an error if not |
|---|
| 363 |
*/ |
|---|
| 364 |
function moveToRemoteGroupPermission($location, $tenant, $group, $extension) { |
|---|
| 365 |
|
|---|
| 366 |
//Move to permission group |
|---|
| 367 |
if(!moveToPermissionGroup($location, $tenant, $group)) { |
|---|
| 368 |
return false; |
|---|
| 369 |
} |
|---|
| 370 |
|
|---|
| 371 |
//Move to group remote permission |
|---|
| 372 |
return checkAndSetErrorNone("permission remote $extension"); |
|---|
| 373 |
} |
|---|
| 374 |
|
|---|
| 375 |
/*############################################### |
|---|
| 376 |
* Moves CLI to queue group permission mode |
|---|
| 377 |
* Takes: location name, tenant name, permission group name, queue name |
|---|
| 378 |
* Returns: true if successful or an error if not |
|---|
| 379 |
*/ |
|---|
| 380 |
function moveToQueueGroupPermission($location, $tenant, $group, $queue) { |
|---|
| 381 |
|
|---|
| 382 |
//Move to permission group |
|---|
| 383 |
if(!moveToPermissionGroup($location, $tenant, $group)) { |
|---|
| 384 |
return false; |
|---|
| 385 |
} |
|---|
| 386 |
|
|---|
| 387 |
//Move to group queue permission |
|---|
| 388 |
return checkAndSetErrorNone("permission queue $queue"); |
|---|
| 389 |
} |
|---|
| 390 |
|
|---|
| 391 |
/*############################################### |
|---|
| 392 |
* Moves CLI to conference room group permission mode |
|---|
| 393 |
* Takes: location name, tenant name, permission group name, conference room name |
|---|
| 394 |
* Returns: true if successful or an error if not |
|---|
| 395 |
*/ |
|---|
| 396 |
function moveToConferenceRoomGroupPermission($location, $tenant, $group, $room) { |
|---|
| 397 |
|
|---|
| 398 |
//Move to permission group |
|---|
| 399 |
if(!moveToPermissionGroup($location, $tenant, $group)) { |
|---|
| 400 |
return false; |
|---|
| 401 |
} |
|---|
| 402 |
|
|---|
| 403 |
//Move to group conference room permission |
|---|
| 404 |
return checkAndSetErrorNone("permission meetme $room"); |
|---|
| 405 |
} |
|---|
| 406 |
?> |
|---|