当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::getUserId方法代码示例

本文整理汇总了PHP中Comment::getUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::getUserId方法的具体用法?PHP Comment::getUserId怎么用?PHP Comment::getUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::getUserId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderComment

 public function renderComment(Comment $comm, $template)
 {
     $vars = array('id' => $comm->getId(), 'username' => $comm->getUsername(), 'text' => $comm->getText(), 'date' => date('j.m.Y H:i', $comm->getDate()), 'ip' => $comm->getIpAddress());
     $user = FrontController::getUser();
     $config = FrontController::$config;
     if (in_array($this->_user->user_group, $config['moder_groups']) || in_array($this->_user->user_id, $config['moders']) || ($user->user_id == $comm->getUserId() && $comm->getUserId() || $user->ip_address == $comm->getIpAddress() && $comm->getDate() > time() - $config['owner_comment_del_time'])) {
         $blocks['perm_del'] = true;
     }
     return $this->render($template, $vars, $blocks);
 }
开发者ID:dautushenka,项目名称:DLE-Statement,代码行数:10,代码来源:Views.php

示例2: onNewComment

 public function onNewComment(FrontController $sender, Comment $comment, Statement $st)
 {
     $users = $st->getSubscribers();
     if ($users) {
         require_once ST_DIR . '/Classes/Mailer.php';
         $mailer = new Mailer();
         $vars = array('text' => strip_tags($comment->getText()), 'st_link' => FrontController::getURLByRoute('view', array('id' => $st->getId()), true), 'title' => $st->getTitle(), 'comment_user' => $comment->getUsername());
         foreach ($users as $user) {
             if ($user->user_id == $comment->getUserId() || $user->email == $comment->getEmail()) {
                 continue;
             }
             $vars['username'] = $user->name;
             $vars['unSubscribeLink'] = $this->_getSubscribeLink($user->email, $user->user_id, $st->getId());
             $mailer->sendMail('SubscribeNewComment', $user->email, $vars);
         }
     }
     $user = FrontController::getUser();
     if (!$user->user_id) {
         $guest = clone $user;
         $guest->email = $comment->getEmail();
         $guest->name = $comment->getUsername();
         $this->_subscribe($st, $guest);
     } else {
         $this->_subscribe($st, $user);
     }
 }
开发者ID:dautushenka,项目名称:DLE-Statement,代码行数:26,代码来源:SubscribeEvent.php

示例3: link_to_comment_delete

/**
 * Ссылка на удаление комментария
 *
 * @param Comment $comment
 */
function link_to_comment_delete($comment, $title = null)
{
    $user = sfContext::getInstance()->getUser();
    if ($user->isAuthenticated() && $user->getGuardUser()->getId() == $comment->getUserId() && $comment->hasDeletable()) {
        return jq_link_to_remote($title ? $title : 'Удалить', array('method' => 'post', 'url' => url_for('comment_delete', $comment), 'success' => 'jQuery("#comment-' . $comment->id . '").remove();', 'confirm' => 'Вы точно хотите удалить свой комментарий?'));
    }
}
开发者ID:pycmam,项目名称:neskuchaik.ru,代码行数:12,代码来源:FrontendHelper.php

