Esempio n. 1
0
 /**
  * creates a condition statment
  * 
  * @param string       $table    table name
  * @param string       $field    field name
  * @param string       $action   what comparison method to use
  * @param mixed        $argument what to compare with. can be: int, string, array (for IN statements) and Query instance (for sub-queries)
  * @param string|array $function a function name|an array of function name and paramters for the function
  * 
  * @access public
  * @return subCondition a condition object
  */
 public function createCondition($table, $field, $action, $argument, $function = '')
 {
     $cond = array();
     if (in_array($action, $this->_actions) == false) {
         $cond['action'] = '=';
     } else {
         $cond['action'] = $action;
     }
     if (is_array($function) && in_array($function[0], $this->_functions)) {
         $cond['func'] = $function;
     } elseif (is_string($function) && in_array($function, $this->_functions)) {
         $cond['func'][0] = $function;
         $cond['func'][1] = '';
     } else {
         $cond['func'] = false;
     }
     if ($argument instanceof query) {
         $cond['argument'] = $argument;
     } elseif (is_numeric($argument) === false && is_string($argument) && NewDao::connected()) {
         $cond['argument'] = NewDao::escape($argument);
     } else {
         $cond['argument'] = $argument;
     }
     $cond['fields'] = array($table, $field);
     return new subCondition($cond);
 }
Esempio n. 2
0
 /**
  * removes a message and its siblings form the database
  * @access private
  */
 protected function removeMessage()
 {
     $id = $this->getId();
     $dbug = $this->isDebug();
     $dna = $this->retrieveDna($id, $dbug);
     $children = $this->retrieveChildrenIds($dna, $dbug);
     foreach ($children as $child) {
         NewDao::getInstance()->delete('messages', array('id' => $child['id']), $dbug);
     }
     NewDao::getInstance()->delete('messages', array('id' => $id), $dbug);
 }
Esempio n. 3
0
<?php

ob_start();
define("_SEP_", DIRECTORY_SEPARATOR);
define("_DEBUG_", true);
require_once 'autoloader.php';
require_once 'errorHandler.php';
require_once ".." . _SEP_ . "classes" . _SEP_ . "library" . _SEP_ . 'firePHP' . _SEP_ . "fb.php";
NewDao::connect('mysql', ".." . _SEP_ . "configs" . _SEP_ . "db.ini");
NewDao::setLogger(array('FB', 'log'));
TreeForumAutoload('TFUserM');
session_start();
session_regenerate_id();
$conf = new IniObject(".." . _SEP_ . "configs" . _SEP_ . "view.ini");
TFRouter::route($conf->base_path, '', $conf);
ob_flush();
Esempio n. 4
0
 /**
  * returns a list of allowed permissions for a user to set
  * 	@param int $level a user's permission level
  * 	@param bool $log
  * @return array
  * @access private
  */
 private function retrieveAllowedPermissions($level, $log = false)
 {
     $query = NewDao::getGenerator();
     $sql = $query->addSelect('permissions', array())->addConditionSet($query->createCondition('permissions', 'level', '>', 0), $query->createCondition('permissions', 'level', '<', $level))->generate();
     return NewDao::getInstance()->queryArray($sql, $log);
 }
Esempio n. 5
0
 /** 
  * a simple select operation, using lower cased comparison
  * 		@param string $table   table name
  * 		@param array  $fields  which fields to select 
  * 		@param array  $conditions  which contions to use
  *		@param bool   $min     whether or not to return a row aor an array holding a row when reciving only 1 row as a result
  * 		@param bool   $log     whether to logg query or not
  * @access public
  * @return database result object  
  */
 public function selectLCASE($table, $fields = array(), $conditions = array(), $min = true, $log = false)
 {
     $query = NewDao::getGenerator();
     $query->addSelect($table, $fields);
     $conds = array();
     foreach ($conditions as $field => $value) {
         if (is_numeric($value)) {
             $conds[] = $query->createCondition($table, $field, '=', $value);
         } else {
             $conds[] = $query->createCondition($table, $field, '=', strtolower($value), 'LCASE');
         }
     }
     $query->addConditionSet($conds);
     $res = $this->queryArray($query->generate(), $log);
     if ($min && count($res) == 1) {
         return $res[0];
     }
     return $res;
 }
Esempio n. 6
0
 public function __get($name)
 {
     if ($name == '_link') {
         $this->_link = NewDao::getInstance();
     }
 }
Esempio n. 7
0
 /**
  * insertes a new forum permission
  * 	@param int $forum
  * 	@param int $perm
  * 	@param array $options a list of permisssion modes to set
  * 	@param bool $log
  * @access private
  */
 private function insertForumPermission($forum, $perm, $options = array(), $log = false)
 {
     if (!is_array($options)) {
         $options = array();
     }
     $options['forum_id'] = $forum;
     $options['permission_id'] = $perm;
     NewDao::getInstance()->insert('forum_actions', $options, $log);
 }
Esempio n. 8
0
 private function doesUserExist($id)
 {
     return NewDao::getInstance()->countFields('users', array('id' => $id), $this->isDebug()) > 0;
 }