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 comment_GET(Web $w) { $p = $w->pathMatch("comment_id", "tablename", "object_id"); $comment_id = intval($p["comment_id"]); $comment = $comment_id > 0 ? $w->Comment->getComment($comment_id) : new Comment($w); if ($comment === null) { $comment = new Comment($w); } $help = <<<EOF //italics// **bold** \t\t * bullet list * second item ** subitem # numbered list # second item ## sub item [[URL|linkname]] == Large Heading === Medium Heading ==== Small Heading Horizontal Line: --- EOF; $form = array(array("Comment", "section"), array("", "textarea", "comment", $comment->comment, 100, 15, false), array("Help", "section"), array("", "textarea", "-help", $help, 100, 5, false), array("", "hidden", "redirect_url", $w->request("redirect_url"))); // return the comment for display and edit $w->setLayout(null); $w->out(Html::form($form, $w->localUrl("/admin/comment/{$p["comment_id"]}/{$p["tablename"]}/{$p["object_id"]}"), "POST", "Save")); }
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)); }
function edit_GET(Web $w) { $p = $w->pathMatch("report_id", "id"); $report_template = !empty($p['id']) ? $w->Report->getReportTemplate($p['id']) : new ReportTemplate($w); $form = array("Add Report Template" => array(array(array("Template", "select", "template_id", $report_template->template_id, $w->Template->findTemplates("report"))), array(array("Type", "select", "type", $report_template->type, $report_template->getReportTypes())), array(array("Report ID", "hidden", "report_id", $p['report_id'])))); $w->out(Html::multiColForm($form, "/report-templates/edit/{$report_template->id}")); }
function printqueue_GET(Web $w) { $print_folder = FILE_ROOT . "print"; $path = realpath($print_folder); // Check if folder exists if ($path === false) { // Make print folder (If you specify a full path, use the recursion flag because it seems to crash without it in unix) // Other wise you would need to chdir to the parent folder, create and change back to wherever execution currently was at mkdir($print_folder, 0777, true); $path = realpath($print_folder); } $exclude = array("THUMBS.db"); $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); $table_data = array(); $table_header = array("Name", "Size", "Date Created", "Actions"); foreach ($objects as $name => $object) { $filename = $object->getFilename(); // Ignore files starting with '.' and in exclude array if ($filename[0] === '.' || in_array($filename, $exclude)) { continue; } $table_data[] = array(Html::a("/uploads/print/" . $filename, $filename), humanReadableBytes($object->getSize()), date("H:i d/m/Y", filectime($name)), Html::box("/admin/printfile?filename=" . urlencode($name), "Print", true) . " " . Html::b("/admin/deleteprintfile?filename=" . urlencode($name), "Delete", "Are you sure you want to remove this file? (This is irreversible)")); } $w->out(Html::table($table_data, null, "tablesorter", $table_header)); }
function taskAjaxGrouptoType_ALL(Web &$w) { $types = array(); // split query string into group and assignee list($group, $assignee) = preg_split('/_/', $w->request('id')); // organise criteria $who = $assignee != "" ? $assignee : null; $where = ""; if ($group != "") { $where .= "task_group_id = " . $group . " and "; } $where .= "is_closed = 0"; // get task types from available task list $tasks = $w->Task->getTasks($who, $where); if ($tasks) { foreach ($tasks as $task) { if (!array_key_exists($task->task_type, $types)) { $types[$task->task_type] = array($task->getTypeTitle(), $task->task_type); } } } if (!$types) { $types = array(array("No assigned Tasks", "")); } // load type dropdown and return $tasktypes = Html::select("tasktypes", $types, null); $w->setLayout(null); $w->out(json_encode($tasktypes)); }
function addcategory_GET(Web $w) { list($parent_id) = $w->pathMatch("a"); $parent = $w->Bend->getWorkCategoryForId($parent_id); $form = array("Category" => array(array(array("Title", "text", "title", "")), array(array("Description", "text", "description", "")))); $w->out(Html::multiColForm($form, "/bend-workhours/addcategory/{$parent_id}", "POST", "Save")); }
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 profile_GET(Web &$w) { $p = $w->pathMatch("box"); $user = $w->Auth->user(); $contact = $user->getContact(); if ($user) { $w->ctx("title", "Administration - Profile - " . $user->login); } else { $w->error("User does not exist."); } $lines = array(); $lines[] = array("Change Password", "section"); $lines[] = array("Password", "password", "password", ""); $lines[] = array("Repeat Password", "password", "password2", ""); $lines[] = array("Contact Details", "section"); $lines[] = array("First Name", "text", "firstname", $contact ? $contact->firstname : ""); $lines[] = array("Last Name", "text", "lastname", $contact ? $contact->lastname : ""); $lines[] = array("Communication", "section"); $lines[] = array("Home Phone", "text", "homephone", $contact ? $contact->homephone : ""); $lines[] = array("Work Phone", "text", "workphone", $contact ? $contact->workphone : ""); $lines[] = array("Private Mobile", "text", "priv_mobile", $contact ? $contact->priv_mobile : ""); $lines[] = array("Work Mobile", "text", "mobile", $contact ? $contact->mobile : ""); $lines[] = array("Fax", "text", "fax", $contact ? $contact->fax : ""); $lines[] = array("Email", "text", "email", $contact ? $contact->email : ""); $lines[] = array("Redirect URL", "text", "redirect_url", $user->redirect_url); $f = Html::form($lines, $w->localUrl("/auth/profile"), "POST", "Update"); if ($p['box']) { $w->setLayout(null); $f = "<h2>Edit Profile</h2>" . $f; } $w->out($f); }
function reportAjaxCategorytoType_ALL(Web $w) { $type = array(); list($category, $module) = preg_split('/_/', $w->request('id')); // organise criteria $who = $w->session('user_id'); $where = array(); if (!empty($module)) { $where['report.module'] = $module; } if (!empty($category)) { $where['report.category'] = $category; } // get report categories from available report list $reports = $w->Report->getReportsbyUserWhere($who, $where); if ($reports) { foreach ($reports as $report) { $arrtype = preg_split("/,/", $report->sqltype); foreach ($arrtype as $rtype) { $rtype = trim($rtype); if (!array_key_exists(strtolower($rtype), $type)) { $type[strtolower($rtype)] = array(strtolower($rtype), strtolower($rtype)); } } } } if (empty($type)) { $type = array(array("No Reports", "")); } $w->setLayout(null); $w->out(json_encode(Html::select("type", $type))); }
function taskAjaxPrioritytoStatus_ALL(Web &$w) { $status = array(); // split query string into proirity, type, group and assignee list($priority, $type, $group, $assignee) = preg_split('/_/', $w->request('id')); // organise criteria $who = $assignee != "" ? $assignee : null; $where = ""; if ($group != "") { $where .= "task_group_id = " . $group . " and "; } if ($type != "") { $where .= "task_type = '" . $type . "' and "; } if ($priority != "") { $where .= "priority = '" . $priority . "' and "; } $where .= "is_closed = 0"; // get statuses from available tasks $tasks = $w->Task->getTasks($who, $where); if ($tasks) { foreach ($tasks as $task) { if (!array_key_exists($task->status, $status)) { $status[$task->status] = array($task->status, $task->status); } } } if (!$status) { $status = array(array("No assigned Tasks", "")); } // load status dropdown and return $status = Html::select("status", $status, null); $w->setLayout(null); $w->out(json_encode($status)); }
function reportAjaxModuletoCategory_ALL(Web $w) { $category = array(); $module = $w->request('id'); // organise criteria $who = $w->session('user_id'); $where = array(); if ($module != "") { $where['report.module'] = $module; } // get report categories from available report list $reports = $w->Report->getReportsbyUserWhere($who, $where); if ($reports) { foreach ($reports as $report) { if (!array_key_exists($report->category, $category)) { $category[$report->category] = array($report->getCategoryTitle(), $report->category); } } } if (!$category) { $category = array(array("No Reports", "")); } // load Category dropdown and return $category = Html::select("category", $category); $w->setLayout(null); $w->out(json_encode($category)); }
function taskAjaxTypetoPriority_ALL(Web &$w) { $priority = array(); // split the query string into type, group and assignee list($type, $group, $assignee) = preg_split('/_/', $w->request('id')); // organise criteria $who = $assignee != "" ? $assignee : null; $where = ""; if ($group != "") { $where .= "task_group_id = " . $group . " and "; } if ($type != "") { $where .= "task_type = '" . $type . "' and "; } $where .= "is_closed = 0"; // get priorities from available task list $tasks = $w->Task->getTasks($who, $where); if ($tasks) { foreach ($tasks as $task) { if (!array_key_exists($task->priority, $priority)) { $priority[$task->priority] = array($task->priority, $task->priority); } } } if (!$priority) { $priority = array(array("No assigned Tasks", "")); } // load priority dropdown and return $priority = Html::select("tpriority", $priority, null); $w->setLayout(null); $w->out(json_encode($priority)); }
/** * Display edit group dialog * * @param <type> $w */ function groupedit_GET(Web $w) { $option = $w->pathMatch("group_id"); $user = $w->Auth->getUser($option['group_id']); $template['Edit Group'] = array(array(array("Group Title: ", "text", "title", $user->login))); $w->out(Html::multiColForm($template, "/admin/groupedit/" . $option['group_id'], "POST", "Save")); $w->setLayout(null); }
function edit_GET(Web $w) { $p = $w->pathMatch("id"); $user = !empty($p['id']) ? $w->Auth->getUser($p['id']) : new User($w); $template[($user->id ? "Edit" : "Create") . ' Group'] = array(array(array("Group Title", "text", "title", $user->login))); $w->out(Html::multiColForm($template, "/admin-groups/edit/" . $user->id)); $w->setLayout(null); }
function taskAjaxSelectbyTable_ALL(Web $w) { $tbl = $_REQUEST['id']; // create dropdowns loaded with respective data $dbfields = $w->Report->getFieldsinTable($tbl); $w->setLayout(null); $w->out(json_encode($dbfields)); }
function token_GET(Web &$w) { $w->setLayout(null); $username = $w->request("username"); $password = $w->request("password"); $api = $w->request("api"); $w->out($w->Rest->getTokenJson($username, $password, $api)); }
function printfile_POST(Web $w) { $printer = $w->Printer->getPrinter($_POST["printer_id"]); if (empty($printer->id)) { $w->out("Printer does not exist"); } $w->Printer->printJob(urldecode($_POST["file"]), $printer); $w->msg("File has been sent to the printer", "/admin/printqueue"); }
/** * Display an edit form for either creating a new * record for ExampleData or edit an existing form. * * Url: * * /kickstart/edit/{id} * * @param Web $w */ function new_GET(Web $w) { // parse the url into parameters $p = $w->pathMatch("id"); // create the edit form $f = Html::form(array(array("New Module", "section"), array("Module Name", "text", "module_name", ""), array("Module Author", "text", "module_author", ""), array("Module Title", "text", "module_title", ""), array("Actions - one per line", "textarea", "actions", "index", null, null, "basic"), array("SQL Structure", "textarea", "sql", "", null, null, "basic")), $w->localUrl("/kickstart/new/" . $p['id']), "POST", " Save"); // circumvent the template and print straight into the layout $w->out($f); }
function editcategory_GET(Web $w) { list($id) = $w->pathMatch("a"); $cat = $w->Bend->getWorkCategoryForId($id); if (empty($cat)) { $w->error("no category found", "/bend-workhours/admin"); } $form = array("Category" => array(array(array("Title", "text", "title", $cat->title)), array(array("Description", "text", "description", $cat->description)))); $w->out(Html::multiColForm($form, "/bend-workhours/editcategory/{$id}", "POST", "Save")); }
function editlot_GET(Web $w) { list($id) = $w->pathMatch("id"); $lot = new BendLot($w); if (!empty($id)) { $lot = $w->Bend->getLotForId($id); } $form = array("Lot" => array(array(array("Lot Number", "text", "lot_number", $lot->lot_number)), array(array("Occupancy", "select", "occupancy", $lot->occupancy, array("single", "dual"))))); $w->out(Html::multiColForm($form, "/bend-lot/editlot/{$id}", "POST", "Save")); }
function editprinter_GET(Web $w) { $p = $w->pathMatch("id"); $printer = new Printer($w); if (!empty($p["id"])) { $printer = $w->Printer->getPrinter($p["id"]); } $form = array("Details" => array(array(array("Printer name", "text", "name", $printer->name)), array(array("Server", "text", "server", $printer->server)), array(array("Port", "text", "port", $printer->port)))); $w->out(Html::multiColForm($form, "/admin/editprinter/{$p['id']}")); }
function ajax_getcontact_GET(Web $w) { $w->setLayout(null); list($userid) = $w->pathMatch("userid"); if (!empty($userid)) { $user = $w->Auth->getUser($userid); if (!empty($user)) { $w->out(json_encode($user->getContact()->toArray())); } } }
function editperiod_GET(Web $w) { list($periodid) = $w->pathMatch("a"); $period = new BendWorkPeriod($w); if (!empty($periodid)) { $period = $w->Bend->getWorkPeriodForId($periodid); } $form["Work Period"] = array(array(array("Date From", "date", "d_start", !empty($period->d_start) ? formatDate($period->d_start) : ""), array("Date To", "date", "d_end", !empty($period->d_end) ? formatDate($period->d_end) : "")), array(array("Monthly Person Hours", "text", "monthly_person_hours", $period->monthly_person_hours), array("Is Closed?", "select", "is_closed", $period->is_closed, booleanNoYesForSelect()))); $w->setLayout(null); $w->out(Html::multiColForm($form, "/bend-workhours/editperiod/{$periodid}", "POST", "Save")); }
function feedAjaxGetReportText_ALL(Web $w) { // get the relevant report $rep = $w->Report->getReportInfo($_REQUEST["id"]); if ($rep) { $feedtext = "<table border=0 class=form>" . "<tr><td class=section colspan=2>Report</td></tr>" . "<tr><td><b>Title</td><td>" . $rep->title . "</td></tr>" . "<tr><td><b>Description</b></td><td>" . $rep->description . "</td></tr>" . "</table><p>"; } else { $feedtext = ""; } $w->setLayout(null); $w->out(json_encode($feedtext)); }
function list_GET(Web &$w) { $w->setLayout(null); $p = $w->pathMatch("classname", "where_key", "where_val"); $token = $w->request("token"); if ($p['where_key'] && $p['where_val']) { $where = array($p['where_key'] => $p['where_val']); } else { $where = null; } $w->out($w->Rest->listJson($p['classname'], $where, $token)); }
function edit_GET(Web $w) { $p = $w->pathMatch("id"); $report_connection = new ReportConnection($w); if (!empty($p["id"])) { $report_connection = $w->Report->getConnection($p["id"]); } if (!empty($report_connection->id)) { $report_connection->decrypt(); } $form = array("Connection" => array(array(array("Driver", "select", "db_driver", $report_connection->db_driver, PDO::getAvailableDrivers()), array("Host", "text", "db_host", $report_connection->db_host)), array(array("Port", "text", "db_port", $report_connection->db_port), array("Database", "text", "db_database", $report_connection->db_database)), array(array("Username", "text", "s_db_user", $report_connection->s_db_user), array("Password", "password", "s_db_password", $report_connection->s_db_password)))); $w->out(Html::multiColForm($form, "/report-connections/edit/{$report_connection->id}")); }
function configwidget_GET(Web $w) { $p = $w->pathMatch("origin", "id"); // "origin", "source", "widget"); // $widget = $w->Widget->getWidget($p["origin"], $p["source"], $p["widget"]); $widget = $w->Widget->getWidgetById($p["id"]); // $widgetname = $p["widget"]; if (empty($widget->id)) { $w->error("Widget not found", "/{$p['origin']}"); } $widgetname = $widget->widget_name; $widget_config = null; if (class_exists($widgetname)) { $widget_config = new $widgetname($w, $widget); } if (!empty($widget_config)) { $w->out(Html::multiColForm($widget_config->getSettingsForm(), "/main/configwidget/{$p['origin']}/{$p['id']}")); // {$p['origin']}/{$p['source']}/{$p['widget']}")); } else { $w->out("Could not find widget class ({$widgetname})"); } }
function editlookup_GET(Web &$w) { $p = $w->pathMatch("id", "type"); $lookup = $w->Admin->getLookupbyId($p['id']); if ($lookup) { $types = $w->Admin->getLookupTypes(); $f = Html::form(array(array("Edit an Existing Entry", "section"), array("Type", "select", "type", $lookup->type, $types), array("Key", "text", "code", $lookup->code), array("Value", "text", "title", $lookup->title)), $w->localUrl("/admin/editlookup/" . $lookup->id . "/" . $p['type']), "POST", " Update "); $w->setLayout(null); $w->out($f); } else { $w->msg("No such Lookup Item?", "/admin/lookup/"); } }
function read_GET(Web $w) { $w->setLayout(null); $p = $w->pathMatch("id"); $id = $p["id"]; if ($id) { $channel = $w->Channel->getChannel($id); if (!empty($channel)) { $channel->read(); exit; } } $w->out("No channel found."); }