public function testEmailOnNewIsTrueWhenPreferenceSet()
 {
     $comment = Table::factory('Comments')->read(3);
     $this->assertTrue($comment->emailOnNew());
     $comment = Table::factory('Comments')->read(4);
     $this->assertTrue($comment->emailOnNew());
 }
Exemple #2
0
 public function index()
 {
     if ($this->request->isGet()) {
         $this->assign("columns", Table::factory('Contacts')->getColumns());
     }
     if ($this->request->isPost()) {
         $contact = Table::factory('Contacts')->newObject();
         if ($contact->setValues($this->request->getPost())) {
             // all good. add, and stuff
             $contact->save();
             $address = Settings::getValue("contact.address");
             $subject = "Enquiry via paynedigital.com";
             $from = $contact->name . " <" . $contact->email . ">";
             $email = Email::factory();
             $email->setFrom($from);
             $email->setTo($address);
             $email->setSubject($subject);
             $email->setBody($this->fetchTemplate("emails/contact", array("query" => $contact->content, "name" => $contact->name)));
             $email->send();
             if (!$this->request->isAjax()) {
                 $this->setFlash("contact_thanks");
                 return $this->redirectAction("thanks");
             }
         } else {
             $this->setErrors($contact->getErrors());
         }
     }
 }
Exemple #3
0
 public function index()
 {
     $articles = Table::factory('Posts')->findRecent(10);
     $this->assign('articles', $articles);
     $this->response->addHeader('Content-Type', 'text/xml; charset=utf-8');
     return $this->render("index");
 }
 public function setUp()
 {
     parent::setUp();
     Utils::reset();
     Utils::setCurrentDate("2011-09-19 00:00:00");
     $this->table = Table::factory("Posts");
 }
Exemple #5
0
 public function generateUniqueIdentifier()
 {
     do {
         $identifier = $this->generateIdentifier();
     } while (Table::factory("Previews")->findByIdentifier($identifier) !== false);
     return $identifier;
 }
 public function do_redirect()
 {
     $link = Table::factory('Shortlinks')->findByUrl($this->getMatch('url'));
     if ($link == null) {
         throw new CoreException('Redirect URL not found', CoreException::PATH_REJECTED);
     }
     return $this->redirect($link->redirect_url);
 }
Exemple #7
0
 public function index()
 {
     $posts = Table::factory('Posts')->findAllForTagOrTitle($this->request->getVar('q'));
     $query = $this->request->getVar('q');
     if ($query !== null && trim($query) != "") {
         $this->assign('search_query', $this->request->getVar('q'));
     }
     $this->assign('posts', $posts);
 }
Exemple #8
0
 public function getRelatedPosts()
 {
     return Table::factory('RelatedPosts')->findAll(array("post_id" => $this->getId()));
 }
 /**
  * Get pages contents
  *
  * @return string
  */
 public static function content($slug = '')
 {
     if (!empty($slug)) {
         $page = Table::factory('pages')->select('[slug="' . $slug . '"]', null);
         if (!empty($page)) {
             $content = Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt'));
             $content = Filter::apply('content', $content);
             return $content;
         } else {
             return '';
         }
     } else {
         return Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . Pages::$page['id'] . '.page.txt'));
     }
 }
Exemple #10
0
 public function delete_related_post()
 {
     $related = Table::factory('RelatedPosts')->read($this->getMatch('related_post_id'));
     if ($related == false || $related->post_id != $this->post->getId()) {
         return $this->redirectAction("index", "You cannot perform this action");
     }
     $related->delete();
     return $this->redirectAction("index", "Relation Deleted");
 }
Exemple #11
0
 /**
  * NB this INCLUDES posts which have been deleted or not yet published
  */
 public function getAllPosts()
 {
     return Table::factory('Posts')->findAll(array("user_id" => $this->getId()));
 }
Exemple #12
0
 protected function assignArchive()
 {
     $archive = Table::factory('Posts')->findMonthsWithPublishedPosts();
     $this->assign('archive', $archive);
 }
Exemple #13
0
 public function testGetTweetUrlWithRecentArticle()
 {
     $post = Table::factory('Posts')->newObject();
     $post->setValues(array("published" => "01/03/2013 00:00:00", "url" => "test-article"));
     $this->assertEquals("articles/2013/03/test-article", $post->getTweetUrl());
 }
Exemple #14
0
 public function setUp()
 {
     parent::setUp();
     $this->table = Table::factory("Users");
 }
 public function testScriptBlockAddsContentWhenProvided()
 {
     $this->request->dispatch("/articles/2011/09/this-is-a-test-post");
     $this->assertBodyHasContents("<script type=\"text/javascript\" src=\"/foo/bar.js\"></script>", Table::factory('Posts')->read(3)->script_block);
 }
Exemple #16
0
 public function testToArrayRemovesSensitiveInformation()
 {
     $user = Table::factory('Users')->read(1);
     $this->assertEquals(array('email' => '*****@*****.**', 'forename' => 'Test', 'surname' => 'User', 'twitter_username' => 'testuser'), $user->toArray());
 }