Пример #1
0
 public static function add($module, $links)
 {
     if (is_array($links)) {
         foreach ($links as $link) {
             MiniAdmin::add($module, $link);
         }
         return true;
     }
     $GLOBALS['MiniAdmin'][$module]['links'][] = $links;
     return true;
 }
Пример #2
0
 /**
  * Adds wiki links to the MiniAdmin box
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function addToMiniAdmin()
 {
     $admin = dgettext('wiki', 'Admin');
     $image = dgettext('wiki', 'Image upload');
     $linkshere = dgettext('wiki', 'What links here');
     $recentchanges = dgettext('wiki', 'Recent changes');
     $randompage = dgettext('wiki', 'Random page');
     $interwiki = dgettext('wiki', 'Interwiki setup');
     if (isset($_REQUEST['page']) && isset($_REQUEST['page_op']) && $_REQUEST['page_op'] == 'view' && PHPWS_Settings::get('wiki', 'what_links_here')) {
         $links[] = PHPWS_Text::moduleLink($linkshere, 'wiki', array('page' => $_REQUEST['page'], 'page_op' => 'whatlinkshere'));
     }
     if (PHPWS_Settings::get('wiki', 'recent_changes')) {
         $links[] = PHPWS_Text::moduleLink($recentchanges, 'wiki', array('op' => 'recentchanges'));
     }
     if (PHPWS_Settings::get('wiki', 'random_page')) {
         $links[] = PHPWS_Text::moduleLink($randompage, 'wiki', array('op' => 'random'));
     }
     if (PHPWS_Settings::get('wiki', 'allow_image_upload') && Current_User::isLogged() || Current_User::allow('wiki', 'upload_images')) {
         $links[] = PHPWS_Text::secureLink($image, 'wiki', array('op' => 'imageupload'));
     }
     if (Current_User::allow('wiki', 'edit_page') || PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) {
         $links[] = PHPWS_Text::secureLink($interwiki, 'wiki', array('op' => 'interwikisetup'));
     }
     if (Current_User::allow('wiki', 'edit_settings')) {
         $links[] = PHPWS_Text::secureLink($admin, 'wiki', array('op' => 'admin'));
     }
     if (isset($links)) {
         /* Clear out any existing links that may be present before adding these */
         $GLOBALS['MiniAdmin']['wiki'] = NULL;
         MiniAdmin::add('wiki', $links);
     }
 }
Пример #3
0
 /**
  * Pathing for which view to display
  */
 public function view()
 {
     require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Event.php';
     $key = new Key($this->calendar->schedule->key_id);
     if (!$key->allowView()) {
         $this->calendar->loadDefaultSchedule();
     }
     $schedule_key = $this->calendar->schedule->getKey();
     if (!$this->calendar->schedule->public && !$schedule_key->allowView()) {
         PHPWS_Core::errorPage('403');
     }
     \Layout::disableRobots();
     $current_date = $this->calendar->current_date * 1000;
     switch ($this->current_view) {
         case 'day':
             $this->content = $this->day();
             break;
         case 'grid':
             if (ALLOW_CACHE_LITE && Current_User::allow('calendar')) {
                 if (strftime('%Y%m', $this->calendar->today) == strftime('%Y%m', $this->calendar->current_date)) {
                     $current_date = $this->calendar->today * 1000;
                 }
                 $this->resetCacheLink('grid', $this->calendar->int_month, $this->calendar->int_year, $this->calendar->schedule->id);
             }
             $this->content = $this->month_grid();
             break;
         case 'list':
             if (ALLOW_CACHE_LITE && Current_User::allow('calendar')) {
                 $this->resetCacheLink('list', $this->calendar->int_month, $this->calendar->int_year, $this->calendar->schedule->id);
             }
             $this->content = $this->month_list();
             break;
         case 'week':
             $this->content = $this->week();
             break;
         case 'event':
             if (isset($_REQUEST['page'])) {
                 $event_id = (int) $_REQUEST['page'];
             } elseif (isset($_REQUEST['event_id'])) {
                 $event_id = $_REQUEST['event_id'];
             } else {
                 $this->content = $this->day();
             }
             if (!$this->loadEvent($event_id) || !$this->event->id) {
                 $this->content = $this->day();
                 break;
             }
             if (isset($_REQUEST['js'])) {
                 $this->content = $this->event(true);
                 Layout::nakedDisplay($this->content);
                 return;
             } else {
                 $this->content = $this->event();
             }
             break;
         default:
             $this->content = dgettext('calendar', 'Incorrect option');
             break;
     }
     if ($this->calendar->schedule->checkPermissions()) {
         if ($this->calendar->schedule->id) {
             require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Admin.php';
             $event = new Calendar_Event(0, $this->calendar->schedule);
             Layout::add(\Calendar_Admin::eventModal($event));
             \Calendar_Admin::includeEventJS();
             $link = '<a style="cursor:pointer" class="add-event" data-schedule-id="' . $this->calendar->schedule->id . '" data-date="' . $current_date * 1000 . '">Add event</a>';
             MiniAdmin::add('calendar', $link);
             MiniAdmin::add('calendar', $this->calendar->schedule->uploadEventsLink());
         }
     }
     if ($this->current_view == 'event') {
         $this->event->flagKey();
     } else {
         $schedule_key->flag();
     }
 }
