yf_dynamic_find user module

Fileplugins/dynamic/modules/dynamic/yf_dynamic_find.class.php
Usemodule('dynamic_find'), URL ?object=dynamic_find

Public properties

A site sets them in its config with $PROJECT_CONF['dynamic_find']['NAME'] = ...;

PropertyDefaultDescription
$_parent null

Public methods 4

find_ids

public function find_ids()

find users over nick or email.

    public function find_ids()
    {
        no_graphics(true);
        if ( ! $_POST || ! main()->USER_ID || IS_ADMIN != 1/* || !strlen($_POST['param'])*/) {
            echo '';
            exit;
        }
        $field = $this->_search_field();
        if ( ! $field) {
            echo '*';
            exit;
        }
        if ($_POST['search_table'] == 'user') {
            // Find account ids of this user
            $Q = db()->query(
                "SELECT a.id
						, a.account_name
						, a.user_id
						, u.nick
						, u.id AS 'uid' 
				FROM " . db('host_accounts') . ' AS a, ' . db('user') . ' AS u 
				WHERE a.user_id=u.id 
					AND u.id IN( 
						SELECT id 
						FROM ' . db('user') . ' 
						WHERE ' . $field . " LIKE '" . _es($_POST['param']) . "%'
					) 
				LIMIT " . (int) ($this->_parent->USER_RESULTS_LIMIT)
            );
            while ($A = db()->fetch_assoc($Q)) {
                $finded_ids[$A['nick']][$A['id']] = $A['account_name'];
            }
        } elseif (($_POST['search_table'] ?? null) == 'host_accounts') {
            $Q = db()->query(
                "SELECT a.id
						, a.account_name
						, a.user_id
						, u.nick
						, u.id AS 'uid' 
				FROM " . db('host_accounts') . ' AS a
					, ' . db('user') . ' AS u 
				WHERE a.' . $field . " LIKE '" . _es($_POST['param']) . "%' 
					AND a.user_id=u.id 
				LIMIT " . (int) ($this->_parent->USER_RESULTS_LIMIT)
            );
            while ($A = db()->fetch_assoc($Q)) {
                $finded_ids[$A['nick']][$A['id']] = $A['account_name'];
            }
        }
        echo $finded_ids ? json_encode($finded_ids) : '*';
    }

find_users

public function find_users()

find users over nick or email.

    public function find_users()
    {
        no_graphics(true);
        if ( ! $_POST || ! main()->USER_ID || IS_ADMIN != 1) {
            echo '';
            return;
        }
        $field = $this->_search_field();
        if ( ! $field) {
            echo '*';
            return;
        }
        $Q = db()->query(
            'SELECT id, nick 
			FROM ' . db('user') . ' 
			WHERE ' . $field . " LIKE '" . _es($_POST['param']) . "%' 
			LIMIT " . (int) ($this->_parent->USER_RESULTS_LIMIT)
        );
        $finded_users = null;
        while ($A = db()->fetch_assoc($Q)) {
            $finded_users[$A['id']] = $A['nick'];
        }
        echo $finded_users ? json_encode($finded_users) : '*';
    }

Methods starting with _ hooks and helpers; not routable as page actions

__call

public function __call($name, $arguments)

Catch missing method call.

    public function __call($name, $arguments)
    {
        trigger_error(__CLASS__ . ': No method ' . $name, E_USER_WARNING);
        return false;
    }

__construct

public function __construct()
    public function __construct()
    {
        $this->_parent = module('dynamic');
    }