Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $addon_utilities = new \TikiAddons_Utilities();
     $addonName = $input->getArgument('addon');
     if (strpos($addonName, '/') !== false && strpos($addonName, '_') === false) {
         $package = $addonName;
         $folder = str_replace('/', '_', $addonName);
     } else {
         $package = str_replace('_', '/', $addonName);
         $folder = $addonName;
     }
     $repository = 'file://addons/' . $folder . '/profiles';
     $reapply = $input->getOption('reapply');
     $ignoredepends = $input->getOption('ignoredepends');
     if (empty(glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml'))) {
         $output->writeln("<error>No profiles found.</error>");
         return false;
     }
     if (!$ignoredepends) {
         $addon_utilities->checkDependencies($folder);
     }
     $addons = \TikiAddons::getInstalled();
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     foreach (glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml') as $file) {
         $profileName = str_replace('.yml', '', basename($file));
         $profile = \Tiki_Profile::fromNames($repository, $profileName);
         if (!$profile) {
             $output->writeln("<error>Profile {$profileName} not found.</error>");
             continue;
         }
         $isInstalled = $installer->isInstalled($profile);
         if ($isInstalled && $reapply) {
             $installer->forget($profile);
             $isInstalled = false;
         }
         if (!$isInstalled) {
             $transaction = $tikilib->begin();
             if ($installer->install($profile)) {
                 $addon_utilities->updateProfile($folder, $addons[$package]->version, $profileName);
                 $transaction->commit();
                 $output->writeln("Profile {$profileName} applied.");
             } else {
                 $output->writeln("<error>Profile {$profileName} installation failed:</error>");
                 foreach ($installer->getFeedback() as $error) {
                     $output->writeln("<error>{$error}</error>");
                 }
             }
         } else {
             $output->writeln("<info>Profile {$profileName} was already applied. Nothing happened.</info>");
         }
     }
 }
Пример #2
0
 function list_layouts($theme = null, $theme_option = null)
 {
     global $prefs;
     if (empty($theme) && empty($theme_option)) {
         // if you submit no parameters, return the current theme/theme option
         if (isset($prefs['site_theme'])) {
             $theme = $prefs['site_theme'];
         }
         if (isset($prefs['theme_option'])) {
             $theme_option = $prefs['theme_option'];
         }
     }
     $themelib = TikiLib::lib('theme');
     $available_layouts = array();
     foreach (scandir(TIKI_PATH . '/templates/layouts/') as $layoutName) {
         if ($layoutName[0] != '.' && $layoutName != 'index.php') {
             $available_layouts[$layoutName] = ucfirst($layoutName);
         }
     }
     foreach (TikiAddons::getPaths() as $path) {
         if (file_exists($path . '/templates/layouts/')) {
             foreach (scandir($path . '/templates/layouts/') as $layoutName) {
                 if ($layoutName[0] != '.' && $layoutName != 'index.php') {
                     $available_layouts[$layoutName] = ucfirst($layoutName);
                 }
             }
         }
     }
     $main_theme_path = $themelib->get_theme_path($theme, '', '', 'templates');
     // path to the main site theme
     if (file_exists(TIKI_PATH . "/" . $main_theme_path . '/layouts/')) {
         foreach (scandir(TIKI_PATH . "/" . $main_theme_path . '/layouts/') as $layoutName) {
             if ($layoutName[0] != '.' && $layoutName != 'index.php') {
                 $available_layouts[$layoutName] = ucfirst($layoutName);
             }
         }
     }
     if ($theme_option) {
         $theme_path = $themelib->get_theme_path($theme, $theme_option, '', 'templates');
         // path to the site theme options
         if (file_exists(TIKI_PATH . "/" . $theme_path . '/layouts/')) {
             foreach (scandir(TIKI_PATH . "/" . $theme_path . '/layouts/') as $layoutName) {
                 if ($layoutName[0] != '.' && $layoutName != 'index.php') {
                     $available_layouts[$layoutName] = ucfirst($layoutName);
                 }
             }
         }
     }
     return $available_layouts;
 }
