diff --git a/include/class.orm.php b/include/class.orm.php index f9e51f55332c15e6546cee9cec5688a29d19e10b..5e41edc482fdaeb95e3b36b244a78be4da001b65 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 80168a07c83a0c1758da2304225e9e66b880a345..a9044f2b77f1c057686dfe87fdeb526284653616 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 27f41475eb61fa7f859fb5cd100a7bce6a29132a..c6cc4e930aad3076b4237db87f8d932d6aac1df6 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 ee8f51f87e4132a9923387bcc21212b50fddd794..5166a6616fbd5ee2ff677124e46aeaaae15b0a2c 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 fa9ba29cc185d435dabaa85daad6d1f79d28a47a..ac4a82f6941f7263b97bef48974865457fbf9fe1 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 c88237571ff1f37e786e78b475049d4ddff1a76a..3708e09ca1a897b42137d0fe5c42c0e48c05c999 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 0019380d022a5e9fd00d7fa87b74785c41854c0b..d66c24470c1475e5d3b05697f1d23ae1ebcfb796 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 6fbd8af00f883083023792023ccb8f896dc6f848..5f364a768592f2c1fb5cf3b61bac752eb019392e 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',