function view($id = null) { if (is_null($id)) { echo "error: no id supplied"; return false; } $this->load->library('bitly'); $this->form_validation->set_rules('name', 'Task Name', 'required|trim'); $data = array(); $docket = new Docket(); $task = new Task(); $user = new User(); if (!$docket->where('shared', 1)->where('id', $id)->count()) { redirect('dockets'); } else { $data['docket'] = $docket->get_by_id($id); } if ($docket->short_url == '') { $docket->short_url = $this->bitly->shorten(base_url() . 'index.php/pub/view/' . $docket->id); $docket->save(); } if ($task->where('completed', 0)->where_related_docket('id', $docket->id)->count() == 0) { $data['pending_tasks'] = array(); } else { $data['pending_tasks'] = $task->where('completed', 0)->where_related_docket('id', $docket->id)->get()->all; } if ($task->where('completed', 1)->where_related_docket('id', $docket->id)->count() == 0) { $data['completed_tasks'] = array(); } else { $data['completed_tasks'] = $task->where('completed', 1)->where_related_docket('id', $docket->id)->get()->all; } $data['user'] = $user->get_by_id($docket->user_id); $this->load->view('pub/view', $data); }
function toggle_docket_sharing() { $id = $this->input->post('id'); $docket = new Docket(); $docket->get_by_id($id); $docket->shared = !$docket->shared; $docket->save(); $result['status'] = $docket->shared ? 'Public' : 'Private'; echo json_encode($result); }
function atom($id) { if ($id == '') { echo 'No Feed exists at this address'; return; } $docket = new Docket(); $task = new Task(); $user = new User(); $data['docket'] = $docket->get_by_id($id); if ($docket->shared == 0) { echo 'No Feed exists at this address'; return; } $data['tasks'] = $task->where('docket_id', $docket->id)->get()->all; $data['author_name'] = $user->get_by_id($docket->user_id); $this->load->view('feed/atom', $data); }
function email_docket($docket_id, $to, $from_email, $from_name) { $this->ci->load->library('email'); $this->email->from($from_email, $from_name); $this->email->to($to); $this->email->subject($from_name . 'wants to share this Docket with you'); $message = "Hi There\n\n%s wants to share the following Docket with you\n\n%s\n\nRegards,\nDockets Team"; $docket = new Docket(); $tasks = new Task(); $docket->get_by_id($id); $tasks->where('docket_id', $id)->get(); foreach ($tasks->all as $task) { $status = $task->pending ? "Pending" : "Completed"; $task_list .= '> ' . $task->name . " (" . $task->due . ") [" . $status . "]" . "\n\r"; } $message = sprintf($message, $this->dx_auth->get_username(), $task_list); $this->email->message($message); return $this->email->send(); }
function email_docket($id) { $data['id'] = $id; $data['message'] = null; $this->form_validation->set_rules('email', 'Email Address', 'required|trim|valid_email'); if ($this->form_validation->run() == false) { } else { $data['message'] = '<p class="success">This Docket has been successfully emailed to ' . $this->input->post('email') . '</p>'; $this->load->library('profile'); $from_name = $this->profile->get_name($this->dx_auth->get_user_id()); $this->email->from($this->dx_auth->get_user_email(), $from_name); $this->email->to($this->input->post('email')); $this->email->subject($from_name . ' wants to share this Docket with you'); $message = "Hi There\n\n%s wants to share the following Docket with you\n\n%s\n\nRegards,\nDockets Team"; $docket = new Docket(); $tasks = new Task(); $docket->get_by_id($id); $tasks->where('docket_id', $id)->get(); foreach ($tasks->all as $task) { $status = $task->pending ? "Pending" : "Completed"; $task_list .= '> ' . $task->name . " (" . $task->due . ") [" . $status . "]" . "\n\r"; } $message = sprintf($message, $from_name, $task_list); $this->email->message($message); $this->email->send(); } $this->load->view('ajax/email_docket', $data); }
function edit($id) { print_r($_POST); if (is_null($id) || !isset($id)) { redirect('dockets'); } $docket = new Docket(); if ($docket->where('id', $id)->where('user_id', $this->dx_auth->get_user_id())->count() == 0) { redirect('dockets'); } $docket->get_by_id($id); $task = new Task(); $this->form_validation->set_rules('name', 'Name', 'required|trim'); $this->form_validation->set_rules('tasks[]', 'tasks[]', 'required|trim'); $data['docket'] = $docket; $data['tasks'] = $task->where('docket_id', $docket->id)->get()->all; if ($this->form_validation->run() == false) { $this->load->view('dockets/edit', $data); } else { $this->load->view('dockets/edit', $data); } }