$cnt = subscribe_model_Subscriber::count(array(array('unsubscr_code', $code))); if ($cnt == 0) { return $code; } } return ''; } /** * Сборщик мусора */ protected function garbageCollect() { // Удаление старых неподтвержденных подписчиков $delDate = new DateTime(); // 1 неделя $delDate->sub(new DateInterval('P1W')); $items = subscribe_model_Subscriber::find(array(array('email_valid', 0), array('created', $delDate->format('Y-m-d H:i:s'), '<='))); if (!empty($items)) { foreach ($items as $itemRow) { $itemRow->delete(); } } } public static function fieldList() { $fields = array('id' => array('type' => 'int', 'description' => 'id', 'primary' => true), 'subscribe' => array('type' => 'link', 'nullable' => false, 'default' => 0, 'description' => cot::$L['subscribe_subscribe'], 'link' => array('model' => 'subscribe_model_Subscribe', 'relation' => SOM::TO_ONE, 'label' => 'title')), 'user' => array('type' => 'int', 'description' => cot::$L['User'], 'default' => 0), 'user_group' => array('type' => 'int', 'description' => cot::$L['Group'], 'default' => 0), 'email' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'nullable' => false, 'description' => cot::$L['Email']), 'name' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['Name']), 'last_executed' => array('type' => 'datetime', 'default' => null, 'description' => cot::$L['subscribe_last_executed']), 'last_error' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['subscribe_last_error']), 'active' => array('type' => 'tinyint', 'length' => '1', 'default' => 0, 'description' => cot::$L['Enabled']), 'params' => array('type' => 'text', 'default' => '', 'description' => 'Служебная информация'), 'ip' => array('type' => 'varchar', 'length' => '100', 'default' => cot::$usr['ip'], 'description' => cot::$L['Ip']), 'unsubscr_code' => array('type' => 'text', 'default' => '', 'description' => cot::$L['subscribe_unsubscr_code']), 'email_valid' => array('type' => 'tinyint', 'length' => '1', 'default' => 0), 'email_valid_date' => array('type' => 'datetime'), 'created' => array('type' => 'datetime', 'default' => date('Y-m-d H:i:s', cot::$sys['now']), 'description' => cot::$L['subscribe_created']), 'created_by' => array('type' => 'int', 'default' => cot::$usr['id'], 'description' => cot::$L['subscribe_created_by']), 'updated' => array('type' => 'datetime', 'default' => date('Y-m-d H:i:s', cot::$sys['now']), 'description' => cot::$L['subscribe_updated']), 'updated_by' => array('type' => 'int', 'default' => cot::$usr['id'], 'description' => cot::$L['subscribe_updated_by'])); return $fields; } } subscribe_model_Subscriber::__init();