Example #1
0
 $validator->addData('field_name', 'Other', false);
 $validator->addData('field_prompt', 'Other', false);
 $validator->addData('field_required', 'matchRegex', false, '!^(on|off)$!');
 $validator->addData('field_active', 'matchRegex', false, '!^(on|off)$!');
 if ($result = $validator->checkData()) {
     // __ FORM IS VALID
     // TODO -> Which below logic is better? the computed diff, or send all fields for update?
     /*
     // make a difference between updated & original field
     $update = array_diff_assoc(Pommo_Fields::makeDB($_POST),$field);
     // restore the ID
     $update['id'] = $field['id'];
     */
     // let MySQL do the difference processing
     $update = Pommo_Fields::makeDB($_POST);
     if (!Pommo_Fields::update($update)) {
         $json->fail('error updating field');
     }
     $json->add('callbackFunction', 'updateField');
     $json->add('callbackParams', $update);
     $json->success(Pommo::_T('Settings updated.'));
 } else {
     // __ FORM NOT VALID
     $fieldErrors = array();
     $errors = $validator->getErrors();
     foreach ($errors as $key => $val) {
         $fieldErrors[] = array('field' => $key, 'message' => $val);
     }
     $json->add('fieldErrors', $fieldErrors);
     $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
 }
Example #2
0
}
if ($state['order'] != 'asc' && $state['order'] != 'desc') {
    $state['order'] = 'asc';
}
if (!is_numeric($state['sort']) && $state['sort'] != 'email' && $state['sort'] != 'ip' && $state['sort'] != 'time_registered' && $state['sort'] != 'time_touched') {
    $state['sort'] = 'email';
}
if (!is_numeric($state['status'])) {
    $state['status'] = 1;
}
if (!is_numeric($state['group']) && $state['group'] != 'all') {
    $state['group'] = 'all';
}
if (isset($_REQUEST['searchClear'])) {
    $state['search'] = false;
} elseif (isset($_REQUEST['searchField']) && (is_numeric($_REQUEST['searchField']) || $_REQUEST['searchField'] == 'email' || $_REQUEST['searchField'] == 'ip' || $_REQUEST['searchField'] == 'time_registered' || $_REQUEST['searchField'] == 'time_touched')) {
    $_REQUEST['searchString'] = trim($_REQUEST['searchString']);
    $state['search'] = empty($_REQUEST['searchString']) ? false : array('field' => $_REQUEST['searchField'], 'string' => trim($_REQUEST['searchString']));
}
/**********************************
	DISPLAY METHODS
*********************************/
// Get the *empty* group [no member IDs. 3rd arg is set TRUE]
$group = new Pommo_Groups($state['group'], $state['status'], $state['search']);
// Calculate and Remember number of pages for this group/status combo
$state['pages'] = is_numeric($group->_tally) && $group->_tally > 0 ? ceil($group->_tally / $state['limit']) : 0;
$view->assign('state', $state);
$view->assign('tally', $group->_tally);
$view->assign('groups', Pommo_Groups::get());
$view->assign('fields', Pommo_Fields::get());
$view->display('admin/subscribers/subscribers_manage');
Example #3
0
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) 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 Pommo.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *  This fork is from https://github.com/soonick/poMMo
 *  Please see docs/contribs for Contributors
 *
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require '../bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Mailing_Template.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
$view->assign('fields', Pommo_Fields::get(array('byName' => true)));
$view->display('admin/mailings/mailing/ajax.personalize');
Example #4
0
 * 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 
 * 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.
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require '../bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
Pommo::init();
$logger =& Pommo::$_logger;
$dbo =& Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$smarty = new Pommo_Template();
$smarty->assign('fields', Pommo_Fields::get());
$smarty->display('admin/subscribers/ajax/subscriber_edit.tpl');
Pommo::kill();
Example #5
0
 function prepareForSubscribeForm()
 {
     $dbo = Pommo::$_dbo;
     require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
     // Get array of fields. Key is ID, value is an array of the demo's info
     $fields = Pommo_Fields::get(array('active' => true, 'byName' => false));
     if (!empty($fields)) {
         $this->assign('fields', $fields);
     }
     foreach ($fields as $field) {
         if ($field['type'] == 'date') {
             $this->assign('datePicker', true);
         }
     }
     // process.php appends serialized values to _GET['input']
     // TODO --> look into this behavior... necessary?
     if (isset($_GET['input'])) {
         $this->assign(unserialize($_GET['input']));
     } elseif (isset($_GET['Email'])) {
         $this->assign(array('Email' => $_GET['Email']));
     }
     $this->assign($_POST);
 }
