public function create_one($params = []) { Session::permit_admin(); $class = Filter::controller_model(get_called_class()); $item = $class::create(Record::allow($params, ['name', 'title'])); Render::json($class::read(['*'], $item['id'])); }
public function evaluate($params = []) { $params['scripting'] = Util::get_scripting()[intval(@$params['scriptingi'])]; $model = Record::allow($params, ['name', 'email', 'phone', 'company', 'url', 'scripting']); $where = [implode(' = ? AND ', array_keys($model)) . ' = ?'] + $model; $evaluator = Evaluator::read(['*'], TRUE, $where); $today = gmdate('Y-m-d'); $update = ['agreement_date' => $today, 'email_date' => $today, 'ip' => $_SERVER['REMOTE_ADDR'], 'opt_out' => 0]; if (isset($evaluator['id'])) { Evaluator::update($update, $evaluator['id']); $evaluator += $update; } else { $model['`key`'] = Evaluator::get_unique_key($model); $model += $update; $evaluator = Evaluator::create($model); $evaluator['key'] = $evaluator['`key`']; unset($evaluator['`key`']); } $body = Template::render_doc_by_name('evaluate-email', $evaluator); $args = ['toname' => $evaluator['name'], 'toemail' => $evaluator['email'], 'fromname' => 'WinWrap Support', 'fromemail' => '*****@*****.**', 'subject' => 'WinWrap Basic Evaluation', 'body' => $body]; if (GoogleMail::send($args) === true) { unset($evaluator['id']); Render::json($evaluator); } else { header('Status: 500'); } }
public static function update($model, $id, $update_lit = '') { Session::permit_admin(); $success = parent::update(Record::allow($model, ['title', 'name', 'type']), $id, $update_lit); if (isset($model['content'])) { $success = DocContent::create(['doc_id' => $id, 'content' => $model['content']]); } if (isset($model['routes'])) { DocRoute::destroy_all($id); if ($model['routes']) { $routes = []; foreach (explode(',', $model['routes']) as $route_def) { $parts = explode('=>', $route_def); $route = trim($parts[0]); if (strlen($route) == 0 || $route[0] != '/') { $route = '/' . $route; } $handler = count($parts) > 1 ? trim($parts[1]) : null; $routes[] = ['doc_id' => $id, 'route' => $route, 'handler' => $handler ? $handler : null]; } DocRoute::create_all($routes); } } return $success; }
public function order_custom($params = []) { $parts = Part::get_parts(); $order = Record::allow($params, array_keys($parts)); $key = Quote::get_unique_key([]); $model['`key`'] = $key; $fields = ['company', 'address', 'country', 'billing_name', 'billing_email', 'billing_phone', 'technical_name', 'technical_email', 'discount', 'discount_desc']; $model += Record::allow($params, $fields); $quote = Quote::create($model); $total = 0; foreach ($order as $name => $value) { if ($value) { $model = ['quote_id' => $quote['id'], 'part' => $name, 'override' => null, 'quantity' => $value]; QuoteItem::create($model); } } return Render::json(['key' => $key]); }
public static function create_one($model) { $model = Record::allow($model, ['email', 'password', 'auth']); $model['password'] = crypt($model['password'], SALT); return parent::create($model); }