/** * Handle User Edit form submission * * @param <type> $w */ function useredit_POST(Web &$w) { $w->pathMatch("id"); $errors = $w->validate(array(array("login", ".+", "Login is mandatory"))); if ($_REQUEST['password'] && $_REQUEST['password'] != $_REQUEST['password2']) { $error[] = "Passwords don't match"; } $user = $w->Auth->getObject("User", $w->ctx('id')); if (!$user) { $errors[] = "User does not exist"; } if (sizeof($errors) != 0) { $w->error(implode("<br/>\n", $errors), "/admin/useredit/" . $w->ctx("id")); } $user->login = $_REQUEST['login']; $user->fill($_REQUEST); if ($_REQUEST['password']) { $user->setPassword($_REQUEST['password']); } else { $user->password = null; } $user->is_admin = isset($_REQUEST['is_admin']) ? 1 : 0; $user->is_active = isset($_REQUEST['is_active']) ? 1 : 0; $user->update(); $contact = $user->getContact(); if ($contact) { $contact->fill($_REQUEST); $contact->private_to_user_id = null; $contact->update(); } $w->callHook("admin", "account_changed", $user); $w->msg("User " . $user->login . " updated.", "/admin/users"); }
function editlookup_POST(Web &$w) { $p = $w->pathMatch("id", "type"); $err = ""; if ($_REQUEST['type'] == "") { $err = "Please add select a TYPE<br>"; } if ($_REQUEST['code'] == "") { $err .= "Please enter a KEY<br>"; } if ($_REQUEST['title'] == "") { $err .= "Please enter a VALUE<br>"; } if ($err != "") { $w->error($err, "/admin/lookup/?type=" . $p['type']); } else { $lookup = $w->Admin->getLookupbyId($p['id']); if ($lookup) { $lookup->fill($_REQUEST); $lookup->update(); $msg = "Lookup Item edited"; } else { $msg = "Could not find item?"; } $w->msg($msg, "/admin/lookup/?type=" . $p['type']); } }
function printview_GET(Web &$w) { $p = $w->pathMatch("table", "id"); $attachments = $w->service("File")->getAttachments($p['table'], $p['$id']); $w->ctx("attachments", $attachments); $w->setLayout(null); }
function edit_POST(Web $w) { $p = $w->pathMatch("id"); $processor_id = $p["id"]; // Break the selected processor up into module and class $processor_class = $w->request("processor_class"); $processor_expl = explode(".", $processor_class); // Make sure we only have two values if (count($processor_expl) !== 2) { $w->error("Missing Processor values", "/channels/listprocessors"); exit; } // make sure the selected class exists in config if (!in_array($processor_expl[1], $w->moduleConf($processor_expl[0], "processors"))) { $w->error("Could not find processor in config", "/channels/listprocessors"); exit; } $processor_object = $processor_id ? $w->Channel->getProcessor($processor_id) : new ChannelProcessor($w); $processor_object->fill($_POST); $processor_object->channel_id = $w->request("channel_id"); $processor_object->module = $processor_expl[0]; $processor_object->class = $processor_expl[1]; $processor_object->insertOrUpdate(); $w->msg("Processor " . ($processor_id ? "updated" : "created"), "/channels/listprocessors"); }
function atfile_GET(Web &$w) { $p = $w->pathMatch("id"); $id = str_replace(".jpg", "", $p['id']); $attachment = $w->service("File")->getAttachment($id); $w->sendFile(FILE_ROOT . $attachment->fullpath); }
function deletereport_ALL(Web &$w) { $p = $w->pathMatch("id"); // if there is report ID in the URL ... if ($p['id']) { // get report details $rep = $w->Report->getReportInfo($p['id']); // if report exists, delete if ($rep) { $rep->is_deleted = 1; $rep->update(); // need to check if there is a feed associated with this report $feed = $w->Report->getFeedInfobyReportId($rep->id); // if feed exists, set is_deleted flag. ie. delete feed as well as report if ($feed) { $feed->is_deleted = 1; $feed->update(); } // return $w->msg("Report deleted", "/report/index/"); } else { $w->msg("Report no longer exists?", "/report/index/"); } } }
function delete_ALL(Web $w) { $p = $w->pathMatch("id"); if (empty($p['id'])) { $w->error("Group not found", "/admin-groups"); } $group = $w->Auth->getUser($p['id']); if (empty($group->id)) { $w->error("Group not found", "/admin-groups"); } $group->delete(); $roles = $group->getRoles(); if (!empty($roles)) { foreach ($roles as $role) { $group->removeRole($role); } } $members = $w->Auth->getGroupMembers($option['group_id']); if ($members) { foreach ($members as $member) { $member->delete(); } } $w->msg("Group deleted", "/admin-groups"); }
function get_GET(Web &$w) { $w->setLayout(null); $p = $w->pathMatch("classname", "id"); $token = $w->request("token"); $w->out($w->Rest->getJson($p['classname'], $p['id'], $token)); }
function view_GET(Web &$w) { $p = $w->pathMatch("m", "a"); // first see if we need to split into sub modules $module = $p['m']; $action = $p['a']; // check if help is allowed for this topic if (!$w->Auth->allowed($p['m'] . '/' . $p['a'])) { $w->ctx("help_content", "Sorry, there is no help for this topic."); } $submodule = ""; // check for submodule if (strcontains($p['m'], array("-"))) { $ms = explode("-", $p['m']); $module = $ms[0]; $submodule = $ms[1]; } // find a module toc $tocf = getHelpFileContent($w, $module, null, $module . "_toc"); if ($tocf) { $w->ctx("module_toc", $module . '/' . $module . "_toc"); $w->ctx("module_title", HelpLib::extractTitle($tocf)); } // load help file $help_file = HelpLib::getHelpFilePath($w, $module, $submodule, $action); $content = "Sorry, this help topic is not yet written."; if (file_exists($help_file)) { $content = file_get_contents($help_file); } // set context $w->ctx("help_content", helpMarkup(pruneRestricted($w, $content), $module)); $w->ctx("module", $module); $w->ctx("submodule", $submodule); $w->ctx("action", $action); }
function taskAjaxSelectbyTaskGroup_ALL(Web $w) { $p = $w->pathMatch("taskgroup_id"); $taskgroup = $w->Task->getTaskGroup($p['taskgroup_id']); if (empty($taskgroup->id)) { return; } $tasktypes = $taskgroup != "" ? $w->Task->getTaskTypes($taskgroup->task_group_type) : array(); $priority = $taskgroup != "" ? $w->Task->getTaskPriority($taskgroup->task_group_type) : array(); $members = $taskgroup != "" ? $w->Task->getMembersBeAssigned($taskgroup->id) : array(); sort($members); $typetitle = $taskgroup != "" ? $taskgroup->getTypeTitle() : ""; $typedesc = $taskgroup != "" ? $taskgroup->getTypeDescription() : ""; // if user cannot assign tasks in this group, leave 'first_assignee' blank for owner/member to delegate $members = $taskgroup->getCanIAssign() ? $members : array(array("Default", "")); // create dropdowns loaded with respective data $ttype = Html::select("task_type", $tasktypes, null); $prior = Html::select("priority", $priority, null); $mem = Html::select("assignee_id", $members, null); // first_ $taskgroup_link = $taskgroup->isOwner($w->Auth->user()) ? "<a href=\"" . $w->localUrl("task-group/viewmembergroup/" . $taskgroup->id) . "\">" . $taskgroup->title . "</a>" : $taskgroup->title; $tasktext = "<table style='width: 100%;'>" . "<tr><td class=section colspan=2>Task Group Description</td></tr>" . "<tr><td><b>Task Group</td><td>" . $taskgroup_link . "</td></tr>" . "<tr><td><b>Task Type</b></td><td>" . $typetitle . "</td></tr>" . "<tr valign=top><td><b>Description</b></td><td>" . $typedesc . "</td></tr>" . "</table>"; // return as array of arrays $result = array($ttype, $prior, $mem, $tasktext, Html::select("status", $taskgroup->getTypeStatus(), null, null, null, null)); $w->setLayout(null); $w->out(json_encode($result)); }
/** * Display member and permission infomation * * @param <type> $w */ function moreInfo_GET(Web &$w) { $option = $w->pathMatch("group_id"); $w->Admin->navigation($w, $w->Auth->getUser($option['group_id'])->login); if ($w->Auth->user()->is_admin || $w->Auth->getRoleForLoginUser($option['group_id'], $w->Auth->user()->id) == "owner") { $w->ctx("addMember", Html::box("/admin/groupmember/" . $option['group_id'], "New Member", true)); } $w->ctx("editPermission", Html::b("/admin/permissionedit/" . $option['group_id'], "Edit Permissions")); //fill in member table; $table = array(array("Name", "Role", "Operations")); $groupMembers = $w->Auth->getGroupMembers($option['group_id']); if ($groupMembers) { foreach ($groupMembers as $groupMember) { $line = array(); $style = $groupMember->role == "owner" ? "<div style=\"color:red;\">" : "<div style=\"color:blue;\">"; $name = $groupMember->getUser()->is_group == 1 ? $groupMember->getUser()->login : $groupMember->getUser()->getContact()->getFullName(); $line[] = $style . $name . "</div>"; $line[] = $style . $groupMember->role . "</div>"; if ($w->Auth->user()->is_admin || $w->Auth->getRoleForLoginUser($option['group_id'], $w->Auth->user()->id) == "owner") { $line[] = Html::a("/admin/memberdelete/" . $option['group_id'] . "/" . $groupMember->id, "Delete", null, null, "Are you sure you want to delete this member?"); } else { $line[] = null; } $table[] = $line; } } $w->ctx("memberList", Html::table($table, null, "tablesorter", true)); }
function editworkentry_POST(Web $w) { list($workentry_id) = $w->pathMatch("id"); if (empty($workentry_id)) { $w->error("Missing an ID"); } $we = $w->Bend->getWorkEntryForId($workentry_id); if (empty($we)) { $w->error("No work entry found for this id: " . $workentry_id); } $we->fill($_POST); if (empty($we->user_id)) { $we->user_id = $w->Auth->user()->id; } // now get the category if (!empty($_POST['category_3'])) { $we->bend_work_category_id = $_POST['category_3']; } else { if (!empty($_POST['category_2'])) { $we->bend_work_category_id = $_POST['category_2']; } else { if (!empty($_POST['category_1'])) { $we->bend_work_category_id = $_POST['category_1']; } } } // TODO check work period, etc. $we->update(); $w->msg("Work hours recorded", "/bend-workhours/list"); }
function list_GET(Web $w) { History::add("List Workhours"); list($userid, $periodid) = $w->pathMatch("a", "b"); // get the user if (!empty($userid)) { $user = $w->Auth->getUser($userid); } else { $user = $w->Auth->user(); } // calculate total work hours for this period $workentries = $w->Bend->getWorkhoursForUser($user, $periodid); $total_worked = 0; $total_accredited = 0; if (!empty($workentries)) { foreach ($workentries as $we) { $total_worked += $we->hours; if ($we->user_id == $we->attributed_user_id) { $total_accredited += $we->hours; } } } $w->ctx("total_worked", $total_worked); $w->ctx("total_accredited", $total_accredited); $w->ctx("user", $user); $w->ctx("workentries", $workentries); $w->ctx("workPeriod", $w->Bend->getWorkPeriodForId($periodid)); $w->ctx("allWorkPeriods", $w->Bend->getAllWorkPeriods()); }
function groupedit_POST(Web $w) { $option = $w->pathMatch("group_id"); $user = $w->Auth->getUser($option['group_id']); $user->login = $_REQUEST['title']; $user->update(); $w->msg("Group info updated!", "/admin/groups"); }
/** * Send media files from within * a modules help/media folder * * @param unknown_type $w */ function media_GET(Web &$w) { $p = $w->pathMatch("m", "f"); $m = $p['m']; $f = $p['f']; $filename = str_replace("..", "", ROOT . "/" . $w->getModuleDir($m) . '/help/media/' . $f); $w->sendFile($filename); }
function editmember_POST(Web &$w) { $p = $w->pathMatch("id"); $member = $w->Report->getReportMember($_POST['report_id'], $p['id']); $member->fill($_REQUEST); $member->update(); $w->msg("Member updated", "/report/edit/" . $_POST['report_id'] . "#members"); }
function callchannel_ALL(Web $w) { $w->setLayout(null); $p = $w->pathMatch("id"); $id = $p["id"]; $channel = $w->Channel->getEmailChannel($id); $channel->doJob(); }
function edit_POST(Web $w) { $p = $w->pathMatch("id"); $report_template = !empty($p['id']) ? $w->Report->getReportTemplate($p['id']) : new ReportTemplate($w); $report_template->fill($_POST); $response = $report_template->insertOrUpdate(); $w->msg("Report template " . (!empty($p['id']) ? "updated" : "created"), "/report/edit/{$report_template->report_id}#templates"); }
function edit_POST(Web $w) { $p = $w->pathMatch("id"); $group = !empty($p['id']) ? $w->Auth->getUser($p['group_id']) : new User($w); $group->login = $w->request('title'); $group->is_group = 1; $group->insertOrUpdate(); $w->msg("Group " . (!empty($p['id']) ? "updated" : "created"), "/admin-groups/show/{$group->id}"); }
/** * Display User edit form in colorbox * * @param <type> $w */ function useradd_GET(Web &$w) { $p = $w->pathMatch("box"); if (!$p['box']) { $w->Admin->navigation($w, "Add User"); } else { $w->setLayout(null); } }
function deletefeed_ALL(Web &$w) { $p = $w->pathMatch("id"); $feed = $w->Report->getFeedInfobyId($p["id"]); $arr["is_deleted"] = 1; $feed->fill($arr); $feed->update(); $w->msg("Feed " . $feed->title . " has been deleted", "/report/listfeed/"); }
function addcategory_POST(Web $w) { list($parent_id) = $w->pathMatch("a"); $cat = new BendWorkCategory($w); $cat->fill($_POST); $cat->parent_id = $parent_id; $cat->insert(); $w->msg("Category created", "/bend-workhours/admin"); }
function memberdelete_GET(Web &$w) { $option = $w->pathMatch("group_id", "member_id"); $member = $w->Auth->getGroupMemberById($option['member_id']); if ($member) { $member->delete(); } $w->msg("Member is deleted!", "/admin/moreInfo/" . $option['group_id']); }
function rendertemplate_ALL(Web $w) { $p = $w->pathMatch("id"); $t = $w->Template->getTemplate($p['id']); $t = $t ? $t : new Template($w); $w->setLayout(null); $w->out($t->testTitle()); $w->out("<hr/>"); $w->out($t->testBody()); }
function edit_POST(Web $w) { $p = $w->pathMatch("id"); $report_connection = !empty($p["id"]) ? $w->Report->getConnection($p["id"]) : new ReportConnection($w); $report_connection->fill($_POST); if (empty($_POST["s_db_password"])) { $report_connection->s_db_password = NULL; } $report_connection->insertOrUpdate(); $w->msg("Connection " . (!empty($p["id"]) ? "updated" : "created"), "/report-connections"); }
function editperiod_POST(Web $w) { list($periodid) = $w->pathMatch("a"); $period = new BendWorkPeriod($w); if (!empty($periodid)) { $period = $w->Bend->getWorkPeriodForId($periodid); } $period->fill($_POST); $period->insertOrUpdate(); $w->msg("Work Period updated", "/bend-workhours/admin"); }
function editlot_POST(Web $w) { list($id) = $w->pathMatch("id"); $lot = new BendLot($w); if (!empty($id)) { $lot = $w->Bend->getLotForId($id); } $lot->fill($_POST); $lot->insertOrUpdate(); $w->msg("Lot updated", "/bend-lot"); }
function deletecategory_GET(Web $w) { list($id) = $w->pathMatch("id"); if (!empty($id)) { $cat = $w->Bend->getWorkCategoryForId($id); if (!empty($cat)) { $cat->delete(); } } $w->msg("Category deleted", "/bend-workhours/admin"); }
function listmessagestatuses_ALL(Web $w) { $p = $w->pathMatch("id"); $id = $p["id"]; $w->Channels->navigation($w, "Message Statuses"); if (!$id) { $w->error("Message ID not found", "/channels/listmessages"); } $messagestatuses = $w->Channel->getMessageStatuses($id); $w->ctx("statuses", $messagestatuses); }
function ajaxSaveComment_POST(Web $w) { $p = $w->pathMatch('parent_id'); $comment = new Comment($w); $comment->obj_table = "comment"; $comment->obj_id = $p['parent_id']; $comment->comment = strip_tags($w->request('comment')); $comment->insert(); $w->setLayout(null); echo $w->partial("displaycomment", array("object" => $comment, 'redirect' => $w->request('redirect')), "admin"); }