public function delete($f3) { $id = $f3->get('PARAMS.3'); $u = $this->Model->Users->fetch($id); if ($id == $this->Auth->user('id')) { \StatusMessage::add('You cannot remove yourself', 'danger'); return $f3->reroute('/admin/user'); } //Remove all posts and comments $posts = $this->Model->Posts->fetchAll(array('user_id' => $id)); foreach ($posts as $post) { $post_categories = $this->Model->Post_Categories->fetchAll(array('post_id' => $post->id)); foreach ($post_categories as $cat) { $cat->erase(); } $post->erase(); } $comments = $this->Model->Comments->fetchAll(array('user_id' => $id)); foreach ($comments as $comment) { $comment->erase(); } $u->erase(); \StatusMessage::add('User has been removed', 'success'); return $f3->reroute('/admin/user'); }
public function delete($f3) { $pagename = $f3->get('PARAMS.3'); $this->Model->Pages->delete($pagename); \StatusMessage::add('Page deleted succesfully', 'success'); return $f3->reroute('/admin/page'); }
/** * saves the DBField value, called with an ajax request * @return bool */ public function fesave() { $response = StatusMessage::create("An unknown error has occured", StatusMessageTypes::DANGER); $response->model = new stdClass(); $item = FrontEndEditItem::createFromRequest(); if ($item->exists()) { $record = $item->getRecord(); if ($item->canEdit()) { if ($item->saveValue()) { $response->setContent($item->field . " saved ")->setType(StatusMessageTypes::SUCCESS); $response->model = $record->toMap(); } else { $response->setContent("Error occurred while trying to save " . $item->field)->setType(StatusMessageTypes::DANGER); } } else { $response->setContent("You do not have permision to edit this item " . $item->field)->setType(StatusMessageTypes::DANGER); } } else { $response->setContent("Unable to locate " . $item->class . " with id " . $item->id)->setType(StatusMessageTypes::DANGER); } /* @var $controller Controller */ $controller = Controller::curr(); if ($controller->getRequest()->isAjax()) { $controller->getResponse()->addHeader('Content-type', 'application/json'); $response = Convert::raw2json($response->jsonSerialize()); } else { $response = array("StatusMessage" => $response); } return $response; }
public function create() { if ($this->isPost()) { try { if ($this->verify()) { $message = new StatusMessage(); $message->body($this->inVars('body')); $message->save(); C(StatusMessage)->commit(); $this->success_redirect(); } } catch (Exception $e) { Log::error($e->getMessage()); } } $this->fail_redirect(); }
public function index($f3) { if ($this->request->is('post')) { extract($this->request->data); $from = "From: {$from}"; mail($to, $subject, $message, $from); StatusMessage::add('Thank you for contacting us'); return $f3->reroute('/'); } }
public function beforeRoute($f3) { parent::beforeRoute($f3); //Check access of user $access = $this->Auth->user('level'); //No access if not logged in if (empty($access)) { \StatusMessage::add('Access Denied', 'danger'); return $f3->reroute('/'); } }
public function edit($f3) { $categoryid = $f3->get('PARAMS.3'); $category = $this->Model->Categories->fetchById($categoryid); if ($this->request->is('post')) { $category->title = $this->request->data['title']; $category->save(); \StatusMessage::add('Category updated succesfully', 'success'); return $f3->reroute('/admin/category'); } $f3->set('category', $category); }
public function edit($f3) { $id = $f3->get('PARAMS.3'); $comment = $this->Model->Comments->fetch($id); if ($this->request->is('post')) { $comment->copyfrom('POST'); $comment->save(); \StatusMessage::add('Comment updated succesfully', 'success'); return $f3->reroute('/admin/comment'); } $_POST = $comment; $f3->set('comment', $comment); }
public function edit($f3) { $categoryid = $f3->get('PARAMS.3'); // get the ID of the category and if that empty return back to same page! $category = $this->Model->Categories->fetchById($categoryid); if (empty($category)) { \StatusMessage::add('Invalid post', 'danger'); return $f3->reroute('/admin/category'); } if ($this->request->is('post')) { $category->title = $this->request->data['title']; $category->save(); \StatusMessage::add('Category updated succesfully', 'success'); return $f3->reroute('/admin/category'); } $f3->set('category', $category); }
public function index($f3) { $settings = $this->Model->Settings->fetchAll(); if ($this->request->is('post')) { foreach ($settings as $setting) { if (isset($this->request->data[$setting->setting])) { $setting->value = $this->request->data[$setting->setting]; $setting->save(); } else { $setting->value = 0; $setting->save(); } } \StatusMessage::add('Settings updated', 'success'); } $f3->set('settings', $settings); }
* our trademarks remain entirely with us. */ /** * messageBox Example * * @copyright CLOUDREXX CMS - CLOUDREXX AG * @author CLOUDREXX Development Team <*****@*****.**> * @package cloudrexx * @subpackage lib_framework */ /** * @ignore */ require_once "StatusMessage.class.php"; # Create new status message Object $msg = new StatusMessage(); # Set Box # $message string # $mode 'error','warning','confirmation' $msg->setBox($message = "Achtung: Schweinegefahr", $mode = "error"); # Generate box $htmlBox = $msg->generateBox(); ?> <html> <body bgcolor='white'> <h2>StatusMessage Example</h2> <? echo $htmlBox ?> </body> </html>
function analyze($daten, StatusMessage $status) { $res = array(); $final = new WeekFinally(); if ($ucv = $final->UpdateChartVorwoche()) { array_push($res, $ucv); } else { $status->addMessages("Fehler beim Vorwochen Update"); } if ($uvp = $final->UpdateChartPoints()) { array_push($res, $uvp); } else { $status->addMessages("Fehler beim Update der Chart Points"); } if ($dvp = $final->VotePointsDelete()) { array_push($res, $dvp); } else { $status->addMessages("Fehler beim Vote Points löschen"); } if ($nu = $final->NewUpdate()) { array_push($res, $nu); } else { $status->addMessages("Fehler beim New Interpreten Update"); } if ($wadd = $final->AddWeek()) { array_push($res, $wadd); } else { $status->addMessages("Fehler beim Woche 1+ "); } return $res; }
function analyze($daten, StatusMessage $status) { $res = array(); $final = new WeekFinally(); if ($UpdateChartVorwoche = $final->UpdateChartVorwoche()) { $res[0][0] = $UpdateChartVorwoche; $res[0][1] = 'UpdateChartVorwoche'; } else { $status->addMessages("Fehler beim Vorwochen Update"); } if ($UpdateChartPoints = $final->UpdateChartPoints()) { $res[1][0] = $UpdateChartPoints; $res[1][1] = 'UpdateChartPoints'; } else { $status->addMessages("Fehler beim Update der Chart Points"); } if ($VotePointsDelete = $final->VotePointsDelete()) { $res[2][0] = $VotePointsDelete; $res[2][1] = 'VotePointsDelete'; } else { $status->addMessages("Fehler beim Vote Points löschen"); } if ($newUpdate = $final->NewUpdate()) { $res[3][0] = $newUpdate; $res[3][1] = 'NewUpdate'; } else { $status->addMessages("Fehler beim New Interpreten Update"); } if ($addWeek = $final->AddWeek()) { $res[4][0] = $addWeek; $res[4][1] = 'AddWeek'; } else { $status->addMessages("Fehler beim Woche 1+ "); } return $res; }
public function run($path, $data = array(), $get = array()) { //Remove first / if (substr($path, 0, 1) == '/') { $path = substr($path, 1); } //Set default path if (empty($path)) { $path = 'blog/index'; } $bits = explode("/", $path); $prefix = ''; $controllerClass = $controller = array_shift($bits); if (strtolower($controller) == 'admin') { $prefix = 'admin'; $controller = array_shift($bits); $controllerClass = $prefix . '\\' . $controller; } if (!empty($bits)) { $action = array_shift($bits); } else { $action = 'index'; } $parameters = $bits; //Before Route $c = new $controllerClass(); $c->beforeRoute($this->f3); //Setup data $c->request->data = $data; if (!empty($data)) { $c->request->type = 'POST'; $_POST = $data; } $_GET = $get; //Setup route $old_params = $this->f3->get('PARAMS'); $new_params = explode("/", $path); //Remove prefix if (!empty($prefix)) { array_shift($new_params); } //Build new path $new_path = strtolower($path); if (substr($new_path, 0, 1) != '/') { $new_path = "/{$new_path}"; } array_unshift($new_params, $new_path); $new_params['controller'] = strtolower($controller); $new_params['action'] = strtolower($action); $this->f3->set('PARAMS', $new_params); //Run route function call_user_func(array($c, $action), $this); $messages = StatusMessage::peek(); $this->messages = $messages; //Handle reroute if (!empty($this->reroute)) { $reroute = $this->reroute; $this->reroute = false; return $this->run($reroute); } //After Route ob_start(); $c->afterRoute($this->f3); $output = ob_get_contents(); ob_end_clean(); //Restore F3 $this->f3->set('PARAMS', $old_params); $this->output = $output; return $output; }
protected function compile() { $this->Template->messages = StatusMessage::getAll($this->intModuleId, $this->blnSkipGeneral); }
public function profile($f3) { $id = $this->Auth->user('id'); extract($this->request->data); $u = $this->Model->Users->fetch($id); if ($this->request->is('post')) { $u->copyfrom('POST'); //Handle avatar upload if (isset($_FILES['avatar']) && isset($_FILES['avatar']['tmp_name']) && !empty($_FILES['avatar']['tmp_name'])) { $allowedTypes = array(IMAGETYPE_PNG, IMAGETYPE_JPEG); $detectedType = exif_imagetype($_FILES['avatar']['tmp_name']); if (!in_array($detectedType, $allowedTypes) || $_FILES['avatar']['size'] > 2 * 1024 * 1024 || !getimagesize($_FILES['avatar']['tmp_name'])) { \StatusMessage::add('Invalid image', 'danger'); return $f3->reroute('/user/profile'); } $ext = end(explode(".", $_FILES['avatar']['name'])); $_FILES['avatar']['name'] = "avatar_of_user_" . $id . "." . $ext; $url = File::Upload($_FILES['avatar']); $u->avatar = $url; } else { if (isset($reset)) { $u->avatar = ''; } } $u->save(); \StatusMessage::add('Profile updated succesfully', 'success'); return $f3->reroute('/user/profile'); } $_POST = $u->cast(); $f3->set('u', $u); }
public function search($f3) { if ($this->request->is('post')) { extract($this->request->data); $f3->set('search', $search); //Get search results $search = str_replace("*", "%", $search); //Allow * as wildcard $ids = $this->db->connection->exec("SELECT id FROM `posts` WHERE `title` LIKE \"%{$search}%\" OR `content` LIKE '%{$search}%'"); $ids = Hash::extract($ids, '{n}.id'); if (empty($ids)) { StatusMessage::add('No search results found for ' . $search); return $f3->reroute('/blog/search'); } //Load associated data $posts = $this->Model->Posts->fetchAll(array('id' => $ids)); $blogs = $this->Model->map($posts, 'user_id', 'Users'); $blogs = $this->Model->map($posts, array('post_id', 'Post_Categories', 'category_id'), 'Categories', false, $blogs); $f3->set('blogs', $blogs); $this->action = 'results'; } }
public function edit($f3) { $postid = $f3->get('PARAMS.3'); $post = $this->Model->Posts->fetchById($postid); $blog = $this->Model->map($post, array('post_id', 'Post_Categories', 'category_id'), 'Categories', false); if ($this->request->is('post')) { extract($this->request->data); $post->copyfrom('POST'); $post->modified = mydate(); $post->user_id = $this->Auth->user('id'); //Determine whether to publish or draft if (!isset($Publish)) { $post->published = null; } else { $post->published = mydate($published); } //Save changes $post->save(); $link = $this->Model->Post_Categories; //Remove previous categories $old = $link->fetchAll(array('post_id' => $postid)); foreach ($old as $oldcategory) { $oldcategory->erase(); } //Now assign new categories if (!isset($categories)) { $categories = array(); } foreach ($categories as $category) { $link->reset(); $link->category_id = $category; $link->post_id = $postid; $link->save(); } \StatusMessage::add('Post updated succesfully', 'success'); return $f3->reroute('/admin/blog'); } $_POST = $post->cast(); foreach ($blog['Categories'] as $cat) { if (!$cat) { continue; } $_POST['categories'][] = $cat->id; } $categories = $this->Model->Categories->fetchList(); $f3->set('categories', $categories); $f3->set('post', $post); }
public function onBeforeInit() { StatusMessage::AddIncludes(); }
public function profile($f3) { $id = $this->Auth->user('id'); extract($this->request->data); $u = $this->Model->Users->fetch($id); if ($this->request->is('post')) { $u->copyfrom('POST'); //Handle avatar upload if (isset($_FILES['avatar']) && isset($_FILES['avatar']['tmp_name']) && !empty($_FILES['avatar']['tmp_name'])) { $url = File::Upload($_FILES['avatar']); $u->avatar = $url; } else { if (isset($reset)) { $u->avatar = ''; } } $u->save(); \StatusMessage::add('Profile updated succesfully', 'success'); return $f3->reroute('/user/profile'); } $_POST = $u->cast(); $f3->set('u', $u); }