/** * returns a message's children's ids * @param string $dna a message's dna * @param bool $log log queries? * @access private */ private function retrieveChildrenIds($dna, $log = false) { $query = NewDao::getGenerator(); $query->addSelect('messages', array()); $query->addConditionSet($query->createCondition('messages', 'dna', 'LIKE', $dna . ".%")); return NewDao::getInstance()->queryArray($query->generate(), $log); }
/** * 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; }
/** * 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); }
/** * retrieves a forum's main permissions (admin editor and users) * @param string $name forum name * @param bool $log * @access private */ private function retrieveForumPermissions($name, $log = false) { $query = NewDao::getGenerator(); $query->addSelect('permissions', array('id', 'name')); $query->addConditionSet($query->createCondition('permissions', 'name', '=', $name . '-admin')); $query->addConditionSet($query->createCondition('permissions', 'name', '=', $name . '-editor')); $query->addConditionSet($query->createCondition('permissions', 'name', '=', $name . '-user')); $perms = NewDao::getInstance()->queryArray($query->generate(), $log); foreach ($perms as $perm) { switch ($perm['name']) { case $name . '-admin': $this->_admin_permission = $perm['id']; break; case $name . '-editor': $this->_editor_permission = $perm['id']; break; case $name . '-user': $this->_user_permission = $perm['id']; break; } } }