Example #6
0
 *********************************/
require 'bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Csv_Stream.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
Pommo::init(array('keep' => TRUE));
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
$emails = Pommo::get('emails');
$dupes = Pommo::get('dupes');
$fields = Pommo_Fields::get();
$flag = FALSE;
foreach ($fields as $field) {
    if ($field['required'] == 'on') {
        $flag = TRUE;
    }
}
if (isset($_GET['continue'])) {
    foreach ($emails as $email) {
        $subscriber = array('email' => $email, 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => array());
        if ($flag) {
            $subscriber['flag'] = 9;
        }
        if (!Pommo_Subscribers::add($subscriber)) {
            die('Error importing subscriber');
        }
Example #7
0
        }
        // check for dupe
        $lookupID = current(Pommo_Subscribers::getIDByEmail($subscriber['email'], array(1, 2)));
        if ($lookupID && $lookupID != $subscriber['id']) {
            $json->fail(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
        }
        if (!Pommo_Validate::subscriberData($subscriber['data'], $validateOptions) && !isset($_REQUEST['force'])) {
            $json->addErr(Pommo::_T('Fields failed validation') . " >>> ");
            $json->addErr($logger->getAll());
            $json->fail(Pommo::_T('Error updating subscriber.'));
        }
        if (!Pommo_Subscribers::update($subscriber, 'REPLACE_ALL')) {
            $json->fail(Pommo::_T('Error updating subscriber.'));
        }
        // subscriber updated successfully, build output
        $out = array('email' => $subscriber['email'], 'id' => $subscriber['id']);
        // return human readable date formatting
        require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
        $dateFields = Pommo_Fields::getByType('date');
        foreach ($subscriber['data'] as $k => $val) {
            $out['d' . $k] = in_array($k, $dateFields) ? Pommo_Helper::timeToStr($val) : htmlspecialchars($val);
        }
        $json->add('callbackFunction', 'editSubscriber');
        $json->add('callbackParams', $out);
        $json->addMsg(Pommo::_T('Subscriber Updated'));
        break;
    default:
        die('invalid request passed to ' . __FILE__);
        break;
}
$json->success();
Example #8
0
 function update(&$in, $mode = 'REPLACE_PASSED')
 {
     $dbo = Pommo::$_dbo;
     $query = "\n            UPDATE " . $dbo->table['subscribers'] . "\n            SET\n            [email='%S',]\n            [time_registered='%S',]\n            [ip=INET_ATON('%S'),]\n            [status=%I,]\n            [flag=%I,]\n            time_touched=CURRENT_TIMESTAMP\n            WHERE subscriber_id=%i";
     $query = $dbo->prepare($query, @array($in['email'], $in['registered'], $in['ip'], $in['status'], $in['flag'], $in['id']));
     if (!$dbo->query($query) || $dbo->affected() != 1) {
         return false;
     }
     if (!empty($in['data']) || $mode == 'REPLACE_ALL') {
         switch ($mode) {
             case "REPLACE_ACTIVE":
                 require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
                 $fields = Pommo_Fields::get(array('active' => TRUE));
                 $select = array_keys($fields);
                 break;
             case "REPLACE_ALL":
                 $select = NULL;
                 break;
             case "REPLACE_PASSED":
             default:
                 $select = array_keys($in['data']);
                 break;
         }
         $query = "\n                DELETE\n                FROM " . $dbo->table['subscriber_data'] . "\n                WHERE subscriber_id=%i\n                [AND field_id IN (%C)]";
         $query = $dbo->prepare($query, array($in['id'], $select));
         if (!$dbo->query($query)) {
             return false;
         }
     }
     $values = array();
     foreach ($in['data'] as $fieldId => $value) {
         if (!empty($value)) {
             $values[] = $dbo->prepare("(%i,%i,'%s')", array($fieldId, $in['id'], $value));
         }
     }
     if (!empty($values)) {
         $query = "\n            INSERT INTO " . $dbo->table['subscriber_data'] . "\n            (field_id, subscriber_id, value)\n            VALUES " . implode(',', $values);
         if (!$dbo->query($query)) {
             return false;
         }
     }
     return true;
 }
Example #9
0
    $field = Pommo_Fields::make(array('name' => $_POST['field_name'], 'type' => $_POST['field_type'], 'prompt' => 'Field Prompt', 'required' => 'off', 'active' => 'off'));
    $id = Pommo_Fields::add($field);
    if ($id) {
        $view->assign('added', $id);
    } else {
        $logger->addMsg(Pommo::_T('Error with addition.'));
    }
}
// check for a deletion request
if (!empty($_GET['delete'])) {
    $field = Pommo_Fields::get(array('id' => $_GET['field_id']));
    $field =& current($field);
    if (count($field) === 0) {
        $logger->addMsg(Pommo::_T('Error with deletion.'));
    } else {
        $affected = Pommo_Fields::subscribersAffected($field['id']);
        if (count($affected) > 0 && empty($_GET['dVal-force'])) {
            $view->assign('confirm', array('title' => Pommo::_T('Confirm Action'), 'nourl' => $_SERVER['PHP_SELF'] . '?field_id=' . $_GET['field_id'], 'yesurl' => $_SERVER['PHP_SELF'] . '?field_id=' . $_GET['field_id'] . '&delete=TRUE&dVal-force=TRUE', 'msg' => sprintf(Pommo::_T('Currently, %1$s subscribers have a non empty value for %2$s. All Subscriber data relating to this field will be lost.'), '<b>' . count($affected) . '</b>', '<b>' . $field['name'] . '</b>')));
            $view->display('admin/confirm');
            Pommo::kill();
        } else {
            Pommo_Fields::delete($field['id']) ? Pommo::redirect($_SERVER['PHP_SELF']) : $logger->addMsg(Pommo::_T('Error with deletion.'));
        }
    }
}
// Get array of fields. Key is ID, value is an array of the demo's info
$fields = Pommo_Fields::get(array('byName' => FALSE));
if (!empty($fields)) {
    $view->assign('fields', $fields);
}
$view->display('admin/setup/setup_fields');
Example #10
0
 case 'delOption':
     // validate field ID
     $field = current(Pommo_Fields::get(array('id' => $_REQUEST['field_id'])));
     if ($field['id'] != $_REQUEST['field_id']) {
         die('bad field ID');
     }
     $affected = Pommo_Fields::subscribersAffected($field['id'], $_REQUEST['options']);
     if (count($affected) > 0 && empty($_REQUEST['confirmed'])) {
         $msg = sprintf(Pommo::_T('Deleting option %1$s will affect %2$s subscribers who have selected this choice. They will be flagged as needing to update their records.'), '<b>' . $_REQUEST['options'] . '</b>', '<em>' . count($affected) . '</em>');
         $msg .= "\n " . Pommo::_T('Are you sure?');
         $json->add('callbackFunction', 'confirm');
         $json->add('callbackParams', $msg);
         $json->serve();
     } else {
         require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
         $options = Pommo_Fields::optionDel($field, $_REQUEST['options']);
         if (!options) {
             $json->fail(Pommo::_T('Error with deletion.'));
         }
         // flag subscribers for update
         if (count($affected) > 0) {
             Pommo_Subscribers::flagByID($affected);
         }
         $json->add('callbackFunction', 'updateOptions');
         $json->add('callbackParams', $options);
         $json->serve();
     }
     break;
 default:
     die('invalid request passed to ' . __FILE__);
     break;
