function saveChanges() { $_POST->setType('etitle', 'string'); $_POST->setType('eimg', 'string'); $_POST->setType('etxt', 'string'); $_POST->setType('active', 'string'); $_POST->setType('regstop', 'string'); $_POST->setType('attendance', 'string'); $_POST->setType('reminder', 'bool'); $_POST->setType('contact', 'numeric'); $_POST->setType('attending_groups', 'numeric', true); $_POST->setType('visibility', 'numeric', true); if ($_POST['etitle']) { $this->that->Name = $_POST['etitle']; $this->that->start = Short::parseDateAndTime('estart', false); $this->that->end = Short::parseDateAndTime('eend', false); $this->that->Image = $_POST['eimg']; $this->that->registration_ends = strtotime($_POST['regstop']); $this->that->setActive(Short::parseDateAndTime('active'), $this->that->end); $this->that->contact = $_POST['contact']; $this->that->attendance = isset($_POST['attendance']); $this->that->attending_groups = $_POST['attending_groups']; $this->that->reminder = $_REQUEST['reminder']; $this->updateVisibility($_POST['visibility']); Flash::queue(__('Event updated'), 'confirmation'); } }
function run() { global $Templates, $CONFIG; if ($this->saveChanges()) { Flash::queue(__('Your changes were saved'), 'confirmation'); redirect($this->that); } $this->setContent('main', Form::quick(false, __('Save'), new Input(__('Page name'), 'name', $this->Name), new Select(__('Group'), 'interesting_groups', $this->that->groups(), $CONFIG->matrikel->interesting_groups, true))); $Templates->render(); }
function saveChanges() { global $CONFIG; $_REQUEST->setType('uncompress', 'any'); if (isset($_FILES['uFiles']) && $this->may($USER, EDIT)) { $u = false; $ue = false; $extensions = $CONFIG->Files->filter; foreach ($_FILES['uFiles']['error'] as $i => $e) { $parts = explode('.', $_FILES['uFiles']['name'][$i]); $extension = array_pop($parts); if ($e == UPLOAD_ERR_NO_FILE) { continue; } $newPath = $this->that->path . '/' . $_FILES['uFiles']['name'][$i]; if ($e == UPLOAD_ERR_OK) { if ($_REQUEST['uncompress'] && in_array(strtolower(strrchr($_FILES['uFiles']['name'][$i], '.')), array('.tar', '.gz', '.tgz', '.bz2', '.tbz', '.zip', '.ar', '.deb'))) { $tmpfile = $_FILES['uFiles']['tmp_name'][$i] . $_FILES['uFiles']['name'][$i]; rename($_FILES['uFiles']['tmp_name'][$i], $tmpfile); $u = true; require_once "File/Archive.php"; error_reporting(E_ALL); $curdir = getcwd(); chdir($this->path); //FIXME: FIXME! if (@File_Archive::extract(File_Archive::filter(File_Archive::predExtension($extensions), File_Archive::read($tmpfile . '/*')), File_Archive::toFiles()) == null) { $ue = true; } else { Flash::queue(__('Extraction failed')); } chdir($curdir); } elseif (!in_array(strtolower($extension), $extensions)) { Flash::queue(__('Invalid format:') . ' ' . $_FILES['uFiles']['name'][$i], 'warning'); continue; } else { $u = (bool) @move_uploaded_file($_FILES['uFiles']['tmp_name'][$i], $newPath); } } if (!$u) { Flash::queue(__('Upload of file') . ' "' . $_FILES['uFiles']['name'][$i] . '" ' . __('failed') . ' (' . ($e ? $e : __('Check permissions')) . ')', 'warning'); } } if ($u) { $this->loadStructure(true); Flash::queue(__('Your file(s) were uploaded')); return true; } if ($ue) { $this->loadStructure(true); Flash::queue(__('Your file(s) were uploaded and extracted')); return true; } return false; } }
function saveChanges() { $_REQUEST->setType('fname', 'string'); if ($_REQUEST['fname'] && strposa($_REQUEST['fname'], array('..', '/', '\\')) === false && $this->that->mayI(EDIT)) { if (@mkdir($this->path . '/' . $_REQUEST['fname'], 0700)) { Flash::queue(__('The folder was created successfully')); } else { Flash::queue(__('There was a problem creating the directory. Check permissions and the name')); } } }
function saveChanges() { $_REQUEST->setType('flows', 'numeric', true); $_REQUEST->setType('items', 'numeric'); if ($_REQUEST['items'] && $_REQUEST['flows']) { $this->that->flows = $_REQUEST['flows']; $this->that->items_per_page = $_REQUEST['items']; Flash::queue(__('Your changes were saved'), 'confirmation'); return true; } return false; }
function saveChanges() { $_REQUEST->setType('to', 'numeric'); if ($_REQUEST['action'] == 'move' && $_REQUEST['to'] && $this->that->mayI(EDIT)) { if ($this->moveFile($_REQUEST['to'])) { Flash::queue(__('The object was successfully moved'), 'confirmation'); redirect(); } else { Flash::queue(__('There was an error moving the file.'), 'warning'); } } }
function saveChanges() { $_POST->setType('calendarname', 'string'); if (!$_POST['calendarname']) { return false; } global $Controller; $new = $Controller->newObj('Calendar'); $new->Name = $_POST['calendarname']; Flash::queue(__('The new calendar') . ' `' . $_POST['calendarname'] . '`' . __('was created'), 'confirmation'); return true; }
function saveChanges() { global $Controller; $_POST->setType('oname', 'string'); $_POST->setType('oparent', 'numeric'); if ($_POST['oname']) { $Obj = $Controller->newObj('Booking_Object'); Flash::queue(__('New object created')); $Obj->Name = $_POST['oname']; $Obj->sortBooking('last', $_POST['oparent']); $Controller->forceReload($Obj); } }
function doDelete() { $_POST->setType('confirm', 'any'); if (!$_POST['confirm']) { return false; } if ($this->that->mayI(DELETE) && $this->that->delete()) { Flash::queue(__('The object was deleted'), 'confirmation'); } else { Flash::queue(__('The object could not be deleted'), 'warning'); } return true; }
function saveChanges() { $_POST->setType('calendars', 'string', true); $_POST->setType('itemsPerPage', 'numeric'); if (!$_POST['calendars']) { return false; } $this->that->calendars = $_POST['calendars']; if ($_POST['itemsPerPage']) { $this->that->itemsPerPage = $_POST['itemsPerPage']; } Flash::queue(__('Your changes were saved'), 'confirmation'); return true; }
function saveChanges() { $_POST->setType('filename', 'string'); $_POST->setType('cropimgx', 'numeric'); $_POST->setType('cropimgy', 'numeric'); $_POST->setType('cropimgw', 'numeric'); $_POST->setType('cropimgh', 'numeric'); $_REQUEST->setType('mkcopy', 'string'); if ($_REQUEST['filename']) { if ($_REQUEST['mkcopy']) { if ($_POST['filename'] != $this->basename && $_POST['filename']) { if (!file_exists($this->dirname . '/' . $_POST['filename'])) { $p = $this->dirname . '/' . $_POST['filename']; } else { Flash::queue(__('File exists. Please give another name or delete the conflicting file. Your changes were not saved.'), 'warning'); break; } } else { $nrofcopies = count(glob(substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy*')); if ($nrofcopies == 0) { $nrofcopies = ''; } $p = substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy' . ($nrofcopies + 1) . substr($this->path, -(strlen($this->extension) + 1)); } touch($p); $copy = File::open($p); } else { if ($_POST['filename'] != $this->basename) { $this->rename($_POST['filename']); } $p = $this->path; $img = new Image($this->path); if ($_POST['cropimgw'] && $_POST['cropimgh']) { $width = $img->width(); $s = $width / min($width, 400); $img->crop(round($s * $_POST['cropimgx']), round($s * $_POST['cropimgy']), round($s * $_POST['cropimgw']), round($s * $_POST['cropimgh'])); } if ($_REQUEST['imgrot']) { $img->rotate($_REQUEST['imgrot']); } $img->save($p); Flash::queue(__('Your changes were saved')); } } }
function saveChanges() { $_POST->setType('title', 'string'); $_POST->setType('template', 'string'); $_POST->setType('alias', 'string'); $_POST->setType('commentsEnabled', 'bool'); if (!$_POST['title']) { return false; } $this->that->Name = $_POST['title']; $this->that->resetAlias(explode(',', $_POST['alias'])); $this->that->setActive(Short::parseDateAndTime('activate'), Short::parseDateAndTime('deactivate')); $this->that->settings['comments'] = isset($_POST['commentsEnabled']); if ($_POST['template']) { $this->that->template = $_POST['template']; } Flash::queue(__('Your changes were saved'), 'confirmation'); return true; }
/** * Display the page for managing installations * @see lib/Page#run() */ function run() { global $USER, $CONFIG, $Templates, $SITE, $Controller; if (!$this->may($USER, READ)) { return; } $_REQUEST->setType('place', 'numeric'); $_REQUEST->setType('parent', 'numeric'); $_REQUEST->setType('reinstall', 'string'); $_REQUEST->setType('new', 'string'); if ($this->mayI(EDIT)) { if ($_REQUEST['reinstall']) { $this->reinstall($_REQUEST['reinstall']); Flash::create($_REQUEST['reinstall'] . ' ' . __('was reinstalled')); } elseif ($_REQUEST['new']) { $class = $_REQUEST['new']; if (validInclude($class) && ($class == 'MenuItem' || @is_subclass_of($class, 'MenuItem')) && $Controller->menuEditor->mayI(EDIT)) { $obj = $Controller->newObj($class); $obj->move($_REQUEST['place'] ? $_REQUEST['place'] : 'last', $_REQUEST['parent']); Flash::queue(__('New') . ' ' . $class . ' ' . __('installed')); redirect(url(array('id' => 'menuEditor'))); } unset($class); } } $installed = $CONFIG->base->installed; $dir = 'plugins'; $fullpath = ROOTDIR . DIRECTORY_SEPARATOR . $dir; $entries = readDirFilesRecursive($fullpath, true); natcasesort($entries); $i = 0; $c = array(); foreach ($entries as $entry) { if (substr($entry, -4) == '.php') { $class = substr($entry, false, -4); $methods = class_exists($class) ? get_class_methods($class) : array(); $c[] = '<span class="fixed-width">' . $class . '</span><div class="tools">' . ($this->may($USER, EDIT) && (@in_array('installable', $methods) && @in_array('install', $methods) && call_user_func(array($class, 'installable')) == $class) ? icon('small/arrow_refresh_small', __('Reinstall'), url(array('reinstall' => $class), array('id'))) : '') . (($class == 'MenuItem' || @is_subclass_of($class, 'MenuItem')) && $Controller->menuEditor->may($USER, EDIT) ? icon('small/add', __('Add new instance to menu'), url(array('new' => $class), array('id'))) : '') . '</div>'; } } $this->setContent('header', __('Installer')); $this->setContent('main', listify($c)); $Templates->admin->render(); }
function saveChanges() { if (!is_a($this->that, 'User')) { return null; } /** * Delete user */ if ($_REQUEST->numeric('del') && $this->that->mayI(DELETE)) { $Controller->{$_REQUEST['del']}(OVERRIDE)->delete(); Flash::queue(__('User was deleted')); redirect(url()); } global $Controller, $DB; $_POST->setType('username', 'string'); $_POST->setType('password1', 'string'); $_POST->setType('password2', 'string'); $_POST->setType('volgroups', 'numeric', true); $changes = false; /** * Save the user */ if ($_POST['username'] && $_POST['username'] != $this->that->username) { if ($DB->users->exists(array('username' => $_POST['username'], 'id!' => $this->that->ID))) { Flash::create(__('Username is already in use'), 'warning'); return false; } else { $user->username = $_POST['username']; $changes = true; } } if ($_POST['password1']) { if ($_POST['password1'] === $_POST['password2']) { $user->password = $_POST['password1']; $changes = true; } else { Flash::create(__("The passwords don't match. Try again"), 'warning'); return false; } } $vgs = (array) $_POST['volgroups']; $volkeys = $DB->{'spine,metadata'}->asList(array('spine.class' => 'Group', 'metadata.field' => 'GroupType', 'metadata.value' => array('vol', 'volpre')), 'spine.id'); $volgroups = $Controller->get($volkeys, OVERRIDE); asort($volgroups); /** * Save group data */ foreach ($volgroups as $vg) { if (in_array($vg->ID, $vgs)) { if ($vg->addMember($this->that)) { $changes = true; } } else { if ($vg->removeMember($this->that)) { $changes = true; } } } $changes = UInfoFields::save($this->that->ID) || $changes; $Controller->forceReload($this->that); if ($changes) { Flash::create(__('Your changes were saved')); } return $changes; }
function saveAttendance() { $_REQUEST->setType('attending', '/yes|no/'); $_REQUEST->setType('user', 'numeric'); $_REQUEST->setType('comment', 'string'); if ($_REQUEST['attending']) { if ($_REQUEST['user'] && $this->mayI(EDIT)) { $user = $_REQUEST['user']; } else { global $USER; $user = $USER->ID; } global $DB; $DB->attendance->update(array('attending' => $_REQUEST['attending'], 'comment' => $_REQUEST['comment']), array('event' => $this->ID, 'attendee' => $user), true); Flash::queue(__('Saved')); return true; } return false; }
private function saveChanges() { global $Controller, $USER; $_REQUEST->setType('stpl', 'string'); $_REQUEST->setType('newName', 'string'); $_REQUEST->setType('page', 'numeric'); $_REQUEST->setType('where', '/below|child/'); $_REQUEST->setType('to', 'numeric'); $_REQUEST->setType('action', 'string'); /** * Delete menusection */ if ($_REQUEST['delete'] && $this->mayI(DELETE)) { $obj = $Controller->{$_REQUEST['delete']}; if ($DB->menu->exists(array('parent' => $_REQUEST['delete']))) { Flash::queue(__('Section not empty'), 'warning'); } else { if ($obj) { $obj->deleteFromMenu(); } Flash::queue(__('Menu item removed'), 'warning'); } } /** * Create a new section */ if ($_REQUEST['newName']) { if ($DB->aliases->exists(array('alias' => $_REQUEST['newName']))) { Flash::queue(__('Alias already in use')); } else { $obj = $Controller->newObj('MenuSection'); $obj->alias = $_REQUEST['newName']; $obj->template = $_REQUEST['stpl']; $obj->move('last', $_REQUEST['section'] ? $_REQUEST['section'] : 0); Flash::create(__('New section created'), 'confirmation'); } } /** * Create new page */ if ($_POST['action'] == 'newpage') { $newObj = $Controller->newObj('Page'); $newObj->Name = __('New page'); $_REQUEST['page'] = $newObj->ID; } /** * Move an item */ if ($_REQUEST['page'] && $_REQUEST['where'] && $_REQUEST['to']) { $obj = $Controller->{$_REQUEST['page']}; if ($obj) { $ruler = $this->getParent($obj); if ($ruler->mayI(EDIT)) { // May edit source parent $to = $Controller->{$_REQUEST['to']}; if ($_REQUEST['where'] == 'below') { $parent = $this->getParent($to); } else { $parent = $to; } if ($parent->mayI(EDIT)) { // May edit target if ($_REQUEST['where'] == 'below') { $obj->move($to->place() + 1, $parent); } else { $obj->move(0, $parent); } } } } } }
function saveChanges() { $changes = false; $_REQUEST->setType('delgroup', 'string'); $_REQUEST->setType('editGroup', 'any'); /** * Deletion of a group */ if ($_REQUEST['delgroup']) { if ($this->that->mayI(DELETE)) { $g = $Controller->{$_REQUEST['delgroup']}; if (is_a($g, 'Group')) { $this->that->delete(); Flash::queue(__('The group was deleted and all privileges were removed')); redirect(url()); } } } $_POST->setType('presentation', 'any'); if ($_POST['presentation']) { $this->saveContent(array('presentation' => $_POST['presentation'])); } $_REQUEST->setType('rem', 'numeric'); $_REQUEST->setType('add', 'numeric'); if ($_REQUEST['add']) { if ($this->that->addMember($_REQUEST['add'])) { if ($_REQUEST['nGM']) { Flash::create(__('Group added as subgroup')); } else { Flash::create(__('User added to group'), 'confirmation'); } } else { Flash::create(__('Action failed'), 'warning'); } } elseif ($_REQUEST['rem']) { if ($this->that->removeMember($_REQUEST['rem'])) { Flash::create(__('User removed from group'), 'confirmation'); } else { Flash::create(__('User could not be removed from group'), 'warning'); } } if ($_REQUEST['group_action'] && $_REQUEST['gid']) { if ($_REQUEST['group_action'] == 'reset_members') { if ($rgroup = $Controller->{$_REQUEST['gid']}('Group')) { $rgroup->resetMembers(); Flash::create(__('Members removed'), 'confirmation'); } } elseif ($_REQUEST['group_action'] == 'copy_members') { if (($from_group = $Controller->{$_REQUEST['gid']}('Group')) && ($to_group = $Controller->{$_REQUEST['copy_to_group']}('Group'))) { $to_group->addMembers($from_group->MEMBERS); Flash::create(__('Members copied'), 'confirmation'); } } } $_POST->setType('gtype', 'string'); $_POST->setType('gimage', 'numeric'); $_POST->setType('dispmembers', 'bool'); if ($_POST['gtype']) { $this->that->GroupType = $_POST['gtype']; $this->that->DisplayMembers = $_POST['dispmembers']; $this->that->Image = $_POST['gimage']; } }