Example #1
0
 /**
  * Constructor
  *
  * @param string $caption      caption
  * @param string $name         element name
  * @param bool   $include_anon Include user "anonymous"?
  * @param mixed  $value        Pre-selected value (or array of them).
  *                             For an item with massive members, such as "Registered Users",
  *                             "$value" should be used to store selected temporary users only
  *                             instead of all members of that item
  * @param int    $size         Number or rows. "1" makes a drop-down-list.
  * @param bool   $multiple     Allow multiple selections?
  */
 public function __construct($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false)
 {
     $xoops = \Xoops::getInstance();
     $limit = 200;
     $select_element = new Select('', $name, $value, $size, $multiple);
     if ($include_anon) {
         $select_element->addOption(0, $xoops->getConfig('anonymous'));
     }
     $member_handler = $xoops->getHandlerMember();
     $user_count = $member_handler->getUserCount();
     $value = is_array($value) ? $value : (empty($value) ? array() : array($value));
     if ($user_count > $limit && count($value) > 0) {
         $criteria = new CriteriaCompo(new Criteria('uid', '(' . implode(',', $value) . ')', 'IN'));
     } else {
         $criteria = new CriteriaCompo();
         $criteria->setLimit($limit);
     }
     $criteria->setSort('uname');
     $criteria->setOrder('ASC');
     $users = $member_handler->getUserList($criteria);
     $select_element->addOptionArray($users);
     if ($user_count <= $limit) {
         parent::__construct($caption, "", $name);
         $this->addElement($select_element);
         return;
     }
     $js_addusers = "<script type='text/javascript'>\n            function addusers(opts){\n                var num = opts.substring(0, opts.indexOf(':'));\n                opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                var sel = xoopsGetElementById('" . $name . "');\n                var arr = new Array(num);\n                for (var n=0; n < num; n++) {\n                    var nm = opts.substring(0, opts.indexOf(':'));\n                    opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                    var val = opts.substring(0, opts.indexOf(':'));\n                    opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                    var txt = opts.substring(0, nm - val.length);\n                    opts = opts.substring(nm - val.length, opts.length);\n                    var added = false;\n                    for (var k = 0; k < sel.options.length; k++) {\n                        if(sel.options[k].value == val){\n                            added = true;\n                            break;\n                        }\n                    }\n                    if (added == false) {\n                        sel.options[k] = new Option(txt, val);\n                        sel.options[k].selected = true;\n                    }\n                }\n                return true;\n            }\n            </script>";
     $token = $xoops->security()->createToken();
     $action_tray = new ElementTray("", " | ");
     $action_tray->addElement(new Label('', '<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name . '\');for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) ' . '{sel.options[i] = null;}}; return false;">' . \XoopsLocale::REMOVE_UNSELECTED_USERS . "</a>"));
     $action_tray->addElement(new Label('', '<a href="#" onclick="openWithSelfMain(\'' . \XoopsBaseConfig::get('url') . '/include/findusers.php?target=' . $name . '&amp;multiple=' . $multiple . '&amp;token=' . $token . '\', \'userselect\', 800, 600, null); return false;" >' . \XoopsLocale::SEARCH_USERS . "</a>" . $js_addusers));
     parent::__construct($caption, '<br /><br />', $name);
     $this->addElement($select_element);
     $this->addElement($action_tray);
 }
Example #2
0
 /**
  * execute the command
  *
  * @param InputInterface  $input  input handler
  * @param OutputInterface $output output handler
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $xoops = \Xoops::getInstance();
     $name = $input->getArgument('name');
     $value = $input->getArgument('value');
     $configHandler = $xoops->getHandlerConfig();
     $sysmodule = $xoops->getModuleByDirname('system');
     if (empty($sysmodule)) {
         $output->writeln('<error>Module system is not installed!</error>');
         return;
     }
     $mid = $sysmodule->mid();
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('conf_modid', $mid));
     $criteria->add(new Criteria('conf_name', $name));
     $objArray = $configHandler->getConfigs($criteria);
     $configItem = reset($objArray);
     if (empty($configItem)) {
         $output->writeln(sprintf('<error>Config item %s not found!</error>', $name));
         return;
     }
     $configItem->setConfValueForInput($value);
     $result = $configHandler->insertConfig($configItem);
     if ($result === false) {
         $output->writeln(sprintf('<error>Could not set %s!</error>', $name));
     }
     $output->writeln(sprintf('Set %s', $name));
 }
Example #3
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;
}
Example #4
0
/**
 * xoops_module_update_system
 *
 * @param XoopsModule $module
 *
 * @return bool
 */
function xoops_module_update_system(XoopsModule $module)
{
    $xoops = Xoops::getInstance();
    if ($module->getVar('version') == 100) {
        $qb = $xoops->db()->createXoopsQueryBuilder();
        $eb = $qb->expr();
        $sql = $qb->select('t1.tpl_id')->fromPrefix('system_tplfile', 't1')->fromPrefix('system_tplfile', 't2')->where($eb->eq('t1.tpl_module', 't2.tpl_module '))->andWhere($eb->eq('t1.tpl_tplset', 't2.tpl_tplset'))->andWhere($eb->eq('t1.tpl_file', 't2.tpl_file'))->andWhere($eb->eq('t1.tpl_id', 't2.tpl_id'));
        $result = $sql->execute();
        $tplids = array();
        while (list($tplid) = $result->fetch(PDO::FETCH_NUM)) {
            $tplids[] = $tplid;
        }
        if (count($tplids) > 0) {
            $tplfile_handler = $xoops->getHandlerTplFile();
            $duplicate_files = $tplfile_handler->getTplObjects(new Criteria('tpl_id', "(" . implode(',', $tplids) . ")", "IN"));
            if (count($duplicate_files) > 0) {
                foreach (array_keys($duplicate_files) as $i) {
                    $tplfile_handler->deleteTpl($duplicate_files[$i]);
                }
            }
        }
    }
    // Copy old configs in new configs and delete old configs
    // Not for conf_catid =5 (Update in search extension)
    // Not for conf_catid =6 (Update in mail user extension)
    $config_handler = $xoops->getHandlerConfig();
    $criteria = new CriteriaCompo();
    $criteria->add(new Criteria('conf_modid', 0));
    $criteria->add(new Criteria('conf_catid', 5, '!='));
    $criteria->add(new Criteria('conf_catid', 6, '!='));
    $configs = $config_handler->getConfigs($criteria);
    $confcount = count($configs);
    if ($confcount > 0) {
        for ($i = 0; $i < $confcount; ++$i) {
            $criteria = new CriteriaCompo();
            $criteria->add(new Criteria('conf_modid', 1));
            $criteria->add(new Criteria('conf_name', $configs[$i]->getVar('conf_name')));
            $new_configs = $config_handler->getConfigs($criteria);
            $new_confcount = count($new_configs);
            if ($new_confcount > 0) {
                for ($j = 0; $j < $new_confcount; ++$j) {
                    $obj = $config_handler->getConfig($new_configs[$j]->getVar('conf_id'));
                }
                $obj->setVar("conf_value", $configs[$i]->getVar('conf_value'));
                $config_handler->insertConfig($obj);
                $config_handler->deleteConfig($configs[$i]);
            }
        }
    }
    return true;
}
Example #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_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;
}
Example #6
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_topposters_show($options)
{
    $xoops = Xoops::getInstance();
    $block = array();
    $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
    $limit = !empty($options[0]) ? $options[0] : 10;
    $size = count($options);
    for ($i = 2; $i < $size; ++$i) {
        $criteria->add(new Criteria('rank', $options[$i], '<>'));
    }
    $criteria->setOrder('DESC');
    $criteria->setSort('posts');
    $criteria->setLimit($limit);
    $member_handler = $xoops->getHandlerMember();
    $topposters = $member_handler->getUsers($criteria);
    $count = count($topposters);
    for ($i = 0; $i < $count; ++$i) {
        $block['users'][$i]['rank'] = $i + 1;
        if ($options[1] == 1) {
            $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') !== 'blank.gif' ? \XoopsBaseConfig::get('uploads-url') . '/' . $topposters[$i]->getVar('user_avatar') : '';
        } else {
            $block['users'][$i]['avatar'] = '';
        }
        $block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
        $block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
        $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
    }
    return $block;
}
Example #7
0
 public function getSmilies($start = 0, $limit = 0, $asobject = true)
 {
     $criteria = new CriteriaCompo();
     $criteria->setSort('smiley_id');
     $criteria->setOrder('ASC');
     $criteria->setStart($start);
     $criteria->setLimit($limit);
     return parent::getAll($criteria, false, $asobject);
 }
Example #8
0
/**
 * @return array|bool|string
 */
function b_system_newmembers_show($options)
{
    $xoops = Xoops::getInstance();
    $block = array();
    $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
    $limit = !empty($options[0]) ? $options[0] : 10;
    $criteria->setOrder('DESC');
    $criteria->setSort('user_regdate');
    $criteria->setLimit($limit);
    $member_handler = $xoops->getHandlerMember();
    $newmembers = $member_handler->getUsers($criteria);
    $count = count($newmembers);
    for ($i = 0; $i < $count; ++$i) {
        if ($options[1] == 1) {
            $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') !== 'blank.gif' ? \XoopsBaseConfig::get('uploads-url') . '/' . $newmembers[$i]->getVar('user_avatar') : '';
        } else {
            $block['users'][$i]['avatar'] = '';
        }
        $block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
        $block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
        $block['users'][$i]['joindate'] = XoopsLocale::formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
    }
    return $block;
}
Example #9
0
 /**
  * Get a list of Avatars
  *
  * @param string $avatar_type    'C' for custom, 'S' for system
  * @param bool   $avatar_display display avatar
  *
  * @return array
  */
 public function getListByType($avatar_type = null, $avatar_display = null)
 {
     $criteria = new CriteriaCompo();
     if (isset($avatar_type)) {
         $avatar_type = $avatar_type === 'C' ? 'C' : 'S';
         $criteria->add(new Criteria('avatar_type', $avatar_type));
     }
     if (isset($avatar_display)) {
         $criteria->add(new Criteria('avatar_display', (int) $avatar_display));
     }
     $avatars = $this->getObjects($criteria, true);
     $ret = array('avatars/blank.gif' => XoopsLocale::NONE);
     foreach (array_keys($avatars) as $i) {
         $ret[$avatars[$i]->getVar('avatar_file')] = $avatars[$i]->getVar('avatar_name');
     }
     return $ret;
 }