Example #11
0
 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)));
     foreach ($values as $value) {
         // if this is a date type field, convert the values from human readable date
         //  strings to timestamps appropriate for matching
         if ($field['type'] == 'date') {
             $value = Pommo_Helper::timeFromStr($value);
         }
         $v[] = $dbo->prepare("(%i,%i,'%s','%s',%i)", array($group, $field['id'], $logic, $value, $type));
     }
     $query = "\n\t\t\tINSERT INTO " . $dbo->table['group_rules'] . "\n\t\t\t(group_id, field_id, logic, value, type)\n\t\t\tVALUES " . implode(',', $v);
     return $dbo->affected($query);
 }
 function notify(&$notices, &$sub, $type, $comments = false)
 {
     global $pommo;
     require_once Pommo::$_baseDir . 'classes/Pommo_Mailer.php';
     $mails = Pommo_Helper::trimArray(explode(',', $notices['email']));
     if (empty($mails[0])) {
         $mails = array(Pommo::$_config['admin_email']);
     }
     $subject = $notices['subject'] . ' ';
     $body = sprintf(Pommo::_T('poMMo %s Notice'), $type);
     $body .= "  [" . date("F j, Y, g:i a") . "]\n\n";
     $body .= "EMAIL: " . $sub['email'] . "\n";
     $body .= "IP: " . $sub['ip'] . "\n";
     $body .= "REGISTERED: " . $sub['registered'] . "\n\n";
     if ($comments) {
         $body .= "COMMENTS: {$comments} \n\n";
     }
     $body .= "DATA:\n";
     require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
     $fields = Pommo_Fields::getNames();
     foreach ($sub['data'] as $fid => $v) {
         $body .= "\t" . $fields[$fid] . ": {$v}\n";
     }
     switch ($type) {
         case 'subscribe':
             $subject .= Pommo::_T('new subscriber!');
             break;
         case 'unsubscribe':
             $subject .= Pommo::_T('user unsubscribed.');
             break;
         case 'pending':
             $subject .= Pommo::_T('new pending!');
             break;
         case 'update':
             $subject .= Pommo::_T('subscriber updated.');
             break;
     }
     $mail = new Pommo_Mailer();
     // allow mail to be sent, even if demo mode is on
     $mail->toggleDemoMode("off");
     // send the confirmation mail
     $mail->prepareMail($subject, $body);
     foreach ($mails as $to) {
         $mail->bmSendmail($to);
     }
     // reset demo mode to default
     $mail->toggleDemoMode();
     return;
 }
 public static function search(&$body)
 {
     $personalizations = array();
     $matches = array();
     $pattern = '/\\[\\[[^\\]]+\\]\\]/';
     if (preg_match_all($pattern, $body, $matches) < 1) {
         return $personalizations;
     }
     $fields = Pommo_Fields::get();
     foreach ($matches[0] as $str) {
         $p = array();
         $p['search'] = $str;
         $a = explode('|', trim($str, '[]'));
         $p['field'] = $a[0];
         $p['default'] = isset($a[1]) ? $a[1] : false;
         foreach ($fields as $f) {
             if ($f['name'] == $p['field']) {
                 $p['field_id'] = $f['id'];
             }
         }
         array_push($personalizations, $p);
     }
     return $personalizations;
 }
