1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8class Tiki_Profile_InstallHandler_TrackerOption extends Tiki_Profile_InstallHandler 9{ 10 private function getData() // {{{ 11 { 12 if ($this->data) { 13 return $this->data; 14 } 15 16 $data = $this->obj->getData(); 17 18 $data = Tiki_Profile::convertYesNo($data); 19 20 return $this->data = $data; 21 } // }}} 22 23 private function getOptionMap() // {{{ 24 { 25 return Tiki_Profile_InstallHandler_Tracker::getOptionMap(); 26 } // }}} 27 28 private function getOptionConverters() // {{{ 29 { 30 return Tiki_Profile_InstallHandler_Tracker::getOptionConverters(); 31 } // }}} 32 33 function canInstall() // {{{ 34 { 35 $data = $this->getData(); 36 37 // Check for mandatory fields 38 if (! isset($data['tracker'], $data['name'], $data['value'])) { 39 return false; 40 } 41 42 return true; 43 } // }}} 44 45 function _install() // {{{ 46 { 47 $input = $this->getData(); 48 $this->replaceReferences($input); 49 50 $name = $input['name']; 51 $value = $input['value']; 52 53 $conversions = $this->getOptionConverters(); 54 if (isset($conversions[$name])) { 55 $value = $conversions[$name]->convert($value); 56 } 57 58 $optionMap = $this->getOptionMap(); 59 60 if (isset($optionMap[$name])) { 61 $name = $optionMap[$name]; 62 } 63 64 $trklib = TikiLib::lib('trk'); 65 $trklib->replace_tracker_option($input['tracker'], $name, $value); 66 67 return true; 68 } // }}} 69} 70