示例4: canPutComment

 public function canPutComment($tripId = '', $commentId = '')
 {
     $user = $this->getUser();
     if ($user) {
         $access = $user->getAccess();
         if ($access === LEVEL_ADMIN) {
             // administrator can put all comments
             return true;
         }
         if ($access === LEVEL_VISITOR || $access === LEVEL_CONTRIB) {
             // visitor and contributor can put their own comments, or
             // new comments (comments that don't have any user ID)
             if ($tripId && $commentId) {
                 $object = new Comment($tripId, $commentId);
                 $objectId = $object->getUserId();
                 return $objectId === '' || $objectId === $user->getUserId();
             }
         }
     }
     return false;
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:21,代码来源:AuthB.php

示例5: InvalidArgumentException

         $requestObject->commentPhotoType = null;
     }
     if (empty($requestObject->commentText) === true) {
         throw new InvalidArgumentException("Comment Text cannot be empty", 408);
     }
     // perform the actual put or post
     if ($method === "PUT") {
         $comment = Comment::getCommentByCommentId($pdo, $commentId);
         if ($comment === null) {
             throw new RuntimeException("Comment does not exist", 404);
         }
         if ($_SESSION["user"] !== "S" && $_SESSION["user"]->getUserId() !== $comment->getUserId()) {
             throw new RuntimeException("You may only edit your own comments", 403);
         }
         // trailId, userId, browser, createDate, ipAddress, commentPhoto, commentPhotoType, commentText
         $comment = new Comment($commentId, $comment->getTrailId(), $comment->getUserId(), $comment->getBrowser(), $comment->getCreateDate(), $comment->getIpAddress(), $requestObject->commentPhoto, $requestObject->commentPhotoType, $requestObject->commentText);
         $comment->update($pdo);
         $reply->message = "Comment updated OK";
     } elseif ($method === "POST") {
         $comment = new Comment(null, $requestObject->trailId, $_SESSION["user"]->getUserId(), $browser, new DateTime(), $ipAddress, $requestObject->commentPhoto, $requestObject->commentPhotoType, $requestObject->commentText);
         $comment->insert($pdo);
         $reply->message = "Comment created OK";
     }
 } elseif ($method === "DELETE") {
     verifyXsrf();
     $comment = Comment::getCommentByCommentId($pdo, $commentId);
     if ($comment === null) {
         throw new RuntimeException("Comment does not exist", 404);
     }
     $comment->delete($pdo);
     $reply->message = "Comment deleted OK";
开发者ID:jmsaul,项目名称:open-trails,代码行数:31,代码来源:index.php

示例6: testOverrideAutomaticAttributesFutureDate

 /**
  * test #14.
  * Overriding automatic attributes using a future date. Because
  * a future date is used, the record can no longer be changed after
  * it was saved.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  * @depends testUpdate
  * @depends testOverrideAutomaticAttributesNewRecord
  */
 public function testOverrideAutomaticAttributesFutureDate()
 {
     global $testTripId1, $testCommentId1, $testUserId1;
     global $testUserId2;
     // Create the object, which automatically gets the current date
     $object = new Comment($testTripId1, $testCommentId1);
     $object->setUserId($testUserId1);
     $object->setReferenceId('-test-reference-id-1');
     $object->setCommentText('comment text');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $originalCreated = $object->getCreated();
     $originalUpdated = $object->getUpdated();
     $originalHash = $object->getHash();
     // Change the object with different values, using a guaranteed
     // future date for the Created and Updated fields. Note that
     // the mySQL timestamp values allow for dates up to January 19,
     // 2038. Select as the future date for this test January 18, 2038
     // values after first save are unchanged
     $object->setCreated('2038-01-18 10:10:10.000000');
     $object->setUpdated('2038-01-18 10:10:11.000000');
     $object->setUserId($testUserId2);
     $object->setReferenceId('-test-reference-id-2');
     $object->setCommentText('comment text 2');
     $object->setDeleted('N');
     $object->setHash('future date hash');
     // Check the values before saving
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testCommentId1, $object->getCommentId());
     $this->assertEquals('2038-01-18 10:10:10.000000', $object->getCreated());
     $this->assertEquals('2038-01-18 10:10:11.000000', $object->getUpdated());
     $this->assertEquals($testUserId2, $object->getUserId());
     $this->assertEquals('-test-reference-id-2', $object->getReferenceId());
     $this->assertEquals('comment text 2', $object->getCommentText());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals('future date hash', $object->getHash());
     // update the record, this adds a row in the database
     $this->assertTrue($object->save());
     $this->assertEquals(2, $this->countTestRows());
     // after the update, the information has been saved
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testCommentId1, $object->getCommentId());
     $this->assertEquals('2038-01-18 10:10:10.000000', $object->getCreated());
     $this->assertEquals('2038-01-18 10:10:11.000000', $object->getUpdated());
     $this->assertEquals($testUserId2, $object->getUserId());
     $this->assertEquals('-test-reference-id-2', $object->getReferenceId());
     $this->assertEquals('comment text 2', $object->getCommentText());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals('future date hash', $object->getHash());
     // Try to update the record. This will add a row in the database
     $object->setReferenceId('-test-reference-id-1');
     $object->setUserId($testUserId1);
     $object->setCommentText('comment text 3');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(3, $this->countTestRows());
     // but the new information is not saved. The previously saved
     // information cannot be overwritten without manually setting the
     // updated field.
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testCommentId1, $object->getCommentId());
     $this->assertEquals('2038-01-18 10:10:10.000000', $object->getCreated());
     $this->assertEquals('2038-01-18 10:10:11.000000', $object->getUpdated());
     $this->assertEquals($testUserId2, $object->getUserId());
     $this->assertEquals('-test-reference-id-2', $object->getReferenceId());
     $this->assertEquals('comment text 2', $object->getCommentText());
     $this->assertEquals('N', $object->getDeleted());
     // Note: this will FAIL in the current implementation!
     //$this->assertEquals('future date hash', $object->getHash());
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:81,代码来源:CommentTest.php

