Example #1
0
 public function admin()
 {
     switch ($_REQUEST['iop']) {
         case 'delete_image':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadImage(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->image->delete();
             PHPWS_Core::goBack();
             break;
         case 'post_image_upload':
             if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             if (!$this->postImageUpload()) {
                 \Cabinet::setMessage('Failed to upload image. Check directory permissions.');
             }
             Layout::nakedDisplay();
             //\PHPWS_Core::goBack();
             break;
         case 'upload_image_form':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadImage(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->edit();
             echo Layout::wrap($this->content, 'Image Upload', true);
             exit;
     }
 }
Example #2
0
 public static function process()
 {
     if (!Current_User::authorized('analytics')) {
         Current_User::disallow();
     }
     $panel = self::cpanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $panel->getCurrentTab();
     }
     switch ($command) {
         case 'list':
             $panel->setContent(self::listTrackers());
             break;
         case 'new':
             $panel->setContent(self::newTracker());
             break;
         case 'create':
             $panel->setContent(self::createTracker());
             break;
         case 'edit':
             $panel->setContent(self::editTracker());
             break;
         case 'delete':
             $panel->setContent(self::deleteTracker());
             break;
         case 'save_tracker':
             $panel->setContent(self::saveTracker());
             break;
     }
     Layout::add(PHPWS_ControlPanel::display($panel->display()));
 }
Example #3
0
 function adminMenu()
 {
     if (!Current_User::allow('whatsnew')) {
         Current_User::disallow();
     }
     $this->loadPanel();
     $javascript = false;
     $this->loadMessage();
     switch ($_REQUEST['aop']) {
         case 'menu':
             if (!isset($_GET['tab'])) {
                 $this->loadForm('settings');
             } else {
                 $this->loadForm($_GET['tab']);
             }
             break;
         case 'post_settings':
             if (!Current_User::authorized('whatsnew')) {
                 Current_User::disallow();
             }
             if ($this->postSettings()) {
                 $this->forwardMessage(dgettext('whatsnew', 'Whatsnew settings saved.'));
                 PHPWS_Core::reroute('index.php?module=whatsnew&aop=menu');
             } else {
                 $this->loadForm('settings');
             }
             break;
         case 'flush_cache':
             if (!Current_User::authorized('whatsnew')) {
                 Current_User::disallow();
             }
             if ($this->flushCache()) {
                 $this->forwardMessage(dgettext('whatsnew', 'Cache flushed.'));
                 PHPWS_Core::reroute('index.php?module=whatsnew&aop=menu');
             } else {
                 $this->loadForm('settings');
             }
             break;
     }
     $tpl['TITLE'] = $this->title;
     $tpl['CONTENT'] = $this->content;
     $tpl['MESSAGE'] = $this->message;
     if ($javascript) {
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'whatsnew', 'main_admin.tpl'));
     } else {
         $this->panel->setContent(PHPWS_Template::process($tpl, 'whatsnew', 'main_admin.tpl'));
         Layout::add(PHPWS_ControlPanel::display($this->panel->display()));
     }
 }
 public function admin()
 {
     switch ($_REQUEST['mop']) {
         case 'delete_multimedia':
             if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadMultimedia(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->multimedia->delete();
             PHPWS_Core::goBack();
             break;
         case 'post_multimedia_upload':
             if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->postMultimediaUpload();
             \PHPWS_Core::goBack();
             break;
         case 'upload_multimedia_form':
             if (!Current_User::secured('filecabinet', 'edit_folders', $this->multimedia->folder_id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadMultimedia(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             if (!$this->multimedia->id) {
                 $this->multimedia->folder_id = filter_input(INPUT_GET, 'folder_id', FILTER_VALIDATE_INT);
             }
             $this->edit();
             echo json_encode(array('title' => $this->title, 'content' => $this->content));
             exit;
         case 'edit_rtmp':
             if (!Current_User::secured('filecabinet', 'edit_folders', $this->multimedia->folder_id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadMultimedia(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->editRTMP();
             echo json_encode(array('title' => $this->title, 'content' => $this->content));
             exit;
         case 'post_rtmp':
             if (!Current_User::authorized('filecabinet', 'edit_folders', $this->multimedia->folder_id, 'folder')) {
                 Current_User::disallow();
             }
             if (!$this->postRTMP()) {
                 $this->editRTMP();
             }
             \PHPWS_Core::goBack();
             break;
     }
     return $this->content;
 }
Example #5
0
 public function get($type)
 {
     switch ($type) {
         case 'new':
             if (Current_User::isRestricted('signup')) {
                 $this->signup->title = dgettext('signup', 'Sorry');
                 $this->signup->content = dgettext('signup', 'You do not have permission for this action.');
                 return;
             }
         case 'edit_sheet':
             if (empty($this->signup->sheet)) {
                 $this->signup->loadSheet();
             }
             if (!Current_User::allow('signup', 'edit_sheet', $this->signup->sheet->id, 'sheet')) {
                 Current_User::disallow();
             }
             $this->editSheet();
             break;
         case 'list':
             $this->signup->panel->setCurrentTab('list');
             $this->listSignup();
             break;
         case 'edit_slots':
             $this->editSlots();
             break;
         case 'edit_peep':
             $this->editPeep();
             break;
         case 'edit_slot_popup':
             $this->editSlotPopup();
             break;
         case 'edit_peep_popup':
             $this->editPeepPopup();
             break;
         case 'user_signup':
             $this->userSignup();
             break;
         case 'report':
             $this->report();
             break;
         case 'email_applicants':
             $this->emailApplicants();
             break;
     }
 }
Example #6
0
 public function post()
 {
     switch ($_POST['aop']) {
         case 'save_property':
             if (!\Current_User::authorized('properties')) {
                 Current_User::disallow('Action not allowed');
             }
             $this->loadProperty();
             if ($this->property->post()) {
                 try {
                     $this->property->save();
                     $this->setCarryMessage('Property saved successfully.');
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                 }
                 \PHPWS_Core::reroute('index.php?module=properties&aop=properties');
             } else {
                 $this->editProperty();
             }
             break;
         case 'save_contact':
             if (!\Current_User::authorized('properties')) {
                 Current_User::disallow();
             }
             $this->loadContact();
             if ($this->contact->post()) {
                 try {
                     $this->contact->save();
                     if (isset($_POST['contact_contact'])) {
                         $this->emailContact($this->contact->username, $_POST['password'], $_POST['email_address']);
                     }
                     $this->setCarryMessage('Contact saved successfully.');
                     \PHPWS_Core::reroute('index.php?module=properties&aop=contacts');
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                     $this->editContact();
                 }
             } else {
                 $this->editContact();
             }
             break;
         case 'post_photo':
             try {
                 $photo = new Photo();
                 $photo->post();
                 $this->setCarryMessage('Photo uploaded');
                 if (isset($_POST['v'])) {
                     $property = new Property($photo->pid);
                     $url = './properties/id/' . $photo->pid . '/photo/1';
                 } else {
                     $url = 'index.php?module=properties&aop=properties&pid=' . $photo->pid;
                 }
                 \PHPWS_Core::reroute($url);
             } catch (\Exception $e) {
                 $this->setCarryMessage($e->getMessage());
                 \PHPWS_Core::goBack();
             }
             break;
         case 'post_settings':
             if ($this->postSettings()) {
                 $this->setCarryMessage('Settings updated');
                 \PHPWS_Core::reroute('index.php?module=properties&aop=settings');
             } else {
                 $this->settingsForm();
             }
             break;
         case 'block_post':
             $this->blockPost();
             $this->viewReported();
             break;
     }
     $this->display();
 }
Example #7
0
 public function admin()
 {
     switch ($_REQUEST['dop']) {
         case 'delete_document':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->document->delete();
             PHPWS_Core::returnToBookmark();
             break;
         case 'post_document_upload':
             if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->postDocumentUpload();
             javascript('close_refresh');
             Layout::nakedDisplay();
             //\PHPWS_Core::goBack();
             break;
         case 'upload_document_form':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadDocument(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->edit();
             echo Layout::wrap($this->content, 'Document Upload', true);
             exit;
         case 'add_access':
             if (!Current_User::authorized('filecabinet')) {
                 Current_User::disallow();
             }
             $keyword = null;
             $this->loadDocument();
             // document exists, try making a shortcut
             if ($this->document->id) {
                 PHPWS_Core::initModClass('access', 'Shortcut.php');
                 $shortcut = new Access_Shortcut();
                 if (isset($_GET['keyword'])) {
                     $keyword = $_GET['keyword'];
                 }
                 if (empty($keyword)) {
                     $keyword = $this->document->title;
                 }
                 $result = $shortcut->setKeyword($keyword);
                 $new_keyword = $shortcut->keyword;
                 // if setKeyword returns a false or error, we have them pick a different name
                 if (!$result || PHPWS_Error::isError($result)) {
                     $message = dgettext('filecabinet', 'Access shortcut name already in use. Please enter another.');
                     $success = false;
                 } else {
                     $shortcut->setUrl('filecabinet', $this->document->getViewLink());
                     $shortcut->save();
                     $success = true;
                     $message = '<p>' . dgettext('filecabinet', 'Access shortcut successful!') . '</p>';
                     $message .= '<a href="' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '">' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '</a>';
                 }
             } else {
                 $message = dgettext('filecabinet', 'File not found');
                 // not really a success but prevents a repost prompt
                 $success = true;
             }
             echo json_encode(array('success' => $success, 'message' => $message, 'keyword' => $new_keyword));
             exit;
     }
 }
Example #8
0
 public function admin()
 {
     if (!Current_User::allow('pagesmith')) {
         Current_User::disallow();
     }
     $this->loadPanel();
     $javascript = false;
     switch ($_REQUEST['aop']) {
         case 'block_info':
             $this->getTextBlockData($_GET['bid'], $_GET['pid'], $_GET['section_id']);
             exit;
         case 'save_block':
             $this->saveBlockData($_POST['pid'], $_POST['bid'], $_POST['section_id'], $_POST['content']);
             PHPWS_Cache::clearCache();
             exit;
         case 'get_undo':
             $this->getLastUndo($_GET['pid'], $_GET['bid'], $_GET['section_id']);
             exit;
         case 'menu':
             $this->loadForms();
             if (!isset($_GET['tab'])) {
                 $tab = $this->panel->getCurrentTab();
             } else {
                 $tab =& $_GET['tab'];
             }
             switch ($tab) {
                 case 'new':
                     $this->resetUndoSession(0);
                     $this->clearPageSession();
                     $this->loadPage();
                     $this->forms->editPage();
                     break;
                 case 'list':
                     $this->forms->pageList();
                     break;
                 case 'settings':
                     if (!Current_User::allow('pagesmith', null, null, null, true)) {
                         Current_User::disallow();
                     }
                     $this->forms->settings();
                     break;
             }
             break;
         case 'edit_page':
             $this->resetUndoSession(0);
             $this->loadPage();
             if (!$this->page->id) {
                 $this->title = dgettext('pagesmith', 'Sorry');
                 $this->content = dgettext('pagesmith', 'Page not found');
                 break;
             }
             $this->loadForms();
             if (!Current_User::allow('pagesmith', 'edit_page', $this->page->id)) {
                 Current_User::disallow();
             }
             $this->page->loadSections(true);
             $this->forms->pageLayout();
             break;
         case 'pick_template':
             $this->resetUndoSession(0);
             $this->loadForms();
             $this->loadPage();
             $this->page->loadTemplate();
             $this->page->loadSections(true);
             $this->killSaved($this->page->id);
             $this->forms->editPage();
             break;
         case 'delete_page':
             if (!Current_User::authorized('pagesmith', 'delete_page')) {
                 Current_User::disallow();
             }
             $this->loadPage();
             $this->page->delete();
             PHPWS_Cache::clearCache();
             $this->loadForms();
             $this->forms->pageList();
             break;
         case 'edit_page_header':
             $this->loadPage();
             $this->loadForms();
             $this->forms->editPageHeader();
             $javascript = true;
             break;
         case 'delete_section':
             $this->deleteSection($_GET['sec_id']);
             exit;
             break;
         case 'post_header':
             $this->postHeader();
             break;
         case 'post_text':
             $this->postText();
             break;
         case 'post_page':
             $result = $this->postPage();
             switch ($result) {
                 case -1:
                     $this->loadForms();
                     $this->page->loadSections(true);
                     $this->forms->editPage();
                     break;
                 case 0:
                     $this->message = dgettext('pagesmith', 'Not enough content to create a page.');
                     $this->loadForms();
                     $this->page->loadSections(true);
                     $this->forms->editPage();
                     break;
                 case 1:
                     $this->killSaved($this->page->id);
                     PHPWS_Cache::clearCache();
                     PHPWS_Core::reroute($this->page->url());
                     break;
             }
             break;
         case 'front_page_toggle':
             $db = \Database::newDB();
             $db->addTable('ps_page')->addValue('front_page', 0);
             $db->update();
             $this->loadPage();
             $this->page->front_page = (bool) $_GET['fp'];
             $this->page->save();
             PHPWS_Cache::clearCache();
             $this->removeFromMenu();
             $this->loadForms();
             $this->forms->pageList();
             break;
         case 'shorten_links':
             if (!Current_User::authorized('pagesmith', 'settings', null, null, true)) {
                 Current_User::disallow();
             }
             $this->shortenLinks();
             PHPWS_Core::goBack();
             break;
         case 'lengthen_links':
             if (!Current_User::authorized('pagesmith', 'settings', null, null, true)) {
                 Current_User::disallow();
             }
             $this->lengthenLinks();
             PHPWS_Core::goBack();
             break;
         case 'post_settings':
             if (!Current_User::authorized('pagesmith', 'settings', null, null, true)) {
                 Current_User::disallow();
             }
             $this->postSettings();
             $this->message = dgettext('pagesmith', 'Settings saved');
             $this->loadForms();
             $this->forms->settings();
             break;
         default:
             PHPWS_Core::errorPage('404');
             break;
     }
     if ($javascript) {
         $tpl['TITLE'] = $this->title;
         $tpl['CONTENT'] = $this->content;
         $tpl['MESSAGE'] = $this->message;
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'pagesmith', 'admin_main.tpl'));
     } else {
         Layout::add(PHPWS_ControlPanel::display($this->panel->display($this->content, $this->title, $this->message)));
     }
 }
Example #9
0
 function remove()
 {
     if (!(Current_User::authorized('wiki', 'delete_page') && $this->getAllowEdit() && !$this->getVrCurrent())) {
         Current_User::disallow(dgettext('wiki', 'User attempted to remove previous page version.'));
         return;
     }
     PHPWS_Core::initModClass('version', 'Version.php');
     $version = new Version('wiki_pages', $this->getId());
     $version->delete(FALSE);
     WikiManager::sendMessage(dgettext('wiki', 'Old revision removed'), array('page' => $this->getTitle(FALSE)), FALSE);
 }
Example #10
0
 /**
  * Image upload
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function imageUpload()
 {
     if (!Current_User::authorized('wiki', 'upload_images') && !(PHPWS_Settings::get('wiki', 'allow_image_upload') && Current_User::isLogged())) {
         Current_User::disallow(dgettext('wiki', 'User attempted access to image upload.'));
         return;
     }
     PHPWS_Core::initModClass('wiki', 'WikiImage.php');
     PHPWS_Core::initCoreClass('DBPager.php');
     if (isset($_POST['op']) && $_POST['op'] == 'doimageupload') {
         $newImage = new WikiImage();
         WikiManager::sendMessage($newImage->save(), 'imageupload');
     }
     if ($_REQUEST['op'] == 'doimagedelete') {
         $delImage = new WikiImage($_REQUEST['id']);
         WikiManager::sendMessage($delImage->delete(), 'imageupload');
     }
     $tags = WikiImage::add();
     $tags['BACK'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to Wiki'), 'wiki');
     $tags['MESSAGE'] = WikiManager::getMessage();
     $tags['IMAGE_UPLOAD_LABEL'] = dgettext('wiki', 'Image Upload');
     $tags['IMAGE_LIST_LABEL'] = dgettext('wiki', 'Image List');
     $tags['USAGE'] = sprintf(dgettext('wiki', 'To include an image in a page, use %s.'), '[[image picture.jpg]]');
     $tags['LIST_FILENAME'] = dgettext('wiki', 'Filename');
     $tags['LIST_SIZE'] = dgettext('wiki', 'Size');
     $tags['LIST_TYPE'] = dgettext('wiki', 'Type');
     $tags['LIST_OWNER'] = dgettext('wiki', 'Uploader');
     $tags['LIST_CREATED'] = dgettext('wiki', 'Upload Date');
     $tags['LIST_ACTIONS'] = dgettext('wiki', 'Actions');
     $pager = new DBPager('wiki_images', 'WikiImage');
     $pager->setModule('wiki');
     $pager->setTemplate('images/admin.tpl');
     $pager->addToggle(PHPWS_LIST_TOGGLE_CLASS);
     $pager->addPageTags($tags);
     $pager->addRowTags('getTpl');
     $pager->setSearch('filename', 'summary');
     $pager->setDefaultOrder('filename', 'asc');
     $pager->setEmptyMessage(dgettext('wiki', 'No images found.'));
     $pager->cacheQueries();
     $template['TITLE'] = dgettext('wiki', 'Wiki Images');
     $template['CONTENT'] = $pager->get();
     Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
 }
Example #11
0
 public static function main()
 {
     if (!Current_User::authorized('blog')) {
         Current_User::disallow(dgettext('blog', 'User attempted access to Blog administration.'));
         return;
     }
     $title = $content = NULL;
     $message = Blog_Admin::getForward();
     $panel = Blog_Admin::cpanel();
     $panel->enableSecure();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $panel->getCurrentTab();
     }
     if (isset($_REQUEST['blog_id'])) {
         $blog = new Blog((int) $_REQUEST['blog_id']);
     } else {
         $blog = new Blog();
     }
     switch ($command) {
         case 'edit':
             $panel->setCurrentTab('list');
             if (!Current_User::isUser($blog->author_id) && !Current_User::authorized('blog', 'edit_blog', $_REQUEST['blog_id'], 'entry')) {
                 Current_User::disallow(dgettext('blog', 'User tried to edit a blog.'));
                 return;
             }
             $title = dgettext('blog', 'Update Blog Entry');
             $content = Blog_Form::edit($blog);
             break;
         case 'new':
             $title = dgettext('blog', 'New Blog Entry');
             $content = Blog_Form::edit($blog);
             break;
         case 'delete':
             //Blog_Admin::resetCache();
             $result = $blog->delete();
             Blog_Admin::setForward(dgettext('blog', 'Blog entry deleted.'), 'list');
             break;
         case 'list':
             $title = dgettext('blog', 'Blog Entries');
             $content = Blog_Admin::entry_list();
             break;
         case 'menu_submit_link':
             Menu::pinLink(dgettext('blog', 'Submit entry'), 'index.php?module=blog&action=user&action=submit');
             PHPWS_Core::reroute('index.php?module=blog&action=admin&tab=settings&authkey=' . Current_User::getAuthKey());
             break;
         case 'sticky':
             if (!Current_User::isUnrestricted('blog')) {
                 Current_User::disallow();
             }
             Blog_Admin::sticky($blog);
             PHPWS_Core::goBack();
             break;
         case 'unsticky':
             if (!Current_User::isUnrestricted('blog')) {
                 Current_User::disallow();
             }
             Blog_Admin::unsticky($blog);
             PHPWS_Core::goBack();
             break;
         case 'post_entry':
             $title = dgettext('blog', 'Blog Archive');
             $panel->setCurrentTab('list');
             $blog->post_entry();
             $link_back = PHPWS_Text::linkAddress('blog', array('action' => 'admin', 'tab' => 'list'), TRUE);
             if ($blog->_error) {
                 if (empty($blog->id)) {
                     $panel->setCurrentTab('new');
                 }
                 $content = Blog_Form::edit($blog);
             } else {
                 if (!isset($_POST['blog_id']) && PHPWS_Core::isPosted()) {
                     Blog_Admin::setForward(dgettext('blog', 'Entry saved successfully.'), 'list');
                 }
                 $result = $blog->save();
                 //Blog_Admin::resetCache();
                 if (PHPWS_Error::isError($result)) {
                     $message = dgettext('blog', 'An error occurred when trying to save your entry. Please check your logs.');
                     PHPWS_Error::log($result);
                     Blog_Admin::setForward($message, 'list');
                 }
                 if (!$blog->approved) {
                     Blog_Admin::setForward(dgettext('blog', 'Your entry is being held for approval.'), 'list');
                 } else {
                     PHPWS_Core::reroute($blog->getViewLink(true));
                 }
             }
             break;
         case 'reset_cache':
             Blog_Admin::resetCache();
             PHPWS_Core::goBack();
             break;
         case 'post_settings':
             if (!Current_User::authorized('blog', 'settings')) {
                 Current_User::disallow();
                 return;
             }
             if (Current_User::isDeity() && isset($_POST['purge_confirm'])) {
                 $title = dgettext('blog', 'Purge Blog Entries');
                 $content = Blog_Admin::confirmPurge($_POST['purge_date']);
                 break;
             }
             Blog_Admin::postSettings();
             $message = dgettext('blog', 'Blog settings saved.');
         case 'settings':
             if (!Current_User::allow('blog', 'settings')) {
                 Current_User::disallow();
                 return;
             }
             $panel->setCurrentTab('settings');
             $title = dgettext('blog', 'Blog Settings');
             $content = Blog_Form::settings();
             break;
         case 'purge_entries':
             if (Current_User::authorized('blog') && Current_User::isDeity()) {
                 Blog_Admin::purgeEntries($_GET['pd']);
                 $message = dgettext('blog', 'Blog entries purged.');
             }
             $content = Blog_Form::settings();
     }
     Layout::add(PHPWS_ControlPanel::display($panel->display($content, $title, $message)));
 }
Example #12
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
if (!defined('PHPWS_SOURCE_DIR')) {
    Error::errorPage(403);
}
if ($_REQUEST['module'] != 'layout' || !isset($_REQUEST['action'])) {
    Error::errorPage('404');
}
if ($_REQUEST['action'] == 'ckeditor') {
    Layout::ckeditor();
    exit;
}
if (!Current_User::allow('layout')) {
    Current_User::disallow();
}
PHPWS_Core::initModClass('layout', 'LayoutAdmin.php');
switch ($_REQUEST['action']) {
    case 'admin':
        Layout_Admin::admin();
        break;
    default:
        PHPWS_Core::errorPage('404');
}
// END action switch
Example #13
0
 public function editFolder($js)
 {
     if (!Current_User::allow('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
         Current_User::disallow();
     }
     $this->loadForms();
     if ($this->folder->ftype == IMAGE_FOLDER) {
         $this->title = dgettext('filecabinet', 'Update image folder');
     } elseif ($this->folder->ftype == DOCUMENT_FOLDER) {
         $this->title = dgettext('filecabinet', 'Update document folder');
     } else {
         $this->title = dgettext('filecabinet', 'Update multimedia folder');
     }
     $this->content = $this->forms->editFolder($this->folder, $js);
     if ($js) {
         echo \Layout::wrap($this->content, $this->title, true);
     } else {
         echo json_encode(array('title' => $this->title, 'content' => $this->content));
     }
     exit;
 }
Example #14
0
 public static function main()
 {
     if (!Current_User::allow('search')) {
         Current_User::disallow();
     }
     $panel = Search_Admin::cpanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } elseif (isset($_REQUEST['tab'])) {
         $command = $_REQUEST['tab'];
     } else {
         $command = $panel->getCurrentTab();
     }
     switch ($command) {
         case 'delete_keyword':
         case 'add_keyword':
         case 'remove_searchword':
         case 'add_ignore':
             if (!Current_User::authorized('search')) {
                 Current_User::disallow();
             }
             break;
     }
     switch ($command) {
         case 'keyword':
             $template = Search_Admin::keyword();
             break;
         case 'ignore':
             $template = Search_Admin::ignore();
             break;
         case 'settings':
             $template = Search_Admin::settings();
             break;
         case 'close_admin':
             unset($_SESSION['Search_Add_Words']);
             unset($_SESSION['Search_Admin']);
             PHPWS_Core::goBack();
             break;
         case 'delete_keyword':
             Search_Admin::deleteKeyword();
             PHPWS_Core::goBack();
             break;
         case 'add_parse_word':
             if (!isset($_REQUEST['keyword'])) {
                 PHPWS_Core::goBack();
             }
             Search_Admin::addParseWord($_REQUEST['keyword']);
             Search_Admin::sendMessage(dgettext('search', 'Keywords added to admin menu.'), 'keyword');
             break;
         case 'drop_keyword':
             if (isset($_SESSION['Search_Add_Words'])) {
                 $array_key = array_search($_REQUEST['kw'], $_SESSION['Search_Add_Words']);
                 if ($array_key !== FALSE) {
                     unset($_SESSION['Search_Add_Words'][$array_key]);
                 }
             }
             PHPWS_Core::goBack();
             break;
         case 'add_keyword':
             if (!isset($_GET['kw']) || !isset($_GET['key_id'])) {
                 PHPWS_Core::goBack();
             }
             Search_Admin::addKeyword($_GET['kw'], $_GET['key_id']);
             PHPWS_Core::goBack();
             break;
         case 'remove_searchword':
             if (!isset($_GET['kw']) || !isset($_GET['key_id'])) {
                 PHPWS_Core::goBack();
             }
             Search_Admin::removeSearchword($_GET['kw'], $_GET['key_id']);
             PHPWS_Core::goBack();
             break;
         case 'add_ignore':
             if (!isset($_GET['keyword'])) {
                 PHPWS_Core::goBack();
             }
             Search_Admin::setIgnore($_GET['keyword'], 1);
             PHPWS_Core::goBack();
             break;
         case 'remove_ignore':
             if (!isset($_GET['keyword'])) {
                 PHPWS_Core::goBack();
             }
             Search_Admin::setIgnore($_GET['keyword'], 0);
             PHPWS_Core::goBack();
             break;
         case 'save_settings':
             Search_Admin::saveSettings();
             Search_Admin::sendMessage(dgettext('search', 'Settings saved'), 'settings');
             break;
     }
     $template['MESSAGE'] = Search_Admin::getMessage();
     $final = PHPWS_Template::process($template, 'search', 'main.tpl');
     $panel->setContent($final);
     $finalPanel = $panel->display();
     Layout::add(PHPWS_ControlPanel::display($finalPanel));
 }
Example #15
0
 public static function postDenyAllow()
 {
     if (!Current_User::authorized('access', 'admin_options')) {
         Current_User::disallow();
         exit;
     }
     PHPWS_Core::initModClass('access', 'Allow_Deny.php');
     if (!empty($_POST['allow_deny_enabled'])) {
         PHPWS_Settings::set('access', 'allow_deny_enabled', 1);
     } else {
         PHPWS_Settings::set('access', 'allow_deny_enabled', 0);
     }
     PHPWS_Settings::save('access');
     if (isset($_POST['add_allow_address']) && !empty($_POST['allow_address'])) {
         $allow = new Access_Allow_Deny();
         $allow->allow_or_deny = 1;
         $result = $allow->setIpAddress($_POST['allow_address']);
         if (!$result) {
             return $result;
         }
         $allow->active = 1;
         return $allow->save();
     }
     if (isset($_POST['add_deny_address']) && !empty($_POST['deny_address'])) {
         $deny = new Access_Allow_Deny();
         $deny->allow_or_deny = 0;
         $result = $deny->setIpAddress($_POST['deny_address']);
         if (!$result) {
             return $result;
         }
         $deny->active = 1;
         return $deny->save();
     }
     if (isset($_POST['allow_action']) && $_POST['allow_action'] != 'none') {
         if ($_POST['allow_action'] == 'allow_all') {
             if (PHPWS_Settings::get('access', 'allow_all')) {
                 PHPWS_Settings::set('access', 'allow_all', 0);
             } else {
                 PHPWS_Settings::set('access', 'allow_all', 1);
             }
             PHPWS_Settings::save('access');
             return true;
         } elseif (!empty($_POST['allows'])) {
             $db = new PHPWS_DB('access_allow_deny');
             // just in case something goes wrong
             $db->addWhere('allow_or_deny', 1);
             $db->addWhere('id', $_POST['allows']);
             switch ($_POST['allow_action']) {
                 case 'active':
                     $db->addValue('active', 1);
                     return $db->update();
                     break;
                 case 'deactive':
                     $db->addValue('active', 0);
                     return $db->update();
                     break;
                 case 'delete':
                     return $db->delete();
                     break;
             }
         }
     }
     if ($_POST['deny_action'] == 'deny_all') {
         if (PHPWS_Settings::get('access', 'deny_all')) {
             PHPWS_Settings::set('access', 'deny_all', 0);
         } else {
             PHPWS_Settings::set('access', 'deny_all', 1);
         }
         PHPWS_Settings::save('access');
         return true;
     } elseif (!empty($_POST['denys'])) {
         $db = new PHPWS_DB('access_allow_deny');
         // just in case something goes wrong
         $db->addWhere('allow_or_deny', 0);
         $db->addWhere('id', $_POST['denys']);
         switch ($_POST['deny_action']) {
             case 'active':
                 $db->addValue('active', 1);
                 return $db->update();
                 break;
             case 'deactive':
                 $db->addValue('active', 0);
                 return $db->update();
                 break;
             case 'delete':
                 return $db->delete();
                 break;
         }
     }
     return true;
 }
Example #16
0
 /**
  * Interwiki Setup
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function setup()
 {
     if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged())) {
         Current_User::disallow(dgettext('wiki', 'User attempted access to Interwiki setup.'));
         return;
     }
     PHPWS_Core::initCoreClass('DBPager.php');
     if ($_REQUEST['op'] == 'editinterwiki') {
         $tags = $this->edit();
     } else {
         if ($_REQUEST['op'] == 'deleteinterwiki') {
             $tags = $this->kill();
         } else {
             $tags = $this->add();
         }
     }
     if ($_REQUEST['op'] == 'addinterwiki' || $_REQUEST['op'] == 'saveinterwiki') {
         WikiManager::sendMessage($this->save(), 'interwikisetup');
     } else {
         if ($_REQUEST['op'] == 'dodeleteinterwiki') {
             WikiManager::sendMessage($this->kill(), 'interwikisetup');
         }
     }
     $tags['MESSAGE'] = WikiManager::getMessage();
     $tags['BACK'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to Wiki'), 'wiki');
     $tags['SITE_LIST_LABEL'] = dgettext('wiki', 'Site list');
     $tags['USAGE'] = sprintf(dgettext('wiki', 'To link to an interwiki site, use %s.'), 'WikiName:PageName');
     $tags['LIST_LABEL'] = dgettext('wiki', 'Site Name');
     $tags['LIST_URL'] = dgettext('wiki', 'URL');
     $tags['LIST_UPDATED'] = dgettext('wiki', 'Updated');
     $tags['LIST_ACTIONS'] = dgettext('wiki', 'Actions');
     $pager = new DBPager('wiki_interwiki', 'InterWiki');
     $pager->setModule('wiki');
     $pager->setTemplate('interwiki/setup.tpl');
     $pager->addToggle(PHPWS_LIST_TOGGLE_CLASS);
     $pager->addPageTags($tags);
     $pager->addRowTags('getTpl');
     $pager->setSearch('label');
     $pager->setDefaultOrder('label', 'asc');
     $pager->cacheQueries();
     $template['TITLE'] = dgettext('wiki', 'Interwiki Setup');
     $template['CONTENT'] = $pager->get();
     Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
 }
Example #17
0
 public static function denyAllowForm()
 {
     if (!Current_User::allow('access', 'admin_options')) {
         Current_User::disallow();
         return;
     }
     PHPWS_Core::initModClass('access', 'Allow_Deny.php');
     $form = new PHPWS_Form('allow_deny');
     $form->addHidden('module', 'access');
     $form->addHidden('command', 'post_deny_allow');
     $form->addCheck('allow_deny_enabled', 1);
     $form->setMatch('allow_deny_enabled', PHPWS_Settings::get('access', 'allow_deny_enabled'));
     $form->setLabel('allow_deny_enabled', dgettext('access', 'Allow/Deny enabled'));
     $form->addSubmit('go', dgettext('access', 'Go'));
     $result = Access::getAllowDeny();
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
     }
     $form->addText('allow_address');
     $form->addText('deny_address');
     $form->addSubmit('add_allow_address', dgettext('access', 'Add allowed IP'));
     $form->addSubmit('add_deny_address', dgettext('access', 'Add denied IP'));
     $db = new PHPWS_DB('access_allow_deny');
     $result = $db->getObjects('Access_Allow_Deny');
     $options['none'] = dgettext('access', '-- Choose option --');
     $options['active'] = dgettext('access', 'Activate');
     $options['deactive'] = dgettext('access', 'Deactivate');
     $options['delete'] = dgettext('access', 'Delete');
     if (PHPWS_Settings::get('access', 'allow_all')) {
         $allow_all = TRUE;
         $options['allow_all'] = dgettext('access', 'Do not allow all');
     } else {
         $allow_all = FALSE;
         $options['allow_all'] = dgettext('access', 'Allow all');
     }
     $form->addSelect('allow_action', $options);
     unset($options['allow_all']);
     if (PHPWS_Settings::get('access', 'deny_all')) {
         $deny_all = TRUE;
         $options['deny_all'] = dgettext('access', 'Do not deny all');
     } else {
         $deny_all = FALSE;
         $options['deny_all'] = dgettext('access', 'Deny all');
     }
     $form->addSelect('deny_action', $options);
     $template = $form->getTemplate();
     if ($allow_all) {
         $template['ALLOW_ALL_MESSAGE'] = dgettext('access', 'You have "Allow all" enabled. All rows below will be ignored.');
     }
     if ($deny_all) {
         $template['DENY_ALL_MESSAGE'] = dgettext('access', 'You have "Deny all" enabled. All rows below will be ignored.');
     }
     $js_vars['value'] = dgettext('access', 'Go');
     $js_vars['action_match'] = 'delete';
     $js_vars['message'] = dgettext('access', 'Are you sure you want to delete the checked ips?');
     $js_vars['select_id'] = 'allow_deny_allow_action';
     $template['ALLOW_ACTION_SUBMIT'] = javascript('select_confirm', $js_vars);
     $js_vars['select_id'] = 'allow_deny_deny_action';
     $template['DENY_ACTION_SUBMIT'] = javascript('select_confirm', $js_vars);
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         return dgettext('access', 'An error occurred when trying to access the allowed and denied ip records. Please check your logs.');
     } elseif (empty($result)) {
         $template['DENY_MESSAGE'] = dgettext('access', 'No denied ip addresses found.');
         $template['ALLOW_MESSAGE'] = dgettext('access', 'No allowed ip addresses found.');
     } else {
         foreach ($result as $allow_deny) {
             $action = PHPWS_Text::secureLink(dgettext('access', 'Delete'), 'access', array('ad_id' => $allow_deny->id, 'command' => 'delete_allow_deny'));
             if ($allow_deny->active) {
                 $active = dgettext('access', 'Yes');
             } else {
                 $active = dgettext('access', 'No');
             }
             if ($allow_deny->allow_or_deny) {
                 $check = sprintf('<input type="checkbox" name="allows[]" value="%s" />', $allow_deny->id);
                 $template['allow_rows'][] = array('ALLOW_CHECK' => $check, 'ALLOW_IP_ADDRESS' => $allow_deny->ip_address, 'ALLOW_ACTIVE' => $active, 'ALLOW_ACTION' => $action);
             } else {
                 $check = sprintf('<input type="checkbox" name="denys[]" value="%s" />', $allow_deny->id);
                 $template['deny_rows'][] = array('DENY_CHECK' => $check, 'DENY_IP_ADDRESS' => $allow_deny->ip_address, 'DENY_ACTIVE' => $active, 'DENY_ACTION' => $action);
             }
         }
         if (empty($template['allow_rows'])) {
             $template['ALLOW_MESSAGE'] = dgettext('access', 'No allowed ip addresses found.');
         }
         if (empty($template['deny_rows'])) {
             $template['DENY_MESSAGE'] = dgettext('access', 'No denied ip addresses found.');
         }
     }
     $template['CHECK_ALL_ALLOW'] = javascript('check_all', array('checkbox_name' => 'allows'));
     $template['CHECK_ALL_DENY'] = javascript('check_all', array('checkbox_name' => 'denys'));
     $template['ACTIVE_LABEL'] = dgettext('access', 'Active?');
     $template['ALLOW_TITLE'] = dgettext('access', 'Allowed IPs');
     $template['DENY_TITLE'] = dgettext('access', 'Denied IPs');
     $template['ACTION_LABEL'] = dgettext('access', 'Action');
     $template['IP_ADDRESS_LABEL'] = dgettext('access', 'IP Address');
     $template['WARNING'] = dgettext('access', 'Remember to "Update" your access file when finished changing IP rules.');
     return PHPWS_Template::process($template, 'access', 'forms/allow_deny.tpl');
 }
Example #18
0
 public static function update_settings()
 {
     $error = null;
     if (!Current_User::authorized('users', 'settings')) {
         Current_User::disallow();
         return;
     }
     if (!isset($_POST['site_contact'])) {
         $error = dgettext('users', 'You need to set a site contact address.');
     } elseif (!PHPWS_Text::isValidInput($_POST['site_contact'], 'email')) {
         $error = dgettext('users', 'Please enter a valid email address as a site contact.');
     }
     $settings['site_contact'] = $_POST['site_contact'];
     if (Current_User::isDeity()) {
         if (is_numeric($_POST['user_signup'])) {
             $settings['new_user_method'] = (int) $_POST['user_signup'];
         }
         $settings['session_warning'] = (int) isset($_POST['session_warning']);
         if (isset($_POST['show_login'])) {
             $settings['show_login'] = 1;
         } else {
             $settings['show_login'] = 0;
         }
         if (isset($_POST['allow_remember'])) {
             $settings['allow_remember'] = 1;
         } else {
             $settings['allow_remember'] = 0;
         }
         if (isset($_POST['graphic_confirm'])) {
             $settings['graphic_confirm'] = 1;
         } else {
             $settings['graphic_confirm'] = 0;
         }
         $settings['user_menu'] = $_POST['user_menu'];
         $settings['allow_new_users'] = (int) $_POST['allow_new_users'];
     }
     $settings['forbidden_usernames'] = str_replace(' ', "\n", strtolower(strip_tags($_POST['forbidden_usernames'])));
     PHPWS_Settings::set('users', $settings);
     if ($error) {
         return $error;
     } else {
         PHPWS_Settings::save('users');
         return true;
     }
 }
Example #19
0
 public function process()
 {
     if (!Current_User::allow('checkin')) {
         Current_User::disallow();
     }
     if (isset($_REQUEST['aop'])) {
         if ($_REQUEST['aop'] == 'switch') {
             if (Current_User::allow('checkin', 'settings')) {
                 $cmd = 'settings';
             } elseif (Current_User::allow('checkin', 'assign_visitors')) {
                 $cmd = 'assign';
             } else {
                 $cmd = 'waiting';
             }
         } else {
             $cmd = $_REQUEST['aop'];
         }
     } elseif ($_REQUEST['tab']) {
         $cmd = $_REQUEST['tab'];
     } else {
         PHPWS_Core::errorPage('404');
     }
     $js = false;
     $js = isset($_GET['print']);
     switch ($cmd) {
         case 'finish_meeting':
             $this->finishMeeting();
             PHPWS_Core::goBack();
             break;
         case 'start_meeting':
             $this->startMeeting();
             PHPWS_Core::goBack();
             break;
         case 'sendback':
             $this->sendBack();
             PHPWS_Core::goBack();
             break;
         case 'unavailable':
             $this->unavailable();
             PHPWS_Core::goBack();
             break;
         case 'available':
             $this->available();
             PHPWS_Core::goBack();
             break;
         case 'report':
             if (!PHPWS_Settings::get('checkin', 'staff_see_reports') && !Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             if (isset($_GET['daily_report'])) {
                 $this->dailyReport(isset($_GET['print']));
             } elseif (isset($_GET['summary_report'])) {
                 $this->summaryReport();
             } else {
                 $this->report();
             }
             //$this->report2();
             break;
         case 'daily_report':
             if (!PHPWS_Settings::get('checkin', 'staff_see_reports') && !Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             break;
         case 'month_report':
             if (!Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             $this->monthReport(isset($_GET['print']));
             break;
         case 'visitor_report':
             if (!Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             $this->visitorReport(isset($_GET['print']));
             break;
         case 'reassign':
             // Called via ajax
             if (Current_User::authorized('checkin', 'assign_visitors')) {
                 if (isset($_GET['staff_id']) && $_GET['staff_id'] >= 0 && isset($_GET['visitor_id'])) {
                     $this->loadVisitor($_GET['visitor_id']);
                     $staff_id = $this->visitor->assigned;
                     $db = new PHPWS_DB('checkin_visitor');
                     $db->addValue('assigned', (int) $_GET['staff_id']);
                     $db->addWhere('id', (int) $_GET['visitor_id']);
                     PHPWS_Error::logIfError($db->update());
                     printf('staff_id %s, visitor_id %s', $_GET['staff_id'], $_GET['visitor_id']);
                     $this->loadStaff($staff_id);
                     /*
                      if ($this->staff->status == 3) {
                      $this->staff->status = 0;
                      $this->staff->save();
                      }
                     */
                 }
             }
             exit;
             break;
         case 'move_up':
             if (Current_User::allow('checkin', 'assign_visitors')) {
                 $db = new PHPWS_DB('checkin_staff');
                 $db->moveRow('view_order', 'id', $_GET['staff_id'], 'up');
             }
             PHPWS_Core::goBack();
             break;
         case 'move_down':
             if (Current_User::allow('checkin', 'assign_visitors')) {
                 $db = new PHPWS_DB('checkin_staff');
                 $db->moveRow('view_order', 'id', $_GET['staff_id'], 'down');
             }
             PHPWS_Core::goBack();
             break;
         case 'assign':
             if (Current_User::allow('checkin', 'assign_visitors')) {
                 $this->panel->setCurrentTab('assign');
                 $this->assign();
             }
             break;
         case 'post_note':
             $this->loadVisitor();
             $this->saveNote();
             PHPWS_Core::goBack();
             break;
         case 'hide_panel':
             PHPWS_Cookie::write('checkin_hide_panel', 1);
             PHPWS_Core::goBack();
             break;
         case 'show_panel':
             PHPWS_Cookie::delete('checkin_hide_panel');
             PHPWS_Core::goBack();
             $this->panel->setCurrentTab('assign');
             $this->assign();
             break;
         case 'hide_sidebar':
             PHPWS_Cookie::write('checkin_hide_sidebar', 1);
             PHPWS_Core::goBack();
             $this->panel->setCurrentTab('assign');
             $this->use_sidebar = false;
             $this->assign();
             break;
         case 'show_sidebar':
             PHPWS_Cookie::delete('checkin_hide_sidebar');
             PHPWS_Core::goBack();
             $this->panel->setCurrentTab('assign');
             $this->assign();
             break;
         case 'waiting':
             $this->panel->setCurrentTab('waiting');
             $this->loadCurrentStaff();
             $this->waiting();
             break;
         case 'repeats':
             $this->repeats();
             break;
         case 'small_wait':
             $this->loadCurrentStaff();
             $this->waiting(true);
             $js = true;
             break;
         case 'remove_visitor':
             if (Current_User::allow('checkin', 'remove_visitors')) {
                 $this->removeVisitor();
             }
             PHPWS_Core::goBack();
             break;
         case 'settings':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->panel->setCurrentTab('settings');
                 $this->settings();
             }
             break;
         case 'reasons':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->panel->setCurrentTab('reasons');
                 $this->reasons();
             }
             break;
         case 'post_reason':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->loadReason();
                 if ($this->postReason()) {
                     $this->reason->save();
                     PHPWS_Core::reroute('index.php?module=checkin&tab=reasons');
                 } else {
                     $this->editReason();
                 }
             }
             break;
         case 'staff':
             $this->panel->setCurrentTab('staff');
             $this->staff();
             break;
         case 'edit_staff':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->loadStaff(null, true);
                 $this->editStaff();
             }
             break;
         case 'search_users':
             $this->searchUsers();
             break;
         case 'update_reason':
             if (Current_User::allow('checkin', 'settings')) {
                 if (Current_User::authorized('checkin', 'settings')) {
                     $this->updateReason();
                 }
                 $this->panel->setCurrentTab('settings');
                 $this->settings();
             }
             break;
         case 'post_staff':
             if (!Current_User::authorized('checkin', 'settings')) {
                 Current_User::disallow();
             }
             if ($this->postStaff()) {
                 // save post
                 $this->staff->save();
                 $this->staff->saveReasons();
                 PHPWS_Core::reroute('index.php?module=checkin&tab=staff');
             } else {
                 // post failed
                 $this->loadStaff();
                 $this->editStaff();
             }
             break;
         case 'post_settings':
             // from Checkin_Admin::settings
             if (Current_User::authorized('checkin', 'settings')) {
                 $this->postSettings();
             }
             PHPWS_Core::reroute('index.php?module=checkin&tab=settings');
             break;
         case 'edit_reason':
             $this->loadReason();
             $this->editReason();
             break;
         case 'delete_reason':
             $this->loadReason();
             $this->reason->delete();
             PHPWS_Core::goBack();
             break;
         case 'deactivate_staff':
             PHPWS_Core::initModClass('checkin', 'Staff.php');
             $staff = new Checkin_Staff($_GET['id']);
             $staff->active = 0;
             $staff->save();
             PHPWS_Core::goBack();
             break;
         case 'activate_staff':
             PHPWS_Core::initModClass('checkin', 'Staff.php');
             $staff = new Checkin_Staff($_GET['id']);
             $staff->active = 1;
             $staff->save();
             PHPWS_Core::goBack();
             break;
             // This is for testing purposes and never happens in actual use
         // This is for testing purposes and never happens in actual use
         case 'unassignAll':
             $this->unassignAll();
             break;
             // This is for testing purposes and never happens in actual use
         // This is for testing purposes and never happens in actual use
         case 'auto_assign':
             $this->autoAssign();
             break;
     }
     if (empty($this->content)) {
         $this->content = dgettext('checkin', 'Command not recognized.');
     }
     if ($js) {
         $tpl['TITLE'] =& $this->title;
         $tpl['CONTENT'] =& $this->content;
         $tpl['MESSAGE'] =& $this->message;
         $content = PHPWS_Template::process($tpl, 'checkin', 'main.tpl');
         Layout::nakedDisplay($content, $this->title);
     } else {
         if (is_array($this->message)) {
             $this->message = implode('<br />', $this->message);
         }
         if (!$this->use_sidebar) {
             Layout::collapse();
         }
         if ($this->use_panel) {
             Layout::add(PHPWS_ControlPanel::display($this->panel->display($this->content, $this->title, $this->message)));
         } else {
             $tpl['TITLE'] =& $this->title;
             $tpl['CONTENT'] =& $this->content;
             $tpl['MESSAGE'] =& $this->message;
             Layout::add(PHPWS_Template::process($tpl, 'checkin', 'main.tpl'));
         }
     }
 }
