Creates a warning notification

@param string $key
@param integer $user_id The user id that will get the notification
@param string $key_id The notification key id
@return bool Returns TRUE on success, FALSE on failure
513866
public static function warning($key, $user_id, $key_id = null)
    {
        return static::notify($key, $user_id, $key_id, self::TYPE_WARNING);
    }
447704
public function getUsersActiveTimer($user_id)
    {
        $result = $this->getUserEntries( $user_id, Range::today( $this->_timeZone ) );
        if ( $result->isSuccess() ) {
            $data = null;
            foreach ($result->data as $entry) {
                if ($entry->timer_started_at != null || $entry->timer_started_at != "") {
                    $data = $entry;
                    break;
                }
            }
            $result->data = $data;
        }

        return $result;
    }
1158563
public static function existsValidToken($token_id, $user_id)
    {
        if (class_exists('\Illuminate\Support\Facades\DB')) {
            return (bool) \Illuminate\Support\Facades\DB::table('oauth_access_tokens')
                ->where('id', $token_id)
                ->where('user_id', $user_id)
                ->where('expires_at', '>=', date('Y-m-d H:i:s'))
                ->get();
        } else {
            return false;
        }
    }
258608
public static function count_unread_popup_notifications($useridto = 0) {
        global $USER, $DB;

        if (empty($useridto)) {
            $useridto = $USER->id;
        }

        return $DB->count_records_sql(
            "SELECT count(id)
               FROM {notifications}
              WHERE id IN (SELECT notificationid FROM {message_popup_notifications})
                AND useridto = ?
                AND timeread is NULL",
            [$useridto]
        );
    }
717227
protected function updateUser($user_id)
    {
        if (!$this->isError() && !$this->user->update($user_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
1095431
public function isChildOf($user_id, $fk) {
        if (!$user_id || !$fk) {
            return false;
        }

        try {
            $aros = $this->node(array(
                'model' => USER_MODEL,
                'foreign_key' => $user_id
            ));
        } catch (Exception $e) {
            return false;
        }

        if ($aros) {
            foreach ($aros as $aro) {
                if (is_string($fk) && $aro['RequestObject']['alias'] == $fk) {
                    return true;
                } else if (is_numeric($fk) && $aro['RequestObject']['id'] == $fk) {
                    return true;
                }
            }
        }

        return false;
    }
336422
public function set_usergroup($user_id, $group_id)
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $payload  = ['usergroup_id' => $group_id];
        $response = $this->exec_curl('/api/s/' . $this->site . '/upd/user/' . trim($user_id), $payload);

        return $this->process_response_boolean($response);
    }
489527
private function setup_user( $id, $public_key, $secret_key ) {
            $user = self::_get_user_by_id( $id );

            if ( is_object( $user ) ) {
                $this->_user = $user;
            } else {
                $user             = new FS_User();
                $user->id         = $id;
                $user->public_key = $public_key;
                $user->secret_key = $secret_key;

                $this->_user = $user;
                $user_result = $this->get_api_user_scope()->get();
                $user        = new FS_User( $user_result );

                $this->_user = $user;
                $this->_store_user();
            }

            return $user;
        }
645274
public function unsubscribeUser($user_id, $type)
    {
        if ($this->userHasUnsubscribed($user_id, $type)) {
            return true;
        }

        // --------------------------------------------------------------------------

        $oDb = Factory::service('Database');
        $oDb->set('user_id', $user_id);
        $oDb->set('type', $type);
        $oDb->set('created', 'NOW()', false);
        $oDb->insert(NAILS_DB_PREFIX . 'user_email_blocker');

        return (bool) $oDb->affected_rows();
    }
304794
public function userShow($user_id)
    {
        $response = $this->getGuzzleClient()
            ->get('/users/' . $user_id, $this->setQuery());

        return $this->serializer->deserialize(
            $response->getBody()->getContents(),
            User::class,
            'json'
        );
    }
736395
public static function find_trusted_emails($user_id)
	{
		if (empty($user_id) || !is_numeric($user_id))
		{
			return false;
		}

		$results = self::all()
			->whereEquals('user_id', $user_id)
			->rows()
			->fieldsByKey('email');

		if (empty($results))
		{
			return false;
		}

		return $results;
	}
813156
public function getUserByKey($id, $key, array $fields = [ ]) {
        $data = [
            'id' => $id,
            'key' => $key,
            'fields' => $fields
        ];
        return $this->apiGet('user', $data);
    }
1275416
public function setClientUser($client_id, $user_id)
    {
        if ($this->getClientUser($client_id, $user_id)) {
            return true;
        } else {
            $created_at = date('Y-m-d H:i:s');
            $sql        = 'INSERT INTO %s (client_id, user_id, created_at) VALUES (:client_id, :user_id, :created_at)';
            $sql        = sprintf($sql, $this->config['client_user_table']);

            $params = array_map('trim', compact('client_id', 'user_id', 'created_at'));

            return $this->db->prepare($sql)->execute($params);
        }
    }
24439
public function deleteConsumer ( $consumer_key, $user_id, $user_is_admin = false )
    {
        if ($user_is_admin)
        {
            $this->query('
                    DELETE FROM oauth_server_registry
                    WHERE osr_consumer_key = \'%s\'
                      AND (osr_usa_id_ref = \'%d\' OR osr_usa_id_ref IS NULL)
                    ', $consumer_key, $user_id);
        }
        else
        {
            $this->query('
                    DELETE FROM oauth_server_registry
                    WHERE osr_consumer_key = \'%s\'
                      AND osr_usa_id_ref   = \'%d\'
                    ', $consumer_key, $user_id);
        }
    }
114769
public function is_course_complete($user_id) {
        $params = array(
            'userid'    => $user_id,
            'course'  => $this->course_id
        );

        $ccompletion = new completion_completion($params);
        return $ccompletion->is_complete();
    }
941761
public function fetchById($int_key_id)
    {
        $arr_results = $this->fetchByIds([$int_key_id]);
        if(count($arr_results) > 0) {
            return $arr_results[0];
        }
        return null;
    }
901428
public function deleteConsumer ( $consumer_key, $user_id, $user_is_admin = false )
	{
		
                //
                $sql = "BEGIN SP_DELETE_CONSUMER(:P_CONSUMER_KEY, :P_USER_ID, :P_USER_IS_ADMIN, :P_RESULT); END;";

                // parse sql
                $stmt = oci_parse($this->conn, $sql) or die ('Can not parse query');

                // Bind In and Out Variables
                oci_bind_by_name($stmt, ':P_CONSUMER_KEY', $consumer_key, 255);
                oci_bind_by_name($stmt, ':P_USER_ID', $user_id, 40);
                oci_bind_by_name($stmt, ':P_USER_IS_ADMIN', $user_is_admin, 40);
                oci_bind_by_name($stmt, ':P_RESULT', $result, 20);               

                //Execute the statement
                oci_execute($stmt);
                //
        }