示例7: testGetValidCommentByUserId

 /**
  * test inserting a comment and and grabbing it by user Id
  */
 public function testGetValidCommentByUserId()
 {
     // get the count of rows in the database
     $numRows = $this->getConnection()->getRowCount("comment");
     // create a new comment and insert to mySQL
     $comment = new Comment(null, $this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_COMMENTPHOTO, $this->VALID_COMMENTPHOTOTYPE, $this->VALID_COMMENTTEXT);
     $comment->insert($this->getPDO());
     //grab the data from mySQL and make sure it matches expectations
     $pdoComments = Comment::getCommentByUserId($this->getPDO(), $comment->getUserId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("comment"));
     foreach ($pdoComments as $pdoComment) {
         $this->assertSame($pdoComment->getBrowser(), $this->VALID_BROWSER);
         $this->assertEquals($pdoComment->getCreateDate(), $this->VALID_CREATEDATE);
         $this->assertSame($pdoComment->getIpAddress(), $this->VALID_IPADDRESS);
         $this->assertSame($pdoComment->getCommentPhoto(), $this->VALID_COMMENTPHOTO);
         $this->assertSame($pdoComment->getCommentPhotoType(), $this->VALID_COMMENTPHOTOTYPE);
         $this->assertSame($pdoComment->getCommentText(), $this->VALID_COMMENTTEXT);
     }
 }
开发者ID:jmsaul,项目名称:open-trails,代码行数:22,代码来源:comment-test.php

示例8: filterByCommentRelatedByUserId

 /**
  * Filter the query by a related Comment object
  *
  * @param     Comment $comment  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    sfGuardUserQuery The current query, for fluid interface
  */
 public function filterByCommentRelatedByUserId($comment, $comparison = null)
 {
     if ($comment instanceof Comment) {
         return $this->addUsingAlias(sfGuardUserPeer::ID, $comment->getUserId(), $comparison);
     } elseif ($comment instanceof PropelCollection) {
         return $this->useCommentRelatedByUserIdQuery()->filterByPrimaryKeys($comment->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByCommentRelatedByUserId() only accepts arguments of type Comment or PropelCollection');
     }
 }
开发者ID:ratibus,项目名称:Crew,代码行数:18,代码来源:BasesfGuardUserQuery.php

示例9: __construct

 public function __construct(Comment $comment, array $users)
 {
     $this->comment = $comment;
     $this->user = $users[$comment->getUserId()];
 }
开发者ID:anzasolutions,项目名称:simlandia,代码行数:5,代码来源:commentto.class.php

示例10: testSynchPut

 /**
  * Test #13. SYNCH request write new object.
  */
 public function testSynchPut()
 {
     global $synchAuthToken;
     global $testTripId1, $testCommentId1;
     $this->assertEquals(0, $this->countTestRows());
     $data = array('tripId' => $testTripId1, 'commentId' => $testCommentId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'userId' => 'user', 'referenceId' => '-reference-1', 'commentText' => 'Comment Text', 'deleted' => 'Y', 'hash' => 'forced hash');
     $result = putApi('synchComment.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertEquals(1, $this->countTestRows());
     $object = new Comment($testTripId1, $testCommentId1);
     $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated());
     $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated());
     $this->assertEquals('user', $object->getUserId());
     $this->assertEquals('-reference-1', $object->getReferenceId());
     $this->assertEquals('Comment Text', $object->getCommentText());
     $this->assertEquals("Y", $object->getDeleted());
     $this->assertEquals('forced hash', $object->getHash());
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:21,代码来源:CommentApiTest.php


注:本文中的Comment::getUserId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。