Example #1
0
function compileNotUsers($uids_conditions, $thiscon, $uid, $member_handler, $reinitialize = false, $entry, $fid)
{
    static $omit_user = null;
    if ($reinitialize) {
        // need to do this when handling saved conditions, since each time we call this function it's a new "event" that we're dealing with
        $omit_user = null;
    }
    if ($thiscon['not_cons_uid'] > 0) {
        $uids_conditions[] = $thiscon['not_cons_uid'];
    } elseif ($thiscon['not_cons_curuser'] > 0) {
        $uids_conditions[] = $uid;
    } elseif ($thiscon['not_cons_groupid'] > 0) {
        $uids_temp = $member_handler->getUsersByGroup($thiscon['not_cons_groupid']);
        $uids_conditions = array_merge((array) $uids_temp, $uids_conditions);
        unset($uids_temp);
    } elseif ($thiscon['not_cons_creator'] > 0) {
        $uids_temp = getEntryOwner($entry, $fid);
        $uids_conditions[] = $uids_temp;
        unset($uids_temp);
    } elseif ($thiscon['not_cons_elementuids'] > 0) {
        // get the entry at issue and extract the uids from the specified element
        $data_handler = new formulizeDataHandler($fid);
        $value = $data_handler->getElementValueInEntry($entry, intval($thiscon['not_cons_elementuids']));
        if ($value) {
            $uids_temp = explode("*=+*:", $value);
            $uids_conditions = array_merge((array) $uids_temp, $uids_conditions);
        }
        unset($uids_temp);
    } elseif ($thiscon['not_cons_linkcreator'] > 0) {
        // get the entry at issue and extract the uid(s) of the creator(s) of the items selected in the specified element
        $data_handler = new formulizeDataHandler($fid);
        $value = $data_handler->getElementValueInEntry($entry, intval($thiscon['not_cons_linkcreator']));
        // get the values in the linked fields
        // the entry ids (in their source form) of the items selected in the linked selectbox, should always be an array of at least one value
        $entry_ids = explode(",", trim($value, ","));
        if (count($entry_ids) > 0) {
            // need to get the form that 'not_cons_linkcreator' is linked to
            $element_handler =& xoops_getmodulehandler('elements', 'formulize');
            $elementObject = $element_handler->get(intval($thiscon['not_cons_linkcreator']));
            // key 0 will be the form id that is the source for the values in this linked selectbox
            $linkProperties = explode("#*=:*", $elementObject->getVar('ele_value'));
            $data_handler2 = new formulizeDataHandler($linkProperties[0]);
            $uids_temp = $data_handler2->getAllUsersForEntries($entry_ids);
            if (count($uids_temp) > 0) {
                // no need for type hint (array) in this case because getAllUsersForEntries always returns an array, even if its empty
                $uids_conditions = array_merge($uids_temp, $uids_conditions);
            }
            unset($uids_temp);
        } else {
            $uids_conditions = array();
        }
    } elseif ($thiscon['not_cons_elementemail'] > 0) {
        // get the element at issue and extract the e-mail address from it
        $data_handler = new formulizeDataHandler($fid);
        $value = $data_handler->getElementValueInEntry($entry, intval($thiscon['not_cons_elementemail']));
        if ($value) {
            // split on commas
            $values = explode(",", $value);
            $good_values = array();
            // check each email address, exclude the ones ending with .archived
            foreach ($values as $a_value) {
                // build a new array of emails
                if (".archived" != substr($a_value, -9)) {
                    $good_values[] = $a_value;
                }
            }
            // implode the new array of emails with commas, set $value to this new string
            $value = implode(",", $good_values);
            $GLOBALS['formulize_notification_email'] = $value;
            $uids_conditions = array_merge(array(-1), $uids_conditions);
        }
    }
    if (in_array($uid, $uids_conditions)) {
        // in Formulize, users are always notified of things, even things they do themselves.
        $omit_user = 0;
    }
    return array(0 => $uids_conditions, 1 => $omit_user);
}