Esempio n. 1
0
 public static function eventSystemPreferencesForm(XoopsModule $module)
 {
     $helper = \Xoops::getModuleHelper('comments');
     if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments')) {
         $helper->loadLanguage('main');
     }
 }
Esempio n. 2
0
/**
 * synchronize number of posts credited to user
 *
 * @param int    $uid  uid of user row
 * @param string $type type of processing, 'user' for one user, 'all users' for all
 *
 * @return void
 */
function synchronize($uid, $type)
{
    $xoops = Xoops::getInstance();
    $db = $xoops->db();
    switch ($type) {
        case 'user':
            $total_posts = 0;
            /* @var $plugin SystemPluginInterface */
            $plugins = \Xoops\Module\Plugin::getPlugins();
            foreach ($plugins as $plugin) {
                if ($res = $plugin->userPosts($uid)) {
                    $total_posts += $res;
                }
            }
            $query = $db->createXoopsQueryBuilder()->updatePrefix('system_user')->set('posts', ':posts')->where('uid = :uid')->setParameter(':posts', $total_posts)->setParameter(':uid', $uid);
            $result = $query->execute();
            //if (!$result) {
            //    $xoops->redirect("admin.php?fct=users", 1, XoopsLocale::E_USER_NOT_UPDATED);
            //}
            break;
        case 'all users':
            $sql = $db->createXoopsQueryBuilder()->select('uid')->fromPrefix('system_user', 'u');
            $result = $sql->execute();
            if (!$result) {
                $xoops->redirect("admin.php?fct=users", 1, XoopsLocale::E_USER_ID_NOT_FETCHED);
            }
            $rows = $result->fetchAll();
            foreach ($rows as $row) {
                synchronize($row['uid'], "user");
            }
            break;
    }
}
Esempio n. 3
0
 /**
  * remove any userconfigs for module being uninstalled
  *
  * @param array $args index 0 is module object
  *
  * @return void
  */
 public static function eventOnModuleUninstall($args)
 {
     /* @var $module XoopsModule */
     $module = $args[0];
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs')) {
         Userconfigs::getInstance()->getHandlerConfig()->deleteConfigsByModule($module->getVar('mid'));
     }
 }
Esempio n. 4
0
 public static function eventOnSystemPreferencesForm($args)
 {
     /* @var $module XoopsModule */
     $module = $args[0];
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'comments')) {
         Comments::getInstance()->loadLanguage('main');
     }
 }
Esempio n. 5
0
/**
 * Blocks functions
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author      Kazumi Ono (AKA onokazu)
 * @package     system
 * @version     $Id$
 */
function b_system_user_show()
{
    $xoops = Xoops::getInstance();
    if (!$xoops->isUser()) {
        return false;
    }
    $block = array();
    $block['modules'] = array();
    $plugins = \Xoops\Module\Plugin::getPlugins('system');
    $i = 0;
    /* @var $plugin SystemPluginInterface */
    foreach ($plugins as $dirname => $plugin) {
        $menu = $plugin->userMenus();
        if (is_array($menu) && !empty($menu)) {
            $block['modules'][$i]['name'] = $menu['name'];
            $block['modules'][$i]['link'] = $xoops->url('modules/' . $dirname . '/' . $menu['link']);
            $block['modules'][$i]['image'] = $menu['image'];
            $block['modules'][$i]['icon'] = 'icon-tags';
            $block['modules'][$i]['dirname'] = $dirname;
            //todo, remove this hardcoded call
            if ($xoops->isModule() && $xoops->module->getVar('dirname') == $dirname && ($plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'menus'))) {
                if (method_exists($plugin, 'subMenus')) {
                    $sublinks = $plugin->subMenus();
                    foreach ($sublinks as $sublink) {
                        $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => \XoopsBaseConfig::get('url') . '/modules/' . $dirname . '/' . $sublink['url']);
                    }
                }
            }
            ++$i;
        }
    }
    // View Account
    array_unshift($block['modules'], array('name' => XoopsLocale::VIEW_ACCOUNT, 'link' => $xoops->url('userinfo.php?uid=' . $xoops->user->getVar('uid')), 'icon' => 'icon-user'));
    // Edit Account
    array_unshift($block['modules'], array('name' => XoopsLocale::EDIT_ACCOUNT, 'link' => $xoops->url('edituser.php'), 'icon' => 'icon-user'));
    // Administration Menu
    if ($xoops->isAdmin()) {
        array_unshift($block['modules'], array('name' => SystemLocale::ADMINISTRATION_MENU, 'link' => $xoops->url('admin.php'), 'rel' => 'external', 'icon' => 'icon-wrench'));
    }
    // Inbox
    $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
    $criteria->add(new Criteria('to_userid', $xoops->user->getVar('uid')));
    $pm_handler = $xoops->getHandlerPrivateMessage();
    $xoops->preload()->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler));
    $name = XoopsLocale::INBOX;
    $class = '';
    if ($pm_count = $pm_handler->getCount($criteria)) {
        $name = XoopsLocale::INBOX . ' <strong>' . $pm_count . '</strong>';
        $class = 'highlight';
    }
    array_push($block['modules'], array('name' => $name, 'link' => $xoops->url('viewpmsg.php'), 'icon' => 'icon-envelope', 'class' => $class));
    // Logout
    array_push($block['modules'], array('name' => XoopsLocale::A_LOGOUT, 'link' => $xoops->url('user.php?op=logout'), 'icon' => 'icon-off'));
    $block['active_url'] = \Xoops\Core\HttpRequest::getInstance()->getUrl();
    return $block;
}
Esempio n. 6
0
function xoops_module_pre_uninstall_notifications(&$module)
{
    $xoops = Xoops::getInstance();
    XoopsLoad::loadFile($xoops->path('modules/notifications/class/helper.php'));
    $helper = Notifications::getInstance();
    $plugins = \Xoops\Module\Plugin::getPlugins('notifications');
    foreach (array_keys($plugins) as $dirname) {
        $helper->deleteModuleRelations($xoops->getModuleByDirname($dirname));
    }
    return true;
}
Esempio n. 7
0
 /**
  * expects an array of array containing:
  * name,      Name of the submenu
  * url,       Url of the submenu relative to the module
  * ex: return array(0 => array(
  *      'name' => _MI_PUBLISHER_SUB_SMNAME3;
  *      'url' => "search.php";
  *    ));
  *
  * @return array
  */
 public function subMenus()
 {
     $ret = array();
     $xoops = \Xoops::getInstance();
     if ($plugins = \Xoops\Module\Plugin::getPlugins('userconfigs')) {
         foreach (array_keys($plugins) as $dirname) {
             $mHelper = $xoops->getModuleHelper($dirname);
             $ret[$dirname]['name'] = $mHelper->getModule()->getVar('name');
             $ret[$dirname]['url'] = 'index.php?op=showmod&mid=' . $mHelper->getModule()->getVar('mid');
         }
     }
     return $ret;
 }