Example #14
0
 function subscriberData(&$in, $p = array())
 {
     $defaults = array('prune' => true, 'active' => true, 'log' => true, 'ignore' => false, 'ignoreInactive' => true, 'skipReq' => false);
     $p = Pommo_Api::getParams($defaults, $p);
     require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
     $logger = Pommo::$_logger;
     $fields = Pommo_Fields::get(array('active' => $p['active']));
     $valid = true;
     foreach ($fields as $id => $field) {
         $inactive = $field['active'] == 'on' ? false : true;
         if (!isset($in[$id]) && $p['skipReq']) {
             continue;
         }
         $in[$id] = @trim($in[$id]);
         if (empty($in[$id])) {
             unset($in[$id]);
             // don't include blank values
             if ($field['required'] == 'on') {
                 if ($p['log']) {
                     $logger->addErr(sprintf(Pommo::_T('%s is a required field.'), $field['prompt']));
                 }
                 $valid = false;
             }
             continue;
         }
         // shorten
         $in[$id] = substr($in[$id], 0, 255);
         switch ($field['type']) {
             case "checkbox":
                 if (strtolower($in[$id]) == 'true') {
                     $in[$id] = 'on';
                 }
                 if (strtolower($in[$id]) == 'false') {
                     $in[$id] = '';
                 }
                 if ($in[$id] != 'on' && $in[$id] != '') {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "multiple":
                 if (is_array($in[$id])) {
                     foreach ($in[$id] as $key => $val) {
                         if (!in_array($val, $field['array'])) {
                             if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                                 unset($in[$id]);
                                 break;
                             }
                             if ($p['log']) {
                                 $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                             }
                             $valid = false;
                         }
                     }
                 } elseif (!in_array($in[$id], $field['array'])) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "date":
                 // convert date to timestamp [float; using adodb time library]
                 if (is_numeric($in[$id])) {
                     $in[$id] = Pommo_Helper::timeToStr($in[$id]);
                 }
                 $in[$id] = Pommo_Helper::timeFromStr($in[$id]);
                 if (!$in[$id]) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Field (%s) must be a date (' . Pommo_Helper::timeGetFormat() . ').'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "number":
                 if (!is_numeric($in[$id])) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Field (%s) must be a number.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
         }
     }
     // prune
     if ($p['prune']) {
         $in = Pommo_Helper::arrayIntersect($in, $fields);
     }
     return $valid;
 }
