/** * Get the names of the possible states * @method states * @static * @return {array} */ static function states() { $column = Base_Streams_Participant::column_state(); return Q::json_decode(str_replace("'", '"', '[' . $column[0][1] . ']')); }
/** * Also saves counterpart row in Streams_Participating table * @method beforeSave * @param {array} $modifiedFields * The fields that were modified * @return {array} */ function beforeSave($modifiedFields) { if (empty($this->extra)) { $this->extra = '{}'; } $modifiedState = isset($modifiedFields['state']); $modifiedExtra = isset($modifiedFields['extra']); foreach ($this->fields as $name => $value) { if (!empty($this->fieldsModified[$name])) { $modifiedFields[$name] = $value; } } if ($modifiedState or $modifiedExtra) { $p = new Streams_Participating(); $p->userId = $this->userId; // shouldn't change $p->publisherId = $this->publisherId; // shouldn't change $p->streamName = $this->streamName; // shouldn't change if ($modifiedState) { $p->state = $modifiedFields['state']; } else { if (isset($this->state)) { $p->state = $this->state; } } if ($modifiedExtra) { $p->extra = $modifiedFields['extra']; } else { if (isset($this->extra)) { $p->extra = $this->extra; } } $p->save(true); } return parent::beforeSave($modifiedFields); }