コード例 #1
0
 public static function getAllCommentsForResource($resource, $con = null)
 {
     $c = new Criteria();
     $c->add(sfEmendCommentPeer::URL, $resource);
     $c->add(sfEmendCommentPeer::IS_PUBLIC, 1);
     return sfEmendCommentPeer::doSelect($c, $con);
 }
コード例 #2
0
 public function executeAddComment()
 {
     $resource = $this->_clearResource($this->getRequestParameter('url'));
     try {
         $this->comment = sfEmendCommentPeer::addComment($resource, array('title' => $this->getRequestParameter('title'), 'body' => $this->getRequestParameter('body'), 'selection' => $this->getRequestParameter('selection'), 'author_name' => $this->hasRequestParameter('author_name') ? $this->getRequestParameter('author_name') : null));
     } catch (Exception $e) {
         $this->error = 'It was not possible to add the comment to the document. ' . $e->getMessage();
     }
 }
 public function executeTogglePublish()
 {
     $comment_id = $this->getRequestParameter('id');
     $comment = sfEmendCommentPeer::retrieveByPk($comment_id);
     $this->forward404Unless($comment);
     // toggle publish state
     if ($comment->getIsPublic()) {
         $comment->setIsPublic(0);
     } else {
         $comment->setIsPublic(1);
     }
     $comment->save();
     if ($referer = $this->getRequest()->getReferer()) {
         $this->redirect($referer);
     } else {
         $this->redirect('sfEmendAdmin/list');
     }
 }
コード例 #4
0
<?php

// initializes testing framework (change app name)
$app = 'fe';
include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php';
include $sf_symfony_lib_dir . '/vendor/lime/lime.php';
// initialize database manager
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = Propel::getConnection();
$resource = 'test1';
// clean all the comments related to the test resource
$comments = sfEmendCommentPeer::getAllCommentsForResource($resource);
foreach ($comments as $comment) {
    $comment->delete($con);
}
$user_options = sfConfig::get('app_sfEmendPlugin_user');
$browser = new sfTestBrowser();
$browser->initialize();
// get empty comments list for the first resource
$browser->test()->comment('Get an empty comments list');
$browser->get("/emend.getComments/" . $resource)->isStatusCode(200)->isRequestParameter('module', 'sfEmendAPI')->isRequestParameter('action', 'getComments')->responseContains('"n_comments": 0');
// try to add a comment through an emulated POST, as an anonymous user with no author name
$browser->test()->comment('Try to add a comment as anonymous user');
$browser->post("/emend.addComment/" . $resource, array('title' => 'Prova', 'body' => 'Un commento di prova', 'selection' => '"s": []'))->isStatusCode(200);
if ($user_options['allow_anonymous'] == 1) {
    $browser->responseContains('Anonymous posting requires an author_name parameter');
} else {
    $browser->responseContains('Anonymous posting not allowed');
}
// add a comment through an emulated POST,
コード例 #5
0
 
          <?php 
        foreach ($documenti as $documento) {
            ?>
	        <?php 
            if ($limit_count >= $limit) {
                ?>
	   		
              <tr>
                <th><?php 
                echo link_to('<strong>' . $i . '</strong>&nbsp;' . $documento->getTitolo(), 'atto/documento?id=' . $documento->getId());
                ?>
</th>
            <td>
            <?php 
                $num_comm = count(sfEmendCommentPeer::getAllCommentsForResource('atto_documento_id_' . $documento->getId()));
                ?>
            <?php 
                echo link_to($num_comm, 'atto/documento?id=' . $documento->getId());
                ?>
            <?php 
                switch ($num_comm) {
                    case 0:
                        $actvitity = 0;
                        break;
                    case $num_comm < 6:
                        $actvitity = 15;
                        break;
                    case $num_comm < 11:
                        $actvitity = 20;
                        break;
コード例 #6
0
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(sfEmendCommentPeer::ID, $pks, Criteria::IN);
         $objs = sfEmendCommentPeer::doSelect($criteria, $con);
     }
     return $objs;
 }