Ejemplo n.º 1
0
 public function test_normal_post_no_inheritance()
 {
     $this->installAndIncludeModels(array('Post', 'Comment'));
     $Post = new Post(array('title' => 'Post for unit testing', 'body' => 'This is a post for testing the model'));
     $Post->comment->create(array('body' => 'hello', 'name' => 'Aditya'));
     $Post->save();
     $Post->reload();
     $expected_id = $Post->getId();
     $this->assertTrue($Result = $Post->find($expected_id, array('include' => array('comments'), 'conditions' => "name = 'Aditya'")));
     $this->assertEqual($Result->comments[0]->get('name'), 'Aditya');
 }
Ejemplo n.º 2
0
    public function update(Post $post)
    {
        $id = $post->getId();
        $content = $this->db->quote($content->getContent());
        $idAuthor = $_SESSION['id'];
        $query = '	UPDATE post
						SET content 	=' . $content . ',
							$idAuthor 	=' . $idAuthor . '
						WHERE id=' . $id;
        $res = $this->db->exec($query);
        if ($res) {
            $id = $this->db->lastInsertId();
            if ($id) {
                return $this->findById($id);
            } else {
                throw new Exception('Internal server Error');
            }
        }
    }
 public function save(Post $post)
 {
     $wp_error = null;
     if ($post->getID() != null) {
         wp_update_post($post->getWPPost());
     } else {
         $post_id = wp_insert_post($post->getWPPost(), $wp_error);
         $post->setID($post_id);
     }
     $metas = get_metadata('post', $post->getId());
     foreach ($post->getMetas() as $key => $value) {
         if (isset($metas[$key]) && $metas[$key] == $value) {
             continue;
         }
         foreach ($value as $subkey => $subvalue) {
             if ($subkey == 0) {
                 update_post_meta($post->getID(), $key, $subvalue);
             } else {
                 add_post_meta($post->getID(), $key, $subvalue);
             }
         }
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Declares an association between this object and a Post object.
  *
  * @param      Post $v
  * @return     Comment The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setPost(Post $v = null)
 {
     if ($v === null) {
         $this->setPostId(NULL);
     } else {
         $this->setPostId($v->getId());
     }
     $this->aPost = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Post object, it will not be re-added.
     if ($v !== null) {
         $v->addComment($this);
     }
     return $this;
 }
Ejemplo n.º 5
0
 public function delete(Post $dto)
 {
     BOL_CommentService::getInstance()->deleteEntityComments('blog-post', $dto->getId());
     BOL_RateService::getInstance()->deleteEntityRates($dto->getId(), 'blog-post');
     BOL_TagService::getInstance()->deleteEntityTags($dto->getId(), 'blog-post');
     BOL_FlagService::getInstance()->deleteByTypeAndEntityId('blog_post', $dto->getId());
     OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
     OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $dto->getId())));
     $this->dao->delete($dto);
 }
						
						<?php 
$optionList = getAllImagesWithSelect($postOnGet->getImage());
echo $optionList;
?>

					</select>

					</select>

					<input class="form-control" type="hidden" name="id_user" id="id_user" value="<?php 
echo $userLogged->getId();
?>
">
					<input class="form-control" type="hidden" name="id" id="id" <?php 
echo 'value=' . $postOnGet->getId();
?>
 >
					<input class="form-control" type="hidden" name="action" id="action" value="edit_post">


					<br>
					<input type="submit" class="btn btn-primary" value="Update Post">
				</form>
			</div>
		</div><!-- /row -->

		<div class="row mt centered ">	
			<div class="col-lg-8 col-lg-offset-2 centered">
				<h3>DELETE POST</h3>
				<hr><br>
Ejemplo n.º 7
0
 /**
  * Deletes specified Post object
  *
  * @param Post $post
  * @return bool
  */
 public function delete(Post $post)
 {
     return $this->persistence->delete($post->getId());
 }
Ejemplo n.º 8
0
 /**
  * Creates a form to create a Post entity.
  *
  * @param Post $entity The entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createCommentForm(CommentFront $model, $entity)
 {
     $form = $this->createForm('BlogBundle\\Form\\CommentFrontType', $model, array('action' => $this->generateUrl('blog_blog_comment', array('post' => $entity->getId())), 'method' => 'POST', 'attr' => array('id' => 'comment-form', 'class' => 'comment-form')));
     return $form;
 }
Ejemplo n.º 9
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Post $value A Post object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Post $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 10
0
 public function delete(Post $dto)
 {
     $this->deletePost($dto->getId());
 }
Ejemplo n.º 11
0
 /**
  * Creates a form to create a Post entity.
  *
  * @param Post $entity The entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createCommentForm(CommentFront $model, $entity)
 {
     $type = new CommentFrontType();
     $form = $this->createForm($type, $model, array('action' => $this->generateUrl('core_blog_blog_comment', array('post' => $entity->getId())), 'method' => 'POST', 'attr' => array('id' => $type->getName(), 'class' => 'comment-form')));
     $form->add('submit', 'submit', array('label' => 'Enviar'));
     return $form;
 }
Ejemplo n.º 12
0
 /**
  * Deletes a Post into the database
  * 
  * @param Post $post The post to be deleted
  * @throws PDOException if a database error occurs
  * @return void
  */
 public function delete(Post $post)
 {
     $stmt = $this->db->prepare("DELETE from posts WHERE id=?");
     $stmt->execute(array($post->getId()));
 }
