1<?php 2/** 3 * Copyright 2012-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file LICENSE for license information (ASL). If you 6 * did not receive this file, see http://www.horde.org/licenses/apache. 7 * 8 * @author Michael Slusarz <slusarz@horde.org> 9 * @category Horde 10 * @license http://www.horde.org/licenses/apache ASL 11 * @package Ingo 12 */ 13 14/** 15 * Defines AJAX actions used in the Ingo smartmobile view. 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @category Horde 19 * @license http://www.horde.org/licenses/apache ASL 20 * @package Ingo 21 */ 22class Ingo_Ajax_Application_Smartmobile extends Horde_Core_Ajax_Application_Handler 23{ 24 /** 25 * AJAX action: Get rule data. 26 * 27 * Variables used: 28 * - rule: (integer) Rule number of the rule 29 * 30 * @return object An object with the following properties: 31 * - descrip: (string) Rule description. 32 * - error: (integer) True if error was encountered. 33 * - label: (string) The rule label. 34 */ 35 public function smartmobileRule() 36 { 37 global $injector, $notification; 38 39 $out = new stdClass; 40 41 $ingo_script = $injector->getInstance('Ingo_Factory_Script') 42 ->create(Ingo::RULE_FILTER); 43 if (!$ingo_script->availableActions()) { 44 $notification->push(_("Individual rules are not supported in the current filtering driver."), 'horde.error'); 45 $out->error = 1; 46 } else { 47 $storage = $injector->getInstance('Ingo_Factory_Storage')->create(); 48 $rule = $storage->retrieve(Ingo_Storage::ACTION_FILTERS) 49 ->getRule($this->vars->rule); 50 51 if (!$rule) { 52 $notification->push(_("Rule not found."), 'horde.error'); 53 $out->error = 1; 54 } else { 55 $out->descrip = trim($storage->ruleDescription($rule)); 56 $out->label = $rule['name']; 57 } 58 } 59 60 return $out; 61 } 62 63} 64