mgd_get_preference

(Midgard 1.4.2 'Bifrost')

mgd_get_preference -- Get a preference

Description

object mgd_get_preference (int id)

object mgd_get_preference (int [person], string preference/domain, string name)

Minimum version: Midgard 1.4 (Bifrost)

Gets information on the preference with id id when only one parameter is given. Gets information on the preference in domain domain with name name if two parameters are passed. Gets information on the preference attached to person with id id in domain domain with name name if three parameters are passed. Preferences are only available when authenticated as the user who they're assigned to or as admin.

Returns an object describing the record if successful. Returns FALSE on failure.


<?php
 $id = 123;
 $pref = mgd_get_preference( $id );
 if( $err = mgd_errno() ) {
   echo "Could not get preference $id.<br>";
   echo "Reason: " . mgd_errstr( $err );
 } else {
   echo $pref->domain . "/" . $pref->name . " : "
         . $pref->value . "<br>\n";
 }

 $domain = "examples";
 $name   = "favcolour";
 $pref = mgd_get_preference( $domain, $name );
 if( $err = mgd_errno() ) {
   echo "You don't seem to have a favorite colour,<br>";
   echo "or at least I failed to get it.<br>";
   echo "reason: " . mgd_errstr( $err );
 } else {
   echo "Your favorite colour is " . $pref->value . ".<br>";
 }
?>