Esempio n. 8
0
/**
 * Blocks functions
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author      Kazumi Ono (AKA onokazu)
 * @package     system
 * @version     $Id$
 */
function b_system_waiting_show()
{
    $block = array();
    $plugins = \Xoops\Module\Plugin::getPlugins('system');
    /* @var $plugin SystemPluginInterface */
    foreach ($plugins as $plugin) {
        if (is_array($res = $plugin->waiting())) {
            if (isset($res['count']) && isset($res['name']) && isset($res['link'])) {
                $block['waiting'][] = $res;
            }
        }
    }
    return $block;
}
Esempio n. 9
0
 public function getSearchFrom($andor, $queries, $mids, $mid)
 {
     $xoops = Xoops::getInstance();
     $search = Search::getInstance();
     // create form
     parent::__construct(_MD_SEARCH, 'search', 'index.php', 'get');
     // create form elements
     $this->addElement(new Xoops\Form\Text(_MD_SEARCH_KEYWORDS, 'query', 30, 255, htmlspecialchars(stripslashes($this->queryArrayToString($queries)), ENT_QUOTES)), true);
     $type_select = new Xoops\Form\Select(_MD_SEARCH_TYPE, 'andor', $andor);
     $type_select->addOptionArray(array('AND' => _MD_SEARCH_ALL, 'OR' => _MD_SEARCH_ANY));
     $this->addElement($type_select);
     if (!empty($mids)) {
         $mods_checkbox = new Xoops\Form\Checkbox(_MD_SEARCH_SEARCHIN, 'mids[]', $mids);
     } else {
         $mods_checkbox = new Xoops\Form\Checkbox(_MD_SEARCH_SEARCHIN, 'mids[]', $mid);
     }
     if (empty($modules)) {
         $gperm_handler = $xoops->getHandlerGroupperm();
         $available_modules = $gperm_handler->getItemIds('module_read', $xoops->getUserGroups());
         $available_plugins = \Xoops\Module\Plugin::getPlugins('search');
         //todo, would be nice to have the module ids availabe also
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('dirname', "('" . implode("','", array_keys($available_plugins)) . "')", 'IN'));
         if (isset($available_modules) && !empty($available_modules)) {
             $criteria->add(new Criteria('mid', '(' . implode(',', $available_modules) . ')', 'IN'));
         }
         $module_handler = $xoops->getHandlerModule();
         $mods_checkbox->addOptionArray($module_handler->getNameList($criteria));
     } else {
         /* @var $module XoopsModule */
         $module_array = array();
         foreach ($modules as $mid => $module) {
             $module_array[$mid] = $module->getVar('name');
         }
         $mods_checkbox->addOptionArray($module_array);
     }
     $this->addElement($mods_checkbox);
     if ($search->getConfig('keyword_min') > 0) {
         $this->addElement(new Xoops\Form\Label(_MD_SEARCH_SEARCHRULE, sprintf(_MD_SEARCH_KEYIGNORE, $search->getConfig('keyword_min'))));
     }
     $this->addElement(new Xoops\Form\Hidden('action', 'results'));
     $this->addElement(new Xoops\Form\Token('id'));
     $this->addElement(new Xoops\Form\Button('', 'submit', _MD_SEARCH, 'submit'));
     return $this;
 }
