Permalink
Browse files

Merge branch 'master' of https://github.com/tbar0970/jethro-pmm

  • Loading branch information...
tbar0970 committed Oct 2, 2017
2 parents b72fdd2 + 194dfe5 commit abbdbba3e2c2d886887918c626e80b68e6d27fca
@@ -897,7 +897,7 @@ public function fromCsvRow($row) {
$fields = $GLOBALS['system']->getDBObjectdata('custom_field');
foreach ($fields as $fieldID => $field) {
$field['id'] = $fieldID;
$customFields[strtolower($field['name'])] = $GLOBALS['system']->getDBObject('custom_field', $fieldID);
$customFields[str_replace(' ', '_', strtolower($field['name']))] = $GLOBALS['system']->getDBObject('custom_field', $fieldID);
}
}
foreach ($row as $k => $v) {
View
@@ -17,8 +17,6 @@
class JethroDB extends PDO
{
// TODO: Comments for all these
/**
* Create a JethroDB object from the details in conf.php and make it a global variable.
* @param type $mode
@@ -70,12 +68,12 @@ public function __construct($dsn, $username, $password, $options = array())
if ($options === NULL) {
$options = array();
}
$options[PDO::ATTR_PERSISTENT] = true;
$options[PDO::ATTR_DEFAULT_FETCH_MODE] = PDO::FETCH_ASSOC;
$options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
try {
$result = parent::__construct($dsn, $username, $password, $options);
} catch (PDOException $e) {
error_log((string)$e);
trigger_error('Could not connect to database - please check for mistakes in your Database configuration in conf.php, and check in MySQL that the database exists and the specified user has been granted access.', E_USER_ERROR);
exit();
}
@@ -75,26 +75,29 @@ public static function getDataURL($type, $id)
if ($res = self::getPhotoData($type, $id)) {
return 'data:image/jpg;base64,'.base64_encode($res);
} else {
return 'data:image/gif;base64,'.base64_encode(file_get_contents(BASE_URL.'resources/img/unknown_family.gif'));
return 'data:image/gif;base64,'.base64_encode(file_get_contents(JETHRO_ROOT.'/resources/img/unknown_family.gif'));
}
}
public static function getPhotoData($type, $id)
{
$db = $GLOBALS['db'];
$SQL = $obj = NULL;
if ($type == 'person') {
$obj = $GLOBALS['system']->getDBObject('person', (int)$id);
$SQL = 'SELECT photodata FROM person_photo WHERE personid = '.$obj->id;
if ($obj) $SQL = 'SELECT photodata FROM person_photo WHERE personid = '.$obj->id;
} else if ($type == 'family') {
$obj = $GLOBALS['system']->getDBObject('family', (int)$id);
// for single-member families, treat person photo as family photo
$SQL = 'SELECT COALESCE(fp.photodata, IF(count(p.id) = 1, pp.photodata, NULL)) as photodata
FROM family f
LEFT JOIN family_photo fp ON fp.familyid = f.id
LEFT JOIN person p ON p.familyid = f.id
LEFT JOIN person_photo pp ON pp.personid = p.id
WHERE f.id = '.(int)$obj->id.'
GROUP BY f.id';
if ($obj) {
// for single-member families, treat person photo as family photo
$SQL = 'SELECT COALESCE(fp.photodata, IF(count(p.id) = 1, pp.photodata, NULL)) as photodata
FROM family f
LEFT JOIN family_photo fp ON fp.familyid = f.id
LEFT JOIN person p ON p.familyid = f.id
LEFT JOIN person_photo pp ON pp.personid = p.id
WHERE f.id = '.(int)$obj->id.'
GROUP BY f.id';
}
}
if ($obj) {
@@ -53,7 +53,7 @@
// Check for / look for a list ID
if (empty($list_id)) {
$lists = $mc->get('lists');
if ($lists == FALSE) {
if (($lists == FALSE) || !$mc->success()) {
trigger_error("Mailchimp API Error calling lists(): ".$mc->getLastError(), E_USER_ERROR);
}
switch (count($lists['lists'])) {
@@ -76,11 +76,11 @@
// Check that the list has the necessary merge vars
$vars = array();
$vars_res = $mc->get('lists/'.$list_id.'/merge-fields');
if (!$vars_res) {
if (!$vars_res || !$mc->success()) {
trigger_error("Mailchimp API Error calling lists/merge-fields: ".$mc->getLastError(), E_USER_ERROR);
}
foreach ($vars_res['merge_fields'] as $var_details) {
foreach (array_get($vars_res, 'merge_fields', Array()) as $var_details) {
$vars[] = $var_details['tag'];
}
$missing_vars = array_diff(Array('STATUS', 'CONG', 'AGEBRACKET', 'GENDER'), $vars);
@@ -118,7 +118,7 @@
// Get the existing members of the mailchimp list
$members_res = $mc->get('lists/'.$list_id.'/members', Array('count' => 10000), 60);
if (FALSE === $members_res) {
if ((FALSE === $members_res) || !$mc->success()) {
trigger_error("Mailchimp API Error fetching list members: ".$mc->getLastError(), E_USER_ERROR);
}
$mc_members = Array();
@@ -11,7 +11,7 @@ function _compareNoteDates($a, $b)
function processView()
{
$this->_notes = $this->_getNotesToShow(array_get($_REQUEST, 'assignee'));
$this->_notes = $this->_getNotesToShow(array_get($_REQUEST, 'assignee'), array_get($_REQUEST, 'search'));
$this->_reassigning = $GLOBALS['user_system']->havePerm(PERM_BULKNOTE) && !empty($_REQUEST['reassigning']);
if ($this->_reassigning && !empty($_POST['reassignments_submitted'])) {
$dummy_note = new Abstract_Note();
@@ -265,6 +265,7 @@ private function getData()
$family = Array(
'familyid' => $familyid,
'optins' => Array(),
'all' => Array(),
);
$adults_use_full = FALSE;
$all_use_full = FALSE;
@@ -7,7 +7,7 @@ static function getMenuPermissionLevel()
return PERM_VIEWNOTE;
}
function _getNotesToShow($assigneeID=NULL)
function _getNotesToShow($assigneeID=NULL, $search=NULL)
{
$conds = Array('status' => 'pending', '>action_date' => date('Y-m-d'));
if ($search) {

0 comments on commit abbdbba

Please sign in to comment.