Example #20
0
 public function adminMenu()
 {
     if (!Current_User::allow('signup')) {
         Current_User::disallow();
     }
     $this->loadPanel();
     $javascript = false;
     $this->loadMessage();
     $command = $_REQUEST['aop'];
     switch ($command) {
         case 'add_slot_peep':
             $javascript = true;
             $this->loadPeep();
             $this->loadForm('edit_peep');
             break;
         case 'menu':
             if (!isset($_GET['tab'])) {
                 $this->loadForm('list');
             } else {
                 $this->loadForm($_GET['tab']);
             }
             break;
         case 'delete_sheet':
             $this->loadSheet();
             $this->sheet->delete();
             $this->message = dgettext('signup', 'Signup sheet deleted.');
             $this->loadForm('list');
             break;
         case 'edit_sheet':
             $this->loadForm('edit_sheet');
             break;
         case 'edit_slot_peep':
             $javascript = true;
             $this->loadPeep();
             $this->loadForm('edit_peep');
             break;
         case 'edit_slot_popup':
             $javascript = true;
             $this->loadSlot();
             $this->loadForm('edit_slot_popup');
             break;
         case 'edit_peep_popup':
             $javascript = true;
             $this->loadSlot();
             $this->loadForm('edit_peep_popup');
             break;
         case 'print_applicants':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->printApplicants();
             exit;
             break;
         case 'email_applicants':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadEmail();
             $this->loadSheet();
             $this->loadForm('email_applicants');
             break;
         case 'post_email':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadEmail();
             $this->loadSheet();
             if ($this->postEmail()) {
                 $this->sendEmail();
             } else {
                 $this->loadForm('email_applicants');
             }
             break;
         case 'slot_listing':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->slotListing();
             exit;
             break;
         case 'csv_applicants':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->csvExport();
             exit;
             break;
         case 'send_email':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->sendEmail();
             break;
         case 'edit_slots':
             $this->loadSheet();
             $this->loadForm('edit_slots');
             break;
         case 'search_slot':
             $this->searchSlots();
             break;
         case 'post_peep':
             $javascript = true;
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             if ($this->postPeep()) {
                 // Since added by an admin, automatically registered
                 $this->peep->registered = 1;
                 if (PHPWS_Error::logIfError($this->peep->save())) {
                     $this->forwardMessage(dgettext('signup', 'Error occurred when saving applicant.'));
                 } else {
                     $this->forwardMessage(dgettext('signup', 'Applicant saved successfully.'));
                 }
                 javascript('close_refresh');
                 Layout::nakedDisplay();
             } else {
                 $this->loadForm('edit_peep');
             }
             break;
         case 'post_sheet':
             $this->loadSheet();
             if (!Current_User::authorized('signup', 'edit_sheet', $this->sheet->id, 'sheet')) {
                 Current_User::disallow();
             }
             if ($this->postSheet()) {
                 if (!$this->sheet->id && PHPWS_Core::isPosted()) {
                     $this->message = dgettext('signup', 'Sheet previously posted.');
                     $this->loadForm('edit_sheet');
                 } else {
                     $new_sheet = !$this->sheet->id;
                     if (PHPWS_Error::logIfError($this->sheet->save())) {
                         $this->forwardMessage(dgettext('signup', 'Error occurred when saving sheet.'));
                         PHPWS_Core::reroute('index.php?module=signup&aop=list');
                     } else {
                         $this->forwardMessage(dgettext('signup', 'Sheet saved successfully.'));
                         if ($new_sheet) {
                             PHPWS_Core::reroute('index.php?module=signup&aop=edit_slots&sheet_id=' . $this->sheet->id);
                         } else {
                             $this->loadForm('list');
                         }
                     }
                 }
             } else {
                 $this->loadForm('edit_sheet');
             }
             break;
         case 'post_slot':
             $javascript = true;
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             if ($this->postSlot()) {
                 if (PHPWS_Error::logIfError($this->slot->save())) {
                     $this->forwardMessage(dgettext('signup', 'Error occurred when saving slot.'));
                 } else {
                     $this->forwardMessage(dgettext('signup', 'Slot saved successfully.'));
                 }
                 javascript('close_refresh');
                 Layout::nakedDisplay();
             } else {
                 $this->loadForm('edit_slot_popup');
             }
             break;
         case 'move_peep':
             $this->loadPeep();
             $result = $this->movePeep();
             if (PHPWS_Error::logIfError($result) || !$result) {
                 $this->forwardMessage(dgettext('signup', 'Error occurred when moving applicant. Slot may be full.'));
             }
             PHPWS_Core::goBack();
             break;
         case 'move_top':
             $this->loadSlot();
             $this->slot->moveTop();
             PHPWS_Core::goBack();
             break;
         case 'move_up':
             $this->loadSlot();
             $this->slot->moveUp();
             PHPWS_Core::goBack();
             break;
         case 'move_down':
             $this->loadSlot();
             $this->slot->moveDown();
             PHPWS_Core::goBack();
             break;
         case 'move_bottom':
             $this->loadSlot();
             $this->slot->moveBottom();
             PHPWS_Core::goBack();
             break;
         case 'delete_slot':
             $this->loadSlot();
             $this->deleteSlot();
             break;
         case 'delete_slot_peep':
             $this->loadPeep();
             $this->peep->delete();
             PHPWS_Core::goBack();
             break;
         case 'report':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->loadForm('report');
             break;
         case 'alpha_order':
         case 'reset_slot_order':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->resetSlots($command);
             $this->forwardMessage(dgettext('signup', 'Slot order reset.'));
             PHPWS_Core::reroute('index.php?module=signup&sheet_id=' . $this->sheet->id . '&aop=edit_slots&authkey=' . Current_User::getAuthKey());
             break;
     }
     $tpl['TITLE'] = $this->title;
     $tpl['CONTENT'] = $this->content;
     $tpl['MESSAGE'] = $this->message;
     if ($javascript) {
         $fonts = '<link rel="stylesheet" type="text/css" href="' . PHPWS_SOURCE_HTTP . 'themes/bootstrap/font-awesome/css/font-awesome.min.css" />
         <link rel="stylesheet" type="text/css" href="' . PHPWS_SOURCE_HTTP . 'themes/bootstrap/css/bootstrap.min.css" />';
         \Layout::addJSHeader($fonts);
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'signup', 'main.tpl'));
     } else {
         $this->panel->setContent(PHPWS_Template::process($tpl, 'signup', 'main.tpl'));
         Layout::add(PHPWS_ControlPanel::display($this->panel->display()));
     }
 }
