1<?php 2/** 3 * Copyright 2010-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (LGPL-2). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl. 7 * 8 * @category Horde 9 * @copyright 2010-2017 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl LGPL-2 11 * @package Horde 12 */ 13 14/** 15 * Horde external API interface. 16 * 17 * This file defines Horde's external API interface. Other 18 * applications can interact with Horde through this API. 19 * 20 * @category Horde 21 * @copyright 2010-2017 Horde LLC 22 * @license http://www.horde.org/licenses/lgpl LGPL-2 23 * @package Horde 24 */ 25class Horde_Api extends Horde_Registry_Api 26{ 27 /** 28 * Returns a list of adminstrative links. 29 * 30 * @return array Keys are link labels, values are array with these keys: 31 * - icon: (string) Graphic for page. 32 * - link: (string) Registry encoded link to page. 33 * - name: (string) Gettext label for page. 34 */ 35 public function admin_list() 36 { 37 $admin = array( 38 'configuration' => array( 39 'link' => '%application%/admin/config/', 40 'name' => _("_Configuration"), 41 'icon' => 'config' 42 ), 43 'users' => array( 44 'link' => '%application%/admin/user.php', 45 'name' => _("_Users"), 46 'icon' => 'user' 47 ), 48 'groups' => array( 49 'link' => '%application%/admin/groups.php', 50 'name' => _("_Groups"), 51 'icon' => 'group' 52 ), 53 'perms' => array( 54 'link' => '%application%/admin/perms/', 55 'name' => _("_Permissions"), 56 'icon' => 'perms' 57 ), 58 'locks' => array( 59 'link' => '%application%/admin/locks.php', 60 'name' => _("_Locks"), 61 'icon' => 'locked' 62 ), 63 'alarms' => array( 64 'link' => '%application%/admin/alarms.php', 65 'name' => _("_Alarms"), 66 'icon' => 'alarm' 67 ), 68 'sessions' => array( 69 'link' => '%application%/admin/sessions.php', 70 'name' => _("Sessions"), 71 'icon' => 'user' 72 ), 73 'phpshell' => array( 74 'link' => '%application%/admin/phpshell.php', 75 'name' => _("P_HP Shell"), 76 'icon' => 'php' 77 ), 78 'sqlshell' => array( 79 'link' => '%application%/admin/sqlshell.php', 80 'name' => _("S_QL Shell"), 81 'icon' => 'sql' 82 ), 83 'cmdshell' => array( 84 'link' => '%application%/admin/cmdshell.php', 85 'name' => _("_CLI"), 86 'icon' => 'shell' 87 ) 88 ); 89 90 if (!empty($GLOBALS['conf']['activesync']['enabled'])) { 91 $admin['activesync'] = array( 92 'link' => '%application%/admin/activesync.php', 93 'name' => _("ActiveSync Devices"), 94 'icon' => 'mobile' 95 ); 96 } 97 98 return $admin; 99 } 100 101 /** 102 * Returns a list of the installed and registered applications. 103 * 104 * @param array $filter An array of the statuses that should be returned. 105 * Defaults to non-hidden. 106 * 107 * @return array List of apps registered with Horde. If no applications 108 * are defined returns an empty array. 109 */ 110 public function listApps($filter = null) 111 { 112 return $GLOBALS['registry']->listApps($filter); 113 } 114 115 /** 116 * Returns all available registry APIs. 117 * 118 * @return array The API list. 119 */ 120 public function listAPIs() 121 { 122 return $GLOBALS['registry']->listAPIs(); 123 } 124 125 /* Blocks. */ 126 127 /** 128 * Returns a Horde_Block's title. 129 * 130 * @param string $app The block application name. 131 * @param string $name The block name (NOT the class name). 132 * @param array $params Block parameters. 133 * 134 * @return string The block title. 135 */ 136 public function blockTitle($app, $name, $params = array()) 137 { 138 $class = $app . '_Block_' . basename($name); 139 try { 140 return $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create()->getBlock($app, $class, $params)->getTitle(); 141 } catch (Horde_Exception $e) { 142 return $e->getMessage(); 143 } 144 } 145 146 /** 147 * Returns a Horde_Block's content. 148 * 149 * @param string $app The block application name. 150 * @param string $name The block name (NOT the classname). 151 * @param array $params Block parameters. 152 * 153 * @return string The block content. 154 */ 155 public function blockContent($app, $name, $params = array()) 156 { 157 $class = $app . '_Block_' . basename($name); 158 try { 159 return $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create()->getBlock($app, $class, $params)->getContent(); 160 } catch (Horde_Exception $e) { 161 return $e->getMessage(); 162 } 163 } 164 165 /** 166 * Returns a pretty printed list of all available blocks. 167 * 168 * @return array A hash with block IDs as keys and application plus block 169 * block names as values. 170 */ 171 public function blocks() 172 { 173 return $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create()->getBlocksList(); 174 } 175 176 /* User data. */ 177 178 /** 179 * Returns the value of the requested preference. 180 * 181 * @param string $app The application of the preference to retrieve. 182 * @param string $pref The name of the preference to retrieve. 183 * 184 * @return string The value of the preference, null if it doesn't exist. 185 */ 186 public function getPreference($app, $pref) 187 { 188 $pushed = $GLOBALS['registry']->pushApp($app); 189 $GLOBALS['registry']->loadPrefs($app); 190 $value = $GLOBALS['prefs']->getValue($pref); 191 if ($pushed) { 192 $GLOBALS['registry']->popApp(); 193 } 194 195 return $value; 196 } 197 198 /** 199 * Sets a preference to the specified value, if the preference is allowed 200 * to be modified. 201 * 202 * @param string $app The application of the preference to modify. 203 * @param string $pref The name of the preference to modify. 204 * @param string $val The new value for this preference. 205 */ 206 public function setPreference($app, $pref, $value) 207 { 208 $pushed = $GLOBALS['registry']->pushApp($app); 209 $GLOBALS['registry']->loadPrefs($app); 210 $value = $GLOBALS['prefs']->setValue($pref, $value); 211 if ($pushed) { 212 $GLOBALS['registry']->popApp(); 213 } 214 } 215 216 /** 217 * Removes user data. 218 * 219 * @param string $user Name of user to remove data for. 220 * @param string $app Remove data from this application. If boolean 221 * true, removes all applications. If boolean false, 222 * removes only base Horde data. 223 * 224 * @throws Horde_Exception 225 */ 226 public function removeUserData($user, $app = false) 227 { 228 if ($app === true) { 229 $app = null; 230 } elseif ($app === false || !strlen($app)) { 231 $app = false; 232 } 233 234 $GLOBALS['registry']->removeUserData($user, $app); 235 } 236 237 /* Groups. */ 238 239 /** 240 * Adds a group to the groups system. 241 * 242 * @param string $name The group's name. 243 * 244 * @return mixed The group's ID. 245 * @throws Horde_Exception 246 */ 247 public function addGroup($name) 248 { 249 if (!$GLOBALS['registry']->isAdmin()) { 250 throw new Horde_Exception(_("You are not allowed to add groups.")); 251 } 252 253 return $GLOBALS['injector'] 254 ->getInstance('Horde_Group') 255 ->create($name); 256 } 257 258 /** 259 * Removes a group from the groups system. 260 * 261 * @param mixed $group The group ID. 262 * 263 * @throws Horde_Exception 264 */ 265 public function removeGroup($group) 266 { 267 if (!$GLOBALS['registry']->isAdmin()) { 268 throw new Horde_Exception(_("You are not allowed to delete groups.")); 269 } 270 271 $GLOBALS['injector']->getInstance('Horde_Group')->remove($group); 272 } 273 274 /** 275 * Adds a user to a group. 276 * 277 * @param mixed $group The group ID. 278 * @param string $user The user to add. 279 * 280 * @throws Horde_Exception 281 */ 282 public function addUserToGroup($group, $user) 283 { 284 if (!$GLOBALS['registry']->isAdmin()) { 285 throw new Horde_Exception(_("You are not allowed to change groups.")); 286 } 287 288 $GLOBALS['injector'] 289 ->getInstance('Horde_Group') 290 ->addUser($group, $user); 291 } 292 293 /** 294 * Removes a user from a group. 295 * 296 * @param mixed $group The group ID. 297 * @param string $user The user to add. 298 * 299 * @throws Horde_Exception 300 */ 301 public function removeUserFromGroup($group, $user) 302 { 303 if (!$GLOBALS['registry']->isAdmin()) { 304 throw new Horde_Exception(_("You are not allowed to change groups.")); 305 } 306 307 $GLOBALS['injector'] 308 ->getInstance('Horde_Group') 309 ->removeUser($group, $user); 310 } 311 312 /** 313 * Returns a list of users that are part of this group (and only this 314 * group). 315 * 316 * @param mixed $group The group ID. 317 * 318 * @return array The user list. 319 * @throws Horde_Exception 320 */ 321 public function listUsersOfGroup($group) 322 { 323 if (!$GLOBALS['registry']->isAdmin()) { 324 throw new Horde_Exception(_("You are not allowed to list users of groups.")); 325 } 326 327 return $GLOBALS['injector'] 328 ->getInstance('Horde_Group') 329 ->listUsers($group); 330 } 331 332 /* Shares. */ 333 334 /** 335 * Adds a share to the shares system. 336 * 337 * @param string $scope The name of the share root, e.g. the 338 * application that the share belongs to. 339 * @param string $shareName The share's name. 340 * @param string $shareTitle The share's human readable title. 341 * @param string $userName The share's owner. 342 * 343 * @throws Horde_Exception 344 */ 345 public function addShare($scope, $shareName, $shareTitle, $userName) 346 { 347 if (!$GLOBALS['registry']->isAdmin()) { 348 throw new Horde_Exception(_("You are not allowed to add shares.")); 349 } 350 351 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 352 $share = $shares->newShare($GLOBALS['registry']->getAuth(), $shareName, $shareTitle); 353 $share->set('owner', $userName); 354 $shares->addShare($share); 355 } 356 357 /** 358 * Removes a share from the shares system permanently. 359 * 360 * @param string $scope The name of the share root, e.g. the 361 * application that the share belongs to. 362 * @param string $shareName The share's name. 363 * 364 * @throws Horde_Exception 365 */ 366 public function removeShare($scope, $shareName) 367 { 368 if (!$GLOBALS['registry']->isAdmin()) { 369 throw new Horde_Exception(_("You are not allowed to delete shares.")); 370 } 371 372 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 373 $share = $shares->getShare($shareName); 374 $shares->removeShare($share); 375 } 376 377 /** 378 * Returns an array of all shares that $userName is the owner of. 379 * 380 * @param string $scope The name of the share root, e.g. the 381 * application that the share belongs to. 382 * @param string $userName The share's owner. 383 * 384 * @return array The list of shares. 385 * @throws Horde_Exception 386 */ 387 public function listSharesOfOwner($scope, $userName) 388 { 389 if (!$GLOBALS['registry']->isAdmin()) { 390 throw new Horde_Exception(_("You are not allowed to list shares.")); 391 } 392 393 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 394 395 $share_list = $shares->listShares($userName, 396 array('perm' => Horde_Perms::SHOW, 397 'attributes' => $userName)); 398 $myshares = array(); 399 foreach ($share_list as $share) { 400 $myshares[] = $share->getName(); 401 } 402 403 return $myshares; 404 } 405 406 /** 407 * Gives a user certain privileges for a share. 408 * 409 * @param string $scope The name of the share root, e.g. the 410 * application that the share belongs to. 411 * @param string $shareName The share's name. 412 * @param string $userName The user's name. 413 * @param array $permissions A list of permissions (show, read, edit, 414 * delete). 415 * 416 * @throws Horde_Exception 417 */ 418 public function addUserPermissions($scope, $shareName, $userName, 419 $permissions) 420 { 421 if (!$GLOBALS['registry']->isAdmin()) { 422 throw new Horde_Exception(_("You are not allowed to change shares.")); 423 } 424 425 $share = $GLOBALS['injector'] 426 ->getInstance('Horde_Core_Factory_Share') 427 ->create($scope) 428 ->getShare($shareName); 429 $perm = $share->getPermission(); 430 foreach ($permissions as $permission) { 431 $permission = Horde_String::upper($permission); 432 if (defined('Horde_Perms::' . $permission)) { 433 $perm->addUserPermission($userName, constant('Horde_Perms::' . $permission), false); 434 } 435 } 436 $share->setPermission($perm); 437 } 438 439 /** 440 * Gives a group certain privileges for a share. 441 * 442 * @param string $scope The name of the share root, e.g. the 443 * application that the share belongs to. 444 * @param string $shareName The share's name. 445 * @param mixed $groupId The group ID. 446 * @param array $permissions A list of permissions (show, read, edit, 447 * delete). 448 * 449 * @throws Horde_Exception 450 */ 451 public function addGroupPermissions($scope, $shareName, $groupId, 452 $permissions) 453 { 454 if (!$GLOBALS['registry']->isAdmin()) { 455 throw new Horde_Exception(_("You are not allowed to change shares.")); 456 } 457 458 $share = $GLOBALS['injector'] 459 ->getInstance('Horde_Core_Factory_Share') 460 ->create($scope) 461 ->getShare($shareName); 462 $perm = $share->getPermission(); 463 foreach ($permissions as $permission) { 464 $permission = Horde_String::upper($permission); 465 if (defined('Horde_Perms::' . $permission)) { 466 $perm->addGroupPermission($groupId, constant('Horde_Perms::' . $permission), false); 467 } 468 } 469 $share->setPermission($perm); 470 } 471 472 /** 473 * Removes a user from a share. 474 * 475 * @param string $scope The name of the share root, e.g. the 476 * application that the share belongs to. 477 * @param string $shareName The share's name. 478 * @param string $userName The user's name. 479 * 480 * @throws Horde_Exception 481 */ 482 public function removeUserPermissions($scope, $shareName, $userName) 483 { 484 if (!$GLOBALS['registry']->isAdmin()) { 485 throw new Horde_Exception(_("You are not allowed to change shares.")); 486 } 487 488 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 489 $share = $shares->getShare($shareName); 490 $share->removeUser($userName); 491 } 492 493 /** 494 * Removes a group from a share. 495 * 496 * @param string $scope The name of the share root, e.g. the 497 * application that the share belongs to. 498 * @param string $shareName The share's name. 499 * @param mixed $groupId The group ID. 500 * 501 * @throws Horde_Exception 502 */ 503 public function removeGroupPermissions($scope, $shareName, $groupId) 504 { 505 if (!$GLOBALS['registry']->isAdmin()) { 506 throw new Horde_Exception(_("You are not allowed to change shares.")); 507 } 508 509 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 510 $share = $shares->getShare($shareName); 511 $share->removeGroup($groupId); 512 } 513 514 /** 515 * Returns an array of all user permissions on a share. 516 * 517 * @param string $scope The name of the share root, e.g. the 518 * application that the share belongs to. 519 * @param string $shareName The share's name. 520 * @param string $userName The user's name. 521 * 522 * @return array All user permissions for this share. 523 * @throws Horde_Exception 524 */ 525 public function listUserPermissions($scope, $shareName, $userName) 526 { 527 if (!$GLOBALS['registry']->isAdmin()) { 528 throw new Horde_Exception(_("You are not allowed to list share permissions.")); 529 } 530 531 $perm_map = array(Horde_Perms::SHOW => 'show', 532 Horde_Perms::READ => 'read', 533 Horde_Perms::EDIT => 'edit', 534 Horde_Perms::DELETE => 'delete'); 535 536 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 537 $share = $shares->getShare($shareName); 538 $perm = $share->getPermission(); 539 $permissions = $perm->getUserPermissions(); 540 if (empty($permissions[$userName])) { 541 return array(); 542 } 543 544 $user_permissions = array(); 545 foreach (array_keys(Horde_Perms::integerToArray($permissions[$userName])) as $permission) { 546 $user_permissions[] = $perm_map[$permission]; 547 } 548 549 return $user_permissions; 550 } 551 552 /** 553 * Returns an array of all group permissions on a share. 554 * 555 * @param string $scope The name of the share root, e.g. the 556 * application that the share belongs to. 557 * @param string $shareName The share's name. 558 * @param string $groupName The group's name. 559 * 560 * @return array All group permissions for this share. 561 * @throws Horde_Exception 562 */ 563 public function listGroupPermissions($scope, $shareName, $groupName) 564 { 565 if (!$GLOBALS['registry']->isAdmin()) { 566 throw new Horde_Exception(_("You are not allowed to list share permissions.")); 567 } 568 569 $perm_map = array(Horde_Perms::SHOW => 'show', 570 Horde_Perms::READ => 'read', 571 Horde_Perms::EDIT => 'edit', 572 Horde_Perms::DELETE => 'delete'); 573 574 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 575 $share = $shares->getShare($shareName); 576 $perm = $share->getPermission(); 577 $permissions = $perm->getGroupPermissions(); 578 if (empty($permissions[$groupName])) { 579 return array(); 580 } 581 582 $group_permissions = array(); 583 foreach (array_keys(Horde_Perms::integerToArray($permissions[$groupName])) as $permission) { 584 $group_permissions[] = $perm_map[$permission]; 585 } 586 587 return $group_permissions; 588 } 589 590 /** 591 * Returns a list of users which have have certain permissions on a share. 592 * 593 * @param string $scope The name of the share root, e.g. the 594 * application that the share belongs to. 595 * @param string $shareName The share's name. 596 * @param array $permissions A list of permissions (show, read, edit, 597 * delete). 598 * 599 * @return array List of users with the specified permissions. 600 * @throws Horde_Exception 601 */ 602 public function listUsersOfShare($scope, $shareName, $permissions) 603 { 604 if (!$GLOBALS['registry']->isAdmin()) { 605 throw new Horde_Exception(_("You are not allowed to list users of shares.")); 606 } 607 608 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 609 $share = $shares->getShare($shareName); 610 $perm = 0; 611 foreach ($permissions as $permission) { 612 $permission = Horde_String::upper($permission); 613 if (defined('Horde_Perms::' . $permission)) { 614 $perm &= constant('Horde_Perms::' . $permission); 615 } 616 } 617 618 return $share->listUsers($perm); 619 } 620 621 /** 622 * Returns a list of groups which have have certain permissions on a 623 * share. 624 * 625 * @param string $scope The name of the share root, e.g. the 626 * application that the share belongs to. 627 * @param string $shareName The share's name. 628 * @param array $permissions A list of permissions (show, read, edit, 629 * delete). 630 * 631 * @return array List of groups with the specified permissions. 632 * @throws Horde_Exception 633 */ 634 public function listGroupsOfShare($scope, $shareName, $permissions) 635 { 636 if (!$GLOBALS['registry']->isAdmin()) { 637 throw new Horde_Exception(_("You are not allowed to list groups of shares.")); 638 } 639 640 $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); 641 $share = $shares->getShare($shareName); 642 $perm = 0; 643 foreach ($permissions as $permission) { 644 $permission = Horde_String::upper($permission); 645 if (defined('Horde_Perms::' . $permission)) { 646 $perm &= constant('Horde_Perms::' . $permission); 647 } 648 } 649 650 return $share->listGroups($perm); 651 } 652 653 /** 654 * Returns a list of ActiveSync devices that are partnered with Horde. 655 * 656 * @param array $filter An array of parameters to filter on: 657 * - user: Only return devices owned by user. If not present will default 658 * to returning devices for current user only. If present, but 659 * empty and current user is admin, will return all devices. 660 * Otherwise, will return devices matching the parameter (must be 661 * admin to list users other than current). 662 * 663 * @return array List of device properties. 664 * @since 5.2.0 665 */ 666 public function listActiveSyncDevices($filter = array()) 667 { 668 global $registry, $injector, $conf; 669 670 if (empty($conf['activesync']['enabled'])) { 671 return array(); 672 } 673 674 $state = $injector->getInstance('Horde_ActiveSyncState'); 675 $state->setLogger($injector->getInstance('Horde_Log_Logger')); 676 if (!isset($filter['user'])) { 677 $filter['user'] = $registry->getAuth(); 678 } elseif (empty($filter['user'])) { 679 if (!$registry->isAdmin()) { 680 throw new Horde_Exception_PermissionDenied(); 681 } 682 $filter['user'] = null; 683 } elseif ($filter['user'] != $registry->getAuth() && !$registry->isAdmin()) { 684 throw new Horde_Exception_PermissionDenied(); 685 } 686 try { 687 $devices = $state->listDevices($filter['user']); 688 } catch (Horde_ActiveSync_Exception $e) { 689 throw new Horde_Exception($e); 690 } 691 foreach ($devices as &$device) { 692 $device['device_properties'] = unserialize($device['device_properties']); 693 $device['last_synctime'] = $state->getLastSyncTimestamp($device['device_id']); 694 } 695 696 return $devices; 697 } 698 699 /** 700 * Perform an administrative action on a single paired ActiveSync device. 701 * 702 * @param string $action The action to perform. One of: 703 * WIPE, CANCEL_WIPE, REMOVE. 704 * @param string $deviceid The device's deviceid. 705 * @param string $user Restrict actions to only this user's 706 * account on the device in the case where the 707 * device may have multiple user accounts on this 708 * server. If empty, all users' state information 709 * will be removed. If a non-admin calls this 710 * method, this will always be set to the current 711 * horde username. 712 * @return boolean 713 * @throws Horde_Exception 714 */ 715 public function performActiveSyncDeviceAction($action, $deviceid, $user = null) 716 { 717 global $injector, $conf, $registry; 718 719 if (empty($conf['activesync']['enabled'])) { 720 throw new Horde_Exception(_("ActiveSync not activated.")); 721 } 722 if (!in_array($action, array('WIPE', 'CANCEL_WIPE', 'REMOVE'))) { 723 throw new Horde_Exception(_("Unsupported action.")); 724 } 725 726 $state = $injector->getInstance('Horde_ActiveSyncState'); 727 $state->setLogger($injector->getInstance('Horde_Log_Logger')); 728 // If not an admin, ensure the device is attached to the $user. 729 // Otherwise, any user could wipe any device if the deviceid is known. 730 if (!$registry->isAdmin()) { 731 $user = $registry->getAuth(); 732 if (!$state->deviceExists($deviceid, $user)) { 733 throw new Horde_Exception_PermissionDenied(); 734 } 735 } 736 switch ($action) { 737 case 'WIPE': 738 try { 739 $state->setDeviceRWStatus($deviceid, Horde_ActiveSync::RWSTATUS_PENDING); 740 } catch (Horde_ActiveSync_Exception $e) { 741 throw new Horde_Exception($e); 742 } 743 return true; 744 case 'CANCEL_WIPE': 745 try { 746 $state->setDeviceRWStatus($deviceid, Horde_ActiveSync::RWSTATUS_OK); 747 } catch (Horde_ActiveSync_Exception $e) { 748 throw new Horde_Exception($e); 749 } 750 return true; 751 case 'REMOVE': 752 try { 753 $state->removeState(array( 754 'devId' => $deviceid, 755 'user' => $user) 756 ); 757 } catch (Horde_ActiveSync_Exception $e) { 758 throw new Horde_Exception($e); 759 } 760 return true; 761 } 762 } 763 764 /** 765 * Perform an admistrative action on ALL paired ActiveSync devices. 766 * 767 * @param string $action The action. Currently, only 'RESET' is supported. 768 * - 'RESET': Causes all state for all devices to be removed. I.e., sets 769 * the synckey for all devices to 0. 770 * 771 * @return boolean 772 */ 773 public function performBulkActiveSyncDeviceAction($action) 774 { 775 global $injector, $conf, $registry; 776 777 if (!$registry->isAdmin()) { 778 throw new Horde_Exception_PermissionDenied(); 779 } 780 if (empty($conf['activesync']['enabled'])) { 781 throw new Horde_Exception(_("ActiveSync not activated.")); 782 } 783 if (!in_array($action, array('RESET'))) { 784 throw new Horde_Exception(_("Unsupported action.")); 785 } 786 try { 787 $injector->getInstance('Horde_ActiveSyncState')->resetAllPolicyKeys(); 788 } catch (Horde_ActiveSync_Exception $e) { 789 throw new Horde_Exception($e); 790 } 791 return true; 792 } 793 794} 795