Example #10
0
    echo "<h2 style='text-align:left;'>" . XoopsLocale::FIND_USERS . " - " . $modes[$mode] . "</h2>";
    $modes_switch = array();
    foreach ($modes as $_mode => $title) {
        if ($mode == $_mode) {
            continue;
        }
        $modes_switch[] = "<a href='findusers.php?target=" . $myts->htmlSpecialChars(@$_REQUEST["target"]) . "&amp;multiple=" . $myts->htmlSpecialChars(@$_REQUEST["multiple"]) . "&amp;token=" . $myts->htmlSpecialChars($token, ENT_QUOTES) . "&amp;mode={$_mode}'>{$title}</a>";
    }
    echo "<h4>" . implode(" | ", $modes_switch) . "</h4>";
    echo "(" . sprintf(XoopsLocale::F_ACTIVE_USERS, "<span style='color:#ff0000;'>{$acttotal}</span>") . " " . sprintf(XoopsLocale::F_INACTIVE_USERS, "<span style='color:#ff0000;'>{$inacttotal}</span>") . ")";
    $form->display();
} else {
    $limit = empty($_POST['limit']) ? 50 : (int) $_POST['limit'];
    $start = (int) @$_POST['start'];
    if (!isset($_POST["query"])) {
        $criteria = new CriteriaCompo();
        foreach (array_keys($items_match) as $var) {
            if (!empty($_POST[$var])) {
                $match = !empty($_POST["{$var}_match"]) ? (int) $_POST["{$var}_match"] : XOOPS_MATCH_START;
                $value = str_replace("_", "\\\\_", trim($_POST[$var]));
                switch ($match) {
                    case XOOPS_MATCH_START:
                        $criteria->add(new Criteria($var, $value . '%', 'LIKE'));
                        break;
                    case XOOPS_MATCH_END:
                        $criteria->add(new Criteria($var, '%' . $value, 'LIKE'));
                        break;
                    case XOOPS_MATCH_EQUAL:
                        $criteria->add(new Criteria($var, $value));
                        break;
                    case XOOPS_MATCH_CONTAIN:
Example #11
0
 /**
  * __construct
  *
  * @param XoopsGroup|XoopsObject &$obj group object
  */
 public function __construct(XoopsGroup &$obj)
 {
     $xoops = Xoops::getInstance();
     if ($obj->isNew()) {
         $s_cat_value = '';
         $a_mod_value = array();
         $r_mod_value = array();
         $r_block_value = array();
     } else {
         $sysperm_handler = $xoops->getHandlerGroupperm();
         $s_cat_value = $sysperm_handler->getItemIds('system_admin', $obj->getVar('groupid'));
         $member_handler = $xoops->getHandlerMember();
         $thisgroup = $member_handler->getGroup($obj->getVar('groupid'));
         $moduleperm_handler = $xoops->getHandlerGroupperm();
         $a_mod_value = $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
         $r_mod_value = $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
         $gperm_handler = $xoops->getHandlerGroupperm();
         $r_block_value = $gperm_handler->getItemIds('block_read', $obj->getVar('groupid'));
     }
     include_once $xoops->path('/modules/system/constants.php');
     $title = $obj->isNew() ? SystemLocale::ADD_NEW_GROUP : SystemLocale::EDIT_GROUP;
     parent::__construct($title, "groupform", 'admin.php', "post", true);
     $this->setExtra('enctype="multipart/form-data"');
     $name_text = new Xoops\Form\Text(SystemLocale::GROUP_NAME, "name", 4, 50, $obj->getVar('name'));
     $desc_text = new Xoops\Form\TextArea(SystemLocale::GROUP_DESCRIPTION, "desc", $obj->getVar('description'));
     $system_catids = new Xoops\Form\ElementTray(SystemLocale::SYSTEM_ADMIN_RIGHTS, '');
     $s_cat_checkbox_all = new Xoops\Form\Checkbox('', "catbox", 1);
     $s_cat_checkbox_all->addOption('allbox', XoopsLocale::ALL);
     $s_cat_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"catbox\" , \"system_catids[]\");' ");
     $s_cat_checkbox_all->setClass('xo-checkall');
     $system_catids->addElement($s_cat_checkbox_all);
     $s_cat_checkbox = new Xoops\Form\Checkbox('', "system_catids", $s_cat_value);
     //$s_cat_checkbox->columns = 6;
     $admin_dir = \XoopsBaseConfig::get('root-path') . '/modules/system/admin/';
     $dirlist = XoopsLists::getDirListAsArray($admin_dir);
     foreach ($dirlist as $file) {
         include \XoopsBaseConfig::get('root-path') . '/modules/system/admin/' . $file . '/xoops_version.php';
         if (!empty($modversion['category'])) {
             if ($xoops->getModuleConfig('active_' . $file, 'system') == 1) {
                 $s_cat_checkbox->addOption($modversion['category'], $modversion['name']);
             }
         }
         unset($modversion);
     }
     unset($dirlist);
     $system_catids->addElement($s_cat_checkbox);
     $admin_mids = new Xoops\Form\ElementTray(SystemLocale::MODULE_ADMIN_RIGHTS, '');
     $s_admin_checkbox_all = new Xoops\Form\Checkbox('', "adminbox", 1);
     $s_admin_checkbox_all->addOption('allbox', XoopsLocale::ALL);
     $s_admin_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"adminbox\" , \"admin_mids[]\");' ");
     $s_admin_checkbox_all->setClass('xo-checkall');
     $admin_mids->addElement($s_admin_checkbox_all);
     $a_mod_checkbox = new Xoops\Form\Checkbox('', "admin_mids[]", $a_mod_value);
     //$a_mod_checkbox->columns = 5;
     $module_handler = $xoops->getHandlerModule();
     $criteria = new CriteriaCompo(new Criteria('hasadmin', 1));
     $criteria->add(new Criteria('isactive', 1));
     $criteria->add(new Criteria('dirname', 'system', '<>'));
     $a_mod_checkbox->addOptionArray($module_handler->getNameList($criteria));
     $admin_mids->addElement($a_mod_checkbox);
     $read_mids = new Xoops\Form\ElementTray(SystemLocale::MODULE_ACCESS_RIGHTS, '');
     $s_mod_checkbox_all = new Xoops\Form\Checkbox('', "readbox", 1);
     $s_mod_checkbox_all->addOption('allbox', XoopsLocale::ALL);
     $s_mod_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"readbox\" , \"read_mids[]\");' ");
     $s_mod_checkbox_all->setClass('xo-checkall');
     $read_mids->addElement($s_mod_checkbox_all);
     $r_mod_checkbox = new Xoops\Form\Checkbox('', "read_mids[]", $r_mod_value);
     //$r_mod_checkbox->columns = 5;
     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
     $criteria->add(new Criteria('isactive', 1));
     $r_mod_checkbox->addOptionArray($module_handler->getNameList($criteria));
     $read_mids->addElement($r_mod_checkbox);
     $criteria = new CriteriaCompo(new Criteria('isactive', 1));
     $criteria->setSort("mid");
     $criteria->setOrder("ASC");
     $module_list = $module_handler->getNameList($criteria);
     $module_list[0] = SystemLocale::CUSTOM_BLOCK;
     $block_handler = $xoops->getHandlerBlock();
     $blocks_obj = $block_handler->getDistinctObjects(new Criteria("mid", "('" . implode("', '", array_keys($module_list)) . "')", "IN"), true);
     $blocks_module = array();
     foreach (array_keys($blocks_obj) as $bid) {
         $title = $blocks_obj[$bid]->getVar("title");
         $blocks_module[$blocks_obj[$bid]->getVar('mid')][$blocks_obj[$bid]->getVar('bid')] = empty($title) ? $blocks_obj[$bid]->getVar("name") : $title;
     }
     ksort($blocks_module);
     $r_block_tray = new Xoops\Form\ElementTray(SystemLocale::BLOCK_ACCESS_RIGHTS, "<br /><br />");
     $s_checkbox_all = new Xoops\Form\Checkbox('', "blocksbox", 1);
     $s_checkbox_all->addOption('allbox', XoopsLocale::ALL);
     $s_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"blocksbox\" , \"read_bids[]\");' ");
     $s_checkbox_all->setClass('xo-checkall');
     $r_block_tray->addElement($s_checkbox_all);
     foreach (array_keys($blocks_module) as $mid) {
         $new_blocks_array = array();
         foreach ($blocks_module[$mid] as $key => $value) {
             $new_blocks_array[$key] = "<a href='" . \XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid={$key}' " . "title='ID: {$key}' rel='external'>{$value}</a>";
         }
         $r_block_checkbox = new Xoops\Form\Checkbox('<strong>' . $module_list[$mid] . '</strong><br />', "read_bids[]", $r_block_value);
         //$r_block_checkbox->columns = 5;
         $r_block_checkbox->addOptionArray($new_blocks_array);
         $r_block_tray->addElement($r_block_checkbox);
         unset($r_block_checkbox);
     }
     if (!$obj->isNew()) {
         $this->addElement(new Xoops\Form\Hidden('g_id', $obj->getVar('groupid')));
         $this->addElement(new Xoops\Form\Hidden("op", "groups_save_update"));
     } else {
         $this->addElement(new Xoops\Form\Hidden("op", "groups_save_add"));
     }
     $this->addElement(new Xoops\Form\Hidden('fct', 'groups'));
     $this->addElement($name_text, true);
     $this->addElement($desc_text);
     $this->addElement($system_catids);
     $this->addElement($admin_mids);
     $this->addElement($read_mids);
     $this->addElement($r_block_tray);
     $this->addElement(new Xoops\Form\Button("", "submit", XoopsLocale::A_SUBMIT, "submit"));
 }
Example #12
0
    /**
     * @param PublisherItem $obj
     */
    public function __construct(PublisherItem $obj)
    {
        $xoops = Xoops::getInstance();
        $publisher = Publisher::getInstance();
        $allowed_editors = PublisherUtils::getEditors($publisher->getPermissionHandler()->getGrantedItems('editors'));
        $group = $xoops->getUserGroups();
        parent::__construct('title', 'form', $xoops->getEnv('PHP_SELF'));
        $this->setExtra('enctype="multipart/form-data"');
        $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
        $mainTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_MAIN, 'maintab');
        // Category
        $category_select = new Xoops\Form\Select(_CO_PUBLISHER_CATEGORY, 'categoryid', $obj->getVar('categoryid', 'e'));
        $category_select->setDescription(_CO_PUBLISHER_CATEGORY_DSC);
        $category_select->addOptionArray($publisher->getCategoryHandler()->getCategoriesForSubmit());
        $mainTab->addElement($category_select);
        // ITEM TITLE
        $mainTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_TITLE, 'title', 50, 255, $obj->getVar('title', 'e')), true);
        // SUBTITLE
        if ($this->_isGranted(_PUBLISHER_SUBTITLE)) {
            $mainTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_SUBTITLE, 'subtitle', 50, 255, $obj->getVar('subtitle', 'e')));
        }
        // SHORT URL
        if ($this->_isGranted(_PUBLISHER_ITEM_SHORT_URL)) {
            $text_short_url = new Xoops\Form\Text(_CO_PUBLISHER_ITEM_SHORT_URL, 'item_short_url', 50, 255, $obj->getVar('short_url', 'e'));
            $text_short_url->setDescription(_CO_PUBLISHER_ITEM_SHORT_URL_DSC);
            $mainTab->addElement($text_short_url);
        }
        // TAGS
        if ($xoops->isActiveModule('tag') && $this->_isGranted(_PUBLISHER_ITEM_TAG)) {
            include_once \XoopsBaseConfig::get('root-path') . '/modules/tag/include/formtag.php';
            $text_tags = new Xoops\Form\Tag('item_tag', 60, 255, $obj->getVar('item_tag', 'e'), 0);
            $mainTab->addElement($text_tags);
        }
        // SELECT EDITOR
        $nohtml = false;
        if (count($allowed_editors) == 1) {
            $editor = $allowed_editors[0];
        } else {
            if (count($allowed_editors) > 0) {
                $editor = @$_POST['editor'];
                if (!empty($editor)) {
                    PublisherUtils::setCookieVar('publisher_editor', $editor);
                } else {
                    $editor = PublisherUtils::getCookieVar('publisher_editor');
                    if (empty($editor) && $xoops->isUser()) {
                        $editor = $xoops->user->getVar('publisher_editor');
                        // Need set through user profile
                    }
                }
                $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $publisher->getConfig('submit_editor') : $editor;
                $form_editor = new Xoops\Form\SelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors);
                $mainTab->addElement($form_editor);
            } else {
                $editor = $publisher->getConfig('submit_editor');
            }
        }
        $editor_configs = array();
        $editor_configs["rows"] = !$publisher->getConfig('submit_editor_rows') ? 35 : $publisher->getConfig('submit_editor_rows');
        $editor_configs["cols"] = !$publisher->getConfig('submit_editor_cols') ? 60 : $publisher->getConfig('submit_editor_cols');
        $editor_configs["width"] = !$publisher->getConfig('submit_editor_width') ? "100%" : $publisher->getConfig('submit_editor_width');
        $editor_configs["height"] = !$publisher->getConfig('submit_editor_height') ? "400px" : $publisher->getConfig('submit_editor_height');
        // SUMMARY
        if ($this->_isGranted(_PUBLISHER_SUMMARY)) {
            // Description
            //$summary_text = new Xoops\Form\TextArea(_CO_PUBLISHER_SUMMARY, 'summary', $obj->getVar('summary', 'e'), 7, 60);
            $editor_configs["name"] = "summary";
            $editor_configs["value"] = $obj->getVar('summary', 'e');
            $summary_text = new Xoops\Form\Editor(_CO_PUBLISHER_SUMMARY, $editor, $editor_configs, $nohtml, $onfailure = null);
            $summary_text->setDescription(_CO_PUBLISHER_SUMMARY_DSC);
            $mainTab->addElement($summary_text);
        }
        // BODY
        $editor_configs["name"] = "body";
        $editor_configs["value"] = $obj->getVar('body', 'e');
        $body_text = new Xoops\Form\Editor(_CO_PUBLISHER_BODY, $editor, $editor_configs, $nohtml, $onfailure = null);
        $body_text->setDescription(_CO_PUBLISHER_BODY_DSC);
        $mainTab->addElement($body_text);
        // VARIOUS OPTIONS
        if ($this->_isGranted(_PUBLISHER_DOHTML) || $this->_isGranted(_PUBLISHER_DOSMILEY) || $this->_isGranted(_PUBLISHER_DOXCODE) || $this->_isGranted(_PUBLISHER_DOIMAGE) || $this->_isGranted(_PUBLISHER_DOLINEBREAK)) {
            if ($this->_isGranted(_PUBLISHER_DOHTML)) {
                $html_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOHTML, 'dohtml', $obj->getVar('dohtml'));
                $mainTab->addElement($html_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOSMILEY)) {
                $smiley_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOSMILEY, 'dosmiley', $obj->getVar('dosmiley'));
                $mainTab->addElement($smiley_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOXCODE)) {
                $xcode_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOXCODE, 'doxcode', $obj->getVar('doxcode'));
                $mainTab->addElement($xcode_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOIMAGE)) {
                $image_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOIMAGE, 'doimage', $obj->getVar('doimage'));
                $mainTab->addElement($image_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOLINEBREAK)) {
                $linebreak_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOLINEBREAK, 'dolinebreak', $obj->getVar('dobr'));
                $mainTab->addElement($linebreak_radio);
            }
        }
        // Available pages to wrap
        if ($this->_isGranted(_PUBLISHER_AVAILABLE_PAGE_WRAP)) {
            $wrap_pages = XoopsLists::getHtmlListAsArray(PublisherUtils::getUploadDir(true, 'content'));
            $available_wrap_pages_text = array();
            foreach ($wrap_pages as $page) {
                $available_wrap_pages_text[] = "<span onclick='publisherPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>";
            }
            $available_wrap_pages = new Xoops\Form\Label(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP, implode(', ', $available_wrap_pages_text));
            $available_wrap_pages->setDescription(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP_DSC);
            $mainTab->addElement($available_wrap_pages);
        }
        // Uid
        /*  We need to retrieve the users manually because for some reason, on the frxoops.org server,
            the method users::getobjects encounters a memory error
            */
        // Trabis : well, maybe is because you are getting 6000 objects into memory , no??? LOL
        if ($this->_isGranted(_PUBLISHER_UID)) {
            $uid_select = new Xoops\Form\SelectUser(_CO_PUBLISHER_UID, 'uid', true, array($obj->getVar('uid', 'e')), 1, false);
            $uid_select->setDescription(_CO_PUBLISHER_UID_DSC);
            //$sql = "SELECT uid, uname FROM " . $obj->db->prefix('users') . " ORDER BY uname ASC";
            //$result = $obj->db->query($sql);
            //$users_array = array();
            //$users_array[0] = $xoops->getConfig('anonymous');
            //while ($myrow = $obj->db->fetchArray($result)) {
            //    $users_array[$myrow['uid']] = $myrow['uname'];
            //}
            //$uid_select->addOptionArray($users_array);
            $mainTab->addElement($uid_select);
        }
        /* else {
           $hidden = new Xoops\Form\Hidden('uid', $obj->getVar('uid'));
           $this->addElement($hidden);
           unset($hidden);
           }*/
        // Author Alias
        if ($this->_isGranted(_PUBLISHER_AUTHOR_ALIAS)) {
            $element = new Xoops\Form\Text(_CO_PUBLISHER_AUTHOR_ALIAS, 'author_alias', 50, 255, $obj->getVar('author_alias', 'e'));
            $element->setDescription(_CO_PUBLISHER_AUTHOR_ALIAS_DSC);
            $mainTab->addElement($element);
            unset($element);
        }
        // STATUS
        if ($this->_isGranted(_PUBLISHER_STATUS)) {
            $options = array(_PUBLISHER_STATUS_PUBLISHED => _CO_PUBLISHER_PUBLISHED, _PUBLISHER_STATUS_OFFLINE => _CO_PUBLISHER_OFFLINE, _PUBLISHER_STATUS_SUBMITTED => _CO_PUBLISHER_SUBMITTED, _PUBLISHER_STATUS_REJECTED => _CO_PUBLISHER_REJECTED);
            $status_select = new Xoops\Form\Select(_CO_PUBLISHER_STATUS, 'status', $obj->getVar('status'));
            $status_select->addOptionArray($options);
            $status_select->setDescription(_CO_PUBLISHER_STATUS_DSC);
            $mainTab->addElement($status_select);
            unset($status_select);
        }
        // Datesub
        if ($this->_isGranted(_PUBLISHER_DATESUB)) {
            $datesub = $obj->getVar('datesub') == 0 ? time() : $obj->getVar('datesub');
            $datesub_datetime = new PublisherFormDateTime(_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub);
            $datesub_datetime->setDescription(_CO_PUBLISHER_DATESUB_DSC);
            $mainTab->addElement($datesub_datetime);
        }
        // NOTIFY ON PUBLISH
        if ($this->_isGranted(_PUBLISHER_NOTIFY)) {
            $notify_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_NOTIFY, 'notify', $obj->getVar('notifypub'));
            $mainTab->addElement($notify_radio);
        }
        $tabtray->addElement($mainTab);
        if ($xoops->isActiveModule('images') && $this->_hasTab(_CO_PUBLISHER_TAB_IMAGES)) {
            $imagesTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_IMAGES, 'imagestab');
            // IMAGE
            if ($this->_isGranted(_PUBLISHER_IMAGE_ITEM)) {
                $imgcat_handler = Images::getInstance()->getHandlerCategories();
                $image_handler = Images::getInstance()->getHandlerImages();
                $objimages = $obj->getImages();
                $mainarray = is_object($objimages['main']) ? array($objimages['main']) : array();
                $mergedimages = array_merge($mainarray, $objimages['others']);
                $objimage_array = array();
                /* @var $imageObj ImagesImage */
                foreach ($mergedimages as $imageObj) {
                    $objimage_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
                }
                $catlist = $imgcat_handler->getListByPermission($group, 'imgcat_read', 1);
                $catids = array_keys($catlist);
                $imageObjs = array();
                if (!empty($catids)) {
                    $criteria = new CriteriaCompo(new Criteria('imgcat_id', '(' . implode(',', $catids) . ')', 'IN'));
                    $criteria->add(new Criteria('image_display', 1));
                    $criteria->setSort('image_nicename');
                    $criteria->setOrder('ASC');
                    $imageObjs = $image_handler->getObjects($criteria, true);
                    unset($criteria);
                }
                $image_array = array();
                foreach ($imageObjs as $imageObj) {
                    $image_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
                }
                $image_array = array_diff($image_array, $objimage_array);
                $image_select = new Xoops\Form\Select('', 'image_notused', '', 5);
                $image_select->addOptionArray($image_array);
                $image_select->setExtra("onchange='showImgSelected(\"image_display\", \"image_notused\", \"uploads/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
                //$image_select->setExtra( "onchange='appendMySelectOption(\"image_notused\", \"image_item\")'");
                unset($image_array);
                $image_select2 = new Xoops\Form\Select('', 'image_item', '', 5, true);
                $image_select2->addOptionArray($objimage_array);
                $image_select2->setExtra("onchange='publisher_updateSelectOption(\"image_item\", \"image_featured\"), showImgSelected(\"image_display\", \"image_item\", \"uploads/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
                $buttonadd = new Xoops\Form\Button('', 'buttonadd', _CO_PUBLISHER_ADD);
                $buttonadd->setExtra("onclick='publisher_appendSelectOption(\"image_notused\", \"image_item\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'");
                $buttonremove = new Xoops\Form\Button('', 'buttonremove', _CO_PUBLISHER_REMOVE);
                $buttonremove->setExtra("onclick='publisher_appendSelectOption(\"image_item\", \"image_notused\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'");
                $opentable = new Xoops\Form\Label('', "<table><tr><td>");
                $addcol = new Xoops\Form\Label('', "</td><td>");
                $addbreak = new Xoops\Form\Label('', "<br />");
                $closetable = new Xoops\Form\Label('', "</td></tr></table>");
                $xoops->theme()->addScript(PUBLISHER_URL . '/js/ajaxupload.3.9.js');
                //todo, find replacement for error class
                $js_data = new Xoops\Form\Label('', '
<script type= "text/javascript">/*<![CDATA[*/
$(document).ready(function(){
    var button = $("#publisher_upload_button"), interval;
    new AjaxUpload(button,{
        action: "' . PUBLISHER_URL . '/include/ajax_upload.php", // I disabled uploads in this example for security reasons
        responseType: "text/html",
        name: "publisher_upload_file",
        onSubmit : function(file, ext){
            // change button text, when user selects file
            $("#publisher_upload_message").html(" ");
            button.html("<img src=\'' . PUBLISHER_URL . '/images/loadingbar.gif\'/>"); this.setData({
                "image_nicename": $("#image_nicename").val(),
                "imgcat_id" : $("#imgcat_id").val()
            });
            // If you want to allow uploading only 1 file at time,
            // you can disable upload button
            this.disable();
            interval = window.setInterval(function(){
            }, 200);
        },
        onComplete: function(file, response){
            button.text("' . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . '");
            window.clearInterval(interval);
            // enable upload button
            this.enable();
            // add file to the list
            var result = eval(response);
            if (result[0] == "success") {
                 $("#image_item").append("<option value=\'" + result[1] + "\' selected=\'selected\'>" + result[2] + "</option>");
                 publisher_updateSelectOption(\'image_item\', \'image_featured\');
                 showImgSelected(\'image_display\', \'image_item\', \'uploads/\', \'\', \'' . \XoopsBaseConfig::get('url') . '\')
            } else {
                 $("#publisher_upload_message").html("<div class=\'errorMsg\'>" + result[1] + "</div>");
            }
        }
    });
});
/*]]>*/</script>
');
                $messages = new Xoops\Form\Label('', "<div id='publisher_upload_message'></div>");
                $button = new Xoops\Form\Label('', "<div id='publisher_upload_button'>" . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . "</div>");
                $nicename = new Xoops\Form\Text('', 'image_nicename', 30, 30, _CO_PUBLISHER_IMAGE_NICENAME);
                $catlist = $imgcat_handler->getListByPermission($group, 'imgcat_read', 1);
                $imagecat = new Xoops\Form\Select('', 'imgcat_id', '', 1);
                $imagecat->addOptionArray($catlist);
                $image_upload_tray = new Xoops\Form\ElementTray(_CO_PUBLISHER_IMAGE_UPLOAD, '');
                $image_upload_tray->addElement($js_data);
                $image_upload_tray->addElement($messages);
                $image_upload_tray->addElement($opentable);
                $image_upload_tray->addElement($imagecat);
                $image_upload_tray->addElement($addbreak);
                $image_upload_tray->addElement($nicename);
                $image_upload_tray->addElement($addbreak);
                $image_upload_tray->addElement($button);
                $image_upload_tray->addElement($closetable);
                $imagesTab->addElement($image_upload_tray);
                $image_tray = new Xoops\Form\ElementTray(_CO_PUBLISHER_IMAGE_ITEMS, '');
                $image_tray->addElement($opentable);
                $image_tray->addElement($image_select);
                $image_tray->addElement($addbreak);
                $image_tray->addElement($buttonadd);
                $image_tray->addElement($addcol);
                $image_tray->addElement($image_select2);
                $image_tray->addElement($addbreak);
                $image_tray->addElement($buttonremove);
                $image_tray->addElement($closetable);
                $image_tray->setDescription(_CO_PUBLISHER_IMAGE_ITEMS_DSC);
                $imagesTab->addElement($image_tray);
                $imagename = is_object($objimages['main']) ? $objimages['main']->getVar('image_name') : '';
                $imageforpath = $imagename != '' ? $imagename : 'blank.gif';
                $image_select3 = new Xoops\Form\Select(_CO_PUBLISHER_IMAGE_ITEM, 'image_featured', $imagename, 1);
                $image_select3->addOptionArray($objimage_array);
                $image_select3->setExtra("onchange='showImgSelected(\"image_display\", \"image_featured\", \"uploads/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
                $image_select3->setDescription(_CO_PUBLISHER_IMAGE_ITEM_DSC);
                $imagesTab->addElement($image_select3);
                $image_preview = new Xoops\Form\Label(_CO_PUBLISHER_IMAGE_PREVIEW, "<img width='500' src='" . \XoopsBaseConfig::get('url') . "/uploads/" . $imageforpath . "' name='image_display' id='image_display' alt='' />");
                $imagesTab->addElement($image_preview);
            }
            $tabtray->addElement($imagesTab);
        }
        if ($this->_hasTab(_CO_PUBLISHER_TAB_FILES)) {
            $filesTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_FILES, 'filestab');
            // File upload UPLOAD
            if ($this->_isGranted(_PUBLISHER_ITEM_UPLOAD_FILE)) {
                // NAME
                $name_text = new Xoops\Form\Text(_CO_PUBLISHER_FILENAME, 'item_file_name', 50, 255, '');
                $name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC);
                $filesTab->addElement($name_text);
                unset($name_text);
                // DESCRIPTION
                $description_text = new Xoops\Form\TextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'item_file_description', '');
                $description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC);
                $filesTab->addElement($description_text);
                unset($description_text);
                $status_select = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'item_file_status', 1);
                //1 - active
                $status_select->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC);
                $filesTab->addElement($status_select);
                unset($status_select);
                $file_box = new Xoops\Form\File(_CO_PUBLISHER_ITEM_UPLOAD_FILE, "item_upload_file");
                $file_box->setDescription(_CO_PUBLISHER_ITEM_UPLOAD_FILE_DSC);
                $file_box->setExtra("size ='50'");
                $filesTab->addElement($file_box);
                unset($file_box);
                if (!$obj->isNew()) {
                    $filesObj = $publisher->getFileHandler()->getAllFiles($obj->getVar('itemid'));
                    if (count($filesObj) > 0) {
                        $table = '';
                        $table .= "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
                        $table .= "<tr>";
                        $table .= "<td width='50' class='bg3' align='center'><strong>ID</strong></td>";
                        $table .= "<td width='150' class='bg3' align='left'><strong>" . _AM_PUBLISHER_FILENAME . "</strong></td>";
                        $table .= "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_DESCRIPTION . "</strong></td>";
                        $table .= "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_HITS . "</strong></td>";
                        $table .= "<td width='100' class='bg3' align='center'><strong>" . _AM_PUBLISHER_UPLOADED_DATE . "</strong></td>";
                        $table .= "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>";
                        $table .= "</tr>";
                        /* @var $fileObj PublisherFile */
                        foreach ($filesObj as $fileObj) {
                            $modify = "<a href='file.php?op=mod&fileid=" . $fileObj->getVar('fileid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif' title='" . _CO_PUBLISHER_EDITFILE . "' alt='" . _CO_PUBLISHER_EDITFILE . "' /></a>";
                            $delete = "<a href='file.php?op=del&fileid=" . $fileObj->getVar('fileid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png' title='" . _CO_PUBLISHER_DELETEFILE . "' alt='" . _CO_PUBLISHER_DELETEFILE . "'/></a>";
                            if ($fileObj->getVar('status') == 0) {
                                $not_visible = "<img src='" . PUBLISHER_URL . "/images/no.gif'/>";
                            } else {
                                $not_visible = '';
                            }
                            $table .= "<tr>";
                            $table .= "<td class='head' align='center'>" . $fileObj->getVar('fileid') . "</td>";
                            $table .= "<td class='odd' align='left'>" . $not_visible . $fileObj->getFileLink() . "</td>";
                            $table .= "<td class='even' align='left'>" . $fileObj->getVar('description') . "</td>";
                            $table .= "<td class='even' align='center'>" . $fileObj->getVar('counter') . "";
                            $table .= "<td class='even' align='center'>" . $fileObj->datesub() . "</td>";
                            $table .= "<td class='even' align='center'> {$modify} {$delete} </td>";
                            $table .= "</tr>";
                        }
                        $table .= "</table>";
                        $files_box = new Xoops\Form\Label(_CO_PUBLISHER_FILES_LINKED, $table);
                        $filesTab->addElement($files_box);
                        unset($files_box, $filesObj, $fileObj);
                    }
                }
            }
            $tabtray->addElement($filesTab);
        }
        if ($this->_hasTab(_CO_PUBLISHER_TAB_OTHERS)) {
            $othersTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_OTHERS, 'otherstab');
            // Meta Keywords
            if ($this->_isGranted(_PUBLISHER_ITEM_META_KEYWORDS)) {
                $text_meta_keywords = new Xoops\Form\TextArea(_CO_PUBLISHER_ITEM_META_KEYWORDS, 'item_meta_keywords', $obj->getVar('meta_keywords', 'e'), 7, 60);
                $text_meta_keywords->setDescription(_CO_PUBLISHER_ITEM_META_KEYWORDS_DSC);
                $othersTab->addElement($text_meta_keywords);
            }
            // Meta Description
            if ($this->_isGranted(_PUBLISHER_ITEM_META_DESCRIPTION)) {
                $text_meta_description = new Xoops\Form\TextArea(_CO_PUBLISHER_ITEM_META_DESCRIPTION, 'item_meta_description', $obj->getVar('meta_description', 'e'), 7, 60);
                $text_meta_description->setDescription(_CO_PUBLISHER_ITEM_META_DESCRIPTION_DSC);
                $othersTab->addElement($text_meta_description);
            }
            // COMMENTS
            if ($this->_isGranted(_PUBLISHER_ALLOWCOMMENTS)) {
                $addcomments_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_ALLOWCOMMENTS, 'allowcomments', $obj->getVar('cancomment'));
                $othersTab->addElement($addcomments_radio);
            }
            // WEIGHT
            if ($this->_isGranted(_PUBLISHER_WEIGHT)) {
                $othersTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_WEIGHT, 'weight', 5, 5, $obj->getVar('weight')));
            }
            $tabtray->addElement($othersTab);
        }
        $this->addElement($tabtray);
        //COMMON TO ALL TABS
        $button_tray = new Xoops\Form\ElementTray('', '');
        if (!$obj->isNew()) {
            $button_tray->addElement(new Xoops\Form\Button('', 'additem', XoopsLocale::A_SUBMIT, 'submit'));
            //orclone
        } else {
            $button_tray->addElement(new Xoops\Form\Button('', 'additem', _CO_PUBLISHER_CREATE, 'submit'));
            $button_tray->addElement(new Xoops\Form\Button('', '', _CO_PUBLISHER_CLEAR, 'reset'));
        }
        $button_tray->addElement(new Xoops\Form\Button('', 'preview', _CO_PUBLISHER_PREVIEW, 'submit'));
        $butt_cancel = new Xoops\Form\Button('', '', _CO_PUBLISHER_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $this->addElement($button_tray);
        $hidden = new Xoops\Form\Hidden('itemid', $obj->getVar('itemid'));
        $this->addElement($hidden);
        unset($hidden);
    }