Example #21
0
 public function postSchedule()
 {
     $default_public = PHPWS_Settings::get('calendar', 'public_schedule');
     if ($this->calendar->schedule->post()) {
         if (!$this->allowSchedulePost()) {
             Current_User::disallow();
             return;
         }
         $result = $this->calendar->schedule->save();
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
             if (PHPWS_Calendar::isJS()) {
                 $this->sendMessage(dgettext('calendar', 'An error occurred when saving your schedule.'), null, false);
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             } else {
                 $this->sendMessage(dgettext('calendar', 'An error occurred when saving your schedule.'), 'aop=schedules');
             }
         } else {
             if ($this->calendar->schedule->public && $default_public < 1) {
                 PHPWS_Settings::set('calendar', 'public_schedule', $this->calendar->schedule->id);
                 PHPWS_Settings::save('calendar');
             }
             if (!$this->calendar->schedule->public && $this->calendar->schedule->id == $default_public) {
                 PHPWS_Settings::set('calendar', 'public_schedule', 0);
                 PHPWS_Settings::save('calendar');
             }
             if (PHPWS_Calendar::isJS()) {
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             } else {
                 $this->sendMessage(dgettext('calendar', 'Schedule saved.'), 'aop=schedules');
             }
         }
     } else {
         $this->message = $this->calendar->schedule->_error;
         $this->editSchedule();
     }
 }
