예제 #1
0
 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 PommoPending::add');
             return false;
     }
     $p = array('subscriber_id' => $subscriber['id'], 'type' => $type, 'code' => PommoHelper::makeCode(), 'array' => $type == 'change' ? $subscriber : array());
     $pending = PommoPending::make($p);
     if (!PommoPending::validate($pending)) {
         $logger->addErr('PommoPending::add() failed validation');
         return false;
     }
     if (!empty($pending['array'])) {
         $pending['array'] = serialize($pending['array']);
     }
     // check for pre-existing pending request
     if (PommoPending::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'];
 }