get() static public method

returns an array of fields. Array key(s) correlates to field key.
static public get ( $p = [] )
コード例 #1
0
ファイル: form_generate.php プロジェクト: systemfirez/poMMo
?>
">
<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\" />";
            }
コード例 #2
0
ファイル: subscribers_manage.php プロジェクト: soonick/poMMo
}
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');
コード例 #3
0
ファイル: Pommo_Validate.php プロジェクト: systemfirez/poMMo
 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;
 }
コード例 #4
0
ファイル: subscriber_edit.php プロジェクト: systemfirez/poMMo
 * 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();
コード例 #5
0
ファイル: field_edit.php プロジェクト: soonick/poMMo
 */
/**********************************
	INITIALIZATION METHODS
*********************************/
require '../bootstrap.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();
// validate field ID
$field = current(Pommo_Fields::get(array('id' => $_REQUEST['field_id'])));
if ($field['id'] != $_REQUEST['field_id']) {
    die('bad field ID');
}
if (empty($_POST)) {
    $vMsg = array();
    $vMsg['field_name'] = $vMsg['field_prompt'] = Pommo::_T('Cannot be empty.');
    $view->assign('vMsg', $vMsg);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    require_once Pommo::$_baseDir . 'classes/Pommo_Validate.php';
コード例 #6
0
ファイル: import_txt.php プロジェクト: soonick/poMMo
 *********************************/
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');
        }
コード例 #7
0
ファイル: ajax.personalize.php プロジェクト: soonick/poMMo
 *  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');
コード例 #8
0
ファイル: Pommo_Template.php プロジェクト: soonick/poMMo
 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);
 }
コード例 #9
0
ファイル: setup_fields.php プロジェクト: soonick/poMMo
    $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');
コード例 #10
0
ファイル: Pommo_Rules.php プロジェクト: systemfirez/poMMo
 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);
 }
コード例 #11
0
 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;
 }
コード例 #12
0
ファイル: Pommo_Subscribers.php プロジェクト: soonick/poMMo
 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;
 }