Example #22
0
 /**
  * Delete
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function delete()
 {
     if (!Current_User::authorized('wiki', 'upload_images') && !(PHPWS_Settings::get('wiki', 'allow_image_upload') && Current_User::isLogged())) {
         Current_User::disallow(dgettext('wiki', 'User attempted access to image delete.'));
         return;
     }
     if (isset($_REQUEST['yes'])) {
         @unlink(PHPWS_HOME_DIR . 'images/wiki/' . $this->getFilename());
         $db = new PHPWS_DB('wiki_images');
         $db->addWhere('id', $this->getId());
         if (PHPWS_Error::logIfError($db->delete())) {
             return dgettext('wiki', 'Error deleting image.');
         }
         return dgettext('wiki', 'Image deleted!');
     } else {
         if (isset($_REQUEST['no'])) {
             return dgettext('wiki', 'Image was not deleted!');
         }
     }
     $tags = array();
     $tags['MESSAGE'] = dgettext('wiki', 'Are you sure you want to delete this image?');
     $tags['YES'] = PHPWS_Text::secureLink(dgettext('wiki', 'Yes'), 'wiki', array('op' => 'doimagedelete', 'yes' => 1, 'id' => $this->getId()));
     $tags['NO'] = PHPWS_Text::secureLink(dgettext('wiki', 'No'), 'wiki', array('op' => 'doimagedelete', 'no' => 1, 'id' => $this->getId()));
     $tags['WIKIPAGE'] = '<img src="images/wiki/' . $this->getFilename() . '" alt="" />';
     return PHPWS_Template::processTemplate($tags, 'wiki', 'confirm.tpl');
 }
 public static function admin()
 {
     if (!Current_User::allow('layout')) {
         Current_User::disallow();
     }
     PHPWS_Core::initModClass('controlpanel', 'Panel.php');
     $title = $content = null;
     $panel = Layout_Admin::adminPanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $panel->getCurrentTab();
     }
     switch ($command) {
         case 'arrange':
             $title = dgettext('layout', 'Arrange Layout');
             $content[] = Layout_Admin::arrangeForm();
             break;
         case 'turn_off_box_move':
             Layout::moveBoxes(false);
             PHPWS_Core::goBack();
             break;
         case 'post_style_change':
             $result = Layout_Admin::postStyleChange();
             if (PHPWS_Error::isError($result)) {
                 PHPWS_Error::log($result);
             }
             javascript('close_refresh');
             break;
         case 'reset_boxes':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::resetDefaultBoxes();
             unset($_SESSION['Layout_Settings']);
             PHPWS_Core::reroute('index.php?module=layout&action=admin&authkey=' . Current_User::getAuthKey());
             break;
         case 'move_boxes_on':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::moveBoxes(true);
             PHPWS_Core::goBack();
             break;
         case 'move_boxes_off':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::moveBoxes(false);
             PHPWS_Core::goBack();
             break;
         case 'confirmThemeChange':
             $title = dgettext('layout', 'Themes');
             if (isset($_POST['confirm'])) {
                 Layout_Admin::changeTheme();
                 PHPWS_Core::reroute('index.php?module=layout&action=admin&tab=theme');
                 exit;
             } else {
                 Layout::reset();
             }
             $content[] = Layout_Admin::adminThemes();
             break;
         case 'meta':
             $title = dgettext('layout', 'Edit Meta Tags');
             $content[] = Layout_Admin::metaForm();
             break;
         case 'clear_templates':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             $files = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'templates/cache', false, true);
             if (!empty($files) && is_array($files)) {
                 foreach ($files as $fn) {
                     $delete_cache_path = "templates/cache/{$fn}";
                     if (is_file($delete_cache_path)) {
                         unlink('templates/cache/' . $fn);
                     }
                 }
             }
             PHPWS_Core::goBack();
             break;
         case 'clear_cache':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             PHPWS_Cache::clearCache();
             PHPWS_Core::goBack();
             break;
         case 'moveBox':
             $result = Layout_Admin::moveBox();
             PHPWS_Error::logIfError($result);
             javascript('close_refresh');
             Layout::nakedDisplay();
             break;
         case 'postMeta':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout_Admin::postMeta();
             if (isset($_POST['key_id'])) {
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             }
             Layout::reset();
             $title = dgettext('layout', 'Edit Meta Tags');
             $template['MESSAGE'] = dgettext('layout', 'Meta Tags updated.');
             $content[] = Layout_Admin::metaForm();
             break;
         case 'demo_fail':
             unset($_SESSION['Layout_Settings']);
             Layout::checkSettings();
             PHPWS_Core::reroute('index.php?module=layout&amp;action=admin&amp;command=confirmThemeChange');
             break;
         case 'demo_theme':
             $title = dgettext('layout', 'Confirm Theme Change');
             $content[] = dgettext('layout', 'If you are happy with the change, click the appropiate button.');
             $content[] = dgettext('layout', 'Failure to respond in ten seconds, reverts phpWebSite to the default theme.');
             $content[] = Layout_Admin::confirmThemeChange();
             break;
         case 'postTheme':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             if ($_POST['default_theme'] != $_SESSION['Layout_Settings']->current_theme) {
                 Layout::reset($_POST['default_theme']);
                 PHPWS_Core::reroute('index.php?module=layout&action=admin&command=demo_theme&authkey=' . Current_User::getAuthKey());
             } else {
                 PHPWS_Settings::set('layout', 'include_css_order', (int) $_POST['include_css_order']);
                 PHPWS_Settings::save('layout');
                 $title = dgettext('layout', 'Themes');
                 $content[] = Layout_Admin::adminThemes();
             }
             break;
         case 'theme':
             $title = dgettext('layout', 'Themes');
             $content[] = Layout_Admin::adminThemes();
             break;
         case 'js_style_change':
             $content = Layout_Admin::jsStyleChange();
             if (empty($content)) {
                 javascript('close_refresh');
             }
             Layout::nakedDisplay($content, dgettext('layout', 'Change CSS'));
             break;
         case 'page_meta_tags':
             $content = Layout_Admin::pageMetaTags((int) $_REQUEST['key_id']);
             if (empty($content)) {
                 javascript('close_refresh');
             }
             Layout::nakedDisplay($content, dgettext('layout', 'Set meta tags'));
             break;
         case 'move_popup':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout_Admin::moveBoxMenu();
             break;
     }
     $template['TITLE'] = $title;
     if (isset($content)) {
         $template['CONTENT'] = implode('<br />', $content);
     }
     if (isset($message)) {
         $template['MESSAGE'] = $message;
     }
     $final = PHPWS_Template::process($template, 'layout', 'main.tpl');
     $panel->setContent($final);
     Layout::add(PHPWS_ControlPanel::display($panel->display()));
 }
Example #24
0
 /**
  * Settings Administration
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function admin()
 {
     if (!Current_User::authorized('wiki', 'edit_settings')) {
         Current_User::disallow(dgettext('wiki', 'User attempted access to Wiki Settings administration.'));
         return;
     }
     javascript('jquery');
     PHPWS_Core::initModClass('wiki', 'WikiPage.php');
     PHPWS_Core::initCoreClass('DBPager.php');
     if (isset($_POST['op']) && $_POST['op'] == 'savesettings') {
         WikiManager::sendMessage(WikiSettings::save(), 'admin');
     }
     $tabs = 1;
     $form = new PHPWS_Form();
     $msg = dgettext('wiki', 'Enabling this setting will show the default wiki page on the home page of the web site.');
     $form->addCheck('show_on_home');
     $form->setMatch('show_on_home', PHPWS_Settings::get('wiki', 'show_on_home'));
     $form->addTplTag('SHOW_ON_HOME_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Show on home page'), 'id' => 'show_on_home_info', 'message' => $msg)));
     $form->setTab('show_on_home', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will allow all visitors to view the wiki.
                              When disabled, only registered users can view the wiki.');
     $form->addCheck('allow_anon_view');
     $form->setMatch('allow_anon_view', PHPWS_Settings::get('wiki', 'allow_anon_view'));
     $form->addTplTag('ALLOW_ANON_VIEW_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Allow anonymous viewing'), 'id' => 'allow_anon_view_info', 'message' => $msg)));
     $form->setTab('allow_anon_view', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will allow all registered users to edit pages.  When disabled, only
                              registered users with admin privileges can edit pages. Anonymous visitors can never edit pages.');
     $form->addCheck('allow_page_edit');
     $form->setMatch('allow_page_edit', PHPWS_Settings::get('wiki', 'allow_page_edit'));
     $form->addTplTag('ALLOW_PAGE_EDIT_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Allow all registered users to edit pages'), 'id' => 'allow_page_edit_info', 'message' => $msg)));
     $form->setTab('allow_page_edit', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will allow all registered users to upload images.  When disabled, only
                              registered users with admin privileges can upload images.  Anonymous visitors can never upload images.');
     $form->addCheck('allow_image_upload');
     $form->setMatch('allow_image_upload', PHPWS_Settings::get('wiki', 'allow_image_upload'));
     $form->addTplTag('ALLOW_IMAGE_UPLOAD_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Allow all registered users to upload images'), 'id' => 'allow_image_upload_info', 'message' => $msg)));
     $form->setTab('allow_image_upload', $tabs++);
     $msg = dgettext('wiki', 'When enabled, the page text will also be parsed by the BBCode parser instead of just the Text_Wiki
                              parser. Keep in mind that everything you can do with BBCode can be done with wikitax.');
     $form->addCheck('allow_bbcode');
     $form->setMatch('allow_bbcode', PHPWS_Settings::get('wiki', 'allow_bbcode'));
     $form->addTplTag('ALLOW_BBCODE_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Enable BBCode parser'), 'id' => 'allow_bbcode_info', 'message' => $msg)));
     $form->setTab('allow_bbcode', $tabs++);
     $msg = dgettext('wiki', 'When enabled, the extended character set will be supported for wiki page names.  For example,
                              German umlauts would be allowed in a wiki page name.');
     $form->addCheck('ext_chars_support');
     $form->setMatch('ext_chars_support', PHPWS_Settings::get('wiki', 'ext_chars_support'));
     $form->addTplTag('EXT_CHARS_SUPPORT_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Enable extended character set'), 'id' => 'ext_chars_support_info', 'message' => $msg)));
     $form->setTab('ext_chars_support', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will add the current wiki page title to the site title which appears in the
                              browser title bar.  The site title is sometimes used in themes meaning this setting would add the
                              wiki page title to the theme as well.');
     $form->addCheck('add_to_title');
     $form->setMatch('add_to_title', PHPWS_Settings::get('wiki', 'add_to_title'));
     $form->addTplTag('ADD_TO_TITLE_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Add wiki page title to site title'), 'id' => 'add_to_title_info', 'message' => $msg)));
     $form->setTab('add_to_title', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will format the current wiki page title before being displayed anywhere
                              (excluding the wiki page text) by the module.  The page title in the page text will have to be formatted
                              manually if you do not like the standard WordsSmashedTogether default. The automatic formatting by the
                              module will add spaces to the WikiPageTitle, making it Wiki Page Title.<br /><br />Remember, you will
                              still have to refer to the page as WikiPageTitle in the page text, but you can change its appearance by
                              using [WikiPageTitle Your Formatted Title Here].<br /><br />If this is confusing to you or others, it is
                              recommended to not use this feature.');
     $form->addCheck('format_title');
     $form->setMatch('format_title', PHPWS_Settings::get('wiki', 'format_title'));
     $form->addTplTag('FORMAT_TITLE_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Format the wiki page title before displaying'), 'id' => 'format_title_info', 'message' => $msg)));
     $form->setTab('format_title', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will show the <b>Last modified by</b> information on each wiki page. However,
                              if UPDATED_INFO tag is not in the view template, the information will never show up, regardless of how
                              this option is set.');
     $form->addCheck('show_modified_info');
     $form->setMatch('show_modified_info', PHPWS_Settings::get('wiki', 'show_modified_info'));
     $form->addTplTag('SHOW_MODIFIED_INFO_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Show page modified information'), 'id' => 'show_modified_info_info', 'message' => $msg)));
     $form->setTab('show_modified_info', $tabs++);
     $msg = dgettext('wiki', 'By default, when comparing two page revisions, the changes will be presented in a two column format.
                              On fixed width layouts this could cause excessive horizontal scrolling.  Setting this option will change
                              the comparison to a single column format.');
     $form->addCheck('diff_type');
     $form->setMatch('diff_type', PHPWS_Settings::get('wiki', 'diff_type') == 'one_col');
     $form->addTplTag('DIFF_TYPE_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Use single column diff'), 'id' => 'diff_type_info', 'message' => $msg)));
     $form->setTab('diff_type', $tabs++);
     $msg = dgettext('wiki', 'Enabling this setting will email a notification to the Wiki Administrator email address on every page edit.');
     $form->addCheck('monitor_edits');
     $form->setMatch('monitor_edits', PHPWS_Settings::get('wiki', 'monitor_edits'));
     $form->addTplTag('MONITOR_EDITS_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Monitor Edits'), 'id' => 'monitor_edits_info', 'message' => $msg)));
     $form->setTab('monitor_edits', $tabs++);
     $msg = dgettext('wiki', 'Enter in the email address of the Wiki administrator.  If this field is left blank or has an invalid email
                              address, then the change will be ignored.');
     $form->addText('admin_email', PHPWS_Settings::get('wiki', 'admin_email'));
     $form->setSize('admin_email', 25);
     $form->addTplTag('ADMIN_EMAIL_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Wiki Admin Email'), 'id' => 'admin_email_info', 'message' => $msg)));
     $form->setTab('admin_email', $tabs++);
     $msg = dgettext('wiki', 'This is the body text of the email sent when wiki pages are edited.  HTML will be stripped out as the email
                              will be sent as Plain Text.  You can use variables [page] and [url] to represent the name of the wiki page
                              and the url to view the page, respectively.');
     $form->addTextArea('email_text', PHPWS_Settings::get('wiki', 'email_text'));
     $form->setWidth('email_text', '80%');
     $form->setRows('email_text', 5);
     $form->addTplTag('EMAIL_TEXT_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Email Notification Text'), 'id' => 'email_text_info', 'message' => $msg)));
     $form->setTab('email_text', $tabs++);
     $msg = dgettext('wiki', 'The default page to display when no instructions are passed to the Wiki module.');
     $form->addText('default_page', PHPWS_Settings::get('wiki', 'default_page'));
     $form->setSize('default_page', 25, 100);
     $form->addTplTag('DEFAULT_PAGE_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Default page'), 'id' => 'default_page_info', 'message' => $msg)));
     $form->setTab('default_page', $tabs++);
     $msg = dgettext('wiki', 'This controls where external pages will appear. _blank opens the new page in a new window. _parent is
                              used in the situation where a frameset file is nested inside another frameset file. A link in one of
                              the inner frameset documents which uses _parent will load the new page where the inner frameset file had
                              been. If the current page\'s frameset file does not have any parent, then _parent works exactly like
                              _top - the new document is loaded in the full window. _self puts the new page in the same window and
                              frame as the current page.');
     $options = array('_blank' => '_blank', '_parent' => '_parent', '_self' => '_self', '_top' => '_top');
     $form->addSelect('ext_page_target', $options);
     $form->setMatch('ext_page_target', PHPWS_Settings::get('wiki', 'ext_page_target'));
     $form->addTplTag('EXT_PAGE_TARGET_LABEL', javascript('slider', array('link' => dgettext('wiki', 'Target for external links'), 'id' => 'ext_page_target_info', 'message' => $msg)));
     $form->setTab('ext_page_target', $tabs++);
     $form->addCheck('immutable_page');
     $form->setMatch('immutable_page', PHPWS_Settings::get('wiki', 'immutable_page'));
     $form->setLabel('immutable_page', dgettext('wiki', 'Show immutable page text (if applicable)'));
     $form->setTab('immutable_page', $tabs++);
     $form->addCheck('raw_text');
     $form->setMatch('raw_text', PHPWS_Settings::get('wiki', 'raw_text'));
     $form->setLabel('raw_text', dgettext('wiki', 'Show raw text link'));
     $form->setTab('raw_text', $tabs++);
     $form->addCheck('print_view');
     $form->setMatch('print_view', PHPWS_Settings::get('wiki', 'print_view'));
     $form->setLabel('print_view', dgettext('wiki', 'Show print view link'));
     $form->setTab('print_view', $tabs++);
     $form->addCheck('what_links_here');
     $form->setMatch('what_links_here', PHPWS_Settings::get('wiki', 'what_links_here'));
     $form->setLabel('what_links_here', dgettext('wiki', 'Show what links here link'));
     $form->setTab('what_links_here', $tabs++);
     $form->addCheck('recent_changes');
     $form->setMatch('recent_changes', PHPWS_Settings::get('wiki', 'recent_changes'));
     $form->setLabel('recent_changes', dgettext('wiki', 'Show recent changes link'));
     $form->setTab('recent_changes', $tabs++);
     $form->addCheck('random_page');
     $form->setMatch('random_page', PHPWS_Settings::get('wiki', 'random_page'));
     $form->setLabel('random_page', dgettext('wiki', 'Show random page link'));
     $form->setTab('random_page', $tabs++);
     $form->addCheck('discussion');
     $form->setMatch('discussion', PHPWS_Settings::get('wiki', 'discussion'));
     $form->setLabel('discussion', dgettext('wiki', 'Enable discussion for registered users'));
     $form->setTab('discussion', $tabs++);
     $form->addCheck('discussion_anon');
     $form->setMatch('discussion_anon', PHPWS_Settings::get('wiki', 'discussion_anon'));
     $form->setLabel('discussion_anon', dgettext('wiki', 'Allow anonymous discussion'));
     $form->setTab('discussion_anon', $tabs++);
     $form->addSubmit('save', dgettext('wiki', 'Save Settings'));
     $form->setTab('save', $tabs);
     $form->addHidden('module', 'wiki');
     $form->addHidden('op', 'savesettings');
     $tags = $form->getTemplate();
     $tags['BACK'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to Wiki'), 'wiki');
     $tags['MESSAGE'] = WikiManager::getMessage();
     $tags['MENU_ITEMS_LABEL'] = dgettext('wiki', 'Menu Items');
     $tags['DISCUSSION_SECTION_LABEL'] = dgettext('wiki', 'Discussion');
     $tags['SETTINGS_LABEL'] = dgettext('wiki', 'Settings');
     $tags['PAGES_LABEL'] = dgettext('wiki', 'Wiki Pages');
     $tags['TITLE'] = dgettext('wiki', 'Page Name');
     $tags['UPDATED'] = dgettext('wiki', 'Updated');
     $tags['VERSION'] = dgettext('wiki', 'Version');
     $tags['HITS'] = dgettext('wiki', 'Hits');
     $tags['ORPHANED'] = dgettext('wiki', 'Orphaned');
     $tags['ACTIONS'] = dgettext('wiki', 'Actions');
     $pager = new DBPager('wiki_pages', 'WikiPage');
     $pager->setModule('wiki');
     $pager->setTemplate('admin.tpl');
     $pager->addToggle(PHPWS_LIST_TOGGLE_CLASS);
     $pager->addPageTags($tags);
     $pager->addRowTags('getTpl');
     $pager->setSearch('title', 'pagetext');
     $pager->setDefaultOrder('title', 'asc');
     $pager->cacheQueries();
     $template['TITLE'] = dgettext('wiki', 'Wiki Administration');
     $template['CONTENT'] = $pager->get();
     Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
 }
Example #25
0
 public static function postBlock(Block_Item $block)
 {
     if (!Current_User::authorized('block', 'edit_block', $block->id)) {
         Current_User::disallow();
     }
     if (isset($_POST['pick_block'])) {
         self::lockBlock($_POST['block_list'], $_POST['key_id']);
         return true;
     }
     if (isset($_POST['hide_title'])) {
         $block->hide_title = 1;
     } else {
         $block->hide_title = 0;
     }
     if (isset($_POST['hide_narrow'])) {
         $block->hide_narrow = 1;
     } else {
         $block->hide_narrow = 0;
     }
     $block->setTitle($_POST['title']);
     $block->setContent($_POST['block_content']);
     if (empty($block->title)) {
         $content = trim(strip_tags($_POST['block_content']));
         if (!empty($content)) {
             try {
                 $offset = strpos($content, ' ', 10);
                 $title_sub = ucfirst(substr($content, 0, $offset));
             } catch (\Exception $e) {
                 /**
                  * strpos will throw a warning which, depending on error settings,
                  * is changed into an exception.
                  * The fastest way to check for a character in a string is strpos, so
                  * error checking cannot be done.
                  * 
                  */
                 if ($e->getCode() == 0) {
                     $title_sub = substr($content, 0, 15);
                 } else {
                     throw $e;
                 }
             }
             $block->setTitle($title_sub);
             $block->hide_title = 1;
         } else {
             $block->setTitle(t('Untitled'));
             $block->hide_title = 1;
         }
     }
     if (empty($block->content) && empty($block->title) && empty($block->file_id)) {
         return false;
     } else {
         return true;
     }
 }
