public function action_index($id) { $page = Model_Page::getBySlug($id, false); if (!$page || !$page->isPublished() && !Helper_Account::is_admin(Auth::instance()->get_user())) { $this->template->content = View::factory("errors/index"); return; } $this->template->content = View::factory("page/index")->set("page", $page); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function action_index($id) { $gallery = Model_Gallery::getBySlug($id, false); if (!$gallery || !$gallery->isPublished() && !Helper_Account::is_admin(Auth::instance()->get_user())) { $this->template->content = View::factory("errors/index"); return; } $this->template->content = View::factory("gallery/index")->set("gallery", $gallery); $this->template->content->reel = Reel::factory($gallery->photos); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function action_remove($wid) { if (Helper_Account::is_admin(Auth::instance()->get_user())) { $wid = filter_var($wid, FILTER_SANITIZE_NUMBER_INT); $watcher = ORM::factory("WatchPhotographer", $wid); if ($watcher->loaded()) { $watcher->delete(); } } $this->request->redirect("admin/watcher"); }
public function action_remove($wid) { if (Helper_Account::is_admin(Auth::instance()->get_user())) { $wid = filter_var($wid, FILTER_SANITIZE_NUMBER_INT); $potd = ORM::factory("DailyPhoto", $wid); if ($potd->loaded()) { $potd->delete(); } } $this->request->redirect("admin/potd"); }
public function action_rotate($degrees, $photo_id) { if (Helper_Account::is_admin($this->user)) { $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find(); } else { $photo = ORM::factory('photo')->where('user_id', '=', $this->user->id)->where('id', '=', $photo_id)->find(); } if (!$photo->loaded()) { Message::set(Message::NOTICE, 'This photo does not exist, try uploading one!'); Request::instance()->redirect('photos/upload'); } $image = Image::factory(Kohana::config('myshot.basePath') . $photo->original); $image->rotate($degrees)->save(); $photo->width = $image->width; $photo->height = $image->height; $photo_controller = new Controller_Photos(Request::instance()); $large_image = $photo_controller->create_large(Kohana::config('myshot.basePath') . $photo->original, $photo); sleep(1); $photo_controller->create_medium($large_image, $photo); Request::instance()->redirect('canvas/photos/' . $photo_id); }
public function action_delete() { $this->auto_render = false; $send_email = $_POST['sendEmail']; $photo_id = $_POST['photoID']; $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find(); $user = ORM::factory('user')->where('id', '=', $photo->user_id)->find(); if (Helper_Account::is_admin()) { $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find(); } else { $photo = ORM::factory('photo')->where('id', '=', $photo_id)->where('user_id', '=', $this->user->id)->find(); } if ($photo->loaded()) { if (Helper_Account::is_admin()) { if ($send_email != 'undefined' && $send_email == 'true') { $reason = $_POST['emailComment']; $additional_text = $_POST['otherText']; if ($reason == 'other') { $additional_text = $_POST['otherText']; } else { $additional_text = $reason; } $email_text = Helper_SendEmail::generate_email($photo->user_id, 'photo', $additional_text); //creative variable naming ftw! $post_office = Library_Notification::factory(); $letter_body = $email_text; $letter = Library_Notification::new_message()->setSubject('NG Kids My Shot - Photo removed!')->setFrom(Kohana::config('email.from'))->setTo(array($user->email => 'Guardian of ' . $user->display_name))->setBody($letter_body, 'text/html'); $post_office->add_message($letter); $post_office->send_messages(); } } else { $email_text = View::factory("email/userremoved")->set("user", $user)->set("photo", $photo); $post_office = Library_Notification::factory(); $letter_body = $email_text->render(); $letter = Library_Notification::new_message()->setSubject('NG Kids My Shot - Photo removed by user')->setFrom(Kohana::config('email.from'))->setTo(Kohana::config('email.ng_staff'))->setBody($letter_body, 'text/html'); $post_office->add_message($letter); $post_office->send_messages(); } $photo_owner_id = $photo->user_id; //remove photo approval action here //------------------- $gameUser = Helper_Game::getUser($photo->user_id); $gameUser->removeItem($photo->id); $photo->delete(); echo $photo_owner_id; } }
echo Helper_Account::get_public_account_link($comment->user); echo $comment->isFlaggable() ? HTML::anchor("comments/moderate/{$comment->id}", "", array("class" => "flag")) : ""; ?> <br /> <span class="date"><?php echo date('F d, Y', strtotime($comment->created)); ?> </span></p> <p> <?php echo $comment->comment; ?> </p> </div> <?php if (Helper_Account::is_admin()) { ?> <div class="remove_comment"> <input id="sf_<?php echo $comment->id; ?> " type="checkbox" class="showform" /><label for="sf_<?php echo $comment->id; ?> ">Delete Comment</label> <form class="remove_comment_form"> <?php echo form::checkbox('send_email' . $comment->id, 'send_email' . $comment->id, FALSE, array("id" => "send_email" . $comment->id, "class" => "send_email")); ?>
<h3>Birthdate:</h3> <?php echo form::input('birthdate', Arr::get($_POST, 'birthdate', $user->birthdate), array('class' => 'field', 'id' => 'datepicker')); ?> <br /><br /> <h3>Gender:</h3> <?php echo form::select('gender', array('male' => 'Male', 'female' => 'Female'), $user->gender); ?> <br /><br /> <h3>Set User as Admin:</h3> <?php echo form::checkbox('admin_user', '1', Arr::get($_POST, 'admin_user', Helper_Account::is_admin($user)), array("id" => "confirm")); ?> Yes <h3>Set User as NG Staff:</h3> <?php echo form::checkbox('ngstaff_user', '1', Arr::get($_POST, 'ngstaff_user', Helper_Account::is_ngstaff($user)), array("id" => "ngstaff_confirm")); ?> Yes <?php if (!Helper_Account::is_approved($user)) { echo new Element("div", HTML::anchor("admin/users/approve/" . $user->id, "Force Parent Approval"), array("style" => "margin-top:15px;")); } ?> </div> <!-- END: title -->
<table cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable"> <thead> <tr> <th><h3>Display Name</h3></th> <th><h3>Email</h3></th> <th><h3>Username</h3></th> <th><h3>Admin</h3></th> <th class="nosort" id="edit"><h3>Edit</h3></th> <th class="nosort" id="delete"><h3>Delete</h3></th> <th class="nosort" id="flag"><h3>Flag</h3></th> </tr> </thead> <tbody> <?php foreach ($users as $user) { $admin = Helper_Account::is_admin($user); ?> <tr> <td><?php echo Helper_Account::get_public_account_link($user); ?> </td> <td><?php echo $user->email; ?> </td> <td><?php echo $user->username; ?> </td> <td id="edit">
/** * Edit a user * * @return void * @author Will Robertson */ public function action_edit($user_id = null) { $user = ORM::factory('user')->where('id', '=', $user_id)->find(); /* Load the view. */ $this->template->styles = array('public/js/vendor/datepicker/jquery-ui-1.8.5.custom.css' => 'screen'); $this->template->scripts = array('public/js/vendor/jquery-ui-1.8.5.custom.min.js', 'public/js/vendor/word-count.js', 'public/js/account/vanity_preview.js'); $content = $this->template->content = View::factory('admin/users/edit'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); if ($user->loaded()) { $this->template->content->set(array('user' => $user)); } else { Message::set(Message::NOTICE, "This user does not exist."); Request::instance()->redirect('admin/users'); } if ($_POST) { /* Do they want to make this user an admin? */ $set_admin_user = Arr::get($_POST, 'admin_user'); /* Do they want to make this user a NG Staff member? */ $set_ngstaff_user = Arr::get($_POST, 'ngstaff_user'); /* Load the validation rules, filters etc.*/ $post = $user->validate_update($_POST); /* If the post data validates using the rules setup in the user model. */ if ($post->check()) { $admin_role = new Model_Role(array('name' => 'admin')); $ngstaff_role = new Model_Role(array('name' => 'ngstaff')); if ($set_admin_user) { if (!Helper_Account::is_admin($user)) { $user->add('roles', $admin_role); } } else { $user->remove('roles', $admin_role); } if ($set_ngstaff_user) { if (!Helper_Account::is_ngstaff($user)) { $user->add('roles', $ngstaff_role); } } else { $user->remove('roles', $ngstaff_role); } /* Affects the sanitized vars to the user object. */ $user->email = $post['email']; $user->username = $post['username']; /* If the user wants to change the display name */ if ($user->display_name != $post['display_name']) { /* Set new display name if it isn't in use already */ if (Helper_Account::display_name_exists($post['display_name'])) { echo 'problem'; Message::set(MESSAGE::ERROR, array('Display name already in use!', 'The display name you entered (' . $post['display_name'] . ') is already in use, please choose another one. Reverting to your previous display name (' . $user->display_name . ').')); } else { $user->display_name = $post['display_name']; } } $user->birthdate = $post['birthdate']; $user->gender = $post['gender']; $user->vanity_url = $post['vanity_url']; /* Create the account. */ $user->save(); /* Redirect to users edit page. */ Request::instance()->redirect('admin/users'); } else { /* Get errors for display in view. */ Message::set(Message::ERROR, $post->errors("user")); } } }
<h1 class="straight_title green"><?php echo $page->name; ?> </h1> <script> $(".logo").css({ "position": "absolute", top: "20px", left: "470px" }); $(".logo img").css({ "width":141 }); </script> <section class="custom-content"> <?php echo $page->content; ?> </section> <?php if (Helper_Account::is_admin(Auth::instance()->get_user())) { echo new Element("hr"); echo HTML::anchor("admin/pages/edit/{$page->id}", "Edit this page"); echo " " . HTML::anchor("admin/pages", "All Pages"); }