Exemplo n.º 1
0
gchar *midgard_test_get_current_person_guid(MidgardConnection *mgd)
{
	g_assert(mgd != NULL);

	MidgardUser *user = midgard_connection_get_user(mgd);
	g_assert(user != NULL);

	MgdObject *person = midgard_user_get_person(user);
	g_assert(person != NULL);
	
	gchar *pguid = NULL;
	g_object_get(person, "guid", &pguid, NULL);
	g_assert_cmpstr(pguid, !=, "");
	g_assert_cmpstr(pguid, !=, NULL);
	
	return pguid;
}
Exemplo n.º 2
0
static GList *midgard_query_builder_execute_or_count(MidgardQueryBuilder *builder, MidgardTypeHolder *holder, guint select_type)
{
	g_assert(builder != NULL);

	if (builder->priv->grouping_ref > 0) {
		g_warning("Incorrect constraint grouping. Missed 'end_group'?");
		return NULL;
	}

	MidgardUser *user = midgard_connection_get_user(builder->priv->mgd);

	if (builder->priv->type == MIDGARD_TYPE_USER) {
		if (user && midgard_user_is_user(user)) {
			if (MGD_OBJECT_GUID (user) == NULL) {
				MIDGARD_ERRNO_SET(builder->priv->mgd, MGD_ERR_ACCESS_DENIED);
				g_warning("Type incompatible with Midgard Query Builder");
				return NULL;
			}

			GValue gval = {0, };
			g_value_init(&gval, G_TYPE_STRING);
			g_value_set_string(&gval, MIDGARD_DBOBJECT (user)->dbpriv->guid);

			midgard_query_builder_add_constraint(builder, "guid", "=", &gval);
		}
	}

	g_signal_emit (builder, MIDGARD_QUERY_BUILDER_GET_CLASS (builder)->signal_id_execution_start, 0);

	GList *list = midgard_core_qb_set_object_from_query(builder, select_type, NULL);

	if (list == NULL) {

		if (holder)
			holder->elements = 0;
	} else {
		
		if (holder)
			holder->elements = g_list_length(list);
	}

	g_signal_emit (builder, MIDGARD_QUERY_BUILDER_GET_CLASS (builder)->signal_id_execution_end, 0);

	return list;
}
static PHP_METHOD(midgard_connection, get_user)
{
	RETVAL_NULL();
	MidgardConnection *mgd =__midgard_connection_get_ptr(getThis());
	CHECK_MGD(mgd);

	if (zend_parse_parameters_none() == FAILURE)
		return;

	MidgardUser *user = midgard_connection_get_user(mgd);

	if (user == NULL)
		RETURN_NULL();

	g_object_ref(user); // this is a direct-pointer: we need to "ref" it explicitly

	php_midgard_gobject_new_with_gobject(return_value, php_midgard_user_class, G_OBJECT(user), TRUE TSRMLS_CC);
}