Пример #3
0
function groupnavloader($data, $params)
{
    global $auto_query_args;
    $auto_query_args_local = array('organicgroup');
    $auto_query_args = empty($auto_query_args) ? $auto_query_args_local : array_merge($auto_query_args, $auto_query_args_local);
    if (!isset($params['from'])) {
        return 'Please specify parameter: from';
    }
    $app = \TikiAddons::get('syn_organicgrp');
    $api = new \TikiAddons_Api_Group();
    if (!isset($_REQUEST['organicgroup']) && !empty($_REQUEST['page'])) {
        $info = $api->getOrganicGroupInfoForItem('wiki page', $_REQUEST['page']);
        $cat = $info['cat'];
        $ogid = $info['organicgroup'];
        $app->smarty->assign('groupTrackerItemId', $ogid);
        $_REQUEST['organicgroup'] = $ogid;
        if (!isset($_REQUEST['cat'])) {
            $_REQUEST['cat'] = $cat;
        }
    }
    if (!isset($_REQUEST['organicgroup']) && !empty($_REQUEST['itemId'])) {
        $info = $api->getOrganicGroupInfoForItem('trackeritem', $_REQUEST['itemId']);
        $cat = $info['cat'];
        $ogid = $info['organicgroup'];
        $app->smarty->assign('groupTrackerItemId', $ogid);
        $_REQUEST['organicgroup'] = $ogid;
        if (!isset($_REQUEST['cat'])) {
            $_REQUEST['cat'] = $cat;
        }
    }
    if (!empty($_REQUEST['organicgroup']) && empty($_REQUEST['cat'])) {
        $ogname = 'syn_organicgrp_' . $_REQUEST['organicgroup'];
        $cat = \TikiLib::lib('categ')->get_category_id($ogname);
        $_REQUEST['cat'] = $cat;
    }
    // if og is private, always redirect to home page
    if (isset($_REQUEST['organicgroup'])) {
        $ogname = 'syn_organicgrp_' . $_REQUEST['organicgroup'];
        global $user;
        if ($_REQUEST['page'] != 'syn_organicgrp_grouphomepage' && $api->organicGroupIsPrivate($ogname) && !\TikiLib::lib('user')->user_is_in_group($user, $ogname)) {
            header('Location: tiki-index.php?page=syn_organicgrp_grouphomepage&itemId=' . $_REQUEST['organicgroup']);
        }
    }
    $userlib = \TikiLib::lib('user');
    $approvalCount = $userlib->nb_users_in_group("syn_organicgrp_pending_" . $_REQUEST['organicgroup']);
    //get the number of pending users
    $app->smarty->assign('approvalcount', $approvalCount);
    $app->smarty->assign('groupnavfrom', $params['from']);
    return $app->smarty->fetch('syn-groupnavloader.tpl');
}
Пример #4
0
 public static function refresh()
 {
     self::$installed = array();
     self::$paths = array();
     foreach (glob(TIKI_PATH . '/addons/*/tikiaddon.json') as $file) {
         try {
             $conf = json_decode(file_get_contents($file));
             $package = str_replace('_', '/', basename(dirname($file)));
             self::$installed[$package] = $conf;
             self::$paths[$package] = dirname($file);
             self::initializeGroupApi($package);
             self::initializeNavbarApi($package);
             self::initializeFileGalleryApi($package);
             self::initializeEventsApi($package);
             self::initializeSearchApi($package);
         } catch (InvalidArgumentException $e) {
             // Do nothing, absence of tikiaddon.json
         }
     }
 }
