本文整理汇总了PHP中Comment::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::getAll方法的具体用法?PHP Comment::getAll怎么用?PHP Comment::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::getAll方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show a list of all the comment posts.
*
* @return View
*/
public function index()
{
// Grab all the comment posts
$comments = $this->commentRepository->getAll();
// Show the page
$this->render('admin.comments.index', compact('comments'));
}
示例2: view
public function view()
{
$thread = Thread::getById(Param::get('thread_id'));
$page = Param::get('page', 1);
$pagination = new SimplePagination($page, self::MAX_ITEM_PER_PAGE);
$filter_username = htmlentities(Param::get('username'));
$comments = Comment::getAll($pagination->start_index - 1, $pagination->count + 1, $thread->id, $filter_username);
$pagination->checkLastPage($comments);
Comment::getUserAttributes($comments, $_SESSION['userid']);
Comment::sortByLikes($comments, Param::get('sort'));
$total = Comment::countAll();
$pages = ceil($total / self::MAX_ITEM_PER_PAGE);
$this->set(get_defined_vars());
}
示例3: view
public function view()
{
// get total number of pages
$thread = Thread::get(Param::get('id'));
$total = Comment::countAll($thread->id);
$pages = ceil($total / self::COMMENTS_PERPAGE);
$page = Param::get('page', 1);
// go to last page
if ($page == self::LAST_PAGE) {
$page = $pages;
}
// paginate comments
$pagination = new SimplePagination($page, self::COMMENTS_PERPAGE);
$comments = Comment::getAll($thread->id, $pagination->start_index - 1, $pagination->count + 1);
$pagination->checkLastPage($comments);
// set other variables needed by the view
$auth_user = User::getAuthenticated();
$title = $thread->title;
$this->set(get_defined_vars());
}
示例4: testDeleteConversation
/**
* @depends testGetUnreadConversationCount
*/
public function testDeleteConversation()
{
$conversations = Conversation::getAll();
$this->assertEquals(3, count($conversations));
$comments = Comment::getAll();
$this->assertEquals(4, count($comments));
//check count of conversation_items
$count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
$this->assertEquals(2, $count['count']);
//remove the account, tests tthat ConversationObserver is correctly removing data from conversation_item
$accounts = Account::getByName('anAccount2');
$this->assertTrue($accounts[0]->delete());
$count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
$this->assertEquals(1, $count['count']);
foreach ($conversations as $conversation) {
$conversationId = $conversation->id;
$conversation->forget();
$conversation = Conversation::getById($conversationId);
$deleted = $conversation->delete();
$this->assertTrue($deleted);
}
//Count of conversation items should be 0 since the ConversationsObserver should make sure it gets removed correctly.
$count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
$this->assertEquals(0, $count['count']);
//check that all comments are removed, since they are owned.
$comments = Comment::getAll();
$this->assertEquals(0, count($comments));
}
示例5: testDeleteMission
/**
* @depends testAddingComments
*/
public function testDeleteMission()
{
$missions = Mission::getAll();
$comments = Comment::getAll();
$personsWhoHaveNotReadLatest = PersonWhoHaveNotReadLatest::getAll();
$this->assertGreaterThan(0, count($missions));
$this->assertGreaterThan(0, count($comments));
$this->assertGreaterThan(0, count($personsWhoHaveNotReadLatest));
foreach ($missions as $mission) {
$missionId = $mission->id;
$mission->forget();
$mission = Mission::getById($missionId);
$deleted = $mission->delete();
$this->assertTrue($deleted);
}
//check that all comments and personsWhoHaveNotReadLatest are removed, since they are owned.
$comments = Comment::getAll();
$this->assertEquals(0, count($comments));
$missions = Mission::getAll();
$this->assertEquals(0, count($missions));
$personsWhoHaveNotReadLatest = PersonWhoHaveNotReadLatest::getAll();
$this->assertEquals(0, count($personsWhoHaveNotReadLatest));
}
示例6: testDeleteSocialItem
/**
* @depends testAddingComments
*/
public function testDeleteSocialItem()
{
$socialItems = SocialItem::getAll();
$this->assertEquals(1, count($socialItems));
$comments = Comment::getAll();
$this->assertEquals(1, count($comments));
$fileModels = FileModel::getAll();
$this->assertEquals(1, count($fileModels));
foreach ($socialItems as $socialItem) {
$socialItemId = $socialItem->id;
$socialItem->forget();
$socialItem = SocialItem::getById($socialItemId);
$deleted = $socialItem->delete();
$this->assertTrue($deleted);
}
$socialItems = SocialItem::getAll();
$this->assertEquals(0, count($socialItems));
//check that all comments are removed, since they are owned.
$comments = Comment::getAll();
$this->assertEquals(0, count($comments));
$fileModels = FileModel::getAll();
$this->assertEquals(0, count($fileModels));
}
示例7: getChangeLines
static function getChangeLines($query_options)
{
global $PH;
global $auth;
fillMissingValues($query_options, array('alive_only' => false));
$date_compare = isset($query_options['date_min']) ? $query_options['date_min'] : "0000-00-00";
/**
* get list of items touched by other people
*/
$changed_items = DbProjectItem::getAll($query_options);
/**
* go through list
*/
$changes = array();
foreach ($changed_items as $i) {
$change_type = NULL;
if (!isset($query_options['project'])) {
$project = Project::getVisibleById($i->project);
} else {
$project = NULL;
}
/**
* get item-change-type depeding on dates
*/
if ($i->deleted >= $i->modified) {
$change_type = ITEM_DELETED;
} else {
if ($i->modified > $i->created) {
$change_type = ITEM_MODIFIED;
} else {
$change_type = ITEM_NEW;
}
}
/**
* build up change-list
*/
switch ($change_type) {
case ITEM_NEW:
if ($i->type == ITEM_TASK) {
if (!($task = Task::getVisibleById($i->id))) {
continue;
}
if ($assigned_people = $task->getAssignedPeople()) {
$tmp = array();
foreach ($assigned_people as $ap) {
$tmp[] = $ap->getLink();
}
$html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
} else {
$html_assignment = '';
}
$html_details = '';
if ($tmp = $task->getFolderLinks(true, $project)) {
$html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
}
if ($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
global $g_prio_names;
$html_details .= ' / ' . $g_prio_names[$task->prio];
}
$change = new ChangeLine(array('item' => $task, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => '<span class=new>' . __('new') . ' ' . $task->getLabel() . '</span>', 'txt_what' => __('new') . ' ' . $task->getLabel(), 'type' => ChangeLine::NEW_TASK, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
$changes[] = $change;
} else {
if ($i->type == ITEM_FILE) {
require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
if ($file = File::getVisibleById($i->id)) {
$change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('New file'), 'txt_what' => __('New file'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
$changes[] = $change;
}
}
}
break;
case ITEM_MODIFIED:
$timestamp_last_change = $date_compare;
# make sure we use the last occured change type
/**
* modified tasks
*/
$type = ChangeLine::UPDATED;
if ($i->type == ITEM_TASK) {
if (!($task = Task::getVisibleById($i->id))) {
continue;
}
if ($assigned_people = $task->getAssignedPeople()) {
$tmp = array();
foreach ($assigned_people as $ap) {
$tmp[] = $ap->getLink();
}
$html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
} else {
$html_assignment = '';
}
$html_details = '';
if ($tmp = $task->getFolderLinks(true, $project)) {
$html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
}
$txt_what = $html_what = __('modified');
$type = ChangeLine::UPDATED;
$html_comment = '';
if ($comments = Comment::getAll(array('person' => $i->modified_by, 'task' => $task->id, 'date_min' => $timestamp_last_change, 'order_by' => 'created ASC'))) {
$last_comment = $comments[count($comments) - 1];
//.........这里部分代码省略.........
示例8: loadComments
public function loadComments()
{
$conditions = "WHERE post_id = '" . $this->id . "'";
$this->comments = Comment::getAll($conditions);
}
示例9: getSubComments
/**
* getSubComments
*
* NOTE: This is NOT recursive!
*/
public function getSubComments()
{
if (!($project = Project::getById($this->project))) {
return array();
}
$comments = Comment::getAll(array('parent_comment' => $this->id));
return $comments;
}
示例10: getForQuery
static function getForQuery($search_query, $project = NULL)
{
$count_overall = 0;
$results = array();
global $PH;
require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
$args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query);
foreach ($companies = Company::getAll($args) as $company) {
$rate = RATE_TYPE_COMPANY;
$rate *= SearchResult::RateItem($company);
$rate *= SearchResult::RateTitle($company, $search_query);
$results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company));
}
require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) {
$rate = RATE_TYPE_PERSON;
$rate *= SearchResult::RateItem($person);
$rate *= SearchResult::RateTitle($person, $search_query);
$results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person));
}
require_once confGet('DIR_STREBER') . "db/class_project.inc.php";
$projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query));
if ($projects) {
foreach ($projects as $project) {
$rate = RATE_TYPE_PROJECT;
if ($project->status == STATUS_TEMPLATE) {
$rate *= RATE_PROJECT_IS_TEMPLATE;
} else {
if ($project->status < STATUS_COMPLETED) {
$rate *= RATE_PROJECT_IS_OPEN;
} else {
$rate *= RATE_PROJECT_IS_CLOSED;
}
}
if ($diz = SearchResult::getExtract($project, $search_query)) {
$rate *= RATE_IN_DETAILS;
}
### status ###
global $g_status_names;
$status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : '';
if ($project->status > STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_CLOSED;
} else {
if ($project->status >= STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_COMPLETED;
}
}
### for company ###
$html_location = '';
if ($company = Company::getVisibleById($project->company)) {
$html_location = __('for') . ' ' . $company->getLink();
}
$rate *= SearchResult::RateItem($project);
$rate *= SearchResult::RateTitle($project, $search_query);
$results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location));
}
}
require_once confGet('DIR_STREBER') . "db/class_task.inc.php";
$order_str = get('sort_' . $PH->cur_page->id . "_tasks");
$tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED));
if ($tasks) {
foreach ($tasks as $task) {
$rate = RATE_TYPE_TASK;
$rate *= SearchResult::RateItem($task);
$rate *= SearchResult::RateTitle($task, $search_query);
if ($task->category == TCATEGORY_FOLDER) {
$rate *= RATE_TASK_IS_FOLDER;
}
if ($diz = SearchResult::getExtract($task, $search_query)) {
$rate *= RATE_IN_DETAILS;
}
global $g_status_names;
$status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : '';
if ($task->status > STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_CLOSED;
} else {
if ($task->status >= STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_COMPLETED;
}
}
if ($project = Project::getVisibleById($task->project)) {
$prj = $project->getLink();
} else {
$prj = '';
}
$html_location = __('in') . " <b>{$prj}</b> > " . $task->getFolderLinks();
$is_done = $task->status < STATUS_COMPLETED ? false : true;
$results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query)));
}
}
require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
$comments = Comment::getAll(array('search' => $search_query));
if ($comments) {
foreach ($comments as $comment) {
$rate = RATE_TYPE_COMMENT;
$rate *= SearchResult::RateItem($comment);
$rate *= SearchResult::RateTitle($comment, $search_query);
if ($diz = SearchResult::getExtract($comment, $search_query)) {
$rate *= RATE_IN_DETAILS;
}
//.........这里部分代码省略.........
示例11: _moveTask
function _moveTask($task_id, $target_project_id, $target_task_id)
{
$task = Task::getEditableById($task_id);
if (!$task) {
new FeedbackWarning(sprintf(__("Can not edit tasks with ID %s"), $task_id));
return false;
}
$target_parents = _getParentOfTaskId($target_task_id);
if (_isTaskInList($task, $target_parents)) {
new FeedbackWarning(sprintf(__("Can not move task <b>%s</b> to own child."), $task->name));
return false;
}
$task->parent_task = $target_task_id;
$task->update();
### move task to another project
if ($target_project_id != $task->project) {
$task->project = $target_project_id;
### move linked comments
if ($comments = Comment::getAll(array('visible_only' => false, 'alive_only' => false, 'task' => $task->id))) {
foreach ($comments as $c) {
$c->project = $target_project_id;
$c->update();
}
}
### move linked efforts
if ($efforts = Effort::getAll(array('visible_only' => false, 'alive_only' => false, 'task' => $task->id))) {
foreach ($efforts as $e) {
$e->project = $target_project_id;
$e->update();
}
}
### move subtasks
foreach ($task->getSubtasksRecursiveAll(array('visible_only' => true, 'alive_only' => false)) as $subtask) {
_moveTask($subtask->id, $target_project_id, $subtask->parent_task);
}
### move linked issue
if ($task->issue_report) {
$task->issue_report->project = $target_project_id;
}
}
$task->update();
$task->nowChangedByUser();
return true;
}