Example #1
0
 /**
  * Constructor sets up {@link $db} and {@link $cfg}.
  */
 public function __construct()
 {
     $this->db = sf_api('LIB', 'Ado');
     $this->cfg = sf_api('LIB', 'Config');
     $this->itemcfg['current_author'] = (int) $this->cfg->auth('uid');
     // remove default sample table
     $this->_removeTable('cms_table');
 }
 protected function _updateSideLangAndCodestatus($idsidelang)
 {
     // update lastmodified
     $sql = "UPDATE \r\n\t\t\t\t" . $this->dbnames['side_lang'] . " \r\n\t\t\tSET \r\n\t\t\t\tlastmodified='" . time() . "', \r\n\t\t\t\tauthor='" . $this->cfg->auth('uid') . "' \r\n\t\t\tWHERE \r\n\t\t\t\tidsidelang='{$idsidelang}'";
     $this->db->query($sql);
     // look up for clonepages
     $sql = "SELECT \r\n\t\t\t\t\tidcatside \r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . $this->dbnames['side_lang'] . " A \r\n\t\t\t\t\tLEFT JOIN " . $this->dbnames['cat_side'] . " B USING(idside) \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tA.idsidelang='{$idsidelang}'";
     $this->db->query($sql);
     while ($this->db->next_record()) {
         $list[] = $this->db->f('idcatside');
     }
     // change code status
     change_code_status($list, '1', 'idcatside');
 }
Example #3
0
 /**
  * Creates a LogItem and decides where to save (database or file) or show directly
  * @param int $priority
  * @param string $type
  * @param string $message
  * @param array $param
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 protected function _handleLog($priority, $type, $message, $param)
 {
     // priority must be a number and type is required
     if (!is_numeric($priority) || strlen($type) < 0) {
         return FALSE;
     }
     $priokey = array_search($priority, $this->priorities);
     $merged = array();
     // add defined type and priority
     if (array_key_exists($type, $this->config['storage']) && is_array($this->config['storage'][$type][$priokey])) {
         $merged = array_merge($merged, $this->config['storage'][$type][$priokey]);
     }
     // add wildcard type for defined priority
     if (array_key_exists('*', $this->config['storage']) && is_array($this->config['storage']['*'][$priokey])) {
         $merged = array_merge($merged, $this->config['storage']['*'][$priokey]);
     }
     // add wildcard priority for defined type
     if (array_key_exists($type, $this->config['storage']) && is_array($this->config['storage'][$type]['*'])) {
         $merged = array_merge($merged, $this->config['storage'][$type]['*']);
     }
     // add wildcard priority and type
     if (array_key_exists('*', $this->config['storage']) && is_array($this->config['storage']['*']['*'])) {
         $merged = array_merge($merged, $this->config['storage']['*']['*']);
     }
     // remove duplicate entries
     $unique = array_unique($merged);
     // is there any output medium to log
     if (count($unique) > 0) {
         // create logitem
         $logitem = sf_api('MODEL', 'LogSqlItem');
         $logitem->setField('is_backend', $this->config['is_backend']);
         $logitem->setField('idclient', $this->config['idclient']);
         $logitem->setField('idlang', $this->config['idlang']);
         $logitem->setField('priority', $priority);
         $logitem->setField('priorityname', $priokey);
         $logitem->setField('type', $type);
         $logitem->setField('message', $message);
         $logitem->setField('created', time());
         $logitem->setField('created_author', $this->cfg->auth('uname'));
         if (!empty($param)) {
             $logitem->setField('param', $param);
         }
         // print_r($logitem);
         foreach ($unique as $outputmedium) {
             // do not add defined type and priority listed in the substract array -> continue to next item
             if (is_array($this->config['storage_substract'][$type][$priokey]) && in_array($outputmedium, $this->config['storage_substract'][$type][$priokey])) {
                 // echo 'do not add: '.$type.' - '.$priokey.' - '.$outputmedium.'<br />\n';
                 continue;
             } else {
                 if (is_array($this->config['storage_substract']['*'][$priokey]) && in_array($outputmedium, $this->config['storage_substract']['*'][$priokey])) {
                     // echo 'do not add: '.$type.' - '.$priokey.' - '.$outputmedium.'<br />\n';
                     continue;
                 } else {
                     if (is_array($this->config['storage_substract'][$type]['*']) && in_array($outputmedium, $this->config['storage_substract'][$type]['*'])) {
                         // echo 'do not add: '.$type.' - '.$priokey.' - '.$outputmedium.'<br />\n';
                         continue;
                     } else {
                         if (is_array($this->config['storage_substract']['*']['*']) && in_array($outputmedium, $this->config['storage_substract']['*']['*'])) {
                             // echo 'do not add: '.$type.' - '.$priokey.' - '.$outputmedium.'<br />\n';
                             continue;
                         } else {
                             // echo 'add: '.$type.' - '.$priokey.' - '.$outputmedium.'<br />\n';
                             // switch where to storage the item
                             switch ($outputmedium) {
                                 case 'database':
                                     $return = $this->_saveLogItemToDB($logitem);
                                     break;
                                 case 'logfile':
                                     $return = $this->_saveLogItemToFile($logitem);
                                     break;
                                 case 'screen':
                                     $return = $this->_displayLogItem($logitem);
                                     break;
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $return = FALSE;
     }
     return $return;
 }