function add(&$subscriber, $type = null) { global $pommo; $dbo =& Pommo::$_dbo; $logger =& Pommo::$_logger; switch ($type) { case 'add': case 'del': case 'change': case 'password': break; default: $logger->addErr('Unknown type passed to Pommo_Pending::add'); return false; } $p = array('subscriber_id' => $subscriber['id'], 'type' => $type, 'code' => Pommo_Helper::makeCode(), 'array' => $type == 'change' ? $subscriber : array()); $pending = Pommo_Pending::make($p); if (!Pommo_Pending::validate($pending)) { $logger->addErr('Pommo_Pending::add() failed validation'); return false; } if (!empty($pending['array'])) { $pending['array'] = serialize($pending['array']); } // check for pre-existing pending request if (Pommo_Pending::isPending($pending['subscriber_id'])) { return false; } $query = "\n\t\t\tINSERT INTO " . $dbo->table['subscriber_pending'] . "\n\t\t\tSET\n\t\t\t\t[pending_array='%S',]\n\t\t\t\tsubscriber_id=%i,\n\t\t\t\tpending_type='%s',\n\t\t\t\tpending_code='%s'"; $query = $dbo->prepare($query, array($pending['array'], $pending['subscriber_id'], $pending['type'], $pending['code'])); if (!$dbo->query($query)) { return false; } return $pending['code']; }