コード例 #1
0
ファイル: deletereport.php プロジェクト: itillawarra/cmfive
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/");
        }
    }
}
コード例 #2
0
ファイル: deletelookup.php プロジェクト: itillawarra/cmfive
function deletelookup_ALL(Web &$w)
{
    $p = $w->pathMatch("id", "type");
    $lookup = $w->Admin->getLookupbyId($p['id']);
    if ($lookup) {
        $arritem['is_deleted'] = 1;
        $lookup->fill($arritem);
        $lookup->update();
        $w->msg("Lookup Item deleted", "/admin/lookup/?type=" . $p['type']);
    } else {
        $w->msg("Lookup Item not found?", "/admin/lookup/?type=" . $p['type']);
    }
}
コード例 #3
0
ファイル: delete.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #4
0
ファイル: editlookup.php プロジェクト: itillawarra/cmfive
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']);
    }
}
コード例 #5
0
ファイル: edit.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #6
0
ファイル: composer.php プロジェクト: itillawarra/cmfive
function composer_ALL(Web $w)
{
    echo "<pre>" . file_get_contents(ROOT_PATH . '/log/composer.log') . "</pre>";
    // Collect dependencies
    $dependencies_array = array();
    foreach ($w->modules() as $module) {
        $dependencies = Config::get("{$module}.dependencies");
        if (!empty($dependencies)) {
            $dependencies_array = array_merge($dependencies, $dependencies_array);
        }
    }
    $json_obj = array();
    $json_obj["config"] = array();
    $json_obj["config"]["vendor-dir"] = 'composer/vendor';
    $json_obj["config"]["cache-dir"] = 'composer/cache';
    $json_obj["config"]["bin-dir"] = 'composer/bin';
    $json_obj["require"] = $dependencies_array;
    // Need to change dir so composer can find the json file
    chdir(SYSTEM_PATH);
    // Create the JSON file
    file_put_contents(SYSTEM_PATH . "/composer.json", json_encode($json_obj, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT));
    //Create the commands
    $input = new ArrayInput(array('command' => 'update', '--prefer-dist' => 'true'));
    $filestream = new StreamOutput(fopen(ROOT_PATH . '/log/composer.log', 'w'));
    //Create the application and run it with the commands
    $application = new Application();
    $exitcode = $application->run($input, $filestream);
    // Change dir back to root
    chdir(ROOT_PATH);
    // This doesn't happen for some reason
    $w->msg("Composer update return exit code " . $exitcode . " (0 is OK)<br/>Check the /log/composer.log for output", "/admin");
}
コード例 #7
0
ファイル: deletemember.php プロジェクト: itillawarra/cmfive
function deletemember_POST(Web &$w)
{
    $p = $w->pathMatch("report_id", "user_id");
    // get the details of the person to delete
    $member = $w->Report->getReportMember($p['report_id'], $p['user_id']);
    $_POST['id'] = $member->id;
    // if member exists, delete them
    if ($member) {
        $member->fill($_POST);
        $member->update();
        $w->msg("Member deleted", "/report/viewreport/" . $p['report_id'] . "?tab=2");
    } else {
        // if member somehow no longer exists, say as much
        $w->msg("Member no longer exists?", "/report/edit/" . $p['report_id'] . "?tab=2");
    }
}
コード例 #8
0
ファイル: attach.php プロジェクト: itillawarra/cmfive
function attach_POST(Web &$w)
{
    $table = $w->request('table');
    $id = $w->request('id');
    $title = $w->request('title');
    $description = $w->request('description');
    $type_code = $w->request('type_code');
    $url = str_replace(" ", "/", $w->request('url'));
    $object = $w->Auth->getObject($table, $id);
    if (!$object) {
        $w->error("Nothing to attach to.", $url);
    }
    $aid = $w->service("File")->uploadAttachment("file", $object, $title, $description, $type_code);
    if ($aid) {
        $w->ctx('attach_id', $aid);
        $w->ctx('attach_table', $table);
        $w->ctx('attach_table_id', $id);
        $w->ctx('attach_title', $title);
        $w->ctx('attach_description', $description);
        $w->ctx('attach_type_code', $type_code);
        $w->msg("File attached.", $url);
    } else {
        $w->error("There was an error. Attachment could not be saved.", $url);
    }
}
コード例 #9
0
ファイル: editworkentry.php プロジェクト: careck/bendms
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");
}
コード例 #10
0
ファイル: useredit.php プロジェクト: itillawarra/cmfive
/**
 * 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");
}
コード例 #11
0
ファイル: groupedit.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #12
0
ファイル: edit.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #13
0
ファイル: groupadd.php プロジェクト: itillawarra/cmfive
function groupadd_POST(Web $w)
{
    $user = new User($w);
    $user->login = $_REQUEST['title'];
    $user->is_group = 1;
    $user->insert();
    $w->msg("New group added!", "/admin/groups");
}
コード例 #14
0
ファイル: editmember.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #15
0
ファイル: memberdelete.php プロジェクト: itillawarra/cmfive
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']);
}
コード例 #16
0
ファイル: printfile.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #17
0
ファイル: edit.php プロジェクト: itillawarra/cmfive
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}");
}
コード例 #18
0
ファイル: deletefeed.php プロジェクト: itillawarra/cmfive
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/");
}
コード例 #19
0
ファイル: addcategory.php プロジェクト: careck/bendms
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");
}
コード例 #20
0
ファイル: resetpassword.php プロジェクト: itillawarra/cmfive
function resetpassword_POST(Web $w)
{
    $email = $w->request('email');
    // email
    $token = $w->request('token');
    // token
    $password = $w->request('password');
    // password
    $password_confirm = $w->request('password_confirm');
    if ($password !== $password_confirm) {
        $w->error("Passwords do not match", "/auth/resetpassword?email={$email}&token={$token}");
        return;
    }
    $user = $w->Auth->getUserForToken($token);
    //getObject("User", array("password_reset_token", $token));
    $validData = false;
    if (!empty($user->id)) {
        // Check that the password reset hasn't expired
        if (time() - strtotime($user->dt_password_reset_at) < 0) {
            $w->msg("Your token has expired (max 24 hours), please submit for a new one", "/admin/forgotpassword");
            return;
        }
        $user_contact = $user->getContact();
        if (!empty($user_contact)) {
            if ($user_contact->email == $email) {
                $user->setPassword($password);
                $user->password_reset_token = null;
                $user->dt_password_reset_at = null;
                $user->update(true);
                // Precautionary logout
                if ($w->Auth->loggedIn()) {
                    $w->sessionDestroy();
                }
                $validData = true;
            }
        }
    }
    if (!$validData) {
        $w->Log->warn("Password reset attempt failed with email: {$email}, token: {$token}");
        $w->out("Invalid email or token, this incident has been logged");
    } else {
        $w->msg("Your password has been reset", "/auth/login");
    }
}
コード例 #21
0
ファイル: comment.php プロジェクト: itillawarra/cmfive
function comment_POST(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);
    }
    $comment->obj_table = $p["tablename"];
    $comment->obj_id = $p["object_id"];
    $comment->comment = strip_tags($w->request("comment"));
    $comment->insertOrUpdate();
    $redirectUrl = $w->request("redirect_url");
    if (!empty($redirectUrl)) {
        $w->msg("Comment saved", urldecode($redirectUrl));
    } else {
        $w->msg("Comment saved", $w->localUrl($_SERVER["REQUEST_URI"]));
    }
}
コード例 #22
0
function deleteprintfile_GET(Web $w)
{
    $filename = strip_tags($_GET["filename"]);
    if (file_exists($filename)) {
        unlink($filename);
        $w->Log->info("File {$filename} deleted");
        $w->msg("File deleted", "/admin/printqueue");
    }
    $w->error("Missing filename", "/admin/printqueue");
}
コード例 #23
0
ファイル: edit.php プロジェクト: itillawarra/cmfive
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");
}
コード例 #24
0
ファイル: editcategory.php プロジェクト: careck/bendms
function editcategory_POST(Web $w)
{
    list($id) = $w->pathMatch("a");
    $cat = $w->Bend->getWorkCategoryForId($id);
    if (empty($cat)) {
        $w->error("no category found", "/bend-workhours/admin");
    }
    $cat->fill($_POST);
    $cat->update();
    $w->msg("Category updated", "/bend-workhours/admin");
}
コード例 #25
0
ファイル: editprinter.php プロジェクト: itillawarra/cmfive
function editprinter_POST(Web $w)
{
    $p = $w->pathMatch("id");
    $printer = new Printer($w);
    if (!empty($p["id"])) {
        $printer = $w->Printer->getPrinter($p["id"]);
    }
    $printer->fill($_POST);
    $printer->insertOrUpdate();
    $w->msg("Printer added", "/admin/printers");
}
コード例 #26
0
ファイル: editperiod.php プロジェクト: careck/bendms
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");
}
コード例 #27
0
ファイル: editlot.php プロジェクト: careck/bendms
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");
}
コード例 #28
0
ファイル: deletecategory.php プロジェクト: careck/bendms
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");
}
コード例 #29
0
ファイル: removewidget.php プロジェクト: itillawarra/cmfive
function removewidget_ALL(Web $w)
{
    $p = $w->pathMatch("origin", "id");
    // "source", "widget");
    $widget = $w->Widget->getWidgetById($p["id"]);
    //, $p["source"], $p["widget"]);
    if (empty($widget->id)) {
        $w->error("Widget not found", "/{$p['origin']}");
    }
    $widget->delete();
    $w->msg("Widget removed", "/{$p['origin']}");
}
コード例 #30
0
ファイル: edit.php プロジェクト: itillawarra/cmfive
function edit_POST(Web $w)
{
    $p = $w->pathMatch("id");
    $t = $p["id"] ? $w->Template->getTemplate($p['id']) : new Template($w);
    $t->fill($_POST);
    // Set is active if saving is originating from the first page
    if (isset($_POST["title"]) && isset($_POST["module"]) && isset($_POST["category"])) {
        $t->is_active = intval($w->request("is_active"));
    }
    $t->insertOrUpdate();
    $w->msg("Template saved", "/admin-templates/edit/" . $t->id);
}