function testEffort() { global $g_streber_url; TestEnvironment::initStreberUrl(); TestEnvironment::prepare('fixtures/project_setup.sql'); $this->addHeader('USER_AGENT: streber_unit_tester'); ### logout first ### $this->assertTrue($this->get($g_streber_url), 'getting login page (%s)'); $this->assertWantedPattern('/please login/i', 'check content (%s)'); $this->assertValidHtmlStucture('login'); ### Test login working ### $this->assertTrue($this->setField('login_name', 'bob')); $this->assertTrue($this->setField('login_password', 'bob_secret')); $this->assertTrue($this->clickSubmit('Submit')); validatePage($this); $this->assertTrue($this->get($g_streber_url . "/index.php?go=projViewEfforts&prj=10"), 'getting project effort view (%s)'); validatePage($this); $this->assertTrue($this->get($g_streber_url . "/index.php?go=homeListEfforts"), 'getting user efforts (%s)'); validatePage($this); $this->assertTrue($this->get($g_streber_url . "/index.php?go=effortNew&prj=10"), 'book new effort (%s)'); validatePage($this); $this->assertTrue($this->setField('effort_name', 'bla2')); $this->assertTrue($this->clickSubmit('Submit')); validatePage($this); }
if (empty($action)) { $pageCount = ceil($noticeCount / $perpage); $page = validatePage($page, $pageCount); $noticeList = $messageServer->getAllNotices($winduid, $page, $perpage); $redirect = 1; } elseif (in_array($action, array('system', 'postcate', 'active', 'apps', 'comment', 'guestbook'))) { $smstype = $messageServer->getConst($type . '_' . $action); $noticeCount = $messageServer->countNotice($winduid, $smstype); $pageCount = ceil($noticeCount / $perpage); $page = validatePage($page, $pageCount); $noticeList = $messageServer->getNotices($winduid, $smstype, $page, $perpage); } elseif ($action == 'unread') { $notReadCount = (int) $messageServer->countNoticesNotRead($winduid); $noticeCount = $notReadCount; $pageCount = ceil($notReadCount / $perpage); $page = validatePage($page, $pageCount); $noticeList = $messageServer->getNoticesNotRead($winduid, $page, $perpage); $redirect = 1; } elseif ($action == 'previous') { if (!($message = $messageServer->getUpNotice($winduid, $rid, $smstype))) { Showmsg("已经是第一条" . $chineseName[$smstype]); } $messageServer->markMessage($winduid, $message['rid']); $message['content'] = messageReplace($message['content']); $notReadCount = (int) $messageServer->countNoticesNotRead($winduid); } elseif ($action == 'next') { if (!($message = $messageServer->getDownNotice($winduid, $rid, $smstype))) { Showmsg("已经是最后一条" . $chineseName[$smstype]); } $messageServer->markMessage($winduid, $message['rid']); $message['content'] = messageReplace($message['content']);
/** * 根据相册ID取回相片列表 *@param $aid int 相册ID *@return Array 返回相片列表 */ function getPhotoListByAid($aid, $paging = true, $ifthumb = true) { $album = $this->albumViewRight($aid); if (!is_array($album)) { return $album; } $ownerid = $album['ownerid']; $userInfo = $this->getUserInfoByUid($ownerid); $album['lastphoto'] = getphotourl($album['lastphoto']); if ($this->_dbshield && $userInfo['groupid'] == 6 && !$this->isPermission()) { $album['lastphoto'] = $this->_pwModeImg . '/banuser.gif'; $album['aintro'] = appShield('ban_album_aintro'); } $cnpho = array(); if ($album['photonum']) { $pageCount = ceil($album['photonum'] / $this->_perpage); $this->_page = validatePage($this->_page, $pageCount); $photoDao = $this->_getDaoFactory('CnPhoto'); !$paging && ($this->_perpage = $album['photonum']); $photoList = $photoDao->getPagePhotosInfoByAid($aid, $this->_page, $this->_perpage, 1); foreach ($photoList as $key => $value) { $value['defaultPath'] = $value['path']; $value['path'] = getphotourl($value['path'], $value['ifthumb'] && $ifthumb); if ($this->_dbshield && $userInfo['groupid'] == 6 && !$this->isPermission()) { $value['path'] = $this->_pwModeImg . '/banuser.gif'; } $value['sub_pintro'] = substrs($value['pintro'], 25); $value['uptime'] = get_date($value['uptime']); $cnpho[] = $value; } } return array($album, $cnpho); }
/* @var $articleService PW_ArticleService */ if (empty($action)) { S::gp(array('page', 'cid', 'title', 'author', 'user')); $conditions = array('cid', 'title', 'author'); $ifcheck = $type == 'recycle' ? '2' : ($type == 'uncheck' ? '0' : '1'); $count = $articleService->searchArticleCount($cid, $title, $author, $ifcheck, $user); $columnService = C::loadClass('columnservice'); $columns = $columnService->findAllColumns(); $columnSelect = "<option value=''></option>"; foreach ($columns as $column) { if (!$column['parent_id']) { $columnSelect .= "<option value='" . $column['column_id'] . "'>" . $column['name'] . "</option>"; getColumnSelectHtml($columns, $column['column_id'], &$columnSelect, 1); } } $page = validatePage($page, $count); $articles = $articleService->searchAtricles($cid, $title, $author, $ifcheck, $user, '', ($page - 1) * $db_perpage, $db_perpage); $pages = numofpage($count, $page, ceil($count / $db_perpage), $basename . '&cid=' . $cid . '&'); } elseif ($action == 'move') { S::gp(array('aids', 'column_id', 'cid')); if (empty($aids)) { Showmsg('ÇëÑ¡ÔñÒªÒƶ¯µÄÎÄÕÂ', 'javascript:history.go(-1);'); } if (empty($column_id)) { Showmsg('·Ç·¨²Ù×÷Çë·µ»Ø', 'javascript:history.go(-1);'); } if (!$articleService->moveArticlesByIds($aids, $column_id)) { Showmsg('Òƶ¯ÎÄÕ²Ù×÷ʧ°Ü', $basename); } Showmsg('Òƶ¯ÎÄÕ²Ù×÷³É¹¦!', $basename . '&cid=' . $cid); } elseif ($action == 'del') {
/* @var $articleService PW_ArticleService */ $db_perpage = 10; if (empty($action)) { S::gp(array('column')); $column = (int) $column ? (int) $column : 0; $columnService = C::loadClass('columnservice'); /* @var $columnService PW_columnService */ $subColumns = $columnService->getAllOrderColumns($column); $subColumnIds = array_keys($subColumns); if (isGM($windid) || checkEditPurview($windid, $column)) { $articleCount = $articleService->searchArticleCount($subColumnIds, '', '', 1); $page = validatePage($page, $articleCount); $articleList = $articleService->searchAtricles($subColumnIds, '', '', 1, '', '', ($page - 1) * $db_perpage, $db_perpage); } else { $articleCount = $articleService->searchArticleCount($subColumnIds, '', '', 1, '', $timestamp); $page = validatePage($page, $articleCount); $articleList = $articleService->searchAtricles($subColumnIds, '', '', 1, '', $timestamp, ($page - 1) * $db_perpage, $db_perpage); } $pages = numofpage($articleCount, $page, ceil($articleCount / $db_perpage), $basename . 'q=list&column=' . $column . '&'); $pageCache = L::loadClass('pagecache', 'pagecache'); $pageCacheConfig = C::loadClass('pagecacheconfiglist', 'pagecache'); $pageCache->init($pageCacheConfig); $tmpHotArticle = $pageCache->getData('hotArticle'); $hotArticle = $articleService->filterArticles($tmpHotArticle); list($columns, $columnInfo) = $columnService->getCurrentAndSubColumns($column); if (!S::isArray($columns)) { list($columns, $columnInfo) = $columnService->getCurrentAndSubColumns($columnInfo['parent_id']); } /* update hits */ /*$hitfile = D_P . "data/bbscache/cms_hits.txt"; $hitsize = @filesize($hitfile);
$keyword = trim($keyword); $forumIds = $fid > 0 ? array($fid) : array(); $sphinxServer = L::loadclass('searcher', 'search'); $result = $sphinxServer->manageThreads($keyword, $sphinxRange, $authorarray, $pstarttime, $sqlPendtime, $forumIds, $page, $lines); $result === false && adminmsg('search_keyword_empty'); $count = $result[0]; $query = $db->query("SELECT t.*,tm.userip FROM pw_threads t LEFT JOIN {$pw_tmsgs} tm ON tm.tid=t.tid WHERE tm.tid IN (" . $result[1] . ") ORDER BY tid DESC"); } else { $rs = $db->get_one("SELECT COUNT(*) AS count FROM pw_threads t LEFT JOIN {$pw_tmsgs} tm ON tm.tid=t.tid WHERE {$sql} LIMIT 1"); $count = $rs['count']; $start = ($page - 1) * $lines; $limit = S::sqlLimit($start, $lines); $query = $db->query("SELECT t.*,tm.userip FROM pw_threads t LEFT JOIN {$pw_tmsgs} tm ON tm.tid=t.tid WHERE {$sql} ORDER BY tid DESC {$limit}"); } $numofpage = ceil($count / $lines); $page = validatePage($page, $numofpage); $pages = pagerforjs($count, $page, $numofpage, "onclick=\"manageclass.superdel(this,'superdel_tpc','')\""); $delid = $topicdb = array(); pwCache::getData(D_P . 'data/bbscache/forum_cache.php'); while ($topic = $db->fetch_array($query)) { if ($direct) { $delid[$topic['tid']] = $topic['fid']; continue; } $topic['forumname'] = $forum[$topic['fid']]['name']; $topic['postdate'] = get_date($topic['postdate']); $topic['lastpost'] = get_date($topic['lastpost']); $topicdb[] = $topic; } $userip = str_replace('%', '*', $userip); include PrintEot('thread');
/** * scenario: * - bob runs beserk an deletes all tasks of manhatten project * - pm logs in an reverts all changes by bob */ function testRevertChanges() { TestEnvironment::initStreberUrl(); global $g_streber_url; TestEnvironment::prepare('fixtures/project_setup.sql'); $this->addHeader('USER_AGENT: streber_unit_tester'); $deleted_items = array(25, 23, 19, 18); ### login as bob ### $this->assertTrue($this->get($g_streber_url), 'getting login page (%s)'); $this->assertTrue($this->setField('login_name', 'bob')); $this->assertTrue($this->setField('login_password', 'bob_secret')); $this->assertTrue($this->clickSubmit('Submit')); validatePage($this); ### View topics ### ### delete all tasks foreach ($deleted_items as $id) { $this->assertTrue($this->get($g_streber_url . '/?go=tasksDelete&tsk=' . $id), 'deleting (%s)'); print $id; $this->assertNoUnwantedText('Warning:'); } ### make sure, we are at home and items are listed as deleted $this->assertWantedText('deleted by '); ### make sure, bob can't access revert function, because it's only for admins $this->assertTrue($this->get($g_streber_url . '/?go=personRevertChanges&person=5'), 'getting revert page (%s)'); $this->assertWantedText('Operation aborted'); ### logout bob ### $this->assertTrue($this->clickLink('Logout')); $this->assertWantedPattern('/please login/i', 'check content (%s)'); $this->assertValidHtmlStucture('login'); ### login as pm ### $this->assertTrue($this->get($g_streber_url), 'getting login page (%s)'); $this->assertTrue($this->setField('login_name', 'pm')); $this->assertTrue($this->setField('login_password', 'pm_secret')); $this->assertTrue($this->clickSubmit('Submit')); validatePage($this); ### make sure he sees the deleted tasks at home $this->assertWantedPattern("/body class=\"home\"/"); #$this->showSource(); foreach ($deleted_items as $id) { $this->assertWantedPattern("/{$id}\">.*deleted by <span class=person>Bob/"); # echo "<pre>" . $this->_browser->getContent() . "</pre>"; } $this->assertTrue($this->get($g_streber_url . '/?go=personRevertChanges&person=5'), 'getting revert page (%s)'); validatePage($this); $this->assertTrue($this->get($g_streber_url)); ### make sure pm does no longer see any changes by bob foreach ($deleted_items as $id) { $this->assertNoUnwantedPattern("/href=\"{$id}\">.*deleted by <span class=person>Bob/"); } }
$page = (object) array_intersect_key(get_object_vars($page), get_object_vars($validKeys)); return $page; } //Verify first chapter is the cover page if (isset($book->chapters[0]->type) && $book->chapters[0]->type === 'coverPage' && $book->chapters[0]->title === 'Cover page') { //Validate cover page $book->chapters[0] = validateCoverPage($book->chapters[0]); //Validate Chapters if (isset($book->chapters)) { foreach ($book->chapters as $chapterPos => $chapter) { if ($chapterPos != 0) { $book->chapters[$chapterPos] = validateChapter($chapter, $chapterPos); //Validate pages if (isset($chapter->pages)) { foreach ($chapter->pages as $pagePos => $page) { $book->chapters[$chapterPos]->pages[$pagePos] = validatePage($page, $chapterPos, $pagePos); } } } } } else { $abort = true; $errorArray[] = "Book must contain at least one chapter."; } } else { $abort = true; $errorArray[] = "First chapter must be the cover page."; } } //If all data valid if (!$abort) {