Esempio n. 10
0
 /**
  * @param XoopsModule|null $mod
  */
 public function getModulesForm($mod = null)
 {
     $xoops = Xoops::getInstance();
     $mid = 0;
     if ($mod instanceof XoopsModule) {
         $mid = $mod->getVar('mid');
     }
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugins = \Xoops\Module\Plugin::getPlugins('userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true, 'inline');
         $ele = new Xoops\Form\Select(_MD_USERCONFIGS_CHOOSE_MODULE, 'mid', $mid);
         foreach (array_keys($plugins) as $dirname) {
             $mHelper = $xoops->getModuleHelper($dirname);
             $ele->addOption($mHelper->getModule()->getVar('mid'), $mHelper->getModule()->getVar('name'));
         }
         $this->addElement($ele);
         $this->addElement(new Xoops\Form\Hidden('op', 'showmod'));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Esempio n. 11
0
/**
 * Blocks functions
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author      Kazumi Ono (AKA onokazu)
 * @package     system
 * @version     $Id$
 */
function b_system_main_show()
{
    $xoops = Xoops::getInstance();
    $block = array();
    $block['lang_home'] = XoopsLocale::HOME;
    $block['lang_close'] = XoopsLocale::A_CLOSE;
    $module_handler = $xoops->getHandlerModule();
    $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
    $criteria->add(new Criteria('isactive', 1));
    $criteria->add(new Criteria('weight', 0, '>'));
    $modules = $module_handler->getObjectsArray($criteria, true);
    $moduleperm_handler = $xoops->getHandlerGroupperm();
    $groups = $xoops->getUserGroups();
    $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups);
    /* @var $module XoopsModule */
    foreach ($modules as $i => $module) {
        if (in_array($i, $read_allowed)) {
            $block['modules'][$i]['name'] = $module->getVar('name');
            $block['modules'][$i]['dirname'] = $module->getVar('dirname');
            if (XoopsLoad::fileExists($xoops->path('modules/' . $module->getVar('dirname') . '/icons/logo_small.png'))) {
                $block['modules'][$i]['image'] = $xoops->url('modules/' . $module->getVar('dirname') . '/icons/logo_small.png');
            }
            if ($xoops->isModule() && $i == $xoops->module->getVar('mid')) {
                $block['modules'][$i]['highlight'] = true;
                $block['nothome'] = true;
            }
            if ($xoops->module && $i == $xoops->module->getVar('mid')) {
                $block['modules'][$i]['highlight'] = true;
                $block['nothome'] = true;
            }
            /* @var $plugin MenusPluginInterface */
            if ($xoops->isModule() && $module->getVar('dirname') == $xoops->module->getVar('dirname') && ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'menus'))) {
                $sublinks = $plugin->subMenus();
                foreach ($sublinks as $sublink) {
                    $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => \XoopsBaseConfig::get('url') . '/modules/' . $module->getVar('dirname') . '/' . $sublink['url']);
                }
            }
        }
    }
    return $block;
}
Esempio n. 12
0
 protected function getModuleMenus($dirname, $pid)
 {
     static $id = -1;
     $xoops = Xoops::getInstance();
     $helper = Menus::getInstance();
     $ret = array();
     /* @var $plugin MenusPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'menus')) {
         if (is_array($subMenus = $plugin->subMenus())) {
             foreach ($subMenus as $menu) {
                 $obj = $helper->getHandlerMenu()->create();
                 $obj->setVar('title', $menu['name']);
                 $obj->setVar('alt_title', $menu['name']);
                 $obj->setVar('link', $xoops->url("modules/{$dirname}/{$menu['url']}"));
                 $obj->setVar('id', $id);
                 $obj->setVar('pid', $pid);
                 $ret[] = $obj->getValues();
                 $id--;
             }
         }
     }
     return $ret;
 }
Esempio n. 13
0
 public function createDefaultUserConfigs($uid, XoopsModule $module)
 {
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs')) {
         // now reinsert them with the new settings
         $configs = $plugin->configs();
         if (!is_array($configs)) {
             $configs = array();
         }
         if (is_array($configs) && count($configs) > 0) {
             $order = 0;
             foreach ($configs as $config) {
                 $confobj = $this->createConfig();
                 $confobj->setVar('conf_modid', $module->getVar('mid'));
                 $confobj->setVar('conf_uid', $uid);
                 $confobj->setVar('conf_name', $config['name']);
                 $confobj->setVar('conf_title', $config['title'], true);
                 $confobj->setVar('conf_desc', $config['description'], true);
                 $confobj->setVar('conf_formtype', $config['formtype']);
                 $confobj->setVar('conf_valuetype', $config['valuetype']);
                 $confobj->setConfValueForInput($config['default'], true);
                 $confobj->setVar('conf_order', $order);
                 if (isset($config['options']) && is_array($config['options'])) {
                     foreach ($config['options'] as $key => $value) {
                         $confop = $this->createConfigOption();
                         $confop->setVar('confop_name', $key, true);
                         $confop->setVar('confop_value', $value, true);
                         $confobj->setConfOptions($confop);
                         unset($confop);
                     }
                 }
                 ++$order;
                 $this->insertConfig($confobj);
                 unset($confobj);
             }
             unset($configs);
         }
     }
 }
Esempio n. 14
0
    $xoops->redirect($xoops->url('index.php'), 3, _MD_USERCONFIGS_NOACCESS);
}
$mid = Request::getInt('mid', 0);
$uid = $xoops->user->getVar('uid');
$op = Request::getCmd('op', 'show');
$xoops->header('module:userconfigs/list.tpl');
$xoops->tpl()->assign('welcome', sprintf(_MD_USERCONFIGS_WELCOME, XoopsUserUtility::getUnameFromId($xoops->user->getVar('uid'), true)));
//Display part
switch ($op) {
    case 'showmod':
        if (!$mid) {
            $xoops->redirect($xoops->url('index.php'), 3, _MD_USERCONFIGS_NOMOD);
        }
        $module = $xoops->getModuleById($mid);
        /* @var $plugin UserconfigsPluginInterface */
        if (!($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs'))) {
            $xoops->redirect($xoops->url('index.php'), 3, _MD_USERCONFIGS_NOPLUGIN);
        }
        $config_handler = $helper->getHandlerConfig();
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('conf_modid', $module->getVar('mid')));
        $criteria->add(new Criteria('conf_uid', $uid));
        $configs = $config_handler->getConfigs($criteria);
        if (empty($configs) || count($configs) != count($plugin->configs())) {
            foreach (array_keys($configs) as $i) {
                $config_handler->deleteConfig($configs[$i]);
            }
            $config_handler->createDefaultUserConfigs($uid, $module);
            $configs = $config_handler->getConfigs($criteria);
        }
        /* @var $form UserconfigsConfigsForm */
Esempio n. 15
0
 /**
  * @param array       $obj
  * @param XoopsModule $mod
  */
 public function getForm(&$obj, XoopsModule $mod)
 {
     $xoops = Xoops::getInstance();
     $helper = Userconfigs::getInstance();
     $config_handler = $helper->getHandlerConfig();
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true);
         if ($mod->getVar('dirname') != 'system') {
             $xoops->loadLanguage('modinfo', $mod->getVar('dirname'));
             $xoops->loadLocale($mod->getVar('dirname'));
         }
         $configs = $plugin->configs();
         $configNames = array();
         foreach (array_keys($configs) as $i) {
             $configNames[$configs[$i]['name']] =& $configs[$i];
         }
         $configCats = $plugin->categories();
         if (!$configCats) {
             $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''));
         }
         if (!in_array('default', array_keys($configCats))) {
             $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '');
         }
         foreach (array_keys($configNames) as $name) {
             if (!isset($configNames[$name]['category'])) {
                 $configNames[$name]['category'] = 'default';
             }
         }
         $tabtray = new Xoops\Form\TabTray('', 'pref_tabtay', $xoops->getModuleConfig('jquery_theme', 'system'));
         $tabs = array();
         foreach ($configCats as $name => $info) {
             $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name);
             if (isset($info['description']) && $info['description'] != '') {
                 $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description']));
             }
         }
         $count = count($obj);
         for ($i = 0; $i < $count; ++$i) {
             $title = Xoops_Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname'));
             $desc = $obj[$i]->getVar('conf_desc') != '' ? Xoops_Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : '';
             switch ($obj[$i]->getVar('conf_formtype')) {
                 case 'textarea':
                     $myts = MyTextSanitizer::getInstance();
                     if ($obj[$i]->getVar('conf_valuetype') == 'array') {
                         // this is exceptional.. only when value type is arrayneed a smarter way for this
                         $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5);
                     } else {
                         $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5);
                     }
                     break;
                 case 'select':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'select_multi':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'yesno':
                     $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'theme':
                 case 'theme_multi':
                     $ele = $obj[$i]->getVar('conf_formtype') != 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $dirlist = XoopsLists::getThemesList();
                     if (!empty($dirlist)) {
                         asort($dirlist);
                         $ele->addOptionArray($dirlist);
                     }
                     break;
                 case 'tplset':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $tplset_handler = $xoops->getHandlerTplSet();
                     $tplsetlist = $tplset_handler->getNameList();
                     asort($tplsetlist);
                     foreach ($tplsetlist as $key => $name) {
                         $ele->addOption($key, $name);
                     }
                     break;
                 case 'cpanel':
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     /*
                                             $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
                                             XoopsLoad::load("cpanel", "system");
                                             $list = XoopsSystemCpanel::getGuis();
                                             $ele->addOptionArray($list);  */
                     break;
                 case 'timezone':
                     $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'language':
                     $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'locale':
                     $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'startpage':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $module_handler = $xoops->getHandlerModule();
                     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
                     $criteria->add(new Criteria('isactive', 1));
                     $moduleslist = $module_handler->getNameList($criteria, true);
                     $moduleslist['--'] = XoopsLocale::NONE;
                     $ele->addOptionArray($moduleslist);
                     break;
                 case 'group':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'group_multi':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                     // RMV-NOTIFY: added 'user' and 'user_multi'
                 // RMV-NOTIFY: added 'user' and 'user_multi'
                 case 'user':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'user_multi':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                 case 'module_cache':
                     $module_handler = $xoops->getHandlerModule();
                     $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true);
                     $currrent_val = $obj[$i]->getConfValueForOutput();
                     $cache_options = array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH);
                     if (count($modules) > 0) {
                         $ele = new Xoops\Form\ElementTray($title, '<br />');
                         foreach (array_keys($modules) as $mid) {
                             $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null;
                             $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val);
                             $selform->addOptionArray($cache_options);
                             $ele->addElement($selform);
                             unset($selform);
                         }
                     } else {
                         $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE);
                     }
                     break;
                 case 'site_cache':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $ele->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH));
                     break;
                 case 'password':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'color':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'hidden':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'textbox':
                 default:
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
             }
             $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id'));
             if (isset($ele)) {
                 $ele->setDescription($desc);
                 if ($obj[$i]->getVar('conf_formtype') != 'hidden') {
                     $name = 'default';
                     if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) {
                         $name = $configNames[$obj[$i]->getVar('conf_name')]['category'];
                     }
                     $tabs[$name]->addElement($ele);
                 } else {
                     $this->addElement($ele);
                 }
                 $this->addElement($hidden);
                 unset($ele);
                 unset($hidden);
             }
         }
         foreach (array_keys($tabs) as $name) {
             if ($tabs[$name]->getElements()) {
                 $tabtray->addElement($tabs[$name]);
             }
         }
         $this->addElement($tabtray);
         $this->addElement(new Xoops\Form\Hidden('op', 'save'));
         $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid')));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Esempio n. 16
