Exemplo n.º 1
0
 /**
  * Returns the API attributes for the model
  * @return array
  */
 public function getApiAttributes($params = array(), $relations = false)
 {
     $data = parent::getApiAttributes($params, $relations);
     $user = Users::model()->findByPk($this->author_id);
     $attributes = $user->getApiAttributes();
     $data['user'] = array('firstName' => $attributes['firstName'], 'lastName' => $attributes['lastName'], 'username' => $attributes['username']);
     $content = Content::model()->findByPk($data['content_id']);
     $data['content'] = array('id' => $data['content_id'], 'title' => $content->title, 'slug' => $content->slug);
     // If this user cannot comment without approval
     if ($user->getReputation() < 100) {
         $data['banned_comment'] = true;
     }
     return $data;
 }