Пример #1
0
 /**
  * 
  * @param WOOOF $wo
  * @param string $messageText
  * @param string $messageType
  * @param number $fadeInSeconds
  * @return bool
  */
 public static function addMessage(WOOOF $wo, $messageText, $messageType = 'I', $fadeInSeconds = 0)
 {
     $newId = $wo->db->getNewId('session_messages');
     $sid = $wo->sid;
     if ($messageType != 'I' and $messageType != 'E' and $messageType != 'S' and $messageType != 'W') {
         $wo->log(WOOOF_loggingLevels::WOOOF_LOG_WARNINGS, "Invalid messageType [{$messageType}] for Message: [{$messageText}]");
         $messageType = 'E';
     }
     $fadeInSeconds = (int) $fadeInSeconds;
     $sql = "insert into session_messages( id, sessionId, messageType, messageText, whenMicrotime, fadeInSeconds ) " . "values ( '{$newId}', '{$sid}', '{$messageType}', '{$messageText}', " . microtime(true) . ", {$fadeInSeconds} )";
     $succ = $wo->db->query($sql);
     return $succ;
 }
Пример #2
0
 /**
  * getDomainValues get the data values for a requested domain/subdomain
  * 
  * @param WOOOD $wo -- the initialized instance of WOOOF to use
  * @param string $value  -- the value to check
  * @param string $requestedDomain  -- the domain whose values we want to retrieve
  * @param string $requestedSubDomain -- optional -- if the domain is split in subdomains, the requested subdomain should be specified here. If there are subdomains in the domain and no subdomain is specified all the values will be returned regardless of subdomain bu a warning will be written to the debug log. 
  * @param string $mandatory -- optional -- if the given value must have content or not
  * 
  * @return boolean TRUE for valid input.
  */
 public static function validateId(WOOOF $wo, $value, $requestedDomain, $requestedSubDomain = '', $mandatory = TRUE)
 {
     if (!$wo->hasContent($value) && $mandatory) {
         return FALSE;
     }
     $domain = $wo->db->getRowByColumn('__domains', 'code', $requestedDomain);
     if ($domain === FALSE) {
         return FALSE;
     } elseif (!isset($domain['id'])) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0301 Requested domain [' . $wo->cleanUserInput($requestedDomain) . '] doesn\'t exist in the database!');
         return FALSE;
     }
     $domainData = new WOOOF_dataBaseTable($wo->db, '__domain_values');
     if (!$domainData->constructedOk) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0302 Internal failure. Failed to construct instance of __domain_values!');
         return FALSE;
     }
     $whereClauses['domainId'] = $domain['id'];
     if ($wo->hasContent($requestedSubDomain)) {
         $subDomainsR = $wo->db->query('select subDomain from __domain_values where domainId = \'' . $wo->db->escape($domain['id']) . '\' and subDomain = \'' . $wo->db->escape($requestedSubDomain) . '\'');
         if (!$wo->db->getNumRows($subDomainsR)) {
             $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0204 Requested subdomain [' . $wo->cleanUserInput($requestedSubDomain) . '] doesn\'t exist in the database!');
             return FALSE;
         }
         $whereClauses['subDomain'] = $requestedSubDomain;
     }
     $whereClauses['active'] = '1';
     $whereClauses['domainValueCode'] = $value;
     $howManyResults = $domainData->getResult($whereClauses);
     if ($howManyResults === FALSE) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0303 Operation failed in result retrieval from domain values.');
         return FALSE;
     }
     if ($howManyResults['rowsFetched'] == 0) {
         return FALSE;
     }
     return TRUE;
 }