/**
  * Adds a comment to the object. The "comment" param can be an associative
  * array (in which each element represents one of the comment properties), or
  * an array of associative arrays. In this case, it adds all the comments to
  * the object.
  * 
  * @param      BaseObject  $object
  * @param      array       $comment
  */
 public function addComment(BaseObject $object, $comment)
 {
     if ($object->isNew() === true) {
         throw new Exception('Comments can only be attached to already saved objects');
     }
     if (is_array($comment)) {
         if (!isset($comment['text'])) {
             foreach ($comment as $onecomment) {
                 $this->addComment($object, $onecomment);
             }
         } else {
             if (strlen($comment['text']) > 0) {
                 $comment['text'] = strip_tags($comment['text']);
                 $comment['created_at'] = time();
                 if (!isset($comment['namespace'])) {
                     $comment['namespace'] = '';
                 }
                 $comment_object = new sfComment();
                 $comment_object->fromArray($comment, BasePeer::TYPE_FIELDNAME);
                 $comment_object->setCommentableId($object->getPrimaryKey());
                 $comment_object->setCommentableModel(get_class($object));
                 $comment_object->save();
                 return $comment_object;
             }
         }
     } elseif (is_string($comment)) {
         $this->addComment($object, array('text' => $comment));
     } else {
         new Exception('A comment must be represented as string or an associative array with a "text" key');
     }
 }
 /**
  * Adds a comment to the object. 
  * The "comment" param can be a string, an associative array 
  * (in which each element represents one of the comment properties), or
  * an array of associative arrays. In this case, it adds all the comments to
  * the object.
  *
  * @param      BaseObject  $object
  * @param      array       $comment
  */
 public function addComment(BaseObject $object, $comment)
 {
     if ($object->isNew() === true) {
         throw new Exception('Comments can only be attached to already saved objects');
     }
     if (is_array($comment)) {
         // array of associative arrays
         if (!isset($comment['text'])) {
             foreach ($comment as $onecomment) {
                 $this->addComment($object, $onecomment);
             }
         } else {
             // associative array (with the text key not void)
             if (strlen($comment['text']) > 0) {
                 if (isset($comment['title'])) {
                     $comment['title'] = strip_tags($comment['title']);
                 }
                 if (isset($comment['author_name'])) {
                     $comment['author_name'] = strip_tags($comment['author_name']);
                 }
                 if (isset($comment['author_email'])) {
                     $comment['author_email'] = strip_tags($comment['author_email']);
                 }
                 if (isset($comment['author_website'])) {
                     $comment['author_website'] = strip_tags($comment['author_website']);
                 }
                 // store comment's text, after cleaning it (see app.yml)
                 $comment['text'] = deppPropelActAsCommentableToolkit::clean($comment['text']);
                 $comment['created_at'] = time();
                 if (!isset($comment['namespace'])) {
                     $comment['namespace'] = null;
                 }
                 $comment_object = new sfComment();
                 $comment_object->fromArray($comment, BasePeer::TYPE_FIELDNAME);
                 $comment_object->setCommentableId($object->getPrimaryKey());
                 $comment_object->setCommentableModel(get_class($object));
                 // when the current user is authenticated, a connection to the user table is made
                 $user_options = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_user', array());
                 $curr_user = sfContext::getInstance()->getUser();
                 if ($user_options['enabled'] && $curr_user->isAuthenticated()) {
                     if (is_callable(get_class($curr_user), $user_options['cu_id_method'])) {
                         $comment_object->setAuthorId(call_user_func(array($curr_user, $user_options['cu_id_method'])));
                     }
                     if (is_callable(array($user_options['class'] . 'Peer', 'retrieveByPK'))) {
                         $user = call_user_func($user_options['class'] . 'Peer::retrieveByPk', $comment_object->getAuthorId());
                         if (array_key_exists('name_method', $user_options) && is_callable(get_class($user), $user_options['name_method'])) {
                             $comment_object->setAuthorName(call_user_func(array($user, $user_options['name_method'])));
                         }
                         if (array_key_exists('email_method', $user_options) && is_callable(get_class($user), $user_options['email_method'])) {
                             $comment_object->setAuthorEmail(call_user_func(array($user, $user_options['email_method'])));
                         }
                         if (array_key_exists('website_method', $user_options) && is_callable(get_class($user), $user_options['website_method'])) {
                             $comment_object->setAuthorWebsite(call_user_func(array($user, $user_options['website_method'])));
                         }
                     }
                 }
                 $comment_object->save();
                 self::_checkAndSaveCountCache($object, $comment['namespace']);
                 return $comment_object;
             }
         }
     } elseif (is_string($comment)) {
         $this->addComment($object, array('text' => $comment));
     } else {
         new Exception('A comment must be represented as string, an associative array with a "text" key, or an array of associative arrays');
     }
 }