/** * Converts a RGB code to hex value, preceded by # * @param integer The red component * @param integer The green component * @param integer The blue component * @param string The converted hex value * @return boolean True on succes, false otherwise */ public static final function RGBToHex($r, $g, $b, &$hex = '') { $val = new \System\Security\Validate(); $val->isInt($r, 'red', 0, 255, true); $val->isInt($g, 'green', 0, 255, true); $val->isInt($b, 'blue', 0, 255, true); if ($val->isInputOk()) { $hex = '#'; $hex .= str_pad(dechex($r), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($g), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($b), 2, "0", STR_PAD_LEFT); return true; } return false; }
public static final function call(\System\Collection\Map $serviceResult, \System\Db\Database $defaultDb) { self::validateHandles(); $val = new \System\Security\Validate(); $val->checkTextLength(self::$get->token, 'token', 10, true); $val->checkTextLength(self::$get->value, 'value', 1, true); if ($val->isInputOk()) { $vec = new \System\Collection\Vector(); $vec[] = self::$get->token; $vec[] = self::$get->value; $onetimecall = \Module\Onetimecall\Onetimecall::load($defaultDb, 'token_value', $vec, false); if ($onetimecall) { $serviceResult->onetimeCall = $onetimecall; $onetimecall->delete($defaultDb); return true; } $event = new \Module\Onetimecall\Event\OnOnetimecallFailEvent(); $event->raise(); } return false; }