Example #15
0
 static function add(&$in)
 {
     $dbo =& Pommo::$_dbo;
     // set the ordering of field if not provided
     if (!is_numeric($in['ordering'])) {
         $query = "\n                SELECT field_ordering\n                FROM " . $dbo->table['fields'] . "\n                ORDER BY field_ordering DESC";
         $query = $dbo->prepare($query);
         $in['ordering'] = $dbo->query($query, 0) + 1;
     }
     if (!Pommo_Fields::validate($in)) {
         return false;
     }
     $query = "\n        INSERT INTO " . $dbo->table['fields'] . "\n        SET\n        field_active='%s',\n        field_ordering=%i,\n        field_name='%s',\n        field_prompt='%s',\n        field_normally='%s',\n        field_array='%s',\n        field_required='%s',\n        field_type='%s'";
     $query = $dbo->prepare($query, @array($in['active'], $in['ordering'], $in['name'], $in['prompt'], $in['normally'], serialize($in['array']), $in['required'], $in['type']));
     return $dbo->lastId($query);
 }
Example #16
0
?>
">
<fieldset>
<legend>Subscribe</legend>

<!--	Email field must be named "Email" -->
<div>
<label for="email"><strong><?php 
echo Pommo::_T('Your Email:');
?>
</strong></label>
<input type="text" name="Email" id="email" maxlength="60" />
</div>

<?php 
$fields =& Pommo_Fields::get(array('active' => TRUE, 'byName' => FALSE));
foreach (array_keys($fields) as $field_id) {
    $field =& $fields[$field_id];
    if ($field['required'] == 'on') {
        echo "<!--\tBEGIN INPUT FOR REQUIRED FIELD \"" . $field['name'] . "\" -->\r\n<div>\r\n<label for=\"field" . $field_id . "\"><strong>" . $field['prompt'] . ":</strong></label>\r\n";
    } else {
        echo "<!--\tBEGIN INPUT FOR FIELD \"" . $field['name'] . "\" -->\r\n<div>\r\n<label for=\"field" . $field_id . "\">" . $field['prompt'] . ":</label>\r\n";
    }
    switch ($field['type']) {
        case "checkbox":
            // checkbox
            if (empty($field['normally'])) {
                echo "\r\n<input type=\"checkbox\" name=\"d[" . $field_id . "]\" id=\"field" . $field_id . "\" />";
            } else {
                echo "\r\n<input type=\"checkbox\" name=\"d[" . $field_id . "]\" id=\"field" . $field_id . "\" checked=\"checked\" />";
            }
Example #17
0
// Remember the Page State
$state =& Pommo_Api::stateInit('groups_edit');
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'displayRule':
        /**********************************
        			SETUP TEMPLATE, PAGE
        		 *********************************/
        require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
        $smarty = new Pommo_Template();
        $group = current(Pommo_Groups::get(array('id' => $state['group'])));
        if (empty($group)) {
            die('invalid input');
        }
        if ($_REQUEST['ruleType'] == 'field') {
            $field = current(Pommo_Fields::get(array('id' => $_REQUEST['fieldID'])));
            $logic = isset($_REQUEST['logic']) && $_REQUEST['logic'] != "0" ? $_REQUEST['logic'] : false;
            $type = $_REQUEST['type'] == 'or' ? 'or' : 'and';
            $values = array();
            // check to see if we're editing [logic is passed *only* when edit button is clicked]
            if ($logic) {
                foreach ($group['rules'] as $rule) {
                    if ($rule['logic'] == $logic && $rule['field_id'] == $_REQUEST['fieldID']) {
                        $values[] = $field['type'] == 'date' ? Pommo_Helper::timeFromStr($rule['value']) : $rule['value'];
                    }
                }
            }
            $firstVal = empty($values) ? false : array_shift($values);
            $logic = $logic ? Pommo_Rules::getEnglish(array($logic)) : Pommo_Rules::getEnglish(end(Pommo_Rules::getLegal($group, array($field))));
            $smarty->assign('type', $type);
            $smarty->assign('field', $field);