0
 public function displayDelete()
 {
     $xoops = Xoops::getInstance();
     $op = Request::getCmd('op', 'delete', 'POST');
     $mode = Request::getString('com_mode', 'flat');
     $order = Request::getString('com_order', COMMENTS_OLD1ST);
     $id = Request::getInt('com_id');
     /* @var $comment CommentsComment */
     /* @var $comment_handler CommentsCommentHandler */
     $comment_handler = $this->getHandlerComment();
     $comment = $comment_handler->get($id);
     if (!is_object($comment)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $module = $xoops->getModuleById($comment->getVar('modid'));
     if (!is_object($module)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     if (!$xoops->isAdminSide && COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname')) || !$xoops->isUser() && !$xoops->getModuleConfig('com_anonpost', $module->getVar('dirname')) || !$xoops->isModule()) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $modid = $module->getVar('mid');
     /* @var $plugin CommentsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'comments')) {
         if ($xoops->isAdminSide) {
             $redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&amp;com_itemid');
         } else {
             $redirect_page = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $plugin->pageName() . '?');
             $comment_confirm_extra = array();
             if (is_array($extraParams = $plugin->extraParams())) {
                 foreach ($extraParams as $extra_param) {
                     if (isset($_GET[$extra_param])) {
                         $redirect_page .= $extra_param . '=' . $_GET[$extra_param] . '&amp;';
                         // for the confirmation page
                         $comment_confirm_extra[$extra_param] = $_GET[$extra_param];
                     }
                 }
             }
             $redirect_page .= $plugin->itemName();
         }
         $accesserror = false;
         if (!$xoops->isUser()) {
             $accesserror = true;
         } else {
             if (!$xoops->user->isAdmin($modid)) {
                 $accesserror = true;
             }
         }
         if (false != $accesserror) {
             $ref = $xoops->getEnv('HTTP_REFERER');
             if ($ref != '') {
                 $xoops->redirect($ref, 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
             } else {
                 $xoops->redirect($redirect_page . '?' . $plugin->itemName() . '=' . (int) $id, 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
             }
         }
         switch ($op) {
             case 'delete_one':
                 if (!$comment_handler->delete($comment)) {
                     $xoops->header();
                     echo $xoops->alert('error', _MD_COMMENTS_COMDELETENG . ' (ID: ' . $comment->getVar('id') . ')');
                     $xoops->footer();
                 }
                 $itemid = $comment->getVar('itemid');
                 $criteria = new CriteriaCompo(new Criteria('modid', $modid));
                 $criteria->add(new Criteria('itemid', $itemid));
                 $criteria->add(new Criteria('status', COMMENTS_ACTIVE));
                 $comment_count = $comment_handler->getCount($criteria);
                 $plugin->update($itemid, $comment_count);
                 // update user posts if its not an anonymous post
                 if ($comment->getVar('uid') != 0) {
                     $member_handler = $xoops->getHandlerMember();
                     $poster = $member_handler->getUser($comment->getVar('uid'));
                     if (is_object($poster)) {
                         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') - 1);
                     }
                 }
                 // get all comments posted later within the same thread
                 $thread_comments = $comment_handler->getThread($comment->getVar('rootid'), $id);
                 $xot = new XoopsObjectTree($thread_comments, 'id', 'pid', 'rootid');
                 $child_comments = $xot->getFirstChild($id);
                 // now set new parent ID for direct child comments
                 $new_pid = $comment->getVar('pid');
                 $errs = array();
                 foreach (array_keys($child_comments) as $i) {
                     $child_comments[$i]->setVar('pid', $new_pid);
                     // if the deleted comment is a root comment, need to change root id to own id
                     if (false != $comment->isRoot()) {
                         $new_rootid = $child_comments[$i]->getVar('id');
                         $child_comments[$i]->setVar('rootid', $child_comments[$i]->getVar('id'));
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <strong>' . $id . '</strong> to <strong>' . $new_pid . '</strong>. (ID: ' . $new_rootid . ')';
                         } else {
                             // need to change root id for all its child comments as well
                             $c_child_comments = $xot->getAllChild($new_rootid);
                             $cc_count = count($c_child_comments);
                             foreach (array_keys($c_child_comments) as $j) {
                                 $c_child_comments[$j]->setVar('rootid', $new_rootid);
                                 if (!$comment_handler->insert($c_child_comments[$j])) {
                                     $errs[] = 'Could not change comment root ID from <strong>' . $id . '</strong> to <strong>' . $new_rootid . '</strong>.';
                                 }
                             }
                         }
                     } else {
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <strong>' . $id . '</strong> to <strong>' . $new_pid . '</strong>.';
                         }
                     }
                 }
                 if (count($errs) > 0) {
                     $xoops->header();
                     echo $xoops->alert('error', $errs);
                     $xoops->footer();
                     exit;
                 }
                 $xoops->redirect($redirect_page . '=' . $itemid . '&amp;com_order=' . $order . '&amp;com_mode=' . $mode, 1, _MD_COMMENTS_COMDELETED);
                 break;
             case 'delete_all':
                 $rootid = $comment->getVar('rootid');
                 // get all comments posted later within the same thread
                 $thread_comments = $comment_handler->getThread($rootid, $id);
                 // construct a comment tree
                 $xot = new XoopsObjectTree($thread_comments, 'id', 'pid', 'rootid');
                 $child_comments = $xot->getAllChild($id);
                 // add itself here
                 $child_comments[$id] = $comment;
                 $msgs = array();
                 $deleted_num = array();
                 $member_handler = $xoops->getHandlerMember();
                 foreach (array_keys($child_comments) as $i) {
                     if (!$comment_handler->delete($child_comments[$i])) {
                         $msgs[] = _MD_COMMENTS_COMDELETENG . ' (ID: ' . $child_comments[$i]->getVar('id') . ')';
                     } else {
                         $msgs[] = _MD_COMMENTS_COMDELETED . ' (ID: ' . $child_comments[$i]->getVar('id') . ')';
                         // store poster ID and deleted post number into array for later use
                         $poster_id = $child_comments[$i]->getVar('uid');
                         if ($poster_id > 0) {
                             $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : $deleted_num[$poster_id] + 1;
                         }
                     }
                 }
                 foreach ($deleted_num as $user_id => $post_num) {
                     // update user posts
                     $poster = $member_handler->getUser($user_id);
                     if (is_object($poster)) {
                         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') - $post_num);
                     }
                 }
                 $itemid = $comment->getVar('itemid');
                 $criteria = new CriteriaCompo(new Criteria('modid', $modid));
                 $criteria->add(new Criteria('itemid', $itemid));
                 $criteria->add(new Criteria('status', COMMENTS_ACTIVE));
                 $comment_count = $comment_handler->getCount($criteria);
                 $plugin->update($itemid, $comment_count);
                 $xoops->header();
                 echo $xoops->alert('info', $msgs);
                 echo '<br /><a href="' . $redirect_page . '=' . $itemid . '&amp;com_order=' . $order . '&amp;com_mode=' . $mode . '">' . XoopsLocale::GO_BACK . '</a>';
                 $xoops->footer();
                 break;
             case 'delete':
             default:
                 $xoops->header();
                 $comment_confirm = array('com_id' => $id, 'com_mode' => $mode, 'com_order' => $order, 'op' => array(_MD_COMMENTS_DELETEONE => 'delete_one', _MD_COMMENTS_DELETEALL => 'delete_all'));
                 if (!empty($comment_confirm_extra) && is_array($comment_confirm_extra)) {
                     $comment_confirm = $comment_confirm + $comment_confirm_extra;
                 }
                 echo $xoops->confirm($comment_confirm, 'comment_delete.php', _MD_COMMENTS_DELETESELECT);
                 $xoops->footer();
                 break;
         }
     }
 }
Esempio n. 17
0
$op = $system->cleanVars($_REQUEST, 'op', 'default', 'string');
// Call Header
$xoops->header('admin:comments/comments.tpl');
$admin_page = new \Xoops\Module\Admin();
$admin_page->renderNavigation('main.php');
$limit_array = array(20, 50, 100);
$status_array = array(COMMENTS_PENDING => _MD_COMMENTS_PENDING, COMMENTS_ACTIVE => _MD_COMMENTS_ACTIVE, COMMENTS_HIDDEN => _MD_COMMENTS_HIDDEN);
$status_array2 = array(COMMENTS_PENDING => '<span style="text-decoration: none; font-weight: bold; color: #008000;">' . _MD_COMMENTS_PENDING . '</span>', COMMENTS_ACTIVE => '<span style="text-decoration: none; font-weight: bold; color: #ff0000;">' . _MD_COMMENTS_ACTIVE . '</span>', COMMENTS_HIDDEN => '<span style="text-decoration: none; font-weight: bold; color: #0000ff;">' . _MD_COMMENTS_HIDDEN . '</span>');
$start = 0;
$status_array[0] = _AM_COMMENTS_FORM_ALL_STATUS;
$comments = array();
$status = !isset($_REQUEST['status']) || !in_array((int) $_REQUEST['status'], array_keys($status_array)) ? 0 : (int) $_REQUEST['status'];
$module = !isset($_REQUEST['module']) ? 0 : (int) $_REQUEST['module'];
$modules_array = array();
$module_handler = $xoops->getHandlerModule();
$available_plugins = \Xoops\Module\Plugin::getPlugins('comments');
if (!empty($available_plugins)) {
    $criteria = new Criteria('dirname', "('" . implode("','", array_keys($available_plugins)) . "')", 'IN');
    $module_array = $module_handler->getNameList($criteria);
}
$module_array[0] = _AM_COMMENTS_FORM_ALL_MODS;
$comment_handler = $helper->getHandlerComment();
switch ($op) {
    case 'comments_jump':
        $id = $system->cleanVars($_GET, 'item_id', 0, 'int');
        if ($id > 0) {
            $comment = $comment_handler->get($id);
            if (is_object($comment)) {
                /* @var $plugin CommentsPluginInterface */
                $module = $xoops->getModuleById($comment->getVar('modid'));
                $plugin = Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'comments');
Esempio n. 18
0
 /**
  * @param CommentsComment $obj
  */
 public function __construct(CommentsComment $obj)
 {
     $xoops = Xoops::getInstance();
     $helper = $xoops->getModuleHelper('comments');
     $module = $xoops->getModuleById($obj->getVar('modid'));
     if (!is_object($module)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $dirname = $module->getVar('dirname');
     // create form
     if ($xoops->isAdminSide) {
         $url = $helper->url("admin/comment_post.php");
     } else {
         $url = $helper->url("comment_post.php");
     }
     parent::__construct(_MD_COMMENTS_POSTCOMMENT, "commentform", $url, "post", true);
     switch ($xoops->getModuleConfig('com_rule', $dirname)) {
         case Comments::APPROVE_ALL:
             $rule_text = _MD_COMMENTS_COMAPPROVEALL;
             break;
         case Comments::APPROVE_USER:
             $rule_text = _MD_COMMENTS_COMAPPROVEUSER;
             break;
         case Comments::APPROVE_ADMIN:
         default:
             $rule_text = _MD_COMMENTS_COMAPPROVEADMIN;
             break;
     }
     $this->addElement(new Xoops\Form\Label(_MD_COMMENTS_COMRULES, $rule_text));
     $this->addElement(new Xoops\Form\Text(_MD_COMMENTS_TITLE, 'com_title', 50, 255, $obj->getVar('title', 'e')), true);
     $iconsRadio = new Xoops\Form\Radio(XoopsLocale::MESSAGE_ICON, 'com_icon', $obj->getVar('icon', 'e'));
     \Xoops\Core\Lists\SubjectIcon::setOptionsArray($iconsRadio);
     $this->addElement($iconsRadio);
     // editor
     $editor = $helper->getConfig('com_editor');
     if (class_exists('Xoops\\Form\\Editor')) {
         $configs = array('name' => 'com_text', 'value' => $obj->getVar('text', 'e'), 'rows' => 25, 'cols' => 90, 'width' => '100%', 'height' => '400px', 'editor' => $editor);
         $this->addElement(new Xoops\Form\Editor(_MD_COMMENTS_MESSAGE, 'com_text', $configs, false, $onfailure = 'textarea'));
     } else {
         $this->addElement(new Xoops\Form\DhtmlTextArea(_MD_COMMENTS_MESSAGE, 'com_text', $obj->getVar('text', 'e'), 10, 50), true);
     }
     $option_tray = new Xoops\Form\ElementTray(XoopsLocale::OPTIONS, '<br />');
     $buttonTray = new Xoops\Form\ElementTray('', '&nbsp;');
     if ($xoops->isUser()) {
         if ($xoops->getModuleConfig('com_anonpost', $dirname)) {
             $noname = $obj->getVar('noname', 'e') ? 1 : 0;
             $noname_checkbox = new Xoops\Form\Checkbox('', 'com_noname', $noname);
             $noname_checkbox->addOption(1, XoopsLocale::POST_ANONYMOUSLY);
             $option_tray->addElement($noname_checkbox);
         }
         if (false != $xoops->user->isAdmin($obj->getVar('modid'))) {
             // show status change box when editing (comment id is not empty)
             if ($obj->getVar('id', 'e')) {
                 $status_select = new Xoops\Form\Select(_MD_COMMENTS_STATUS, 'com_status', $obj->getVar('status', 'e'));
                 $status_select->addOptionArray(array(Comments::STATUS_PENDING => _MD_COMMENTS_PENDING, Comments::STATUS_ACTIVE => _MD_COMMENTS_ACTIVE, Comments::STATUS_HIDDEN => _MD_COMMENTS_HIDDEN));
                 $this->addElement($status_select);
                 $buttonTray->addElement(new Xoops\Form\Button('', 'com_dodelete', XoopsLocale::A_DELETE, 'submit'));
             }
             if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
                 $html_checkbox = new Xoops\Form\Checkbox('', 'com_dohtml', $obj->getVar('dohtml', 'e'));
                 $html_checkbox->addOption(1, _MD_COMMENTS_DOHTML);
                 $option_tray->addElement($html_checkbox);
             }
         }
     }
     if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
         //Yeah, what?
     }
     $smiley_checkbox = new Xoops\Form\Checkbox('', 'com_dosmiley', $obj->getVar('domsiley', 'e'));
     $smiley_checkbox->addOption(1, _MD_COMMENTS_DOSMILEY);
     $option_tray->addElement($smiley_checkbox);
     $xcode_checkbox = new Xoops\Form\Checkbox('', 'com_doxcode', $obj->getVar('doxcode', 'e'));
     $xcode_checkbox->addOption(1, _MD_COMMENTS_DOXCODE);
     $option_tray->addElement($xcode_checkbox);
     if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
         $br_checkbox = new Xoops\Form\Checkbox('', 'com_dobr', $obj->getVar('dobr', 'e'));
         $br_checkbox->addOption(1, _MD_COMMENTS_DOAUTOWRAP);
         $option_tray->addElement($br_checkbox);
     } else {
         $this->addElement(new Xoops\Form\Hidden('com_dohtml', 1));
         $this->addElement(new Xoops\Form\Hidden('com_dobr', 0));
     }
     $this->addElement($option_tray);
     if (!$xoops->isUser()) {
         $this->addElement(new Xoops\Form\Captcha());
     }
     $this->addElement(new Xoops\Form\Hidden('com_modid', $obj->getVar('modid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_pid', $obj->getVar('pid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_rootid', $obj->getVar('rootid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_id', $obj->getVar('id', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_itemid', $obj->getVar('itemid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_order', Request::getInt('com_order', $helper->getUserConfig('com_order'))));
     $this->addElement(new Xoops\Form\Hidden('com_mode', Request::getString('com_mode', $helper->getUserConfig('com_mode'))));
     // add module specific extra params
     if (!$xoops->isAdminSide) {
         /* @var $plugin CommentsPluginInterface */
         $plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'comments');
         if (is_array($extraParams = $plugin->extraParams())) {
             foreach ($extraParams as $extra_param) {
                 // This routine is included from forms accessed via both GET and POST
                 if (isset($_POST[$extra_param])) {
                     $hidden_value = $_POST[$extra_param];
                 } else {
                     if (isset($_GET[$extra_param])) {
                         $hidden_value = $_GET[$extra_param];
                     } else {
                         $hidden_value = '';
                     }
                 }
                 $this->addElement(new Xoops\Form\Hidden($extra_param, $hidden_value));
             }
         }
     }
     $buttonTray->addElement(new Xoops\Form\Button('', 'com_dopreview', XoopsLocale::A_PREVIEW, 'submit'));
     $buttonTray->addElement(new Xoops\Form\Button('', 'com_dopost', _MD_COMMENTS_POSTCOMMENT, 'submit'));
     $this->addElement($buttonTray);
     return $this;
 }
Esempio n. 19
0
$system = System::getInstance();
if (!$xoops->isUser() || !$xoops->isModule() || !$xoops->user->isAdmin($xoops->module->mid())) {
    exit(XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$xoops->logger()->quiet();
//$xoops->disableErrorReporting();
if (isset($_REQUEST["op"])) {
    $op = $_REQUEST["op"];
} else {
    @($op = "default");
}
switch ($op) {
    // Display post
    case 'display_post':
        include_once $xoops->path('modules/system/include/functions.php');
        $uid = $system->cleanVars($_REQUEST, 'uid', 'int');
        $total_posts = 0;
        /* @var $plugin SystemPluginInterface */
        $plugins = \Xoops\Module\Plugin::getPlugins();
        foreach ($plugins as $plugin) {
            if ($res = $plugin->userPosts($uid)) {
                $total_posts += $res;
            }
        }
        $qb = $xoops->db()->createXoopsQueryBuilder();
        $eb = $qb->expr();
        $sql = $qb->updatePrefix('users')->set('posts', ':posts')->where('uid = :uid')->setParameter(':posts', $total_posts)->setParameter(':uid', $uid);
        $row_count = $sql->execute();
        echo $row_count;
        break;
}
            $content .= "<dt>{$tempvar}</dt>";
        }
        $content .= "</ul>";
    } else {
        $content = "<div class='x2-note confirmMsg'>" . NO_INSTALLED_MODULES . "</div>";
    }
    //Reset module lists in cache folder
    $xoops->cache()->delete('system/modules');
    $dirnames = $xoops->setActiveModules();
    /*
     * With multiple module installs in one pass, preload events are not refreshed in between.
     * One side effect is that plugins that modify configurations (specifically comments and notifications)
     * do not get a chance to process the install events as is needed. Here, we will loop through all
     * the modules supplying a plugin interface and update them, reprocessing and fixing everything.
     */
    \Xoops\Module\Plugin::resetPluginsCache();
    $xoops->setTpl(new Xoops\Core\XoopsTpl());
    // update() uses this???
    foreach ($dirnames as $dirname) {
        if ($dirname !== 'system') {
            if (\XoopsLoad::fileExists($xoops->path("modules/{$dirname}/class/plugin/interface.php"))) {
                $xoops->clearModuleConfigsCache();
                $system_module->update($dirname);
            }
        }
    }
} else {
    if (!$xoops->getConfig('locale')) {
        $xoops->setConfig('locale', $_COOKIE['xo_install_lang']);
    }
    $xoops->loadLocale('system');
Esempio n. 21
0
     /* @var $formHandler SearchSearchForm */
     $formHandler = $search->getForm(null, 'search');
     $form = $formHandler->getSearchFrom($andor, $queries, $mids, $mid);
     $form->display();
     break;
 case "showall":
 case 'showallbyuser':
     $xoops->header('module:search/search.tpl');
     $xoops->tpl()->assign('search', true);
     $xoops->tpl()->assign('queries', $queries);
     $xoops->tpl()->assign('ignored_words', sprintf(_MD_SEARCH_IGNOREDWORDS, $search->getConfig('keyword_min')));
     $xoops->tpl()->assign('ignored_queries', $ignored_queries);
     $module_handler = $xoops->getHandlerModule();
     $module = $xoops->getModuleById($mid);
     /* @var $plugin SearchPluginInterface */
     $plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'search');
     $results = $plugin->search($queries, $andor, 20, $start, $uid);
     $modules_result[$mid]['name'] = $module->getVar('name');
     $modules_result[$mid]['image'] = $xoops->url('modules/' . $module->getVar('dirname') . '/icons/logo_large.png');
     $count = count($results);
     if (is_array($results) && $count > 0) {
         $next_results = $plugin->search($queries, $andor, 1, $start + 20, $uid);
         $next_count = count($next_results);
         $has_next = false;
         if (is_array($next_results) && $next_count == 1) {
             $has_next = true;
         }
         $xoops->tpl()->assign('sr_showing', sprintf(_MD_SEARCH_SHOWING, $start + 1, $start + $count));
         $res = array();
         for ($i = 0; $i < $count; ++$i) {
             if (isset($results[$i]['image']) && $results[$i]['image'] != "") {
Esempio n. 22
0
 /**
  * Get an array of info for all events (each event has associative array)
  * in the selected category of the selected module.
  *
  * @param string $category_name Category name
  * @param bool   $enabled_only  If true, return only enabled events
  * @param string $dirname       Dirname of the module (default current module)
  *
  * @return mixed
  */
 public function getEvents($category_name, $enabled_only, $dirname = null)
 {
     $xoops = Xoops::getInstance();
     $helper = Notifications::getInstance();
     if (!isset($dirname)) {
         $dirname = $xoops->isModule() ? $xoops->module->getVar('dirname') : '';
     }
     /* @var $plugin NotificationsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'notifications')) {
         $events = $plugin->events();
         $category = $this->getCategory($category_name, $dirname);
         $event_array = array();
         $override_comment = false;
         $override_commentsubmit = false;
         $override_bookmark = false;
         foreach ($events as $event) {
             if ($event['category'] == $category_name) {
                 if (!is_dir($dir = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/locale/' . $xoops->getConfig('locale') . '/templates/')) {
                     $dir = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/locale/en_US/templates/';
                 }
                 $event['mail_template_dir'] = $dir;
                 if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
                     $event_array[] = $event;
                 }
                 if ($event['name'] === 'comment') {
                     $override_comment = true;
                 }
                 if ($event['name'] === 'comment_submit') {
                     $override_commentsubmit = true;
                 }
                 if ($event['name'] === 'bookmark') {
                     $override_bookmark = true;
                 }
             }
         }
         $helper->loadLanguage('main');
         // Insert comment info if applicable
         /* @var $commentsPlugin CommentsPluginInterface */
         if ($xoops->isActiveModule('comments') && ($commentsPlugin = \Xoops\Module\Plugin::getPlugin($dirname, 'comments'))) {
             //todo replace this
             if (!empty($category['item_name']) && $category['item_name'] == $commentsPlugin->itemName()) {
                 if (!is_dir($dir = \XoopsBaseConfig::get('root-path') . '/locale/' . $xoops->getConfig('locale') . '/templates/')) {
                     $dir = \XoopsBaseConfig::get('root-path') . '/locale/en_US/templates/';
                 }
                 $mail_template_dir = $dir;
                 $com_config = $xoops->getModuleConfigs($dirname);
                 if (!$enabled_only) {
                     $insert_comment = true;
                     $insert_submit = true;
                 } else {
                     $insert_comment = false;
                     $insert_submit = false;
                     switch ($com_config['com_rule']) {
                         case COMMENTS_APPROVENONE:
                             // comments disabled, no comment events
                             break;
                         case COMMENTS_APPROVEALL:
                             // all comments are automatically approved, no 'submit'
                             if (!$override_comment) {
                                 $insert_comment = true;
                             }
                             break;
                         case COMMENTS_APPROVEUSER:
                         case COMMENTS_APPROVEADMIN:
                             // comments first submitted, require later approval
                             if (!$override_comment) {
                                 $insert_comment = true;
                             }
                             if (!$override_commentsubmit) {
                                 $insert_submit = true;
                             }
                             break;
                     }
                 }
                 if ($insert_comment) {
                     $event = array('name' => 'comment', 'category' => $category['name'], 'title' => _MD_NOTIFICATIONS_COMMENT_NOTIFY, 'caption' => _MD_NOTIFICATIONS_COMMENT_NOTIFYCAP, 'description' => _MD_NOTIFICATIONS_COMMENT_NOTIFYDSC, 'mail_template_dir' => $mail_template_dir, 'mail_template' => 'comment_notify', 'mail_subject' => _MD_NOTIFICATIONS_COMMENT_NOTIFYSBJ);
                     if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
                         $event_array[] = $event;
                     }
                 }
                 if ($insert_submit) {
                     $event = array('name' => 'comment_submit', 'category' => $category['name'], 'title' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFY, 'caption' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYCAP, 'description' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYDSC, 'mail_template_dir' => $mail_template_dir, 'mail_template' => 'commentsubmit_notify', 'mail_subject' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYSBJ, 'admin_only' => 1);
                     if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
                         $event_array[] = $event;
                     }
                 }
             }
         }
         // Insert bookmark info if appropriate
         if (!empty($category['allow_bookmark'])) {
             if (!$override_bookmark) {
                 $event = array('name' => 'bookmark', 'category' => $category['name'], 'title' => _MD_NOTIFICATIONS_BOOKMARK_NOTIFY, 'caption' => _MD_NOTIFICATIONS_BOOKMARK_NOTIFYCAP, 'description' => _MD_NOTIFICATIONS_BOOKMARK_NOTIFYDSC);
                 if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
                     $event_array[] = $event;
                 }
             }
         }
         return $event_array;
     }
     return array();
 }
Esempio n. 23
0
function menus_mainmenu_show()
{
    $block = array();
    $xoops = Xoops::getInstance();
    $helper = Xoops::getModuleHelper('menus');
    $module_handler = $xoops->getHandlerModule();
    $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
    $criteria->add(new Criteria('isactive', 1));
    $criteria->add(new Criteria('weight', 0, '>'));
    $modules = $module_handler->getObjectsArray($criteria, true);
    $moduleperm_handler = $xoops->getHandlerGroupPermission();
    $groups = $xoops->getUserGroups();
    $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups);
    $menus = array();
    $menu = $helper->getHandlerMenu()->create();
    $menu->setVar('id', 1);
    $menu->setVar('pid', 0);
    $menu->setVar('alt_title', _MB_MENUS_HOME);
    $menu->setVar('title', _MB_MENUS_HOME);
    $menu->setVar('link', \XoopsBaseConfig::get('url'));
    $menu->setVar('image', 'icon-home');
    $menus[] = $menu->getValues();
    foreach (array_keys($modules) as $i) {
        if (in_array($i, $read_allowed)) {
            /* @var $plugin MenusPluginInterface */
            $menu = $helper->getHandlerMenu()->create();
            $menu->setVar('id', $i);
            $menu->setVar('pid', 0);
            $menu->setVar('title', $modules[$i]->getVar('name'));
            $menu->setVar('alt_title', $modules[$i]->getVar('name'));
            $menu->setVar('link', \XoopsBaseConfig::get('url') . '/modules/' . $modules[$i]->getVar('dirname'));
            $menu->setVar('image', 'icon-tags');
            $menus[] = $menu->getValues();
            if ($xoops->isModule() && $xoops->module->getVar('dirname') == $modules[$i]->getVar('dirname') && ($plugin = \Xoops\Module\Plugin::getPlugin($modules[$i]->getVar('dirname'), 'menus'))) {
                $sublinks = $plugin->subMenus();
                $j = -1;
                foreach ($sublinks as $sublink) {
                    $menu = $helper->getHandlerMenu()->create();
                    $menu->setVar('id', $j);
                    $menu->setVar('pid', $i);
                    $menu->setVar('title', $sublink['name']);
                    $menu->setVar('alt_title', $sublink['name']);
                    $menu->setVar('link', \XoopsBaseConfig::get('url') . '/modules/' . $modules[$i]->getVar('dirname') . '/' . $sublink['url']);
                    $menus[] = $menu->getValues();
                    $j--;
                }
            }
        }
    }
    $builder = new MenusBuilder($menus);
    $block = $builder->render();
    $skin_info = $helper->getSkinInfo('mainmenu', false);
    $blockTpl = new XoopsTpl();
    $blockTpl->assign('block', $block);
    $blockTpl->assign('config', $skin_info['config']);
    $blockTpl->assign('skinurl', $skin_info['url']);
    $blockTpl->assign('skinpath', $skin_info['path']);
    $block['content'] = $blockTpl->fetch($skin_info['template']);
    return $block;
}
Esempio n. 24
0
/**
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         Comments
 * @author          trabis <*****@*****.**>
 * @author          Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
 * @version         $Id$
 */
function b_comments_show($options)
{
    $xoops = Xoops::getInstance();
    $helper = $xoops->getModuleHelper('comments');
    $block = array();
    $available_modules = \Xoops\Module\Plugin::getPlugins('comments');
    if (empty($available_modules)) {
        return $block;
    }
    $comment_handler = $helper->getHandlerComment();
    $criteria = new CriteriaCompo(new Criteria('status', Comments::STATUS_ACTIVE));
    $criteria->setLimit((int) $options[0]);
    $criteria->setSort('created');
    $criteria->setOrder('DESC');
    // Check modules permissions
    $moduleperm_handler = $xoops->getHandlerGroupPermission();
    $gperm_groupid = $xoops->getUserGroups();
    $criteria1 = new CriteriaCompo(new Criteria('gperm_name', 'module_read', '='));
    $criteria1->add(new Criteria('gperm_groupid', '(' . implode(',', $gperm_groupid) . ')', 'IN'));
    $perms = $moduleperm_handler->getObjects($criteria1, true);
    $modIds = array();
    foreach ($perms as $item) {
        $modIds[] = $item->getVar('gperm_itemid');
    }
    if (count($modIds) > 0) {
        $modIds = array_unique($modIds);
        $criteria->add(new Criteria('modid', '(' . implode(',', $modIds) . ')', 'IN'));
    } else {
        return $block;
    }
    $comments = $comment_handler->getObjects($criteria, true);
    $member_handler = $xoops->getHandlerMember();
    $module_handler = $xoops->getHandlerModule();
    $modules = $module_handler->getObjectsArray(new Criteria('dirname', "('" . implode("','", array_keys($available_modules)) . "')", 'IN'), true);
    $comment_config = array();
    foreach (array_keys($comments) as $i) {
        $mid = $comments[$i]->getVar('modid');
        $com['module'] = '<a href="' . \XoopsBaseConfig::get('url') . '/modules/' . $modules[$mid]->getVar('dirname') . '/">' . $modules[$mid]->getVar('name') . '</a>';
        if (!isset($comment_config[$mid])) {
            $comment_config[$mid] = \Xoops\Module\Plugin::getPlugin($modules[$mid]->getVar('dirname'), 'comments');
        }
        $com['id'] = $i;
        $com['title'] = '<a href="' . \XoopsBaseConfig::get('url') . '/modules/' . $modules[$mid]->getVar('dirname') . '/' . $comment_config[$mid]->pageName() . '?' . $comment_config[$mid]->itemName() . '=' . $comments[$i]->getVar('itemid') . '&amp;com_id=' . $i . '&amp;com_rootid=' . $comments[$i]->getVar('rootid') . '&amp;' . htmlspecialchars($comments[$i]->getVar('exparams')) . '#comment' . $i . '">' . $comments[$i]->getVar('title') . '</a>';
        $com['icon'] = htmlspecialchars($comments[$i]->getVar('icon'), ENT_QUOTES);
        $com['icon'] = $com['icon'] != '' ? $com['icon'] : 'icon1.gif';
        $com['time'] = XoopsLocale::formatTimestamp($comments[$i]->getVar('created'), 'm');
        if ($comments[$i]->getVar('uid') > 0) {
            $poster = $member_handler->getUser($comments[$i]->getVar('uid'));
            if (is_object($poster)) {
                $com['poster'] = '<a href="' . \XoopsBaseConfig::get('url') . '/userinfo.php?uid=' . $comments[$i]->getVar('uid') . '">' . $poster->getVar('uname') . '</a>';
            } else {
                $com['poster'] = $xoops->getConfig('anonymous');
            }
        } else {
            $com['poster'] = $xoops->getConfig('anonymous');
        }
        $block['comments'][] = $com;
        unset($com);
    }
    return $block;
}
Esempio n. 25
0
 /**
  * remove any userconfigs for module being uninstalled
  *
  * @param XoopsModule $module module object
  *
  * @return void
  */
 public static function eventSystemModuleUninstall(XoopsModule $module)
 {
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs')) {
         Userconfigs::getInstance()->getHandlerConfig()->deleteConfigsByModule($module->getVar('mid'));
     }
 }
Esempio n. 26
0
 public static function eventSystemPreferencesForm(XoopsModule $module)
 {
     if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'notifications')) {
         Notifications::getInstance()->loadLanguage('main');
     }
 }