Пример #5
0
function libaccess($data, $params)
{
    // extracts parameters passed from wikiplugin_addon.php
    // Note that $data is the data passed as well
    extract($params, EXTR_SKIP);
    $og_addon = \TikiAddons::get('syn_organicgrp');
    $oglib = $og_addon->lib('organicgrp');
    $result = "";
    switch ($function) {
        case "getOrganicGroupIdByCat":
            if (empty($category)) {
                return false;
            }
            return $oglib->getOrganicGroupIdByCat($category);
        case "getCatByOrganicGroupId":
            if (empty($organicgrp)) {
                return false;
            }
            return $oglib->getCatByOrganicGroupId($organicgrp);
    }
    return "Library function not found";
}
Пример #6
0
function wikiplugin_showpref($data, $params)
{
    global $prefs;
    $tikilib = TikiLib::lib('tiki');
    $name = $params['pref'];
    if (substr($name, 0, 3) == 'ta_') {
        $midpos = strpos($name, '_', 3);
        $pos = strpos($name, '_', $midpos + 1);
        $file = substr($name, 0, $pos);
    } elseif (false !== ($pos = strpos($name, '_'))) {
        $file = substr($name, 0, $pos);
    } else {
        $file = 'global';
    }
    $inc_file = "lib/prefs/{$file}.php";
    if (substr($file, 0, 3) == "ta_") {
        $paths = TikiAddons::getPaths();
        $package = str_replace('_', '/', substr($file, 3));
        $inc_file = $paths[$package] . "/prefs/{$file}.php";
    }
    if (file_exists($inc_file)) {
        require_once $inc_file;
        $function = "prefs_{$file}_list";
        if (function_exists($function)) {
            $preffile = $function();
        } else {
            $preffile = array();
        }
    }
    // Security public prefs only, you would not want all prefs to be displayed via wiki syntax
    if (isset($preffile[$name]['public']) && $preffile[$name]['public']) {
        return $tikilib->get_preference($name);
    } else {
        return '';
    }
}
Пример #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $addon_utilities = new \TikiAddons_Utilities();
     $addonName = $input->getArgument('addon');
     if (strpos($addonName, '/') !== false && strpos($addonName, '_') === false) {
         $package = $addonName;
         $folder = str_replace('/', '_', $addonName);
     } else {
         $package = str_replace('_', '/', $addonName);
         $folder = $addonName;
     }
     $repository = 'file://addons/' . $folder . '/profiles';
     $ignoredepends = $input->getOption('ignoredepends');
     $confirm = $input->getOption('confirm');
     if (empty(glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml'))) {
         $output->writeln("<error>No profiles found.</error>");
         return;
     }
     if (!$ignoredepends) {
         $addon_utilities->checkDependencies($folder);
     }
     $upgradeInfo = json_decode(file_get_contents(TIKI_PATH . '/addons/' . $folder . '/upgrade.json'));
     $validVersions = array();
     foreach ($upgradeInfo as $version => $info) {
         $validVersions[] = $version;
     }
     $config = null;
     $lastVersionInstalled = $addon_utilities->getLastVersionInstalled($folder);
     $reapplyProfiles = array();
     $forgetProfiles = array();
     $removeItems = array();
     foreach ($validVersions as $v) {
         if ($addon_utilities->checkVersionMatch($lastVersionInstalled, $v)) {
             $config = $upgradeInfo->{$v};
             $removeItems = $config->remove;
             $forgetProfiles = $config->forget;
             $reapplyProfiles = $config->reapply;
             break;
         }
     }
     $addons = \TikiAddons::getInstalled();
     if (!$config) {
         if (strnatcmp($lastVersionInstalled, $addons[$package]->version) <= 0) {
             $output->writeln("<error>Currently installed version ({$lastVersionInstalled}) is already up to date.</error>");
         } else {
             $output->writeln("<error>No valid versions currently installed to upgrade found.</error>");
         }
         return false;
     }
     $installedProfiles = $addon_utilities->getInstalledProfiles($folder);
     $installedProfileNames = array_keys($installedProfiles);
     $willRemove = false;
     foreach ($removeItems as $remove) {
         if (empty($remove->profile)) {
             $profile = '';
         } else {
             $profile = $remove->profile;
         }
         $objectId = $addon_utilities->getObjectId($folder, $remove->ref, $profile);
         $objectType = $remove->type;
         if ($objectId) {
             if ($confirm) {
                 $addon_utilities->removeObject($objectId, $objectType);
                 $output->writeln("{$objectType} '{$objectId}' has been deleted.");
             } else {
                 $output->writeln("<info>{$objectType} '{$objectId}' will be deleted.</info>");
             }
             $willRemove = true;
         }
     }
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     // First forget profiles that need to be forgotten
     foreach ($forgetProfiles as $toForget) {
         if (in_array($toForget, $installedProfileNames)) {
             if ($confirm || !$willRemove) {
                 $addon_utilities->forgetProfileAllVersions($folder, $toForget);
                 $profile = \Tiki_Profile::fromNames($repository, $toForget);
                 if (!$profile) {
                     $output->writeln("<error>Profile {$toForget} not found.</error>");
                 } else {
                     $installer->forget($profile);
                 }
             } else {
                 $output->writeln("<info>The installed profile {$toForget} will be forgotten.</info>");
             }
         }
     }
     if (!$confirm && $willRemove) {
         $output->writeln("<error>There will be NO undo, and all data in the above objects will be deleted as part of the upgrade.</error>");
         $output->writeln("<info>Use the --confirm option to proceed with removal and upgrade.</info>");
     }
     if ($confirm || !$willRemove) {
         // Finally install profiles
         foreach (glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml') as $file) {
             $profileName = str_replace('.yml', '', basename($file));
             $profile = \Tiki_Profile::fromNames($repository, $profileName);
             if (in_array($profileName, $reapplyProfiles)) {
                 $reapply = true;
             } else {
                 $reapply = false;
             }
             if (!$profile) {
                 $output->writeln("<error>Profile {$profileName} not found.</error>");
                 continue;
             }
             $isInstalled = $installer->isInstalled($profile);
             if ($isInstalled && $reapply) {
                 $installer->forget($profile);
                 $isInstalled = false;
             }
             if (!$isInstalled) {
                 $transaction = $tikilib->begin();
                 if ($installer->install($profile)) {
                     $addon_utilities->updateProfile($folder, $addons[$package]->version, $profileName);
                     $transaction->commit();
                     $output->writeln("Profile {$profileName} applied.");
                 } else {
                     $output->writeln("<error>Profile {$profileName} installation failed:</error>");
                     foreach ($installer->getFeedback() as $error) {
                         $output->writeln("<error>{$error}</error>");
                     }
                 }
             } else {
                 $output->writeln("<info>Profile {$profileName} was already applied. Nothing happened.</info>");
             }
         }
     }
 }