Example #26
0
 public function post_entry()
 {
     if (!Current_User::authorized('blog', 'edit_blog')) {
         Current_User::disallow();
     }
     if (empty($_POST['title'])) {
         $this->_error[] = dgettext('blog', 'Missing title.');
     } else {
         $this->title = strip_tags($_POST['title']);
     }
     $summary_and_entry = $_POST['summary'];
     if (!$this->id && strlen($summary_and_entry) > 1000) {
         if (!preg_match('/<hr[^>]?/', $summary_and_entry)) {
             $paragraphs = explode('<p>', $summary_and_entry);
             if (count($paragraphs) > 3) {
                 $paragraphs[2] .= '<hr />';
                 $summary_and_entry = implode('<p>', $paragraphs);
             }
         }
     }
     if (empty($summary_and_entry)) {
         $this->_error[] = dgettext('blog', 'Your submission must have some content.');
     } else {
         // We don't catch the regular expression result because we only care about matches
         preg_replace_callback('@(.*?)<hr[^>]*/>(.*)@s', function ($matches) {
             $GLOBALS['split_summary'] = $matches;
         }, $summary_and_entry);
         if (isset($GLOBALS['split_summary'])) {
             $this->setSummary($GLOBALS['split_summary'][1]);
             $this->setEntry($GLOBALS['split_summary'][2]);
         } else {
             $this->setSummary($summary_and_entry);
             $this->entry = null;
         }
     }
     if (isset($_POST['image_id'])) {
         $this->image_id = (int) $_POST['image_id'];
     }
     if (isset($_POST['thumbnail'])) {
         $this->thumbnail = 1;
     } else {
         $this->thumbnail = 0;
     }
     if (empty($this->author)) {
         $this->author = Current_User::getDisplayName();
     }
     if (empty($_POST['publish_date'])) {
         $this->publish_date = time();
     } else {
         $this->publish_date = strtotime($_POST['publish_date']);
     }
     if (empty($_POST['expire_date'])) {
         $this->expire_date = 0;
     } else {
         $this->expire_date = strtotime($_POST['expire_date']);
     }
     $this->approved = 1;
     $link_choices[] = 'none';
     $link_choices[] = 'default';
     $link_choices[] = 'readmore';
     $link_choices[] = 'parent';
     $link_choices[] = 'url';
     $image_link =& $_POST['image_link'];
     if (!in_array($image_link, $link_choices)) {
         $this->image_link = 'default';
     } elseif ($_POST['image_link'] != 'url') {
         $this->image_link = $image_link;
     } else {
         $url = $_POST['image_url'];
         if (!empty($url) || $url == 'http://') {
             $this->image_link = PHPWS_Text::checkLink($url);
         } else {
             $this->image_link = 'default';
         }
     }
     return true;
 }
