/** * Объединяет два блога. Текущий удаляется * * @param Blog $newBlog тэг, в который слить текущий */ public function MergeBlogs($newBlog) { if ($this->getId() == $newBlog->getId()) { return; } // удаляем все записи из блога, которые уже есть в новом блоге $query = "DELETE bp1\r\n FROM blog_post bp1\r\n LEFT JOIN blog_post bp2 ON bp1.post_id = bp2.post_id\r\n WHERE bp1.blog_id = " . $this->getId() . "\r\n AND bp2.blog_id = " . $newBlog->getId(); Doctrine_Manager::connection()->execute($query); // меняем все записи на новый блог Doctrine_Query::create()->update('BlogPost')->set('blog_id', $newBlog->getId())->where('blog_id = ?', $this->getId())->execute(); // удаляем нас $this->delete(); }
public function login(Blog $blog) { $this->setAuthenticated(true); $this->setAttribute('id', $blog->getId(), 'user'); $this->setAttribute('mid', $blog->getMid(), 'user'); $this->setAttribute('name', $blog->getAuthor(), 'user'); }
public static function getNewestTimestamp(Blog $blog) { $c = new Criteria(); $c->addDescendingOrderByColumn(PostPeer::CREATED_AT); $c->add(PostPeer::BLOG_ID, $blog->getId()); $post = PostPeer::doSelectOne($c); return $post ? $post->getCreatedAt(null) : 0; }
/** * Performs the action; returns true on success, false on error. * * @param $p_context - the current context object * @return bool */ public function takeAction(CampContext &$p_context) { $Blog = new Blog($this->m_properties['blog_id']); if (!$Blog->exists()) { $this->m_error = new PEAR_Error('None or invalid blog was given.', ACTION_BLOGENTRY_ERR_INVALID_BLOG); return false; } /* if (!$p_context->user->defined) { $this->m_error = new PEAR_Error('User must be logged in to add interview question.', ACTION_INTERVIEWITEM_ERR_NO_USER); return false; } */ if ($this->m_blogentry->exists()) { /* // to edit existing blogentry, check privileges $MetaInterview = new MetaInterview($this->m_blogentry->getProperty('fk_interview_id')); $is_admin = $MetaInterview->isUserAdmin($p_context); $is_moderator = $MetaInterview->isUserModerator($p_context); $is_guest = $MetaInterview->isUserGuest($p_context); if (!$is_admin && !$is_moderator && !$is_guest) { return false; } if ($is_guest) { # have to answer, change status automatically if (!strlen($this->m_properties['answer'])) { $this->m_error = new PEAR_Error('An answer was not given.', ACTION_INTERVIEWITEM_ERR_NO_ANSWER); return false; } $this->m_blogentry->setProperty('answer', $this->m_properties['answer']); $this->m_blogentry->setProperty('status', 'date'); } if ($is_moderator) { if (isset($this->m_properties['question'])) { $this->m_blogentry->setProperty('question', $this->m_properties['question']); } if (isset($this->m_properties['answer'])) { $this->m_blogentry->setProperty('answer', $this->m_properties['answer']); } if (isset($this->m_properties['status']) && ($is_admin || $is_moderator)) { $this->m_blogentry->setProperty('status', $this->m_properties['status']); } } if ($is_admin) { if (isset($this->m_properties['question'])) { $this->m_blogentry->setProperty('question', $this->m_properties['question']); } if (isset($this->m_properties['answer'])) { $this->m_blogentry->setProperty('answer', $this->m_properties['answer']); } if (isset($this->m_properties['status']) && ($is_admin || $is_moderator)) { $this->m_blogentry->setProperty('status', $this->m_properties['status']); } } $this->m_error = ACTION_OK; return true; */ } else { // create new blogentry if (!strlen($this->m_properties['title'])) { $this->m_error = new PEAR_Error('No entry title was given.', ACTION_BLOGENTRY_ERR_NO_TITLE); return false; } if (!strlen($this->m_properties['content'])) { $this->m_error = new PEAR_Error('No entry was given.', ACTION_BLOGENTRY_ERR_NO_CONTENT); return false; } if ($this->m_blogentry->create($Blog->getId(), $p_context->user->identifier, $this->m_properties['title'], $this->m_properties['content'], null, $this->m_properties['mood_id'])) { //$_REQUEST['f_blogentry_id'] = $this->m_blogentry->identifier; $this->m_error = ACTION_OK; return true; } } return false; }
/** * Declares an association between this object and a Blog object. * * @param Blog $v * @return void * @throws PropelException */ public function setBlog($v) { if ($v === null) { $this->setBlogId(NULL); } else { $this->setBlogId($v->getId()); } $this->aBlog = $v; }