Пример #4
0
 public static function shortcut(Key $key)
 {
     $modal = new Modal('access-shortcut', null, dgettext('access', 'Shortcuts'));
     $modal->sizeSmall();
     $button = '<button class="btn btn-success" id="save-shortcut">Save</button>';
     $modal->addButton($button);
     \Layout::add((string) $modal);
     javascript('jquery');
     //\Layout::includeJavascript('mod/access/javascript/access.js');
     \Layout::includeJavascript('mod/access/javascript/access.min.js');
     $link = '<a href="javascript:void(0)" data-authkey="' . \Current_User::getAuthKey() . '" data-key="' . $key->id . '" id="add-shortcut">' . dgettext('access', 'Shortcut') . '</a>';
     MiniAdmin::add('access', $link);
 }
Пример #5
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
if (Current_User::isLogged()) {
    $key = Key::getCurrent(true);
    if ($key) {
        $qr_func = function ($key_id, $size) {
            $qr = new QR($key_id);
            $qr->setSize($size);
            $image = $qr->get();
            return '<a download="QR-image.png" href="' . $qr->image . '">' . $qr->get() . '</a>';
        };
        $tpl_vars['small'] = $qr_func($key->id, 5);
        $tpl_vars['medium'] = $qr_func($key->id, 6);
        $tpl_vars['large'] = $qr_func($key->id, 8);
        $tpl_vars['xlarge'] = $qr_func($key->id, 12);
        $tpl = new \Template($tpl_vars);
        $tpl->setModuleTemplate('qr', 'modal.html');
        $content = $tpl->get();
        $modal = new Modal('qr-modal', $content, 'QR Codes (click to download)');
        $modal->sizeLarge();
        Layout::add($modal->get());
        MiniAdmin::add('qr', '<a data-toggle="modal" data-target="#qr-modal" class="pointer">Show QR codes</a>');
    }
}
Пример #6
0
 public function view()
 {
     Layout::addStyle('pagesmith');
     if (Current_User::allow('pagesmith', 'edit_page', $this->id)) {
         MiniAdmin::add('pagesmith', $this->editLink(dgettext('pagesmith', 'Edit this page')));
         MiniAdmin::add('pagesmith', $this->frontPageToggle());
     }
     $this->loadTemplate();
     $this->_tpl->loadStyle();
     $this->flag();
     $this->loadSections();
     if (!empty($this->title) && !PHPWS_Core::atHome()) {
         Layout::addPageTitle($this->title);
     }
     if (!$this->hide_title) {
         $this->_content['page_title'] =& $this->title;
     }
     $anchor_title = $tpl['ANCHOR'] = preg_replace('/\\W/', '-', $this->title);
     if (Current_User::allow('pagesmith') && $this->_key->show_after > time()) {
         $tpl['SHOW_AFTER'] = t('Page hidden until %s', strftime('%F %H:%M', $this->_key->show_after));
     }
     $tpl['CONTENT'] = PHPWS_Template::process($this->_content, 'pagesmith', $this->_tpl->page_path . 'page.tpl');
     $this->pageLinks($tpl);
     if (PHPWS_Settings::get('pagesmith', 'back_to_top')) {
         $tpl['BACK_TO_TOP'] = sprintf('<a href="%s#%s">%s</a>', PHPWS_Core::getCurrentUrl(), $anchor_title, '<i class="fa fa-arrow-circle-up"></i> ' . dgettext('pagesmith', 'Back to top'));
     }
     $content = PHPWS_Template::process($tpl, 'pagesmith', 'page_frame.tpl');
     return $content;
 }