Ejemplo n.º 13
0
 private function setPostData(Post $post, PostsProcessor $pp)
 {
     $this->setExtraData('pid', $post->getId());
     $this->setExtraData('rid', $post->getRubricId());
     $this->setExtraData('ptype', $post->getPostType());
     $this->setExtraData('pdate', $post->getDtPublication());
     $this->setExtraData('pdate_dmy', $post->getDtEvent(DF_JS_DATEPICKER));
     $this->setExtraData('cover', $pp->getCoverDi4Show($post->getIdent())->getRelPath());
     $this->setExtraData('cover96x96', $pp->getCoverDi($post->getIdent(), '96x96')->getRelPath());
     $this->setExtraData('cover156x156', $pp->getCoverDi($post->getIdent(), '156x156')->getRelPath());
     $this->setExtraData('post');
     //isPost
 }
Ejemplo n.º 14
0
 public function update(Post $post)
 {
     $this->updateObject('Post', 'p_id', $post->getId(), ['p_text' => $post->getText()]);
 }
Ejemplo n.º 15
0
 public function process($ctrl)
 {
     OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
     $service = PostService::getInstance();
     /* @var $postDao PostService */
     $data = $this->getValues();
     $data['title'] = UTIL_HtmlTag::stripJs($data['title']);
     $postIsNotPublished = $this->post->getStatus() == 2;
     $text = UTIL_HtmlTag::sanitize($data['post']);
     /* @var $post Post */
     $this->post->setTitle($data['title']);
     $this->post->setPost($text);
     $this->post->setIsDraft($_POST['command'] == 'draft');
     $isCreate = empty($this->post->id);
     if ($isCreate) {
         $this->post->setTimestamp(time());
         //Required to make #698 and #822 work together
         if ($_POST['command'] == 'draft') {
             $this->post->setIsDraft(2);
         }
         BOL_AuthorizationService::getInstance()->trackAction('blogs', 'add_blog');
     } else {
         //If post is not new and saved as draft, remove their item from newsfeed
         if ($_POST['command'] == 'draft') {
             OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $this->post->id)));
         } else {
             if ($postIsNotPublished) {
                 // Update timestamp if post was published for the first time
                 $this->post->setTimestamp(time());
             }
         }
     }
     $service->save($this->post);
     $tags = array();
     if (intval($this->post->getId()) > 0) {
         $tags = $data['tf'];
         foreach ($tags as $id => $tag) {
             $tags[$id] = UTIL_HtmlTag::stripTags($tag);
         }
     }
     $tagService = BOL_TagService::getInstance();
     $tagService->updateEntityTags($this->post->getId(), 'blog-post', $tags);
     if ($this->post->isDraft()) {
         $tagService->setEntityStatus('blog-post', $this->post->getId(), false);
         if ($isCreate) {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_draft_success_msg'));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_draft_success_msg'));
         }
     } else {
         $tagService->setEntityStatus('blog-post', $this->post->getId(), true);
         //Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'blogs', 'entityType' => 'blog-post', 'entityId' => $this->post->getId(), 'userId' => $this->post->getAuthorId()));
         OW::getEventManager()->trigger($event);
         if ($isCreate) {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_success_msg'));
             OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array('postId' => $this->post->getId())));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_success_msg'));
             OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_EDIT, array('postId' => $this->post->getId())));
         }
         $ctrl->redirect(OW::getRouter()->urlForRoute('post', array('id' => $this->post->getId())));
     }
 }
Ejemplo n.º 16
0
 protected function increasePostRevCount(Post $post)
 {
     $this->dbBean()->increasePostRevCount($post->getId());
 }
Ejemplo n.º 17
0
 /**
  * Declares an association between this object and a Post object.
  *
  * @param      Post $v
  * @return     void
  * @throws     PropelException
  */
 public function setPost($v)
 {
     if ($v === null) {
         $this->setPostId(NULL);
     } else {
         $this->setPostId($v->getId());
     }
     $this->aPost = $v;
 }