From 402cd9bb09580a9ceb25cb5bdc805bb60ea6ac4a Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Tue, 2 Dec 2014 05:23:58 +0000 Subject: [PATCH] orm: Rename Aggregate to SqlAggregate --- include/class.orm.php | 2 +- include/client/faq-category.inc.php | 2 +- include/client/kb-categories.inc.php | 4 ++-- include/client/kb-search.inc.php | 4 ++-- include/client/knowledgebase.inc.php | 4 ++-- include/staff/categories.inc.php | 2 +- include/staff/faq-categories.inc.php | 10 +++++----- include/staff/pages.inc.php | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/class.orm.php b/include/class.orm.php index f9e51f553..5e41edc48 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -566,7 +566,7 @@ class SqlCode extends SqlFunction { } } -class Aggregate extends SqlFunction { +class SqlAggregate extends SqlFunction { var $func; var $expr; diff --git a/include/client/faq-category.inc.php b/include/client/faq-category.inc.php index 80168a07c..a9044f2b7 100644 --- a/include/client/faq-category.inc.php +++ b/include/client/faq-category.inc.php @@ -14,7 +14,7 @@ if(!defined('OSTCLIENTINC') || !$category || !$category->isPublic()) die('Access $faqs = FAQ::objects() ->filter(array('category'=>$category)) ->exclude(array('ispublished'=>false)) - ->annotate(array('has_attachments'=>Aggregate::COUNT('attachments', false, + ->annotate(array('has_attachments'=>SqlAggregate::COUNT('attachments', false, array('attachments__inline'=>0)))) ->order_by('-ispublished', 'question'); diff --git a/include/client/kb-categories.inc.php b/include/client/kb-categories.inc.php index 27f41475e..c6cc4e930 100644 --- a/include/client/kb-categories.inc.php +++ b/include/client/kb-categories.inc.php @@ -3,7 +3,7 @@ <?php $categories = Category::objects() ->exclude(Q::any(array('ispublic'=>false, 'faqs__ispublished'=>false))) - ->annotate(array('faq_count'=>Aggregate::count('faqs'))) + ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) ->filter(array('faq_count__gt'=>0)); if ($categories->all()) { ?> <div><?php echo __('Click on the category to browse FAQs.'); ?></div> @@ -45,7 +45,7 @@ <option value="">— Browse by Topic —</option> <?php $topics = Topic::objects() - ->annotate(array('has_faqs'=>Aggregate::COUNT('faqs'))) + ->annotate(array('has_faqs'=>SqlAggregate::COUNT('faqs'))) ->filter(array('has_faqs__gt'=>0)); foreach ($topics as $T) { ?> <option value="<?php echo $T->getId(); ?>"><?php echo $T->getFullName(); diff --git a/include/client/kb-search.inc.php b/include/client/kb-search.inc.php index ee8f51f87..5166a6616 100644 --- a/include/client/kb-search.inc.php +++ b/include/client/kb-search.inc.php @@ -34,7 +34,7 @@ <div class="header"><?php echo __('Help Topics'); ?></div> <?php foreach (Topic::objects() - ->annotate(array('faqs_count'=>Aggregate::count('faqs'))) + ->annotate(array('faqs_count'=>SqlAggregate::count('faqs'))) ->filter(array('faqs_count__gt'=>0)) as $t) { ?> <div><a href="?topicId=<?php echo urlencode($t->getId()); ?>" @@ -45,7 +45,7 @@ foreach (Topic::objects() <div class="header"><?php echo __('Categories'); ?></div> <?php foreach (Category::objects() - ->annotate(array('faqs_count'=>Aggregate::count('faqs'))) + ->annotate(array('faqs_count'=>SqlAggregate::count('faqs'))) ->filter(array('faqs_count__gt'=>0)) as $C) { ?> <div><a href="?cid=<?php echo urlencode($C->getId()); ?>" diff --git a/include/client/knowledgebase.inc.php b/include/client/knowledgebase.inc.php index fa9ba29cc..ac4a82f69 100644 --- a/include/client/knowledgebase.inc.php +++ b/include/client/knowledgebase.inc.php @@ -6,8 +6,8 @@ if(!defined('OSTCLIENTINC')) die('Access Denied'); if($_REQUEST['q'] || $_REQUEST['cid'] || $_REQUEST['topicId']) { //Search $faqs = FAQ::allPublic() ->annotate(array( - 'attachment_count'=>Aggregate::COUNT('attachments'), - 'topic_count'=>Aggregate::COUNT('topics') + 'attachment_count'=>SqlAggregate::COUNT('attachments'), + 'topic_count'=>SqlAggregate::COUNT('topics') )) ->order_by('question'); diff --git a/include/staff/categories.inc.php b/include/staff/categories.inc.php index c88237571..3708e09ca 100644 --- a/include/staff/categories.inc.php +++ b/include/staff/categories.inc.php @@ -3,7 +3,7 @@ if(!defined('OSTSCPINC') || !$thisstaff) die('Access Denied'); $qstr=''; $categories = Category::objects() - ->annotate(array('faq_count'=>Aggregate::COUNT('faqs'))); + ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))); $sortOptions=array('name'=>'name','type'=>'ispublic','faqs'=>'faq_count','updated'=>'updated'); $orderWays=array('DESC'=>'-','ASC'=>''); $sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name'; diff --git a/include/staff/faq-categories.inc.php b/include/staff/faq-categories.inc.php index 0019380d0..d66c24470 100644 --- a/include/staff/faq-categories.inc.php +++ b/include/staff/faq-categories.inc.php @@ -11,7 +11,7 @@ if(!defined('OSTSTAFFINC') || !$thisstaff) die('Access Denied'); <option value="">— <?php echo __('All Categories');?> —</option> <?php $categories = Category::objects() - ->annotate(array('faq_count'=>Aggregate::COUNT('faqs'))) + ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) ->filter(array('faq_count__gt'=>0)) ->order_by('name'); print $categories; @@ -31,7 +31,7 @@ print $categories; <option value="">— <?php echo __('All Help Topics');?> —</option> <?php $topics = Topic::objects() - ->annotate(array('faq_count'=>Aggregate::COUNT('faqs'))) + ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) ->filter(array('faq_count__gt'=>0)) ->all(); usort($topics, function($a, $b) { @@ -53,8 +53,8 @@ print $categories; if($_REQUEST['q'] || $_REQUEST['cid'] || $_REQUEST['topicId']) { //Search. $faqs = FAQ::objects() ->annotate(array( - 'attachment_count'=>Aggregate::COUNT('attachments'), - 'topic_count'=>Aggregate::COUNT('topics') + 'attachment_count'=>SqlAggregate::COUNT('attachments'), + 'topic_count'=>SqlAggregate::COUNT('topics') )) ->order_by('question'); @@ -89,7 +89,7 @@ if($_REQUEST['q'] || $_REQUEST['cid'] || $_REQUEST['topicId']) { //Search. } } else { //Category Listing. $categories = Category::objects() - ->annotate(array('faq_count'=>Aggregate::COUNT('faqs'))) + ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) ->all(); if (count($categories)) { diff --git a/include/staff/pages.inc.php b/include/staff/pages.inc.php index 6fbd8af00..5f364a768 100644 --- a/include/staff/pages.inc.php +++ b/include/staff/pages.inc.php @@ -3,7 +3,7 @@ if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied'); $pages = Page::objects() ->filter(array('type__in'=>array('other','landing','thank-you','offline'))) - ->annotate(array('topics'=>Aggregate::count('topics'))); + ->annotate(array('topics'=>SqlAggregate::COUNT('topics'))); $qstr=''; $sortOptions=array( 'name'=>'name', 'status'=>'isactive', -- GitLab