public function add($feedback) { $from = null; $data = array(); if (ConnectionHelper::isLogin()) { $user = ConnectionHelper::userLogin(); $from = (int) $user['id']; } else { $ticket = array('subject' => htmlspecialchars($feedback['subject']), 'message' => nl2br(htmlspecialchars($feedback['message']))); connectionNotificationModel::run(connectionNotificationModel::EVENT_NEW_FEEDBACK_ANONIMUS, array('user' => array('name' => htmlspecialchars($feedback['name']), 'email' => htmlspecialchars($feedback['email'])), 'ticket' => $ticket), Language::getActiveLanguageISO()); return $ticket; } foreach ($this->field as $field) { if (!isset($feedback) || empty($feedback)) { return false; } else { $data[$field] = htmlspecialchars($feedback[$field]); } } $data['message'] = nl2br($data['message']); if (is_null($from)) { if (!isset($feedback['email']) || empty($feedback['email']) || !filter_var($feedback['email'], FILTER_VALIDATE_EMAIL)) { return false; } if (!isset($feedback['name']) || empty($feedback['name'])) { return false; } $data['contact'] = array('email' => htmlspecialchars($feedback['email']), 'name' => htmlspecialchars($feedback['name'])); } else { $data['contact'] = $from; } $data['status'] = self::FEEDBACK_STATUS_NEW; $data['date'] = strtotime('now'); $data['url'] = md5($data['date'] . $data['subject'] . uniqid()); $data['last_action'] = 'user'; if (isset($feedback['attachment']) && is_array($feedback['attachment'])) { $data['attachment'] = $feedback['attachment']; } $id = $this->insert($data); $data['id'] = $id; connectionNotificationModel::run(connectionNotificationModel::EVENT_NEW_FEEDBACK, array('user' => ConnectionHelper::userLogin(), 'ticket' => $data), Language::getActiveLanguageISO()); return $id; }
public function registration($array) { $data = array(); if (!Validator::mapFields($this->regFields, $array, $data) || $this->getFromEmail($data['email'])) { return false; } $data['country'] = (int) $data['country']; // $data['confirmation'] = true; $data['last_active'] = 0; $data['last_login'] = 0; $data['birth_date'] = (int) strtotime($data['birth_year'] . '-' . $data['birth_month'] . '-' . $data['birth_day']); $data['date'] = strtotime('now'); $data['password'] = md5($data['password']); $data['status'] = self::STATUS_DRAFT; $data['lang'] = Language::getActiveLanguageISO(); $data['confirmation_email_id'] = md5($data['email'] . $data['date']); $data['balance'] = (double) Settings::getValue('start_balance', 'connection'); unset($data['birth_day']); unset($data['birth_month']); unset($data['birth_year']); $user = $this->insert($data); $this->addHistory($user, self::HISTORY_REGISTRATION); $this->changeStatus($user, self::STATUS_DRAFT); $userInfo = $this->getInfo((int) $user); connectionNotificationModel::run(connectionNotificationModel::EVENT_REGISTRATION, array('user' => $userInfo), Language::getActiveLanguageISO()); connectionNotificationModel::run(connectionNotificationModel::EVENT_EMAIL_CONFIRMATION, array('user' => $userInfo, 'link' => 'http://' . Settings::getValue('domain', 'connection') . '/?confirm_email=' . $data['confirmation_email_id']), Language::getActiveLanguageISO()); return true; }