static function createBy(User $user, array $info) { $fields = array('name', 'surname', 'address', 'phone', 'notes'); $fields = userFields($fields, 'order'); $order = with(new static())->fill_raw(array_intersect_key($info, array_flip($fields)))->fill_raw(array('password' => static::generatePassword(), 'user' => $user->id, 'manager' => \Vane\Current::config('general.new_order_manager'), 'sum' => Cart::subtotal(), 'ip' => Request::ip())); return Event::insertModel($order, 'order'); }
$matched = array_first($perms, function ($i, $perm) use($feature) { return fnmatch($perm, $feature, FNM_NOESCAPE | FNM_PATHNAME | FNM_CASEFOLD); }); return (bool) ($allBut ^ !!$matched); } } function emailRecipient() { $self = $this; return (string) Event::result('user.recipient', $this, function ($result) use($self) { if (strpos($result, $self->email) === false) { return 'a string without the actual e-mail address'; } }); } function resetHash($days = null, $hash = null) { $args = func_num_args(); if ($args === 0) { $date = date('d'); return md5($this->id . '-' . \Config::get('application.key') . '-' . $date); } else { $date = date('d', strtotime('+' . $days . ' day')); $value = md5($this->id . '-' . \Config::get('application.key') . '-' . $date); return $args === 1 ? $value : $value === $hash; } } } User::$table = \Config::get('vanemart::general.table_prefix') . User::$table; User::$fields = userFields(User::$fields, 'user');
function ajax_post_show($id = null) { $valid = Validator::make($this->in(), array('status' => 'in:' . join(',', Order::statuses()))); if ($valid->fails()) { return $valid; } elseif (!($order = Order::find($id))) { return; } elseif (!$this->editable($order)) { return false; } $fields = array('status', 'name', 'surname', 'phone', 'address', 'notes'); $fields = userFields($fields, 'order'); $order->fill_raw(S::trim(Input::only($fields))); if (!$order->dirty()) { return E_UNCHANGED; } $changes = $order->changeMessages(); $msg = __('vanemart::order.set.post', join($changes, "\n"))->get(); $post = with(new Post())->fill_raw(array('type' => 'order', 'object' => $order->id, 'author' => $this->user()->id, 'flags' => 'field-change ' . ($this->can('manager') ? 'manager' : ''), 'body' => $msg, 'html' => format('post', $msg), 'ip' => Request::ip())); \DB::transaction(function () use($order, $post) { if (!$post->save()) { throw new Error("Cannot save new system post for order {$order->id}."); } elseif (!$order->save()) { throw new Error("Cannot update fields of order {$order->id}."); } }); if ($order->user != $this->user()->id) { $to = $order->user()->first(); \Vane\Mail::sendTo($to->emailRecipient(), 'vanemart::mail.order.post', array('order' => $order->to_array(), 'user' => $this->user()->to_array(), 'recipient' => $to->to_array(), 'post' => $post->to_array(), 'files' => array())); } return $order; }