Пример #8
0
                $sequence = $tikilib->generate_unique_sequence(16);
                $_SESSION['extra_validation'] = $sequence;
                setcookie($extra_cookie_name, $sequence, time() + 365 * 24 * 3600, ini_get('session.cookie_path'));
                unset($sequence);
            }
        } catch (Zend_Session_Exception $e) {
            // Ignore
        }
    }
}
// Moved here from tiki-setup.php because smarty use a copy of session
if (isset($prefs['feature_fullscreen']) && $prefs['feature_fullscreen'] == 'y') {
    require_once 'lib/setup/fullscreen.php';
}
// Retrieve Tiki addons
TikiAddons::refresh();
// Retrieve all preferences
require_once 'lib/setup/prefs.php';
$access = TikiLib::lib('access');
require_once 'lib/setup/absolute_urls.php';
// Smarty needs session since 2.6.25
global $smarty;
$smarty = TikiLib::lib('smarty');
// Define the special maxRecords global variable
$maxRecords = $prefs['maxRecords'];
$smarty->assignByRef('maxRecords', $maxRecords);
global $userlib;
$userlib = TikiLib::lib('user');
require_once 'lib/breadcrumblib.php';
// ------------------------------------------------------
// DEAL WITH XSS-TYPE ATTACKS AND OTHER REQUEST ISSUES
Пример #9
0
if (!empty($_SESSION['try_theme'])) {
    list($theme_active, $theme_option_active) = $themelib->extract_theme_and_option($_SESSION['try_theme']);
}
//START loading theme related items
//1) Always add default bootstrap JS and make some preference settings
$headerlib->add_jsfile('vendor/twitter/bootstrap/dist/js/bootstrap.js');
$headerlib->add_jsfile('lib/jquery_tiki/tiki-bootstrapmodalfix.js');
if ($prefs['feature_fixed_width'] === 'y') {
    $headerlib->add_css('@media (min-width: 1200px) { .container { width:' . (!empty($prefs['layout_fixed_width']) ? $prefs['layout_fixed_width'] : '1170px') . '; } }');
}
//2) Always add tiki_base.css. Add it first, so that it can be overriden in the custom themes
$headerlib->add_cssfile("themes/base_files/css/tiki_base.css");
//3) Always add bundled font-awesome css for the default icon fonts
$headerlib->add_cssfile('vendor/fortawesome/font-awesome/css/font-awesome.min.css');
//4) Add Addon custom css first, so it can be overridden by themes
foreach (TikiAddons::getPaths() as $path) {
    foreach (glob('addons/' . basename($path) . '/css/*.css') as $filename) {
        $headerlib->add_cssfile($filename);
    }
}
//5) Now add the theme or theme option
$themelib = TikiLib::lib('theme');
// compile a new CSS file using header_custom_less and using the real theme and the theme option
if (!empty($prefs['header_custom_less'])) {
    $cssfiles = $headerlib->compile_custom_less($prefs['header_custom_less'], $theme_active, $theme_option_active);
    foreach ($cssfiles as $cssfile) {
        $headerlib->add_cssfile($cssfile);
    }
} else {
    if ($theme_active == 'custom_url' && !empty($prefs['theme_custom_url'])) {
        //custom URL, use only if file exists at the custom location
Пример #10
0
 private function getAvailableFiles()
 {
     $files = array();
     foreach (glob(__DIR__ . '/prefs/*.php') as $file) {
         if (basename($file) === "index.php") {
             continue;
         }
         $files[] = substr(basename($file), 0, -4);
     }
     foreach (TikiAddons::getPaths() as $path) {
         foreach (glob($path . '/prefs/*.php') as $file) {
             if (basename($file) === "index.php") {
                 continue;
             }
             $files[] = substr(basename($file), 0, -4);
         }
     }
     return $files;
 }
Пример #11
0
 function initializePaths()
 {
     global $prefs, $tikidomainslash, $section;
     if (!$this->main_template_dir) {
         // First run only
         $this->main_template_dir = TIKI_PATH . '/templates/';
         $this->setCompileDir(TIKI_PATH . "/templates_c");
         $this->setPluginsDir(array(TIKI_PATH . '/' . TIKI_SMARTY_DIR, SMARTY_DIR . 'plugins'));
     }
     $this->setTemplateDir([]);
     // when called from release.php TikiLib isn't initialised so we can ignore the themes and addons
     if (class_exists('TikiLib')) {
         // Theme templates
         $themelib = TikiLib::lib('theme');
         if (!empty($prefs['theme']) && !in_array($prefs['theme'], ['custom_url'])) {
             $theme_path = $themelib->get_theme_path($prefs['theme'], $prefs['theme_option'], '', 'templates');
             // path to the theme options
             $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/");
             //if theme_admin is empty, use main theme and site_layout instead of site_layout_admin
             if ($section != "admin" || empty($prefs['theme_admin'])) {
                 $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/" . 'layouts/' . $prefs['site_layout'] . '/');
             } else {
                 $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/" . 'layouts/' . $prefs['site_layout_admin'] . '/');
             }
             $this->addTemplateDir(TIKI_PATH . "/{$theme_path}/" . 'layouts/');
             $main_theme_path = $themelib->get_theme_path($prefs['theme'], '', '', 'templates');
             // path to the main theme
             $this->addTemplateDir(TIKI_PATH . "/{$main_theme_path}/");
             //if theme_admin is empty, use main theme and site_layout instead of site_layout_admin
             if ($section != "admin" || empty($prefs['theme_admin'])) {
                 $this->addTemplateDir(TIKI_PATH . "/{$main_theme_path}/" . 'layouts/' . $prefs['site_layout'] . '/');
             } else {
                 $this->addTemplateDir(TIKI_PATH . "/{$main_theme_path}/" . 'layouts/' . $prefs['site_layout_admin'] . '/');
             }
         }
         // Tikidomain main template folder
         if (!empty($tikidomainslash)) {
             $this->addTemplateDir(TIKI_PATH . "/themes/{$tikidomainslash}templates/");
             // This dir is for all the themes in the tikidomain
             $this->addTemplatedir($this->main_template_dir . '/' . $tikidomainslash);
             // legacy tpls just in case, for example: /templates/mydomain.ltd/
         }
         $this->addTemplateDir(TIKI_PATH . "/themes/templates/");
         //This dir stores templates for all the themes
         //Addon templates
         foreach (TikiAddons::getPaths() as $path) {
             $this->addTemplateDir($path . '/templates/');
         }
     }
     //Layout templates
     if (!empty($prefs['site_layout']) && ($section != "admin" || empty($prefs['theme_admin']))) {
         //use the admin layout if in the admin section
         $this->addTemplateDir($this->main_template_dir . '/layouts/' . $prefs['site_layout'] . '/');
     } elseif (!empty($prefs['site_layout_admin'])) {
         $this->addTemplateDir($this->main_template_dir . '/layouts/' . $prefs['site_layout_admin'] . '/');
     }
     $this->addTemplateDir($this->main_template_dir . '/layouts/');
     $this->addTemplateDir($this->main_template_dir);
 }
Пример #12
0
 function getAddonFilePath($filepath)
 {
     foreach (TikiAddons::getPaths() as $path) {
         if (file_exists($path . "/" . $filepath)) {
             return $path . "/" . $filepath;
         }
     }
     return false;
 }