public function run()
 {
     $contacts = \Model_Contact::find('all');
     foreach ($contacts as $contact) {
         $this->sendMailToAdmin($contact);
     }
 }
예제 #2
0
 public function action_index()
 {
     $where = [["deleted_at", 0]];
     $data["contacts"] = Model_Contact::find("all", ["where" => $where, "order_by" => [["id", "desc"]]]);
     $config = array('pagination_url' => "", 'uri_segment' => "p", 'num_links' => 9, 'per_page' => 20, 'total_items' => count($data["contacts"]));
     $data["pager"] = Pagination::forge('mypagination', $config);
     $data["contacts"] = array_slice($data["contacts"], $data["pager"]->offset, $data["pager"]->per_page);
     $view = View::forge("admin/contacts", $data);
     $this->template->content = $view;
 }
예제 #3
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('contact');
     if ($contact = Model_Contact::find($id)) {
         $contact->delete();
         Session::set_flash('success', 'Deleted contact #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete contact #' . $id);
     }
     Response::redirect('contact');
 }
예제 #4
0
 public function post_changecontactstatus()
 {
     $code = 0;
     $message = "ok";
     if ($this->auth_status) {
         $contact = Model_Contact::find(Input::post("id", 0));
         if ($contact != null) {
             $contact->status = Input::post("status", 0);
             $contact->save();
         } else {
             $code = 404;
             $message = "Content not found.";
         }
     } else {
         $code = 500;
         $message = "Auth error.";
     }
     $this->response(array('code' => $code, 'message' => $message));
 }