You are here

public function Messaging_Message::__set in Messaging 6.4

Same name and namespace in other branches
  1. 7 messaging.message.inc \Messaging_Message::__set()

Magic method, set protected properties

Warning: This also runs for unset properties

File

includes/messaging_message.class.inc, line 684
Drupal Messaging Framework - Message class file

Class

Messaging_Message
Message class

Code

public function __set($name, $value) {
  switch ($name) {
    case 'sender_account':
      $this->_sender = $value;
      if (!isset($this->sender)) {
        $this->sender = $value ? $value->uid : 0;
      }
      break;
    case 'destination':
      if (is_array($value)) {
        $this
          ->set_multiple($value);
      }
      else {
        $this
          ->set_destination($value);
      }
      break;
    case 'user':
    case 'account':
      $this
        ->set_user($value);
      break;
    default:

      // For unset fields, though they're public, when there's a __set function it is called too
      // When creating records, serial fields are unset() by drupal_write_record
      $this->{$name} = $value;
      break;
  }
}