Пример #7
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
Block::show();
if (Current_User::allow('block')) {
    $key = Key::getCurrent();
    if (Key::checkKey($key) && javascriptEnabled()) {
        javascript('jquery');
        javascript('ckeditor');
        $js_address = PHPWS_SOURCE_HTTP . 'mod/block/javascript/addblock/script.js';
        Layout::addJSHeader('<script src="' . $js_address . '" type="text/javascript"></script>', 'addblock');
        $modal = new \Modal('block-form-modal', '<div id="block-form-dialog"></div>', 'Add block here');
        $modal->sizeLarge();
        $save_button = '<button class="btn btn-success" id="save-block">Save</button>';
        $modal->addButton($save_button);
        Layout::add((string) $modal);
        MiniAdmin::add('block', '<a style="cursor:pointer" data-auth-key="' . Current_User::getAuthKey() . '" data-key-id="' . $key->id . '" id="add-block"><i class="fa fa-plus"></i> Add block here</a>');
    }
}
Пример #8
0
<?php

if (Current_User::allow('pagesmith', 'edit_page')) {
    $vars = array('aop' => 'pick_template', 'tpl' => 'text_only', 'pid' => 0);
    MiniAdmin::add('pagesmith', PHPWS_Text::secureLink('<i class="fa fa-file-text-o"></i> ' . dgettext('pagesmith', 'Create New Web Page'), 'pagesmith', $vars));
    $key = \Key::getCurrent();
    if (!empty($key) && !$key->isDummy() && $key->module == 'pagesmith') {
        $vars['aop'] = 'edit_page';
        $vars['id'] = $key->item_id;
        unset($vars['tpl']);
        unset($vars['pid']);
        MiniAdmin::add('pagesmith', PHPWS_Text::secureLink('<i class="fa fa-pencil-square-o"></i> ' . dgettext('pagesmith', 'Edit current page'), 'pagesmith', $vars));
    }
}
Пример #9
0
<?php

/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
MiniAdmin::get();
Пример #10
0
 private static function miniadminUnpin($key)
 {
     $menus = self::getMenuListing(false);
     $assoc = self::getAssociations($key->id);
     if (!empty($assoc)) {
         foreach ($assoc as $a) {
             $ignore[] = $a['menu_id'];
         }
     } else {
         $ignore = array();
     }
     $choice[] = '<div class="input-group-sm" style="margin-bottom : 5px"><select class="form-control" name="menu_id" id="menu-unpin-page" data-key-id="' . $key->id . '">';
     $choice[] = '<option value="0" disabled="disabled" selected="selected"><i class="fa fa-caret-down"></i>' . t('Remove menu') . '</option>';
     $menu_found = false;
     foreach ($menus as $menu) {
         if (in_array($menu['id'], $ignore)) {
             $menu_found = true;
             $choice[] = '<option value="' . $menu['id'] . '">' . $menu['title'] . '</option>';
         }
     }
     if (!$menu_found) {
         // No menus need removing
         return;
     }
     $choice[] = '</select></div>';
     $menu_choice = implode("\n", $choice);
     MiniAdmin::add('menu', $menu_choice);
 }
