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 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 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 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)); }
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 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 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 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 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 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)); }
/** * 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 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 index_ALL(Web &$w) { // $w->out(print_r($w->Search->getIndexes(),true)); $w->ctx("indexes", $w->Search->getIndexes()); if ($w->request("isbox") !== NULL) { $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 callchannel_ALL(Web $w) { $w->setLayout(null); $p = $w->pathMatch("id"); $id = $p["id"]; $channel = $w->Channel->getEmailChannel($id); $channel->doJob(); }
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 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 results_GET(Web $w) { $response = array("success" => true, "data" => ""); $w->setLayout(null); $q = $w->request('q'); // query $idx = $w->request('idx'); // index $p = $w->request('p'); // page $ps = $w->request('ps'); // pageSize $tr = $w->request('tr'); // total results if ($q && strlen($q) >= 3) { $results = $w->Search->getResults($q, $idx, $p, $ps); if (empty($p) && empty($ps) && empty($tr)) { $buffer = ""; if (!empty($results[0])) { // Group results by class_name $filter_results = array(); foreach ($results[0] as $res) { $searchobject = $w->Search->getObject($res['class_name'], $res['object_id']); if (!empty($searchobject)) { $filter_results[$res['class_name']][] = $searchobject; } } foreach ($filter_results as $class => $objects) { // Transform class into readable text $t_class = preg_replace('/(?<=\\w)(?=[A-Z])/', " \$1", $class); $buffer .= "<div class='row search-class'><h4 style='padding-top: 10px; font-weight: lighter;'>{$t_class}</h4>"; if (!empty($objects)) { foreach ($objects as $object) { if ($object->canList($w->Auth->user())) { $buffer .= '<div class="panel search-result">'; if ($object->canView($w->Auth->user())) { $buffer .= "<a class=\"row search-title\" href=\"" . $w->localUrl($object->printSearchUrl()) . "\">{$object->printSearchTitle()}</a>" . "<div class=\"row search-listing\">{$object->printSearchListing()}</div>"; } else { $buffer .= "<div class=\"small-12 columns search-title\">{$object->printSearchTitle()}</div><div class=\"row search-listing\">(restricted)</div>"; } $buffer .= "</div>"; } } } $buffer .= "</div>"; } } $response["data"] = $buffer; } } else { $response["success"] = false; $response["data"] = "Please enter at least 3 characters for searching."; } echo json_encode($response); }
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"); }
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 editmember_GET(Web &$w) { $p = $w->pathMatch("repid", "userid"); // get member details for edit $member = $w->Report->getReportMember($p['repid'], $p['userid']); // build editable form for a member allowing change of membership type $f = Html::form(array(array("Member Details", "section"), array("", "hidden", "report_id", $p['repid']), array("Name", "static", "name", $w->Report->getUserById($member->user_id)), array("Role", "select", "role", $member->role, $w->Report->getReportPermissions())), $w->localUrl("/report/editmember/" . $p['userid']), "POST", " Update "); // display form $w->setLayout(null); $w->ctx("editmember", $f); }
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 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 attach_GET(Web &$w) { $w->setLayout(null); $p = $w->pathMatch("table", "id", "url"); $object = $w->Auth->getObject($p['table'], $p['id']); if (!$object) { $w->error("Nothing to attach to."); } $types = $w->File->getAttachmentTypesForObject($object); $w->ctx("types", $types); $w->ctx("table", $p['table']); $w->ctx("id", $p['id']); $w->ctx("url", $p['url']); }
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."); }
function deletemember_GET(Web &$w) { $p = $w->pathMatch("report_id", "user_id"); // get details of member to be deleted $member = $w->Report->getReportMember($p['report_id'], $p['user_id']); if ($member) { // build a static form displaying members details for confirmation of delete $f = Html::form(array(array("Confirm Delete Member", "section"), array("", "hidden", "is_deleted", "1"), array("Name", "static", "name", $w->Report->getUserById($member->user_id))), $w->localUrl("/report/deletemember/" . $member->report_id . "/" . $member->user_id), "POST", " Delete "); } else { $f = "No such member?"; } // display form $w->setLayout(null); $w->ctx("deletemember", $f); }
function ajax_getchildcategories_GET(Web $w) { $w->setLayout(null); list($id) = $w->pathMatch("a"); $cat = $w->Bend->getWorkCategoryForId($id); $out = []; if (!empty($cat)) { $children = $cat->getChildren(); if (!empty($children)) { foreach ($children as $ch) { $out[] = $ch->toArray(); } } } $w->out(json_encode($out)); }
function process_GET(Web $w) { $w->setLayout(null); $p = $w->pathMatch("id"); $id = $p["id"]; if ($id) { $processors = $w->Channel->getProcessors($id); if (!empty($processors)) { foreach ($processors as $processor) { $processor_class = $processor->retrieveProcessor(); $processor_class->process($processor); } } } else { $w->out("No channel found."); } }