public function _onload() { #Get the user session, if no session is given - we skip all of the processing #The user could also check the token $s = Session::getInstance(); $u = $s->getUser(); $t = isset($_GET['token']) ? db()->table('token')->get('token', $_GET['token'])->fetch() : null; if (!$u && !$t) { return; } #Export the user to the controllers that may need it. $user = $u ? db()->table('user')->get('_id', $u)->fetch() : $t->user; $this->user = $user; $this->token = $t; try { #Check if the user is an administrator $admingroupid = SysSettingModel::getValue('admin.group'); $isAdmin = !!db()->table('user\\group')->get('group__id', $admingroupid)->addRestriction('user', $user)->fetch(); } catch (PrivateException $e) { $isAdmin = false; } $this->isAdmin = $isAdmin; $this->view->set('authUser', $this->user); $this->view->set('userIsAdmin', $isAdmin); }
public function deliver(\EmailModel $model) { $post = array(); $post['from'] = \SysSettingModel::getValue('smtp.from'); $post['to'] = $model->to; $post['subject'] = $model->subject; $post['text'] = html_entity_decode(strip_tags($model->body)); $post['html'] = $model->body; #Assemble the curl request $ch = curl_init(sprintf('https://api.mailgun.net/v3/%s/messages', $this->domain)); curl_setopt($ch, CURLOPT_USERPWD, 'api:' . $this->apiKey); #Tell curl we're posting and give it the data curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); #We also want to hear back curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $json = curl_exec($ch); $response = $json ? json_decode($json) : false; if (!$response) { throw new \spitfire\exceptions\PublicException('Invalid response from Mailgun'); } return $response !== false; }
<div class="spacer" style="height: 30px;"></div> <div class="row1"> <div class="span1"> <h1>Current logo</h1> </div> </div> <div class="row1 material"> <div class="span1"> <img src="<?php echo URL::asset(SysSettingModel::getValue('page.logo')); ?> "> </div> </div> <div class="row1"> <div class="span1"> <h1>Upload a new logo</h1> </div> </div> <div class="row1 material"> <div class="span1"> <p>Upload a new logo. Recommended dimensions are 722px x 450px</p> <form method="POST" enctype="multipart/form-data"> <input type="file" name="file" id="file"> <input type="submit" value="Upload">
<tr> <th>Group</th> <th>Owner</th> <th></th> </tr> </thead> <?php foreach ($records as $record) { ?> <tr> <td><?php echo __($record->name); ?> <?php echo $record->_id === SysSettingModel::getValue('admin.group') ? '<i>(Admin)</i>' : ''; ?> </td> <td><?php echo __($record->creator); ?> </td> <td><a href="<?php echo new URL('group', 'detail', $record->_id); ?> ">Show</a></td> </tr> <?php } ?> </table>