Permalink
Browse files

Fixed strict standards errors for groups pages

  • Loading branch information...
1 parent f647093 commit 8ced90f26c36598514f656ada3d6ad98cad369e5 @soonick committed Apr 13, 2013
Showing with 137 additions and 137 deletions.
  1. +8 −8 classes/Pommo_Groups.php
  2. +50 −50 classes/Pommo_Rules.php
  3. +73 −73 classes/Pommo_Sql.php
  4. +6 −6 groups_edit.php
View
@@ -98,7 +98,7 @@ function members($p = array(),
// make a group template
// accepts a group template (assoc array)
// return a group object (array)
- function & make($in = array()) {
+ public static function make($in = array()) {
$o = Pommo_Type::group();
return Pommo_Api::getParams($o, $in);
}
@@ -119,7 +119,7 @@ static function & makeDB(&$row) {
// returns true if group ($in) is valid, false if not
// TODO -> add validation of group array
- function validate(&$in) {
+ public static function validate(&$in) {
$logger =& Pommo::$_logger;
$invalid = array();
@@ -181,7 +181,7 @@ static function & get($p = array()) {
// accepts a filtering array -->
// id (int || array) -> an array of field IDs
// returns an array of group names. Array key(s) correlates to group ID.
- function & getNames($id = null) {
+ public static function getNames($id = null) {
$dbo =& Pommo::$_dbo;
$o = array();
@@ -224,7 +224,7 @@ function & getMemberIDs($group, $status = 1, $filter = false) {
// accepts filter by status (int) either 1 (active) (default), 0 (inactive), 2 (pending)
// accepts a toggle (bool) to return IDs or Group Tally
// returns a tally (int)
- function tally($group, $status = 1) {
+ public static function tally($group, $status = 1) {
$dbo =& Pommo::$_dbo;
require_once(Pommo::$_baseDir. 'classes/Pommo_Sql.php');
@@ -239,7 +239,7 @@ function tally($group, $status = 1) {
// adds a group to the database
// accepts a group object (array)
// returns the database ID of the added group or FALSE if failed
- function add(&$in) {
+ public static function add($in) {
$dbo =& Pommo::$_dbo;
if (!Pommo_Groups::validate($in))
@@ -259,7 +259,7 @@ function add(&$in) {
// removes a group from the database
// accepts a single ID (int) or array of IDs
// returns the # of deleted groups (int). 0 (false) if none.
- function delete(&$id) {
+ public static function delete($id) {
$dbo =& Pommo::$_dbo;
$query = "
@@ -286,7 +286,7 @@ function delete(&$id) {
// Returns the # of rules affected by a group deletion
// accepts a single ID (int) or array of IDs.
// Returns a count (int) of affected rules. 0 if none.
- function rulesAffected($id = array()) {
+ public static function rulesAffected($id = array()) {
$dbo =& Pommo::$_dbo;
$query = "
@@ -302,7 +302,7 @@ function rulesAffected($id = array()) {
// Checks if a group name exists
// accepts a name (str)
// returns (bool) true if exists, false if not
- function nameExists($name = null) {
+ public static function nameExists($name = null) {
$dbo =& Pommo::$_dbo;
$query = "
View
@@ -1,53 +1,53 @@
<?php
/**
* Copyright (C) 2005, 2006, 2007, 2008 Brice Burgess <bhb@iceburg.net>
- *
+ *
* This file is part of poMMo (http://www.pommo.org)
- *
- * poMMo is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
+ *
+ * poMMo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or any later version.
- *
+ *
* poMMo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with program; see the file docs/LICENSE. If not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
class Pommo_Rules {
-
- // returns the legal(logical) group selections for new filters
+
+ // returns the legal(logical) group selections for new filters
// accepts a group object
// accepts an array of all groups
// returns array of group names. Array key correlates to group's ID
- function & getLegalGroups(&$group, &$groups) {
+ public static function getLegalGroups(&$group, &$groups) {
$o = array();
-
+
foreach($groups as $id => $g) {
if($g['name'] != $group['name'])
$o[$id] = $g['name'];
}
-
+
// remember; for is_in/not_in .. field ID should be NULL, value is ID of group to include/exclude
foreach($group['rules'] as $r) {
if ($r['logic'] == 'is_in' || $r['logic'] == 'not_in')
unset($o[$r['value']]);
}
-
+
return $o;
}
-
+
// returns the legal(logical) selections for new filters based off current rules
// accepts a group object (can be empty -- thus returning all legal field filters)
// accepts a array of fields
// returns an array of logics. Array key correlates to field_id.
- function & getLegal(&$group, $fields) {
+ public static function getLegal(&$group, $fields) {
$c = array();
-
+
$legalities = array(
'checkbox' => array('true','false'),
'multiple' => array('is','not'),
@@ -56,22 +56,22 @@ function & getLegal(&$group, $fields) {
'number' => array('is','not','greater','less'),
'comment' => array()
);
-
+
foreach ($fields as $field)
$c[$field['id']] = $legalities[$field['type']];
-
+
if(empty($group['rules']))
return $c;
-
+
// subtract illogical selections from $c
- foreach ($group['rules'] as $rule) {
-
+ foreach ($group['rules'] as $rule) {
+
if (!isset($c[$rule['field_id']]))
continue;
-
- // create reference to this field's legalities
+
+ // create reference to this field's legalities
$l =& $c[$rule['field_id']];
-
+
switch($rule['logic']) {
case 'true' :
case 'false' :
@@ -92,16 +92,16 @@ function & getLegal(&$group, $fields) {
break;
}
}
-
+
foreach($c as $key => $val) {
if (empty($val))
unset($c[$key]);
}
-
+
return $c;
}
-
- function getEnglish($str = null) {
+
+ public static function getEnglish($str = null) {
$english = array(
'is' => Pommo::_T('is'),
'not' => Pommo::_T('is not'),
@@ -112,7 +112,7 @@ function getEnglish($str = null) {
'is_in' => Pommo::_T('or in group'),
'not_in' => Pommo::_T('and not in group')
);
-
+
if(is_array($str)) {
$out = array();
@@ -122,14 +122,14 @@ function getEnglish($str = null) {
}
return $out;
}
-
- return (empty($str)) ? $english : $english[$str];
+
+ return (empty($str)) ? $english : $english[$str];
}
-
+
function addBoolRule(&$group, &$match, &$logic) {
global $pommo;
$dbo =& Pommo::$_dbo;
-
+
$query = "
INSERT INTO " . $dbo->table['group_rules']."
SET
@@ -139,11 +139,11 @@ function addBoolRule(&$group, &$match, &$logic) {
$query=$dbo->prepare($query,array($group,$match,$logic));
return $dbo->affected($query);
}
-
+
function addGroupRule(&$groupID, &$match, &$logic) {
global $pommo;
$dbo =& Pommo::$_dbo;
-
+
$query = "
INSERT INTO " . $dbo->table['group_rules']."
SET
@@ -153,16 +153,16 @@ function addGroupRule(&$groupID, &$match, &$logic) {
$query=$dbo->prepare($query,array($groupID,$match,$logic));
return $dbo->affected($query);
}
-
+
function addFieldRule(&$group, &$field, &$logic, &$values, $type = 0) {
global $pommo;
$dbo =& Pommo::$_dbo;
-
+
$type = ($type == 'or')? 1 : 0;
-
+
// remove previous filters
Pommo_Rules::deleteRule($group, $field, $logic);
-
+
// get the field
require_once(Pommo::$_baseDir.'classes/Pommo_Fields.php');
$field = current(Pommo_Fields::get(array('id' => $field)));
@@ -174,42 +174,42 @@ function addFieldRule(&$group, &$field, &$logic, &$values, $type = 0) {
$value = Pommo_Helper::timeFromStr($value);
$v[] = $dbo->prepare("(%i,%i,'%s','%s',%i)",array($group, $field['id'], $logic, $value, $type));
}
-
+
$query = "
INSERT INTO " . $dbo->table['group_rules']."
(group_id, field_id, logic, value, type)
VALUES ".implode(',', $v);
return $dbo->affected($query);
}
-
-
+
+
function deleteRule($gid, $fid, $logic) {
global $pommo;
$dbo =& Pommo::$_dbo;
-
- $where = ($logic == 'is_in' || $logic == 'not_in') ?
+
+ $where = ($logic == 'is_in' || $logic == 'not_in') ?
"AND field_id=0 AND rule_id=%i" :
"AND field_id=%i";
-
+
$query = "
DELETE FROM " . $dbo->table['group_rules']."
WHERE group_id=%i AND logic='%s' ".$where;
$query = $dbo->prepare($query,array($gid, $logic, $fid));
- return ($dbo->affected($query));
+ return ($dbo->affected($query));
}
-
+
function changeType($gid, $fid, $logic, $type) {
global $pommo;
$dbo =& Pommo::$_dbo;
-
+
$type = ($type == 'or') ? 1 : 0;
-
+
$query = "
UPDATE " . $dbo->table['group_rules']."
SET type=$type
WHERE group_id=%i AND logic='%s' AND field_id=%i";
- $query = $dbo->prepare($query,array($gid, $logic, $fid));
- return ($dbo->affected($query));
+ $query = $dbo->prepare($query,array($gid, $logic, $fid));
+ return ($dbo->affected($query));
}
}
?>
Oops, something went wrong.

0 comments on commit 8ced90f

Please sign in to comment.