public function updateBranches(&$content) { if (!PHPWS_Core::moduleExists('branch')) { return true; } PHPWS_Core::initModClass('branch', 'Branch_Admin.php'); $branches = Branch_Admin::getBranches(true); if (empty($branches)) { return true; } $keys = array_keys($this->status); foreach ($branches as $branch) { $GLOBALS['Boost_In_Branch'] = $branch; // used as the "local" directory in updateFiles $GLOBALS['boost_branch_dir'] = $branch->directory; if (PHPWS_Error::isError($branch->loadBranchDB())) { $content[] = dgettext('boost', 'Problem connecting to the branch. May be too many connections.'); continue; } // create a new boost based on the branch database $branch_boost = new PHPWS_Boost(); $branch_boost->loadModules($keys, false); $content[] = '<hr />'; $content[] = sprintf(dgettext('boost', 'Updating branch %s'), $branch->branch_name); $result = $branch_boost->update($content); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); $content[] = dgettext('boost', 'Unable to update branch.'); } } Branch::loadHubDB(); $GLOBALS['Boost_In_Branch'] = false; }
/** * routes administrative commands */ public function main() { if (!Current_User::allow('calendar')) { Current_User::disallow(); return; } $panel = $this->getPanel(); if (isset($_REQUEST['aop'])) { $command = $_REQUEST['aop']; } elseif (isset($_REQUEST['tab'])) { $command = $_REQUEST['tab']; } else { $command = $panel->getCurrentTab(); } switch ($command) { case 'get_event_json': $this->getEventJson(); break; case 'post_event': if (!$this->calendar->schedule->checkPermissions(true)) { Current_User::disallow(); } $this->postEvent(); break; case 'schedule_json': $this->scheduleJSON(filter_input(INPUT_GET, 'sch_id', FILTER_SANITIZE_NUMBER_INT)); exit; break; case 'approval': $this->approval(); break; case 'approve_suggestion': $this->approveSuggestion($_GET['suggestion_id']); PHPWS_Core::goBack(); break; case 'create_event': $panel->setCurrentTab('schedules'); $event = $this->calendar->schedule->loadEvent(); if ($this->calendar->current_date) { $event->start_time = mktime(12, 0, 0, $this->calendar->int_month, $this->calendar->int_day, $this->calendar->int_year); $event->end_time = mktime(12, 0, 0, $this->calendar->int_month, $this->calendar->int_day, $this->calendar->int_year); } $this->editEvent($event); break; case 'create_schedule': if (!Current_User::allow('calendar') || !Current_User::allow('calendar', 'edit_public') && !PHPWS_Settings::get('calendar', 'personal_schedules')) { Current_User::disallow(); } $this->calendar->schedule = new Calendar_Schedule(); $panel->setCurrentTab('schedules'); $this->editSchedule(); break; case 'blog_event': if (PHPWS_Core::moduleExists('blog') && Current_User::allow('blog', 'edit_blog') && $this->calendar->schedule->checkPermissions(true)) { $event = $this->calendar->schedule->loadEvent(); $this->blogEvent(); } break; case 'post_blog': if (PHPWS_Core::moduleExists('blog') && Current_User::allow('blog', 'edit_blog') && $this->calendar->schedule->checkPermissions(true)) { $this->postBlog(); } javascript('close_refresh'); Layout::nakedDisplay(); break; case 'edit_event': $panel->setCurrentTab('schedules'); if (!$this->calendar->schedule->checkPermissions()) { Current_User::disallow(); } $event = $this->calendar->schedule->loadEvent(); $this->editEvent($event); break; case 'delete_event': if ($this->calendar->schedule->checkPermissions(true)) { $event = $this->calendar->schedule->loadEvent(); $result = $event->delete(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); } } PHPWS_Core::goBack(); break; case 'delete_schedule': if (Current_User::authorized('calendar', 'delete_schedule') && Current_User::isUnrestricted('calendar')) { $this->calendar->schedule->delete(); $this->sendMessage(dgettext('calendar', 'Schedule deleted.'), 'aop=schedules'); } else { Current_User::disallow(); } break; case 'disapprove_suggestion': $this->disapproveSuggestion($_GET['suggestion_id']); PHPWS_Core::goBack(); break; case 'edit_schedule': if (empty($_REQUEST['sch_id'])) { PHPWS_Core::errorPage('404'); } if (!$this->calendar->schedule->checkPermissions()) { Current_User::disallow(); } $panel->setCurrentTab('schedules'); $this->editSchedule(); break; case 'make_default_public': if (Current_User::isUnrestricted('calendar')) { PHPWS_Settings::set('calendar', 'public_schedule', (int) $_REQUEST['sch_id']); PHPWS_Settings::save('calendar'); $this->message = dgettext('calendar', 'Default public schedule set.'); } $this->scheduleListing(); break; case 'post_schedule': $this->postSchedule(); break; case 'post_settings': if (!Current_User::authorized('calendar', 'settings')) { Current_User::disallow(); } $this->postSettings(); $this->message = dgettext('calendar', 'Settings saved'); $this->settings(); break; case 'repeat_event': $panel->setCurrentTab('schedules'); $event = $this->calendar->schedule->loadEvent(); $this->repeatEvent($event); break; case 'reset_cache': if (!Current_User::allow('calendar')) { Current_User::disallow(); } PHPWS_Cache::remove($_REQUEST['key']); PHPWS_Core::goBack(); break; case 'schedules': $panel->setCurrentTab('schedules'); $this->scheduleListing(); break; case 'settings': $this->settings(); break; case 'upload_event': if (!$this->calendar->schedule->checkPermissions()) { Current_User::disallow(); } $this->uploadEvent(); break; case 'post_upload': if (!$this->calendar->schedule->checkPermissions(true)) { Current_User::disallow(); } $this->postUpload(); break; } $tpl['CONTENT'] = $this->content; $tpl['TITLE'] = $this->title; if (is_array($this->message)) { $tpl['MESSAGE'] = implode('<br />', $this->message); } else { $tpl['MESSAGE'] = $this->message; } // Clears in case of js window opening $this->content = $this->title = $this->message = null; $final = PHPWS_Template::process($tpl, 'calendar', 'admin/main.tpl'); if (PHPWS_Calendar::isJS()) { Layout::nakedDisplay($final); } else { $panel->setContent($final); Layout::add(PHPWS_ControlPanel::display($panel->display())); } }
/** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function layout_update(&$content, $currentVersion) { switch ($currentVersion) { case version_compare($currentVersion, '2.2.0', '<'): $content[] = 'This package will not update versions under 2.2.0.'; return false; case version_compare($currentVersion, '2.2.1', '<'): $content[] = '+ Fixed improper sql call in update_220.sql file.'; case version_compare($currentVersion, '2.3.0', '<'): $content[] = '<pre>'; if (PHPWS_Boost::updateFiles(array('conf/config.php', 'conf/error.php'), 'layout')) { $content[] = 'Updated conf/config.php and conf/error.php file.'; } else { $content[] = 'Unable to update conf/config.php and conf/error.php file.'; } $content[] = ' 2.3.0 changes ------------- + Removed references from object constructors. + Added the plug function to allow users to inject content directly into a theme. + Added translate functions. + Layout now looks for and includes a theme\'s theme.php file. + Fixed unauthorized access. + Added XML mode to config.php file. Puts Layout in XHTML+XML content mode. + Added missing media parameters to XML mode. </pre>'; case version_compare($currentVersion, '2.4.0', '<'): $files = array('img/layout.png', 'templates/no_cookie.tpl'); $content[] = '<pre>'; if (PHPWS_Boost::updateFiles($files, 'layout')) { $content[] = '--- Successfully updated the following files:'; } else { $content[] = '--- Was unable to copy the following files:'; } $content[] = ' ' . implode("\n ", $files); $content[] = ' 2.4.0 changes ------------- + Layout now checks and forces a user to enable cookies on their browser. + Rewrote Javascript detection. Was buggy before as session destruction could disrupt it. + Added German translations + Updated language functions + Fixed: bug in Layout confused a user\'s style sheet settings after the theme was changed. + Rewrote theme change code. + Added ability to force theme on layout settings construction. + Changed Control Panel icon </pre>'; case version_compare($currentVersion, '2.4.1', '<'): $files = array('conf/config.php'); $content[] = '<pre>'; if (PHPWS_Boost::updateFiles($files, 'layout')) { $content[] = '--- Successfully updated the following files:'; } else { $content[] = '--- Was unable to copy the following files:'; } $content[] = ' ' . implode("\n ", $files); $content[] = ' 2.4.1 changes ------------- + Bug #1741111 - Fixed moving a top box up and a bottom box down. + The cookie check is not determined by a define in the config file. + The cookie check was interfering with the rss feed. Cut off the page too quickly. Moved cookie check to the close.php file. </pre>'; case version_compare($currentVersion, '2.4.2', '<'): $content[] = '<pre>'; $files = array('templates/arrange.tpl', 'conf/error.php', 'templates/move_box_select.tpl'); layoutUpdateFiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/layout/boost/changes/2_4_2.txt'); } $content[] = '</pre>'; case version_compare($currentVersion, '2.4.3', '<'): $content[] = '<pre>2.4.3 changes ----------------- + nakedDisplay now allows a choice whether to use the blank template or not when it wraps. Default is to not. + Fixed noCache. </pre>'; case version_compare($currentVersion, '2.4.4', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('layout_config'); if (PHPWS_Error::logIfError($db->dropTableColumn('userAllow'))) { $content[] = '--- An error occurred when trying to drop the userAllow column from the layout_config table.'; } else { $content[] = '--- Dropped the userAllow column from the layout_config table.'; } layoutUpdateFiles(array('templates/user_form.tpl'), $content); $content[] = '2.4.4 changes ------------------- + Dropped unused column from config table. + Added collapse function. Adds id="layout-collapse" to theme template under the {COLLAPSE} tag. + Changed method of checking for javascript status. Less chance for error. + Fixed notice.</pre>'; case version_compare($currentVersion, '2.4.5', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('layout_config'); if (PHPWS_Error::logIfError($db->addTableColumn('deity_reload', 'smallint not null default 0'))) { $content[] = 'Could not create layout_config.deity_reload column.'; return false; } else { $content[] = 'Added layout_config.deity_reload column.'; } layoutUpdateFiles(array('templates/metatags.tpl', 'conf/config.php'), $content); $content[] = '2.4.5 changes -------------------- + Added option to use a Key\'s summary or title to fill in the meta description. + Added new cacheHeader function to retain javascript and css information should a module return cached content before the above can be established. + Deities can now move a box to a theme locked area. + Added LAYOUT_IGNORE_JS_CHECK to force javascript use. + PHP 5 formatted'; case version_compare($currentVersion, '2.4.6', '<'): $content[] = '<pre>2.4.6 changes --------------------- + Fix to cache headers </pre>'; case version_compare($currentVersion, '2.4.7', '<'): $content[] = '<pre>'; layoutUpdateFiles(array('templates/themes.tpl'), $content); $content[] = '2.4.7 changes --------------------- + Added option to layout theme tab to disable or order module style sheet inclusion. + Can enable box move from mini admin </pre>'; case version_compare($currentVersion, '2.4.8', '<'): $content[] = '<pre>2.4.8 changes --------------------- + Bug#2424256 - Removed browser check to use @import on style sheets. </pre>'; case version_compare($currentVersion, '2.5.0', '<'): $content[] = '<pre>2.5.0 changes --------------------- + Icon class used. + Change of template directories to conform with core hub/branch change. + PHP 5 strict fixes. + New javascript detection method. + Default theme is now simple. + Allow admin to use hub or local themes. </pre>'; case version_compare($currentVersion, '2.5.1', '<'): $content[] = '<pre>2.5.1 changes --------------------- + Eloi George javascript patch applied </pre>'; case version_compare($currentVersion, '2.5.2', '<'): $content[] = '<pre>2.5.2 changes --------------------- + Eloi George templating patch added. + Fixed silent javascript failure. </pre>'; case version_compare($currentVersion, '2.5.3', '<'): $content[] = '<pre>2.5.3 changes --------------------- + Added HTTP tag for theming. Assists with http vs https + HOME_URL also added for theming. </pre>'; case version_compare($currentVersion, '2.5.4', '<'): $content[] = '<pre>2.5.4 changes --------------------- + Static notice corrected. + Page title can be changed from miniadmin </pre>'; case version_compare($currentVersion, '2.5.5', '<'): require_once PHPWS_SOURCE_DIR . 'mod/users/class/My_Page.php'; My_Page::unregisterMyPage('layout'); $content[] = '<pre>2.5.5 changes --------------------- + Unregister My Page </pre>'; case version_compare($currentVersion, '2.6.0', '<'): $content[] = <<<EOF <pre>2.6.0 changes -------------------- + Removed Layout\\'s caching code. + Fixed layout's problem with locked content variables. + Fixed: Content without a content_var was overwriting previously unlabeled content. + Added Layout method includeJavascript. Shortcut for script inclusion over addJSHeader. + Added Font Awesome icons. + Reworded box move command in miniadmin. + Removed deprecated ckeditor function. </pre> EOF; case version_compare($currentVersion, '2.6.1', '<'): $content[] = <<<EOF <pre>2.6.1 changes -------------------- + Added THEME_HTTP to the Layout wrap function. </pre> EOF; case version_compare($currentVersion, '2.7.0', '<'): if (PHPWS_Core::moduleExists('block')) { $db = Database::newDB(); $t = $db->addTable('layout_config'); $t->addField('header'); $t->addField('footer'); $config_result = $db->selectOneRow(); if (!empty($config_result['header'])) { $header_block = new Block_Item(); $header_block->title = 'Layout header'; $header_block->content = $_SESSION['Layout_Settings']->header; $header_block->hide_title = true; $header_block->save(); } if (!empty($config_result['footer'])) { $footer_block = new Block_Item(); $footer_block->title = 'Layout footer'; $footer_block->content = $_SESSION['Layout_Settings']->footer; $footer_block->hide_title = true; $footer_block->save(); } } $content[] = <<<EOF <pre>2.7.0 changes -------------------- + Removed header and footer. Moved data to Blocks. + Fixed some admin forms </pre> EOF; } return true; }
<?php if (PHPWS_Core::moduleExists('analytics')) { PHPWS_Core::initModClass('analytics', 'Analytics.php'); Analytics::injectTrackers(); }
public static function show($start_date = null, $end_date = null) { if (!Blog_User::allowView()) { return null; } $db = new PHPWS_DB('blog_entries'); if ($start_date) { $db->addWhere('publish_date', $start_date, '>=', 'and', 2); } if ($end_date) { $db->addWhere('publish_date', $end_date, '<=', 'and', 2); } $db->addWhere('approved', 1); $db->addWhere('publish_date', time(), '<'); $db->addWhere('expire_date', time(), '>', 'and', 1); $db->addWhere('expire_date', 0, '=', 'or', 1); $db->setGroupConj(1, 'and'); Key::restrictView($db, 'blog'); $total_entries = Blog_User::totalEntries($db); $limit = PHPWS_Settings::get('blog', 'blog_limit'); if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 0; } if (!is_numeric($page) || $page < 2) { $offset = $page = 0; } else { $offset = ($page - 1) * $limit; } Layout::addStyle('blog'); $result = Blog_User::getEntries($db, $limit, $offset); if ($page > 0 && empty($result)) { PHPWS_Core::reroute('blog/action/view/page/1'); } if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); return NULL; } if (empty($result)) { if (Current_User::allow('blog')) { MiniAdmin::add('blog', PHPWS_Text::secureLink(dgettext('blog', 'Create first blog entry!'), 'blog', array('action' => 'admin', 'command' => 'new'))); } return NULL; } if ($page < 2) { $past_entries = PHPWS_Settings::get('blog', 'past_entries'); if ($past_entries) { $db->setLimit($past_entries, $limit); $past = $db->getObjects('Blog'); if (PHPWS_Error::isError($past)) { PHPWS_Error::log($past); } elseif ($past) { Blog_User::showPast($past); } } } $rss = false; foreach ($result as $blog) { if (!$rss) { if (PHPWS_Core::moduleExists('rss')) { PHPWS_Core::initModClass('rss', 'RSS.php'); $key = new Key($blog->key_id); RSS::showIcon($key); $rss = true; } } $view = $blog->view(); if (!empty($view)) { $list[] = $view; } } $page_vars['action'] = 'view'; if ($page > 1) { $page_vars['page'] = $page - 1; $tpl['PREV_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Previous page'), 'blog', $page_vars); if ($limit + $offset < $total_entries) { $page_vars['page'] = $page + 1; $tpl['NEXT_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Next page'), 'blog', $page_vars); } } elseif ($limit + $offset < $total_entries) { $page_vars['page'] = 2; $tpl['NEXT_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Next page'), 'blog', $page_vars); } $tpl['ENTRIES'] = implode('', $list); $content = PHPWS_Template::process($tpl, 'blog', 'list_view.tpl'); if (Current_User::allow('blog', 'edit_blog')) { Blog_User::miniAdminList(); $vars['action'] = 'admin'; $vars['command'] = 'new'; $link[] = PHPWS_Text::secureLink(dgettext('blog', 'Add new blog'), 'blog', $vars); MiniAdmin::add('blog', $link); } return $content; }
private function menuList() { \Layout::addStyle('menu', 'admin.css'); javascript('jquery'); javascript('jquery_ui'); //commenting out for now. problem clearing select dropdown //javascript('select2'); $template = new \Template(); $template->setModuleTemplate('menu', 'admin/administrate.html'); $first_menu_pin_all = 0; $first_menu_template = null; $db = new PHPWS_DB('menus'); $db->addOrder('queue'); $result = $db->getObjects('Menu_Item'); $first_menu = null; if (!empty($result)) { foreach ($result as $menu) { $menu->_show_all = true; if (empty($first_menu)) { $first_menu = $menu; $active = 'active'; } else { $active = null; } $tpl['menus'][] = array('title' => $menu->title, 'id' => $menu->id, 'active' => $active); } $first_menu_template = $first_menu->template; // for display, use the admin template $first_menu->template = 'admin'; $tpl['first_menu'] = $first_menu->view(true); $first_menu_pin_all = $first_menu->pin_all; $first_menu_id = $first_menu->id; } else { $first_menu_id = 0; $tpl['first_menu'] = null; } $vars['delete'] = t('Delete'); $vars['confirm_delete'] = t('Confirm deletion'); $vars['first_menu_id'] = $first_menu_id; $vars['authkey'] = \Current_User::getAuthKey(); $vars['blank_title'] = t('Title must not be blank'); $vars['title_error'] = t('Make sure you have filled in the required inputs.'); $vars['url_error'] = t('Please enter a url or choose a PageSmith page.'); $vars['delete_menu_message'] = t('Are you sure you want to delete this menu and links?'); $vars['edit'] = t('Edit'); $vars['title_error'] = t('Please enter a menu title'); if (PHPWS_Settings::get('menu', 'display_type')) { $vars['pin_all'] = null; $vars['pin_some'] = null; } else { $vars['pin_all'] = t('Shown on all pages'); $vars['pin_some'] = t('Shown on some pages'); } $jvar = json_encode($vars); $script = <<<EOF <script type="text/javascript">var translate = {$jvar}; var fmp={$first_menu_pin_all};</script> EOF; \Layout::addJSHeader($script); \Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'mod/menu/javascript/administrate/script.js"></script>'); $main_menu_templates = PHPWS_File::listDirectories(PHPWS_Template::getTemplateDirectory('menu') . 'menu_layout/'); $theme_menu_templates = PHPWS_File::listDirectories(PHPWS_Template::getTplDir('menu') . 'menu_layout/'); $menu_tpls[] = '<optgroup label="' . t('Menu module templates') . '">'; foreach ($main_menu_templates as $menu_tpl) { if ($first_menu_template == $menu_tpl) { $selected = ' selected="selected"'; } else { $selected = null; } $menu_tpls[] = "<option value='{$menu_tpl}'{$selected}>{$menu_tpl}</option>"; } $menu_tpls[] = '</optgroup>'; if (!empty($theme_menu_templates)) { $menu_tpls[] = '<optgroup label="' . t('Theme templates') . '">'; foreach ($theme_menu_templates as $menu_tpl) { if ($first_menu_template == $menu_tpl) { $selected = ' selected="selected"'; } else { $selected = null; } $menu_tpls[] = "<option value='{$menu_tpl}'{$selected}>{$menu_tpl}</option>"; } $menu_tpls[] = '</optgroup>'; } $tpl['templates'] = implode('', $menu_tpls); $tpl['display_type'] = \PHPWS_Settings::get('menu', 'display_type'); if (isset($first_menu) && $first_menu->pin_all) { $tpl['pin_all'] = $vars['pin_all']; $tpl['pin_button_class'] = 'btn-primary'; } else { $tpl['pin_all'] = $vars['pin_some']; $tpl['pin_button_class'] = 'btn-default'; } if (\Current_User::isDeity()) { $tpl['reset_menu_link'] = PHPWS_Text::linkAddress('menu', array('command' => 'reset_menu'), true); } else { $tpl['reset_menu_link'] = '#'; } $tpl['link_limit'] = \PHPWS_Settings::get('menu', 'max_link_characters'); if (\PHPWS_Core::moduleExists('carousel')) { $tpl['carousel'] = $this->carouselSlidesForm(); } else { $tpl['carousel'] = null; } $template->addVariables($tpl); return $template->get(); }
public function getTpl() { javascript('jquery'); $tpl = $this->tplFormatTime(); if ($this->show_busy && !$this->_schedule->checkPermissions()) { $tpl['SUMMARY'] = dgettext('calendar', 'Busy'); $tpl['DESCRIPTION'] = null; } else { $tpl['SUMMARY'] = $this->getSummary(); $tpl['DESCRIPTION'] = $this->getDescription(); } if ($this->_schedule->checkPermissions()) { $link[] = $this->editLink('icon'); $link[] = $this->deleteLink('icon'); if (PHPWS_Core::moduleExists('blog')) { if (Current_User::allow('blog', 'edit_blog', null, null, true)) { $link[] = $this->blogLink('icon'); } } $tpl['LINKS'] = implode(' ', $link); } if (!empty($this->location)) { $tpl['LOCATION_LABEL'] = dgettext('calendar', 'Location'); $tpl['LOCATION'] = $this->getLocation(); } $tpl['BACK_LINK'] = PHPWS_Text::backLink(); return $tpl; }