Пример #11
0
 private static function deleteLinksAdmin()
 {
     if (!\Current_User::isDeity()) {
         return;
     }
     $delete_links = filter_input(INPUT_GET, 'delete_links', FILTER_VALIDATE_INT);
     $remove_cp_link = filter_input(INPUT_GET, 'remove_cp_link', FILTER_VALIDATE_INT);
     if ($delete_links === 1) {
         $_SESSION['controlpanel_delete_links'] = true;
     } elseif ($delete_links === 0) {
         unset($_SESSION['controlpanel_delete_links']);
     } else {
         $delete_links = isset($_SESSION['controlpanel_delete_links']);
     }
     if ($delete_links) {
         $link = '<a href="index.php?module=controlpanel&amp;delete_links=0">Turn off link deletion</a>';
         if ($remove_cp_link) {
             $db = \Database::newDB();
             $tbl = $db->addTable('controlpanel_link');
             $tbl->addFieldConditional('id', $remove_cp_link);
             $db->delete();
             unset($_SESSION['CP_All_links']);
         }
     } else {
         $link = '<a href="index.php?module=controlpanel&amp;delete_links=1">Allow link deletion</a>';
     }
     \MiniAdmin::add('controlpanel', $link);
 }
Пример #12
0
 public static function miniLinks()
 {
     $vars['action'] = 'admin';
     if (Layout::isMoveBox()) {
         $vars['command'] = 'turn_off_box_move';
         $links[] = PHPWS_Text::moduleLink('<i class="fa fa-toggle-on"></i> ' . dgettext('layout', 'Turn box move off'), 'layout', $vars);
     } else {
         $vars['command'] = 'move_boxes_on';
         $links[] = PHPWS_Text::secureLink('<i class="fa fa-toggle-off"></i> ' . dgettext('layout', 'Turn box move on'), 'layout', $vars);
     }
     unset($vars['command']);
     $vars['tab'] = 'meta';
     $links[] = PHPWS_Text::secureLink('<i class="fa fa-edit"></i> ' . dgettext('layout', 'Change Website Title'), 'layout', $vars);
     $key = Key::getCurrent();
     if (javascriptEnabled() && Layout::getExtraStyles() && Key::checkKey($key)) {
         $js_vars['width'] = 400;
         $js_vars['height'] = 200;
         $vars['key_id'] = $key->id;
         $vars['action'] = 'admin';
         $js_vars['label'] = '<i class="fa fa-paint-brush"></i> ' . dgettext('layout', 'Change style');
         $vars['command'] = 'js_style_change';
         $js_vars['address'] = PHPWS_Text::linkAddress('layout', $vars, TRUE);
         $links[] = javascript('open_window', $js_vars);
         if (!$key->isHomeKey()) {
             $js_vars['height'] = 400;
             $js_vars['label'] = dgettext('layout', 'Meta tags');
             $vars['command'] = 'page_meta_tags';
             $js_vars['address'] = PHPWS_Text::linkAddress('layout', $vars, TRUE);
             $links[] = javascript('open_window', $js_vars);
         }
     }
     if (!isset($links)) {
         return;
     }
     MiniAdmin::add('layout', $links);
     // MiniAdmin runs get before layout and runtime won't work
     // with flagged keys
     MiniAdmin::get();
 }
Пример #13
0
 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;
 }
