Esempio n. 1
0
 /**
  * This test case demonstrates an issue with the identity case in the
  * Doctrine_Table class.  The brief summary is that if you create a
  * record, then delete it, then create another record with the same
  * primary keys, the record can get into a state where it is in the
  * database but may appear to be marked as TCLEAN under certain
  * circumstances (such as when it comes back as part of a collection).
  * This makes the $record->exists() method return false, which prevents
  * the record from being deleted among other things.
  */
 public function testIdentityMapAndRecordStatus()
 {
     // load our user and our collection of pages
     $user = Doctrine_Query::create()->query('SELECT * FROM BookmarkUser u WHERE u.name=?', array('Anonymous'))->getFirst();
     $pages = Doctrine_Query::create()->query('SELECT * FROM Page');
     // bookmark the pages (manually)
     foreach ($pages as $page) {
         $bookmark = new Bookmark();
         $bookmark['page_id'] = $page['id'];
         $bookmark['user_id'] = $user['id'];
         $bookmark->save();
     }
     // select all bookmarks
     $bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
     $this->assertEqual(count($bookmarks), 1);
     // verify that they all exist
     foreach ($bookmarks as $bookmark) {
         $this->assertTrue($bookmark->exists());
     }
     // now delete them all.
     $user['Bookmarks']->delete();
     // verify count when accessed directly from database
     $bookmarks = Doctrine_Query::create()->query('SELECT * FROM Bookmark');
     $this->assertEqual(count($bookmarks), 0);
     // now recreate bookmarks and verify they exist:
     foreach ($pages as $page) {
         $bookmark = new Bookmark();
         $bookmark['page_id'] = $page['id'];
         $bookmark['user_id'] = $user['id'];
         $bookmark->save();
     }
     // select all bookmarks for the user
     $bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
     $this->assertEqual(count($bookmarks), 1);
     // verify that they all exist
     foreach ($bookmarks as $bookmark) {
         $this->assertTrue($bookmark->exists());
     }
 }
Esempio n. 2
0
 /**
  *  Проверяет имеется ли тема в закладках
  * @param  integer  $user_id id пользователя
  * @return boolean  имеется ли тема в закладках
  */
 public function isBookmarked($user_id)
 {
     return Bookmark::exists(['conditions' => ['topic_id = ? AND user_id = ?', $this->id, $user_id]]);
 }
Esempio n. 3
0
        $a->content = showThumb($avatar_id, 'Avatar', 150, 150);
        echo $a->render();
        $lb = new YuiLightbox();
        echo $lb->render() . '<br/>';
    }
}
echo '<br/>';
if ($session->id && $user_id != $session->id) {
    echo '&raquo; ' . ahref('u/messages/send/' . $user_id, 'Send message') . '<br/>';
    echo '&raquo; ' . ahref('u/poke/send/' . $user_id, 'Poke user') . '<br/>';
    //XXX: FIXME move to rr-project view
    echo '&raquo; ' . ahref('videomsg/send/' . $user_id, 'Send video message') . '<br/>';
    if (Bookmark::exists(BOOKMARK_FAVORITEUSER, $user_id, $session->id)) {
        echo '&raquo; ' . ahref('u/bookmark/removeuser/' . $user_id, 'Remove favorite') . '<br/>';
    } else {
        echo '&raquo; ' . ahref('u/bookmark/adduser/' . $user_id, 'Add favorite') . '<br/>';
    }
    echo '<br/>';
    if (Bookmark::exists(BOOKMARK_USERBLOCK, $user_id, $session->id)) {
        echo '<b>THIS USER IS BLOCKED FROM CONTACTING YOU</b><br/>';
    } else {
        echo '&raquo; ' . ahref('u/block/user/' . $user_id, 'Block user') . '<br/>';
    }
    echo '&raquo; ' . ahref('u/report/user/' . $user_id, 'Report user') . '<br/>';
}
echo '&raquo; ' . ahref('u/guestbook/' . $user_id, 'Guestbook') . '<br/>';
echo '&raquo; ' . ahref('u/album/overview/' . $user_id, 'Photos') . '<br/>';
echo '<br/>';
if ($session->id && $user_id == $session->id) {
    echo '&raquo; ' . ahref('u/edit', 'Edit profile') . '<br/>';
}
Esempio n. 4
0
             case PRIV_MSG:
                 echo nl2br($msg->body) . '<br/>';
                 break;
             case RECORDING_MSG:
                 echo 'VIDEO MSG!!!<br/>';
                 echo embed_flv($msg->body) . '<br/>';
                 break;
             default:
                 throw new \Exception('eh');
         }
         echo '<hr/>';
     }
     break;
 case 'send':
     // child = send to user id
     if (Bookmark::exists(BOOKMARK_USERBLOCK, $session->id, $this->child)) {
         echo 'User has blocked you from access';
         return;
     }
     function msgSubmit($p)
     {
         Message::send($p['to'], $p['msg']);
         js_redirect('u/messages/inbox');
     }
     $user = User::get($this->child);
     echo '<h2>Send a message to ' . $user->name . '</h2>';
     $form = new XhtmlForm();
     $form->addTextarea('msg', 'Msg');
     $form->addHidden('to', $this->child);
     $form->addSubmit('Send');
     $form->setHandler('msgSubmit');