Example #13
0
 // Initialize blocks handler
 $block_handler = $xoops->getHandlerBlock();
 // Get avatar id
 $block_id = $system->cleanVars($_POST, 'bid', 0, 'int');
 if ($block_id > 0) {
     $block = $block_handler->get($block_id);
     if ($block_handler->deleteBlock($block)) {
         // Delete Group link
         $blockmodulelink_handler = $xoops->getHandlerBlockmodulelink();
         $blockmodulelink = $blockmodulelink_handler->getObjects(new CriteriaCompo(new Criteria('block_id', $block_id)));
         foreach ($blockmodulelink as $link) {
             $blockmodulelink_handler->delete($link, true);
         }
         // Delete Group permission
         $groupperm_handler = $xoops->getHandlerGroupperm();
         $criteria = new CriteriaCompo(new Criteria('gperm_name', 'block_read'));
         $criteria->add(new Criteria('gperm_itemid', $block_id));
         $groupperm = $groupperm_handler->getObjects($criteria);
         /* @var $perm XoopsGroupPerm */
         foreach ($groupperm as $perm) {
             $groupperm_handler->delete($perm, true);
         }
         // Delete template
         if ($block->getVar('template') != '') {
             $tplfile_handler = $xoops->getHandlerTplfile();
             $btemplate = $tplfile_handler->find($xoops->getConfig('template_set'), 'block', $block_id);
             if (count($btemplate) > 0) {
                 $tplfile_handler->deleteTpl($btemplate[0]);
             }
         }
         $xoops->redirect('admin.php?fct=blocksadmin', 1, XoopsLocale::S_DATABASE_UPDATED);
Example #14
0
/**
 * addCriteria - add a criteria for a column enforcing XOOPS_MATCH_* rules
 *
 * @param CriteriaCompo $criteria A CriteriaCompo object to add to
 * @param string        $column   column name
 * @param int|string    $value    column value
 * @param integer       $match    A XOOPS_MATCH_* value
 *
 * @return void
 */
function addCriteria(CriteriaCompo $criteria, $column, $value, $match)
{
    $relation = 'LIKE';
    switch ($match) {
        default:
        case XOOPS_MATCH_START:
            $value = $value . '%';
            break;
        case XOOPS_MATCH_END:
            $value = '%' . $value;
            break;
        case XOOPS_MATCH_EQUAL:
            //$value = $value;
            $relation = '=';
            break;
        case XOOPS_MATCH_CONTAIN:
            $value = '%' . $value . '%';
            break;
    }
    $criteria->add(new Criteria($column, $value, $relation));
}
Example #15
0
 $verif_write = false;
 $text = '';
 if (!is_dir($template_overload)) {
     //Creation du dossier modules
     if (!is_dir($template_overload)) {
         mkdir($template_overload, 0777);
     }
     chmod($template_overload, 0777);
     copy($indexFile, $template_overload . "/index.html");
 }
 $tplset = $system->cleanVars($POST, 'tplset', 'default', 'string');
 //on crée uniquement les templates qui n'existent pas
 $module_handler = $xoops->getHandlerModule();
 $tplset_handler = $xoops->getHandlerTplSet();
 $tpltpl_handler = $xoops->getHandlerTplFile();
 $criteria = new CriteriaCompo();
 $criteria->add(new Criteria('tplset_name', $tplset));
 $tplsets_arr = $tplset_handler->getObjects();
 $tcount = $tplset_handler->getCount();
 $installed_mods = $tpltpl_handler->getModuleTplCount($tplset);
 //all templates or only one template
 if ($_REQUEST['active_templates'] == 0) {
     foreach (array_keys($tplsets_arr) as $i) {
         $tplsetname = $tplsets_arr[$i]->getVar('tplset_name');
         $tplstats = $tpltpl_handler->getModuleTplCount($tplsetname);
         if (count($tplstats) > 0) {
             foreach ($tplstats as $moddir => $filecount) {
                 $module = $xoops->getModuleByDirname($moddir);
                 if (is_object($module)) {
                     // create module folder
                     if (!is_dir($template_overload . '/' . $module->getVar('dirname'))) {
Example #16
0
            $xoops->tpl()->assign('help_module', true);
        }
        $xoops->tpl()->assign('helpcontent', $helpcontent);
    } else {
        if ($helpfile = XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getVar('dirname', 'e') . '/locale/' . XoopsLocale::getLocale() . '/help/module_index.html')) {
            $helpcontent = $xoops->tpl()->fetch(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getVar('dirname', 'e') . '/locale/' . XoopsLocale::getLocale() . '/help/module_index.html');
        } elseif (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getVar('dirname', 'e') . '/language/' . $xoops->getConfig('language') . '/help/module_index.html')) {
            $helpcontent = $xoops->tpl()->fetch(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getVar('dirname', 'e') . '/language/' . $xoops->getConfig('language') . '/help/module_index.html');
        } else {
            $helpcontent = '<p>' . $module->getInfo('description') . '</p>';
        }
        $xoops->tpl()->assign('helpcontent', $helpcontent);
    }
} else {
    $system_breadcrumb->render();
    $criteria = new CriteriaCompo();
    $criteria->setOrder('weight');
    // Get all installed modules
    $installed_mods = $xoops->getHandlerModule()->getObjectsArray($criteria);
    $listed_mods = array();
    $i = 0;
    $j = 0;
    foreach ($installed_mods as $module) {
        /* @var $module XoopsModule */
        $list_help = array();
        $listed_mods[$i] = $module->getValues();
        $listed_mods[$i]['image'] = $module->getInfo('image');
        $listed_mods[$i]['adminindex'] = $module->getInfo('adminindex');
        $listed_mods[$i]['version'] = round($module->getVar('version') / 100, 2);
        $listed_mods[$i]['last_update'] = XoopsLocale::formatTimestamp($module->getVar('last_update'), 'm');
        $listed_mods[$i]['author'] = $module->getInfo('author');
Example #17
0
 if (!in_array($group->getVar('groupid'), array(FixedGroups::ADMIN, FixedGroups::USERS, FixedGroups::ANONYMOUS))) {
     if (count($system_catids) > 0) {
         $group->setVar('group_type', 'Admin');
     } else {
         $group->setVar('group_type', '');
     }
 }
 if (!$member_handler->insertGroup($group)) {
     $xoops->header();
     echo $group->getHtmlErrors();
     $xoops->footer();
 } else {
     $xoops->db()->beginTransaction();
     $groupid = $group->getVar('groupid');
     $gperm_handler = $xoops->getHandlerGroupPermission();
     $criteria = new CriteriaCompo(new Criteria('gperm_groupid', $groupid));
     $criteria->add(new Criteria('gperm_modid', 1));
     $criteria2 = new CriteriaCompo(new Criteria('gperm_name', 'system_admin'));
     $criteria2->add(new Criteria('gperm_name', 'module_admin'), 'OR');
     $criteria2->add(new Criteria('gperm_name', 'module_read'), 'OR');
     $criteria2->add(new Criteria('gperm_name', 'block_read'), 'OR');
     $criteria->add($criteria2);
     $gperm_handler->deleteAll($criteria);
     if (count($system_catids) > 0) {
         array_push($admin_mids, 1);
         foreach ($system_catids as $s_cid) {
             $sysperm = $gperm_handler->create();
             $sysperm->setVar('gperm_groupid', $groupid);
             $sysperm->setVar('gperm_itemid', $s_cid);
             $sysperm->setVar('gperm_name', 'system_admin');
             $sysperm->setVar('gperm_modid', 1);
Example #18
0
 /**
  * getForm - get block edit form
  *
  * @param string $mode mode for form, edit or clone
  *
  * @return void
  */
 public function getForm($mode = 'edit')
 {
     $xoops = Xoops::getInstance();
     $xoops->loadLanguage('blocks', 'system');
     if ($this->obj->isNew()) {
         $title = SystemLocale::ADD_BLOCK;
         $modules = array(-1);
         $groups = array(FixedGroups::USERS, FixedGroups::ANONYMOUS, FixedGroups::ADMIN);
         $this->obj->setVar('block_type', 'C');
         $this->obj->setVar('visible', 1);
         $op = 'save';
     } else {
         $title = '';
         $modules = array();
         // Search modules
         $blockmodulelink_handler = $xoops->getHandlerBlockmodulelink();
         $criteria = new CriteriaCompo(new Criteria('block_id', $this->obj->getVar('bid')));
         $blockmodulelink = $blockmodulelink_handler->getObjects($criteria);
         /* @var $link XoopsBlockmodulelink */
         foreach ($blockmodulelink as $link) {
             $modules[] = $link->getVar('module_id');
         }
         // Search perms
         $groupperm_handler = $xoops->getHandlerGroupperm();
         $groups = $groupperm_handler->getGroupIds('block_read', $this->obj->getVar('bid'));
         switch ($mode) {
             case 'edit':
                 $title = SystemLocale::EDIT_BLOCK;
                 break;
             case 'clone':
                 $title = SystemLocale::CLONE_BLOCK;
                 $this->obj->setVar('bid', 0);
                 if ($this->obj->isCustom()) {
                     $this->obj->setVar('block_type', 'C');
                 } else {
                     $this->obj->setVar('block_type', 'D');
                 }
                 break;
         }
         $op = 'save';
     }
     parent::__construct($title, 'blockform', 'admin.php', 'post', true);
     if (!$this->obj->isNew()) {
         $this->addElement(new Xoops\Form\Label(XoopsLocale::NAME, $this->obj->getVar('name')));
     }
     // Side position
     $side_select = new Xoops\Form\Select(XoopsLocale::SIDE, 'side', $this->obj->getVar('side'));
     $side_select->addOptionArray(array(0 => XoopsLocale::LEFT, 1 => XoopsLocale::RIGHT, 3 => SystemLocale::TOP_LEFT, 4 => SystemLocale::TOP_RIGHT, 5 => SystemLocale::TOP_CENTER, 7 => SystemLocale::BOTTOM_LEFT, 8 => SystemLocale::BOTTOM_RIGHT, 9 => SystemLocale::BOTTOM_CENTER));
     $this->addElement($side_select);
     // Order
     $weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'weight', 1, 5, $this->obj->getVar('weight'), '');
     $weight->setPattern('^\\d+$', XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER);
     $this->addElement($weight, true);
     // Display
     $this->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::VISIBLE, 'visible', $this->obj->getVar('visible')));
     // Visible In
     $mod_select = new Xoops\Form\Select(XoopsLocale::VISIBLE_IN, 'modules', $modules, 5, true);
     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
     $criteria->add(new Criteria('isactive', 1));
     $module_list = $xoops->getHandlerModule()->getNameList($criteria);
     $module_list[-1] = XoopsLocale::TOP_PAGE;
     $module_list[0] = XoopsLocale::ALL_PAGES;
     ksort($module_list);
     $mod_select->addOptionArray($module_list);
     $this->addElement($mod_select);
     // Title
     $this->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'title', 5, 255, $this->obj->getVar('title')), false);
     if ($this->obj->isNew() || $this->obj->isCustom()) {
         $editor_configs = array();
         $editor_configs["name"] = "content_block";
         $editor_configs["value"] = $this->obj->getVar('content', 'e');
         $editor_configs["rows"] = 15;
         $editor_configs["cols"] = 6;
         $editor_configs["editor"] = $xoops->getModuleConfig('blocks_editor', 'system');
         $this->addElement(new Xoops\Form\Editor(XoopsLocale::CONTENT, "content_block", $editor_configs), true);
         if (in_array($editor_configs["editor"], array('dhtmltextarea', 'textarea'))) {
             $ctype_select = new Xoops\Form\Select(SystemLocale::CONTENT_TYPE, 'c_type', $this->obj->getVar('c_type'));
             $ctype_select->addOptionArray(array('H' => XoopsLocale::HTML, 'P' => SystemLocale::PHP_SCRIPT, 'S' => SystemLocale::AUTO_FORMAT_SMILIES_ENABLED, 'T' => SystemLocale::AUTO_FORMAT_SMILIES_DISABLED));
             $this->addElement($ctype_select);
         } else {
             $this->addElement(new Xoops\Form\Hidden('c_type', 'H'));
         }
     } else {
         if ($this->obj->getVar('template') != '') {
             $tplfile_handler = $xoops->getHandlerTplfile();
             $btemplate = $tplfile_handler->find($xoops->getConfig('template_set'), 'block', $this->obj->getVar('bid'));
             if (count($btemplate) > 0) {
                 $this->addElement(new Xoops\Form\Label(XoopsLocale::CONTENT, '<a href="' . \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
             } else {
                 $btemplate2 = $tplfile_handler->find('default', 'block', $this->obj->getVar('bid'));
                 if (count($btemplate2) > 0) {
                     $this->addElement(new Xoops\Form\Label(XoopsLocale::CONTENT, '<a href="' . \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" rel="external">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
                 }
             }
         }
         if ($this->obj->getOptions() != false) {
             $this->addElement(new Xoops\Form\Label(XoopsLocale::OPTIONS, $this->obj->getOptions()));
         } else {
             $this->addElement(new Xoops\Form\Hidden('options', $this->obj->getVar('options')));
         }
         $this->addElement(new Xoops\Form\Hidden('c_type', 'H'));
     }
     $cache_select = new Xoops\Form\Select(SystemLocale::CACHE_LIFETIME, 'bcachetime', $this->obj->getVar('bcachetime'));
     $cache_select->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));
     $this->addElement($cache_select);
     // Groups
     $this->addElement(new Xoops\Form\SelectGroup(XoopsLocale::GROUPS, 'groups', true, $groups, 5, true));
     $this->addElement(new Xoops\Form\Hidden('block_type', $this->obj->getVar('block_type')));
     $this->addElement(new Xoops\Form\Hidden('mid', $this->obj->getVar('mid')));
     $this->addElement(new Xoops\Form\Hidden('func_num', $this->obj->getVar('func_num')));
     $this->addElement(new Xoops\Form\Hidden('func_file', $this->obj->getVar('func_file')));
     $this->addElement(new Xoops\Form\Hidden('show_func', $this->obj->getVar('show_func')));
     $this->addElement(new Xoops\Form\Hidden('edit_func', $this->obj->getVar('edit_func')));
     $this->addElement(new Xoops\Form\Hidden('template', $this->obj->getVar('template')));
     $this->addElement(new Xoops\Form\Hidden('dirname', $this->obj->getVar('dirname')));
     $this->addElement(new Xoops\Form\Hidden('name', $this->obj->getVar('name')));
     $this->addElement(new Xoops\Form\Hidden('bid', $this->obj->getVar('bid')));
     $this->addElement(new Xoops\Form\Hidden('op', $op));
     $this->addElement(new Xoops\Form\Hidden('fct', 'blocksadmin'));
     $button_tray = new Xoops\Form\ElementTray('', '&nbsp;');
     if ($this->obj->isNew() || $this->obj->isCustom()) {
         $preview = new Xoops\Form\Button('', 'previewblock', XoopsLocale::A_PREVIEW, 'preview');
         $preview->setExtra("onclick=\"blocks_preview();\"");
         $button_tray->addElement($preview);
     }
     $button_tray->addElement(new Xoops\Form\Button('', 'submitblock', XoopsLocale::A_SUBMIT, 'submit'));
     $this->addElement($button_tray);
 }
Example #19
0
/* @var $wizard XoopsInstallWizard */
$wizard = $_SESSION['wizard'];
$xoops->loadLocale('system');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $config_handler = $xoops->getHandlerConfig();
    if (array_key_exists('conf_ids', $_REQUEST)) {
        foreach ($_REQUEST['conf_ids'] as $key => $conf_id) {
            $config = $config_handler->getConfig($conf_id);
            $new_value = $_REQUEST[$config->getVar('conf_name')];
            $config->setConfValueForInput($new_value);
            $config_handler->insertConfig($config);
        }
    }
    $wizard->redirectToPage('+1');
}
$config_handler = $xoops->getHandlerConfig();
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('conf_modid', 1));
$criteria2 = new CriteriaCompo();
foreach ($wizard->configs['conf_names'] as $conf_name) {
    $criteria2->add(new Criteria('conf_name', $conf_name), 'OR');
}
$criteria->add($criteria2);
$criteria->setSort('conf_catid ASC, conf_order');
$configs = $config_handler->getConfigs($criteria);
include XOOPS_INSTALL_PATH . '/include/createconfigform.php';
$wizard->form = createConfigform($configs);
$_SESSION['pageHasHelp'] = true;
$_SESSION['pageHasForm'] = true;
$_SESSION['content'] = $wizard->CreateForm();
include XOOPS_INSTALL_PATH . '/include/install_tpl.php';
Example #20
0
 /**
  * Perform notification maintenance activites at login time.
  * In particular, any notifications for the newly logged-in
  * user with mode NOTIFICATIONS_MODE_WAITFORLOGIN are
  * switched to mode NOTIFICATIONS_MODE_SENDONCETHENWAIT.
  *
  * @param int $user_id ID of the user being logged in
  *
  * @return void
  **/
 public function doLoginMaintenance($user_id)
 {
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('uid', (int) $user_id));
     $criteria->add(new Criteria('mode', NOTIFICATIONS_MODE_WAITFORLOGIN));
     $notifications = $this->getObjectsArray($criteria, true);
     foreach ($notifications as $n) {
         /* @var $n NotificationsNotification */
         $n->setVar('mode', NOTIFICATIONS_MODE_SENDONCETHENWAIT);
         $this->insert($n);
     }
 }
Example #21
0
 /**
  * @param array  $queryarray
  * @param string $andor
  * @param int    $limit
  * @param int    $offset
  * @param int    $userid
  * @param array  $categories
  * @param int    $sortby
  * @param string $searchin
  * @param string $extra
  *
  * @return array
  */
 public function getItemsFromSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = array(), $sortby = 0, $searchin = "", $extra = "")
 {
     $xoops = Xoops::getInstance();
     $ret = array();
     $gperm_handler = $xoops->getHandlerGroupPermission();
     $groups = $xoops->getUserGroups();
     $searchin = empty($searchin) ? array("title", "body", "summary") : (is_array($searchin) ? $searchin : array($searchin));
     if (in_array("all", $searchin) || count($searchin) == 0) {
         $searchin = array("title", "subtitle", "body", "summary", "meta_keywords");
     }
     if (is_array($userid) && count($userid) > 0) {
         $userid = array_map("intval", $userid);
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
     } elseif (is_numeric($userid) && $userid > 0) {
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('uid', $userid), 'OR');
     }
     $count = count($queryarray);
     if (is_array($queryarray) && $count > 0) {
         $criteriaKeywords = new CriteriaCompo();
         for ($i = 0; $i < count($queryarray); ++$i) {
             $criteriaKeyword = new CriteriaCompo();
             if (in_array('title', $searchin)) {
                 $criteriaKeyword->add(new Criteria('title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('subtitle', $searchin)) {
                 $criteriaKeyword->add(new Criteria('subtitle', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('body', $searchin)) {
                 $criteriaKeyword->add(new Criteria('body', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('summary', $searchin)) {
                 $criteriaKeyword->add(new Criteria('summary', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('meta_keywords', $searchin)) {
                 $criteriaKeyword->add(new Criteria('meta_keywords', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             $criteriaKeywords->add($criteriaKeyword, $andor);
             unset($criteriaKeyword);
         }
     }
     if (!PublisherUtils::IsUserAdmin() && count($categories) > 0) {
         $criteriaPermissions = new CriteriaCompo();
         // Categories for which user has access
         $categoriesGranted = $gperm_handler->getItemIds('category_read', $groups, $this->publisher->getModule()->getVar('mid'));
         if (count($categories) > 0) {
             $categoriesGranted = array_intersect($categoriesGranted, $categories);
         }
         if (count($categoriesGranted) == 0) {
             return $ret;
         }
         $grantedCategories = new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
         $criteriaPermissions->add($grantedCategories, 'AND');
     } elseif (count($categories) > 0) {
         $criteriaPermissions = new CriteriaCompo();
         $grantedCategories = new Criteria('categoryid', "(" . implode(',', $categories) . ")", 'IN');
         $criteriaPermissions->add($grantedCategories, 'AND');
     }
     $criteriaItemsStatus = new CriteriaCompo();
     $criteriaItemsStatus->add(new Criteria('status', _PUBLISHER_STATUS_PUBLISHED));
     $criteria = new CriteriaCompo();
     if (!empty($criteriaUser)) {
         $criteria->add($criteriaUser, 'AND');
     }
     if (!empty($criteriaKeywords)) {
         $criteria->add($criteriaKeywords, 'AND');
     }
     if (!empty($criteriaPermissions)) {
         $criteria->add($criteriaPermissions);
     }
     if (!empty($criteriaItemsStatus)) {
         $criteria->add($criteriaItemsStatus, 'AND');
     }
     $criteria->setLimit($limit);
     $criteria->setStart($offset);
     if (empty($sortby)) {
         $sortby = "datesub";
     }
     $criteria->setSort($sortby);
     $order = 'ASC';
     if ($sortby === "datesub") {
         $order = 'DESC';
     }
     $criteria->setOrder($order);
     $ret = $this->getItemObjects($criteria);
     return $ret;
 }
Example #22
0
 /**
  * Get all subcats and put them in an array indexed by parent id
  *
  * @param array $categories
  *
  * @return array
  */
 public function &getSubCats($categories)
 {
     $xoops = Xoops::getInstance();
     $criteria = new CriteriaCompo(new Criteria('parentid', "(" . implode(',', array_keys($categories)) . ")", 'IN'));
     $ret = array();
     if (!PublisherUtils::IsUserAdmin()) {
         $categoriesGranted = $this->publisher->getPermissionHandler()->getGrantedItems('category_read');
         if (count($categoriesGranted) > 0) {
             $criteria->add(new Criteria('categoryid', '(' . implode(',', $categoriesGranted) . ')', 'IN'));
         } else {
             return $ret;
         }
         if ($xoops->isUser()) {
             $criteria->add(new Criteria('moderator', $xoops->user->getVar('uid')), 'OR');
         }
     }
     $criteria->setSort('weight');
     $criteria->setOrder('ASC');
     $subcats = $this->getObjects($criteria, true);
     /* @var $subcat PublisherCategory */
     foreach ($subcats as $subcat) {
         $ret[$subcat->getVar('parentid')][$subcat->getVar('categoryid')] = $subcat;
     }
     return $ret;
 }
Example #23
0
 $xoopsTpl->assign('lang_date', _MD_PUBLISHER_DATE);
 $xoopsTpl->assign('lang_views', _MD_PUBLISHER_HITS);
 // must adjust the selected time to server timestamp
 $timeoffset = $useroffset - $xoops->getConfig('server_TZ');
 $monthstart = mktime(0 - $timeoffset, 0, 0, $frommonth, 1, $fromyear);
 $monthend = mktime(23 - $timeoffset, 59, 59, $frommonth + 1, 0, $fromyear);
 $monthend = $monthend > time() ? time() : $monthend;
 $count = 0;
 $itemhandler = $publisher->getItemHandler();
 $itemhandler->table_link = $xoops->db()->prefix('publisher_categories');
 $itemhandler->field_link = 'categoryid';
 $itemhandler->field_object = 'categoryid';
 // Categories for which user has access
 $categoriesGranted = $publisher->getPermissionHandler()->getGrantedItems('category_read');
 $grantedCategories = new Criteria('l.categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
 $criteria = new CriteriaCompo();
 $criteria->add($grantedCategories, 'AND');
 $criteria->add(new Criteria('o.status', 2), 'AND');
 $critdatesub = new CriteriaCompo();
 $critdatesub->add(new Criteria('o.datesub', $monthstart, '>'), 'AND');
 $critdatesub->add(new Criteria('o.datesub', $monthend, '<='), 'AND');
 $criteria->add($critdatesub);
 $criteria->setSort('o.datesub');
 $criteria->setOrder('DESC');
 $criteria->setLimit(3000);
 $storyarray = $itemhandler->getByLink($criteria);
 //Query Efficiency?
 /* @var $item PublisherItem */
 $count = count($storyarray);
 if (is_array($storyarray) && $count > 0) {
     foreach ($storyarray as $item) {
Example #24
0
 /**
  * Returns permissions for a certain type
  *
  * @param string $gperm_name "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
  *
  * @return array
  */
 public function getGrantedItems($gperm_name)
 {
     static $items;
     if (isset($items[$gperm_name])) {
         return $items[$gperm_name];
     }
     $ret = array();
     //Instead of calling groupperm handler and get objects, we will save some memory and do it our way
     $criteria = new CriteriaCompo(new Criteria('gperm_name', $gperm_name));
     $criteria->add(new Criteria('gperm_modid', $this->publisher->getModule()->getVar('mid')));
     //Get user's groups
     $groups = \Xoops::getInstance()->getUserGroups();
     $criteria2 = new CriteriaCompo();
     foreach ($groups as $gid) {
         $criteria2->add(new Criteria('gperm_groupid', $gid), 'OR');
     }
     $criteria->add($criteria2);
     $qb = $this->db2->createXoopsQueryBuilder();
     $qb->select('gperm_itemid')->fromPrefix('group_permission', '');
     $criteria->renderQb($qb);
     $result = $qb->execute();
     while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
         $ret[$myrow['gperm_itemid']] = $myrow['gperm_itemid'];
     }
     $items[$gperm_name] = $ret;
     return $ret;
 }
Example #25
0
 /**
  * retrieve all files
  *
  * @param int     $itemid
  * @param int     $status
  * @param int     $limit
  * @param int     $start
  * @param string  $sort
  * @param string  $order
  * @param array   $category
  *
  * @return array array of {@link PublisherFile} objects
  */
 public function &getAllFiles($itemid = 0, $status = -1, $limit = 0, $start = 0, $sort = 'datesub', $order = 'DESC', $category = array())
 {
     $this->table_link = $this->db2->prefix('publisher_items');
     $this->field_object = 'itemid';
     $this->field_link = 'itemid';
     $hasStatusCriteria = false;
     $criteriaStatus = new CriteriaCompo();
     if (is_array($status)) {
         $hasStatusCriteria = true;
         foreach ($status as $v) {
             $criteriaStatus->add(new Criteria('o.status', $v), 'OR');
         }
     } elseif ($status != -1) {
         $hasStatusCriteria = true;
         $criteriaStatus->add(new Criteria('o.status', $status), 'OR');
     }
     $hasCategoryCriteria = false;
     $criteriaCategory = new CriteriaCompo();
     $category = (array) $category;
     if (count($category) > 0 && $category[0] != 0) {
         $hasCategoryCriteria = true;
         foreach ($category as $cat) {
             $criteriaCategory->add(new Criteria('l.categoryid', $cat), 'OR');
         }
     }
     $criteriaItemid = new Criteria('o.itemid', $itemid);
     $criteria = new CriteriaCompo();
     if ($itemid != 0) {
         $criteria->add($criteriaItemid);
     }
     if ($hasStatusCriteria) {
         $criteria->add($criteriaStatus);
     }
     if ($hasCategoryCriteria) {
         $criteria->add($criteriaCategory);
     }
     $criteria->setSort($sort);
     $criteria->setOrder($order);
     $criteria->setLimit($limit);
     $criteria->setStart($start);
     $files = $this->getByLink($criteria, array('o.*'), true);
     return $files;
 }
Example #26
0
 /**
  * remove a list of users from a group
  *
  * @param int   $group_id ID of the group
  * @param array $user_ids array of user-IDs
  *
  * @return bool success?
  */
 public function removeUsersFromGroup($group_id, $user_ids = array())
 {
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('groupid', $group_id));
     $criteria2 = new CriteriaCompo();
     foreach ($user_ids as $uid) {
         $criteria2->add(new Criteria('uid', $uid), 'OR');
     }
     $criteria->add($criteria2);
     return $this->membershipHandler->deleteAll($criteria);
 }
 /**
  * Get all group IDs assigned a specific permission for a particular item
  *
  * @param string $gperm_name   Name of permission
  * @param int    $gperm_itemid ID of an item
  * @param int    $gperm_modid  ID of a module
  *
  * @return  array   array of group IDs
  */
 public function getGroupIds($gperm_name, $gperm_itemid, $gperm_modid = 1)
 {
     $ret = array();
     $criteria = new CriteriaCompo(new Criteria('gperm_name', (string) $gperm_name));
     $criteria->add(new Criteria('gperm_itemid', (int) $gperm_itemid));
     $criteria->add(new Criteria('gperm_modid', (int) $gperm_modid));
     $perms = $this->getObjects($criteria, true);
     foreach (array_keys($perms) as $i) {
         $ret[] = $perms[$i]->getVar('gperm_groupid');
     }
     return $ret;
 }
Example #28
0
 /**
  * Get a list of imagesCategories
  *
  * @param array $groups
  * @param string $perm
  * @param null $display
  * @param null $storetype
  *
  * @return array Array of {@link ImagesImage} objects
  */
 public function getListByPermission($groups = array(), $perm = 'imgcat_read', $display = null, $storetype = null)
 {
     $xoops = Xoops::getInstance();
     $criteria = new CriteriaCompo();
     if (is_array($groups) && !empty($groups)) {
         $criteriaTray = new CriteriaCompo();
         foreach ($groups as $gid) {
             $criteriaTray->add(new Criteria('gperm_groupid', $gid), 'OR');
         }
         $criteria->add($criteriaTray);
         if ($perm == 'imgcat_read' || $perm == 'imgcat_write') {
             $criteria->add(new Criteria('gperm_name', $perm));
             $mid = $xoops->getModuleByDirname('images')->getVar('mid');
             $criteria->add(new Criteria('gperm_modid', $mid));
         }
     }
     if (isset($display)) {
         $criteria->add(new Criteria('imgcat_display', (int) $display));
     }
     if (isset($storetype)) {
         $criteria->add(new Criteria('imgcat_storetype', $storetype));
     }
     $categories = $this->getPermittedObjects($criteria, 0, 0, true);
     $ret = array();
     foreach (array_keys($categories) as $i) {
         $ret[$i] = $categories[$i]->getVar('imgcat_name');
     }
     return $ret;
 }
Example #29
0
 /**
  * Get a list of configs
  *
  * @param int $conf_modid ID of the modules
  * @param int $conf_uid   ID of the user
  *
  * @return    array   Associative array of name=>value pairs.
  */
 public function getConfigList($conf_modid, $conf_uid = 0)
 {
     if (!empty($this->_cachedConfigs[$conf_modid][$conf_uid])) {
         return $this->_cachedConfigs[$conf_modid][$conf_uid];
     } else {
         $criteria = new CriteriaCompo(new Criteria('conf_modid', $conf_modid));
         if (empty($conf_uid)) {
             $criteria->add(new Criteria('conf_uid', $conf_uid));
         }
         $criteria->setSort('conf_order');
         $criteria->setOrder('ASC');
         $configs = $this->_iHandler->getObjects($criteria);
         $confcount = count($configs);
         $ret = array();
         for ($i = 0; $i < $confcount; ++$i) {
             $ret[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
         }
         $this->_cachedConfigs[$conf_modid][$conf_uid] = $ret;
         return $ret;
     }
 }
Example #30
0
 /**
  * installBlocks
  *
  * @param XoopsModule $module module context
  *
  * @return void
  */
 public function installBlocks(XoopsModule $module)
 {
     $xoops = Xoops::getInstance();
     $blocks = $module->getInfo('blocks');
     $this->trace[] = SystemLocale::MANAGING_BLOCKS;
     $block_handler = $xoops->getHandlerBlock();
     $blockmodulelink_handler = $xoops->getHandlerBlockModuleLink();
     $tplfile_handler = $xoops->getHandlerTplFile();
     $showfuncs = array();
     $funcfiles = array();
     if (is_array($blocks) && count($blocks) > 0) {
         foreach ($blocks as $i => $block) {
             if (isset($block['show_func']) && $block['show_func'] != '' && isset($block['file']) && $block['file'] != '') {
                 $showfuncs[] = $block['show_func'];
                 $funcfiles[] = $block['file'];
                 $criteria = new CriteriaCompo();
                 $criteria->add(new Criteria('mid', $module->getVar('mid')));
                 $criteria->add(new Criteria('func_num', $i));
                 $block_obj = $block_handler->getObjects($criteria);
                 if (count($block_obj) == 0) {
                     $block_obj[0] = $block_handler->create();
                     $block_obj[0]->setVar('func_num', $i);
                     $block_obj[0]->setVar('mid', $module->getVar('mid'));
                     $block_obj[0]->setVar('name', addslashes($block['name']));
                     $block_obj[0]->setVar('title', addslashes($block['name']));
                     $block_obj[0]->setVar('side', 0);
                     $block_obj[0]->setVar('weight', 0);
                     $block_obj[0]->setVar('visible', 0);
                     $block_obj[0]->setVar('block_type', $module->getVar('dirname') == 'system' ? 'S' : 'M');
                     $block_obj[0]->setVar('isactive', 1);
                     $block_obj[0]->setVar('content', '');
                     $block_obj[0]->setVar('c_type', 'H');
                     $block_obj[0]->setVar('dirname', $module->getVar('dirname'));
                     $block_obj[0]->setVar('options', isset($block['options']) ? $block['options'] : '');
                 }
                 $block_obj[0]->setVar('func_file', $block['file']);
                 $block_obj[0]->setVar('show_func', isset($block['show_func']) ? $block['show_func'] : '');
                 $block_obj[0]->setVar('edit_func', isset($block['edit_func']) ? $block['edit_func'] : '');
                 $template = $this->getTemplate($module->getVar('dirname'), $block['template'], 'blocks');
                 $block_obj[0]->setVar('template', !empty($template) ? $block['template'] : '');
                 $block_obj[0]->setVar('last_modified', time());
                 if (!$block_handler->insert($block_obj[0])) {
                     $this->trace[]['sub'] = '<span class="red">' . sprintf(XoopsLocale::EF_NOT_UPDATED, $block_obj[0]->getVar('name')) . '</span>';
                 } else {
                     $this->trace[]['sub'] = sprintf(SystemLocale::SF_BLOCK_UPDATED, '<strong>' . $block_obj[0]->getVar('name')) . '</strong>' . sprintf(SystemLocale::F_BLOCK_ID, '<strong>' . $block_obj[0]->getVar('bid') . '</strong>');
                     if (0 == $blockmodulelink_handler->getCount(new Criteria('block_id', $block_obj[0]->getVar('bid')))) {
                         $blockmodulelink = $blockmodulelink_handler->create();
                         $blockmodulelink->setVar('block_id', $block_obj[0]->getVar('bid'));
                         $blockmodulelink->setVar('module_id', 0);
                         //show on all pages
                         $blockmodulelink_handler->insert($blockmodulelink);
                     }
                     if ($template != '') {
                         $tplfile = $tplfile_handler->find('default', 'block', $block_obj[0]->getVar('bid'));
                         if (count($tplfile) == 0) {
                             $tplfile_new = $tplfile_handler->create();
                             $tplfile_new->setVar('tpl_module', $module->getVar('dirname'));
                             $tplfile_new->setVar('tpl_refid', $block_obj[0]->getVar('bid'));
                             $tplfile_new->setVar('tpl_tplset', 'default');
                             $tplfile_new->setVar('tpl_file', $block_obj[0]->getVar('template'));
                             $tplfile_new->setVar('tpl_type', 'block');
                         } else {
                             /* @var $tplfile_new XoopsTplFile */
                             $tplfile_new = $tplfile[0];
                             $tplfile_new->setVars($tplfile_new->getValues());
                         }
                         $tplfile_new->setVar('tpl_source', $template);
                         $tplfile_new->setVar('tpl_desc', $block['description']);
                         $tplfile_new->setVar('tpl_lastmodified', time());
                         $tplfile_new->setVar('tpl_lastimported', 0);
                         if (!$tplfile_handler->insertTpl($tplfile_new)) {
                             $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_TEMPLATE_NOT_UPDATED, '<strong>' . $block['template'] . '</strong>') . '</span>';
                         } else {
                             $this->trace[]['sub'] = sprintf(SystemLocale::SF_TEMPLATE_UPDATED, '<strong>' . $block['template'] . '</strong>');
                             if ($module->getVar('dirname') == 'system') {
                                 if (!$xoops->templateTouch($tplfile_new->getVar('tpl_id'))) {
                                     $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_TEMPLATE_NOT_RECOMPILED, '<strong>' . $block['template'] . '</strong>') . '</span>';
                                 } else {
                                     $this->trace[]['sub'] = sprintf(SystemLocale::SF_TEMPLATE_RECOMPILED, '<strong>' . $block['template'] . '</strong>');
                                 }
                             } else {
                                 if ($xoops->config['template_set'] == 'default') {
                                     if (!$xoops->templateTouch($tplfile_new->getVar('tpl_id'))) {
                                         $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_TEMPLATE_NOT_RECOMPILED, '<strong>' . $block['template'] . '</strong>') . '</span>';
                                     } else {
                                         $this->trace[]['sub'] = sprintf(SystemLocale::SF_TEMPLATE_RECOMPILED, '<strong>' . $block['template'] . '</strong>');
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $blocks = $block_handler->getByModule($module->getVar('mid'));
     foreach ($blocks as $block) {
         /* @var $block XoopsBlock */
         if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
             if (!$block_handler->delete($block)) {
                 $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_BLOCK_NOT_DELETED, "<strong>" . $block->getVar('name') . "</strong>") . sprintf(SystemLocale::F_BLOCK_ID, "<strong>" . $block->getVar('bid') . "</strong>") . '</span>';
             } else {
                 $this->trace[]['sub'] = sprintf(SystemLocale::SF_BLOCK_DELETED, '<strong>' . $block->getVar('name') . '</strong>') . '&nbsp;' . sprintf(SystemLocale::F_BLOCK_ID, '<strong>' . $block->getVar('bid') . '</strong>');
                 if ($block->getVar('template') != '') {
                     $tplfiles = $tplfile_handler->find(null, 'block', $block->getVar('bid'));
                     if (is_array($tplfiles)) {
                         /* @var $tplfile XoopsTplFile */
                         foreach ($tplfiles as $tplfile) {
                             if (!$tplfile_handler->deleteTpl($tplfile)) {
                                 $this->trace[]['sub'] = '<span class="red">' . SystemLocale::E_BLOCK_TEMPLATE_DEPRECATED_NOT_REMOVED . '(ID: <strong>' . $tplfile->getVar('tpl_id') . '</strong>)</span>';
                             } else {
                                 $this->trace[]['sub'] = sprintf(SystemLocale::SF_BLOCK_TEMPLATE_DEPRECATED, "<strong>" . $tplfile->getVar('tpl_file') . "</strong>");
                             }
                         }
                     }
                 }
             }
         }
     }
 }