<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
$tree = array();
while ($dao->fetch()) {
if (!array_key_exists($dao->child, $tree)) {
- $tree[$dao->child] = array('children' => array(),
+ $tree[$dao->child] = array(
+ 'children' => array(),
'parents' => array(),
);
}
if (!array_key_exists($dao->parent, $tree)) {
- $tree[$dao->parent] = array('children' => array(),
+ $tree[$dao->parent] = array(
+ 'children' => array(),
'parents' => array(),
);
}
$values = array();
foreach (array_keys($tree) as $id) {
- $parents = implode(',', $tree[$id]['parents']);
+ $parents = implode(',', $tree[$id]['parents']);
$children = implode(',', $tree[$id]['children']);
- $parents = $parents == NULL ? 'null' : "'$parents'";
+ $parents = $parents == NULL ? 'null' : "'$parents'";
$children = $children == NULL ? 'null' : "'$children'";
- $sql = "
+ $sql = "
UPDATE civicrm_group
SET parents = $parents ,
children = $children
*
* @return bool
*/
- static function checkCyclicGraph(&$tree) {
+ public static function checkCyclicGraph(&$tree) {
// lets keep this simple, we should probably use a graph algoritm here at some stage
// foreach group that has a parent or a child, ensure that
/**
* @param $tree
- * @param $id
+ * @param int $id
*
* @return bool
*/
- static function isCyclic(&$tree, $id) {
+ public static function isCyclic(&$tree, $id) {
$parents = $children = array();
self::getAll($parent, $tree, $id, 'parents');
self::getAll($child, $tree, $id, 'children');
}
/**
- * @param $id
+ * @param int $id
* @param $groups
*
* @return array
*/
- static function getPotentialCandidates($id, &$groups) {
+ public static function getPotentialCandidates($id, &$groups) {
$tree = CRM_Core_BAO_Cache::getItem('contact groups', 'nestable tree hierarchy');
if ($tree === NULL) {
/**
* @param $potential
* @param $tree
- * @param $id
+ * @param int $id
* @param $token
*/
- static function invalidate(&$potential, &$tree, $id, $token) {
+ public static function invalidate(&$potential, &$tree, $id, $token) {
unset($potential[$id]);
if (!isset($tree[$id]) ||
/**
* @param $all
* @param $tree
- * @param $id
+ * @param int $id
* @param $token
*/
- static function getAll(&$all, &$tree, $id, $token) {
+ public static function getAll(&$all, &$tree, $id, $token) {
// if seen before, dont do anything
if (isset($all[$id])) {
return;
/**
* @return string
*/
- static function json() {
+ public static function json() {
$tree = CRM_Core_BAO_Cache::getItem('contact groups', 'nestable tree hierarchy');
if ($tree === NULL) {
}";
return $json;
}
-}
+}