Пример #14
0
 /**
  * Displays the blog entry
  *
  * @param boolean edit       If true, show edit link
  * @param boolean summarized If true, this is a summarized entry
  */
 public function view($edit = true, $summarized = true)
 {
     if (!$this->id) {
         PHPWS_Core::errorPage(404);
     }
     $key = new Key($this->key_id);
     if (!$key->allowView() || !Blog_User::allowView()) {
         Current_User::requireLogin();
         return dgettext('blog', 'You do not have permission to view this entry.');
     }
     $template['TITLE'] = sprintf('<a href="%s" rel="bookmark">%s</a>', $this->getViewLink(true), $this->title);
     $template['TITLE_NO_LINK'] = $this->title;
     if ($this->publish_date > time()) {
         $template['UNPUBLISHED'] = dgettext('blog', 'Unpublished');
     } elseif ($this->expire_date && $this->expire_date < time()) {
         $template['UNPUBLISHED'] = dgettext('blog', 'Expired');
     }
     $template['LOCAL_DATE'] = $this->getPublishDate();
     $summary = $this->getSummary(true);
     $entry = $this->getEntry(true);
     if ($summarized) {
         if (empty($summary)) {
             $template['SUMMARY'] = PHPWS_Text::parseTag($entry);
         } else {
             if (!empty($entry)) {
                 $template['READ_MORE'] = PHPWS_Text::rewriteLink(Icon::get('chevron-circle-down') . '&nbsp;' . dgettext('blog', 'Read more'), 'blog', array('id' => $this->id), null, 'Read more of this entry', 'btn btn-default');
             }
             $template['SUMMARY'] = PHPWS_Text::parseTag($summary);
         }
     } else {
         $template['SUMMARY'] = PHPWS_Text::parseTag($summary);
         $template['ENTRY'] = PHPWS_Text::parseTag($entry);
     }
     $template['IMAGE'] = $this->getFile($this->thumbnail && $summarized);
     if ($edit && (Current_User::allow('blog', 'edit_blog', $this->id, 'entry') || Current_User::allow('blog', 'edit_blog') && $this->author_id == Current_User::getId())) {
         $vars['blog_id'] = $this->id;
         $vars['action'] = 'admin';
         $vars['command'] = 'edit';
         $template['EDIT_LINK'] = PHPWS_Text::secureLink(dgettext('blog', 'Edit'), 'blog', $vars);
         $template['EDIT_URI'] = PHPWS_Text::linkAddress('blog', $vars, true);
         if (!$summarized) {
             MiniAdmin::add('blog', array(PHPWS_Text::secureLink(dgettext('blog', 'Edit blog'), 'blog', $vars)));
         }
     }
     // Check setting for showing when the entry was posted
     if (PHPWS_Settings::get('blog', 'show_posted_by')) {
         $template['POSTED_BY'] = dgettext('blog', 'By');
         $template['AUTHOR'] = $this->author;
     }
     // Check settings for showing the author of the entry
     if (PHPWS_Settings::get('blog', 'show_posted_date')) {
         $template['PUBLISHED'] = dgettext('blog', 'Published');
         $template['POSTED_ON'] = dgettext('blog', 'Posted on');
         $template['PUBLISHED_DATE'] = $this->getPublishDateShort();
     }
     if ($summarized) {
         $view_tpl = 'view_list.tpl';
     } else {
         $template['COMMENT_SCRIPT'] = PHPWS_Settings::get('blog', 'comment_script');
         $key->flag();
         $view_tpl = 'view_full.tpl';
     }
     return PHPWS_Template::process($template, 'blog', $view_tpl);
 }
Пример #15
0
 public static function permissionMenu()
 {
     $key = Key::getCurrent();
     if (empty($key) || $key->isDummy() || empty($key->edit_permission)) {
         return;
     }
     if (Current_User::isUnrestricted($key->module) && Current_User::allow($key->module, $key->edit_permission)) {
         if (!javascriptEnabled()) {
             $tpl = User_Form::permissionMenu($key);
             $content = PHPWS_Template::process($tpl, 'users', 'forms/permission_menu.tpl');
             Layout::add($content, 'users', 'permissions');
         } else {
             $links[] = Current_User::popupPermission($key->id, sprintf(dgettext('users', 'Set permissions'), $key->title));
             MiniAdmin::add('users', $links);
         }
     }
 }