Example #27
0
 function doMove()
 {
     if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) || !$this->allow_edit) {
         Current_User::disallow(dgettext('wiki', 'User attempted to execute a wiki page move.'));
         return;
     }
     if (strlen($_POST['newpage']) == 0) {
         WikiManager::sendMessage(dgettext('wiki', 'Please supply a new page title'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $db = new PHPWS_DB('wiki_pages');
     $db->addWhere('title', $_POST['newpage']);
     $result = $db->select();
     if ($result != NULL) {
         WikiManager::sendMessage(dgettext('wiki', 'Page with that name already exists!'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $this->setTitle($_POST['newpage']);
     $db->reset();
     $db->saveObject($this);
     $db2 = new PHPWS_DB('wiki_pages_version');
     $db2->addWhere('title', $_POST['page']);
     $db2->addValue('title', $this->getTitle(FALSE));
     $db2->update();
     $db3 = new PHPWS_DB('phpws_key');
     $db3->addWhere('item_id', $this->getId());
     $db3->addWhere('module', 'wiki');
     $db3->addValue('title', $this->getTitle());
     $db3->addValue('url', (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $this->getTitle(FALSE));
     $db3->update();
     // Create redirect page
     $redirect = new WikiPage($_POST['page']);
     $redirect->setPagetext(sprintf(dgettext('wiki', 'This page has moved to %s.  Please modify links to point to the new location.'), $this->getTitle(FALSE)));
     $redirect->setOwnerId(Current_User::getId());
     $redirect->setEditorId(Current_User::getId());
     $redirect->setCreated(mktime());
     $redirect->setUpdated(mktime());
     $redirect->setComment(sprintf(dgettext('wiki', 'Moved page to %s.'), $this->getTitle(FALSE)));
     $redirect->save();
     PHPWS_Core::initModClass('version', 'Version.php');
     $version = new Version('wiki_pages');
     $version->setSource($redirect);
     $version->setApproved(1);
     $version->save();
     WikiManager::sendMessage(dgettext('wiki', 'Wiki Page Moved!'), array('page' => $this->getTitle(FALSE)), FALSE);
 }
Example #28
0
 public function main()
 {
     $request = \Server::getCurrentRequest();
     $title = $content = $message = NULL;
     PHPWS_Core::initModClass('menu', 'Menu_Item.php');
     if (!Current_User::allow('menu')) {
         Current_User::disallow(dgettext('menu', 'User attempted access to Menu administration.'));
         return;
     }
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = 'list';
     }
     // This is the AJAX switch. Byproduct of old module design :(
     switch ($command) {
         case 'adminlinks':
             $this->adminLinks($request);
             exit;
         case 'delete_link':
             $this->deleteLink($request);
             exit;
         case 'key_select':
             $this->keySelect();
             exit;
         case 'post_link':
             $this->postLink($request);
             exit;
         case 'move_link':
             $this->moveLink($request);
             exit;
         case 'move_menu':
             $this->moveMenu($request);
             exit;
         case 'menu_options':
             $this->menuOptions($request);
             exit;
         case 'move_under':
             $this->moveUnder($request);
             exit;
         case 'transfer_link':
             $this->transferLink($request);
             exit;
         case 'add_key_link':
             $this->addKeyLink($request);
             exit;
         case 'remove_key_link':
             $this->removeKeyLink($request);
             exit;
         case 'delete_menu':
             $this->deleteMenu($request);
             exit;
         case 'post_menu':
             $this->postMenu($request);
             \PHPWS_Core::goBack();
             exit;
         case 'pin_menu':
             $this->pinMenu($request);
             exit;
         case 'unpin_menu':
             $this->unpinMenu($request);
             exit;
         case 'change_display_type':
             $this->changeDisplayType($request);
             exit;
         case 'menu_data':
             $this->menuData($request);
             exit;
         case 'pin_all':
             $this->menuPinAll($request);
             exit;
         case 'clear_image':
             $this->clearImage($request);
             exit;
         case 'update_character_limit':
             $this->updateCharacterLimit($request);
             exit;
         case 'new_link_menu':
             $this->updateNewLink($request);
             exit;
         case 'link_icons':
             $this->updateLinkIcons($request);
             exit;
         case 'force_shortcut':
             $this->forceShortcut();
             exit;
     }
     // This is the display switch or the HTML view switch
     switch ($command) {
         case 'list':
             $title = 'Menus';
             $content = $this->menuList();
             break;
         case 'reset_menu':
             if (!\Current_User::isDeity() && !\Current_User::authorized('menu')) {
                 throw new \Http\MethodNotAllowedException();
             }
             $this->resetMenu();
             PHPWS_Core::goBack();
             exit;
         default:
             throw new \Http\MethodNotAllowedException();
     }
     $tpl['title'] = $title;
     $tpl['content'] = $content;
     if (!empty($message)) {
         $tpl['message'] = $message;
     }
     $template = new \Template($tpl);
     $template->setModuleTemplate('menu', 'admin/main.html');
     Layout::add(PHPWS_ControlPanel::display($template->get()));
 }
Example #29
0
 public static function main()
 {
     $tpl['MESSAGE'] = NULL;
     $message = RSS_Admin::getMessage();
     PHPWS_Core::initModClass('rss', 'Feed.php');
     PHPWS_Core::initModClass('rss', 'Channel.php');
     if (!Current_User::allow('rss')) {
         Current_User::disallow();
     }
     $panel = RSS_Admin::adminPanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } elseif (isset($_REQUEST['tab'])) {
         $command = $_REQUEST['tab'];
     } else {
         $command = $panel->getCurrentTab();
     }
     if (isset($_REQUEST['channel_id'])) {
         $channel = new RSS_Channel($_REQUEST['channel_id']);
     } else {
         $channel = new RSS_Channel();
     }
     if (isset($_REQUEST['feed_id'])) {
         $feed = new RSS_Feed($_REQUEST['feed_id']);
     } else {
         $feed = new RSS_Feed();
     }
     switch ($command) {
         case 'channels':
             $tpl = RSS_Admin::channels();
             break;
         case 'settings':
             $tpl = RSS_Admin::settings();
             break;
         case 'save_settings':
             $result = RSS_Admin::save_settings();
             if (!$result) {
                 PHPWS_Settings::save('rss');
                 $result = dgettext('rss', 'Settings saved successfully.');
             }
             $tpl = RSS_Admin::settings();
             $tpl['MESSAGE'] =& $result;
             break;
         case 'feedInfo':
             $feed = new RSS_Feed(filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT));
             echo json_encode($feed);
             exit;
             break;
         case 'save_feed':
             $result = $feed->post();
             if (is_array($result)) {
                 $tpl['CONTENT'] = RSS_Admin::editFeed($feed, true);
                 $tpl['MESSAGE'] = implode('<br />', $result);
             } else {
                 $result = $feed->save();
                 PHPWS_Core::reroute('index.php?module=rss&tab=import');
             }
             break;
         case 'edit_channel':
             $tpl = RSS_Admin::editChannel($channel);
             break;
         case 'post_channel':
             $result = $channel->post();
             if (is_array($result)) {
                 $message = implode('<br />', $result);
                 $tpl = RSS_Admin::editChannel($channel);
             } else {
                 $result = $channel->save();
                 if (PHPWS_Error::isError($result)) {
                     RSS_Admin::sendMessage(dgettext('rss', 'An error occurred when saving your channel.'), 'channels');
                 } else {
                     RSS_Admin::sendMessage(dgettext('rss', 'Channel saved.'), 'channels');
                 }
             }
             break;
         case 'reset_feed':
             $feed->reset();
         case 'import':
             $tpl = RSS_Admin::import();
             break;
         case 'turn_on_display':
             $feed->display = 1;
             $feed->save();
             $tpl = RSS_Admin::import();
             break;
         case 'turn_off_display':
             $feed->display = 0;
             $feed->save();
             $tpl = RSS_Admin::import();
             break;
         case 'add_feed':
             $tpl = RSS_Admin::editFeed($feed);
             Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl'));
             exit;
             break;
         case 'edit_feed':
             $tpl = RSS_Admin::editFeed($feed);
             Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl'));
             exit;
             break;
         case 'delete_feed':
             $feed->delete();
             $tpl = RSS_Admin::import();
             break;
         default:
             PHPWS_Core::errorPage('404');
             break;
     }
     if (!empty($message)) {
         $tpl['MESSAGE'] = $message;
     }
     $content = PHPWS_Template::process($tpl, 'rss', 'main.tpl');
     $panel->setContent($content);
     $content = $panel->display();
     Layout::add(PHPWS_ControlPanel::display($content));
 }
Example #30
0
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 *
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @package
 * @license http://opensource.org/licenses/gpl-3.0.html
 */
if (isset($_REQUEST['aop'])) {
    if (!Current_User::allow('properties')) {
        Current_User::disallow('Action not allowed');
    }
    PHPWS_Core::initModClass('properties', 'Admin.php');
    $admin = new Properties\Admin();
    if (isset($_GET['aop'])) {
        $admin->get();
    } elseif (isset($_POST['aop'])) {
        $admin->post();
    }
} elseif (isset($_REQUEST['uop'])) {
    PHPWS_Core::initModClass('properties', 'User.php');
    $user = new Properties\User();
    if (isset($_GET['uop'])) {
        $user->get();
    } elseif (isset($_POST['uop'])) {
        $user->post();