コード例 #1
0
ファイル: good_search.php プロジェクト: jlm69/alumni-26x
    public function search($queries, $andor, $limit, $start, $userid)
    {
        $xoops = Xoops::getInstance();
        $alumni = Alumni::getInstance();
        $myts = MyTextSanitizer::getInstance();
        $by_cat = Request::getInt('by_cat', '');
        $andor = Request::getWord('andor', 'AND');
        $queries = array();
        $query = Request::getString('query', '');
        $start = Request::getInt('start', '0');
        $helper = $xoops->getModuleHelper('alumni');
        $module_id = $helper->getModule()->getVar('mid');
        $listingHandler = $helper->getHandler('listing');
        $groups = $xoops->getUserGroups();
        $alumni_ids = $xoops->getHandlerGroupperm()->getItemIds('alumni_view', $groups, $module_id);
        $all_ids = implode(', ', $alumni_ids);
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('valid', 1, '='));
        //  $criteria->add(new Criteria('date', time(), '<='));
        $criteria->add(new Criteria('cid', '(' . $all_ids . ')', 'IN'));
        if ($userid != 0) {
            $criteria->add(new Criteria('usid', $userid, '='));
        }
        if ($by_cat) {
            $criteria->add(new Criteria('cid', $by_cat, '='));
        }
        $queries = array($query);
        $queries = implode('+', $queries);
        $count = 0;
        $i = 0;
        $criteria->add(new Criteria('name', '%' . $queries . '%', 'LIKE'), 'AND');
        $criteria->add(new Criteria('mname', '%' . $queries . '%', 'LIKE'), 'OR');
        $criteria->add(new Criteria('lname', '%' . $queries . '%', 'LIKE'), 'OR');
        $criteria->add(new Criteria('school', '%' . $queries . '%', 'LIKE'), 'OR');
        $criteria->add(new Criteria('year', '%' . $queries . '%', 'LIKE'), 'OR');
        $criteria->setLimit($limit);
        $criteria->setSort('date');
        $criteria->setOrder('DESC');
        $criteria->setStart($start);
        $numrows = $listingHandler->getCount();
        $this_search = $listingHandler->getall($criteria);
        $ret = array();
        $k = 0;
        foreach ($this_search as $obj) {
            $ret[$k]['image'] = 'images/cat/default.gif';
            $ret[$k]['link'] = 'listing.php?lid=' . $obj->getVar('lid') . '';
            $ret[$k]['title'] = $obj->getVar('name') . ' ' . $obj->getVar('mname') . ' ' . $obj->getVar('lname') . '   ---   ' . $obj->getVar('school') . '
		---   ' . $obj->getVar('year');
            $ret[$k]['time'] = $obj->getVar('date');
            $ret[$k]['uid'] = $obj->getVar('usid');
            $k++;
        }
        return $ret;
    }
コード例 #2
0
ファイル: listing.php プロジェクト: jlm69/alumni-26x
 public function getListingPublished($start = 0, $limit = 0, $sort = 'date', $order = 'ASC')
 {
     $helper = Alumni::getInstance();
     $xoops = $helper->xoops();
     $module_id = $helper->getModule()->getVar('mid');
     // get permitted id
     $groups = $xoops->isUser() ? $xoops->user->getGroups() : '3';
     $alumni_ids = $helper->getGrouppermHandler()->getItemIds('alumni_view', $groups, $module_id);
     // criteria
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('valid', 1, '='));
     $criteria->add(new Criteria('cid', '(' . implode(', ', $alumni_ids) . ')', 'IN'));
     $criteria->setSort($sort);
     $criteria->setOrder($order);
     $criteria->setStart($start);
     $criteria->setLimit($limit);
     return parent::getAll($criteria);
 }
コード例 #3
0
ファイル: header.php プロジェクト: jlm69/alumni-26x
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
 * Alumni module for Xoops
 *
 * @copyright       XOOPS Project http://xoops.org/
 * @license         GPL 2.0 or later
 * @package         alumni
 * @since           2.6.x
 * @author          John Mordo (jlm69)
 */
include_once dirname(dirname(__DIR__)) . '/mainfile.php';
include_once __DIR__ . '/include/common.php';
XoopsLoad::load('system', 'system');
$system = System::getInstance();
$helper = Alumni::getInstance();
$xoops = $helper->xoops();
$categoriesHandler = $helper->getCategoryHandler();
$listingHandler = $helper->getListingHandler();
$gpermHandler = $helper->getGrouppermHandler();
//permission
$groups = $xoops->getUserGroups();
$uid = $helper->getUserId();
$xoops->theme()->addStylesheet($helper->url('css/styles.css'));
$xoops->theme()->addStylesheet($helper->url('css/rating.css'));
$module_id = $helper->getModule()->getVar('mid');
$interval = 3600;
//1 hour
コード例 #4
0
ファイル: listing.php プロジェクト: jlm69/alumni-26x
    exit;
}
if (!$gpermHandler->checkRight('' . $moduleDirName . '_premium', $perm_itemid, $groups, $module_id)) {
    $prem_perm = '0';
} else {
    $prem_perm = '1';
}
$lid = Request::getInt('lid', 0);
$xoops->header('module:alumni/alumni_item.tpl');
Xoops::getInstance()->header();
$op = Request::getCmd('op', 'list');
switch ($op) {
    case 'list':
    default:
        $listingHandler = $xoops->getModuleHandler('listing', 'alumni');
        $alumni = Alumni::getInstance();
        $helper = $xoops->getModuleHelper('alumni');
        $module_id = $helper->getModule()->getVar('mid');
        $listingObj = $listingHandler->get($lid);
        $categoriesHandler = $xoops->getModuleHandler('category', 'alumni');
        $catObj = $categoriesHandler->get($listingObj->getVar('cid'));
        $homePath = "<a href='" . ALUMNI_URL . "/index.php'>" . XoopsLocale::MAIN . "</a>&nbsp;:&nbsp;";
        $itemPath = "<a href='" . ALUMNI_URL . "/categories.php?cid=" . $catObj->getVar("cid") . "'>" . $catObj->getVar("title") . "</a>";
        $path = '';
        $myParent = $catObj->getVar('pid');
        $catpath_criteria = new CriteriaCompo();
        $catpath_criteria->add(new Criteria('cid', $myParent, '='));
        $catpath_arr = $categoriesHandler->getall($catpath_criteria);
        foreach (array_keys($catpath_arr) as $i) {
            $mytitle = $catpath_arr[$i]->getVar('title');
        }
コード例 #5
0
ファイル: permission.php プロジェクト: jlm69/alumni-26x
 /**
  * constructor
  */
 public function __construct()
 {
     $this->alumni = Alumni::getInstance();
     $this->db2 = \Xoops::getInstance()->db();
 }
コード例 #6
0
ファイル: search.php プロジェクト: jlm69/alumni-26x
 public function alumni_getSearchFrom($andor, $queries, $mids, $mid, $bycat)
 {
     $xoops = Xoops::getInstance();
     $alumni = Alumni::getInstance();
     // create form
     parent::__construct(XoopsLocale::SEARCH, 'alumni', 'search.php', 'get');
     // create form elements
     $this->addElement(new XoopsFormText(XoopsLocale::KEYWORDS, 'query', 30, 255, htmlspecialchars(stripslashes(implode(' ', $queries)), ENT_QUOTES)), true);
     $type_select = new XoopsFormSelect(XoopsLocale::TYPE, 'andor', $andor);
     $type_select->addOptionArray(array('AND' => XoopsLocale::ALL_AND, 'OR' => XoopsLocale::ANY_OR, 'exact' => XoopsLocale::EXACT_MATCH));
     $this->addElement($type_select);
     $by_cat = Request::getInt('by_cat', 0);
     $categoriesHandler = $xoops->getModuleHandler('category', 'alumni');
     $search = Search::getInstance();
     $module_id = $xoops->module->getVar('mid');
     $groups = $xoops->isUser() ? $xoops->user->getGroups() : '3';
     $alumni_ids = $alumni->getGrouppermHandler()->getItemIds('alumni_view', $groups, $module_id);
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('cid', '(' . implode(', ', $alumni_ids) . ')', 'IN'));
     $criteria->setOrder($xoops->getModuleConfig('alumni_csortorder'));
     $category_arr = $categoriesHandler->getall($criteria);
     foreach (array_keys($category_arr) as $i) {
         $cid = $category_arr[$i]->getVar('cid');
         $pid = $category_arr[$i]->getVar('pid');
         $title = $category_arr[$i]->getVar('title');
     }
     $categories = $alumni->getCategoryHandler()->getCategoriesForSearch();
     $category_select = new XoopsFormSelect(AlumniLocale::L_ALUMNI_CATEGORIES, 'by_cat', $by_cat);
     foreach ($categories as $cid => $title) {
         $category_select->addOption('0', XoopsLocale::ALL);
         $category_select->addOptionArray(array($cid => $title));
     }
     $this->addElement($category_select);
     if (!empty($mids)) {
         $mods_checkbox = new XoopsFormCheckBox(XoopsLocale::SEARCH_IN, 'mids[]', $mids);
     } else {
         $mods_checkbox = new XoopsFormCheckBox(XoopsLocale::SEARCH_IN, 'mids[]', $mid);
     }
     if (empty($modules)) {
         $gperm_handler = $xoops->getHandlerGroupPermission();
         $available_modules = $gperm_handler->getItemIds('module_read', $xoops->getUserGroups());
         $available_plugins = Xoops\Module\Plugin::getPlugins('search');
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('dirname', '(\'' . implode('\',\'', array_keys($available_plugins)) . '\')', 'IN'));
         if (isset($available_modules) && !empty($available_modules)) {
             $criteria->add(new Criteria('mid', '(' . implode(',', $available_modules) . ')', 'IN'));
         }
         $module_handler = $xoops->getHandlerModule();
         $mods_checkbox->addOptionArray($module_handler->getNameList($criteria));
     } else {
         /* @var $module XoopsModule */
         $module_array = array();
         foreach ($modules as $mid => $module) {
             $module_array[$mid] = $module->getVar('name');
         }
         $mods_checkbox->addOptionArray($module_array);
     }
     $this->addElement($mods_checkbox);
     if ($search->getConfig('keyword_min') > 0) {
         $this->addElement(new XoopsFormLabel(XoopsLocale::SEARCH_RULE, sprintf(XoopsLocale::EF_KEYWORDS_MUST_BE_GREATER_THAN, $search->getConfig('keyword_min'))));
     }
     $this->addElement(new XoopsFormHidden('action', 'results'));
     $this->addElement(new XoopsFormHiddenToken('id'));
     $this->addElement(new XoopsFormButton('', 'submit', XoopsLocale::SEARCH, 'submit'));
     return $this;
 }
コード例 #7
0
ファイル: category.php プロジェクト: jlm69/alumni-26x
 /**
  * @return array
  */
 public function &getCategoriesForSearch()
 {
     global $theresult, $xoops, $alumni;
     $xoops = Xoops::getInstance();
     $alumni = Alumni::getInstance();
     $module_id = $alumni->getModule()->mid();
     $ret = array();
     $criteria = new CriteriaCompo();
     $criteria->setSort('cid');
     $criteria->setOrder('ASC');
     if (!$xoops->isAdmin()) {
         //          $gperm_handler        = $xoops->gethandler('groupperm');
         $groups = is_object($xoops->isUser()) ? ${$xoops}->isUser()->getGroups() : '3';
         $allowedCategoriesIds = $alumni->getGrouppermHandler()->getItemIds('alumni_view', $groups, $module_id);
         $criteria->add(new Criteria('cid', '(' . implode(',', $allowedCategoriesIds) . ')', 'IN'));
     }
     $categories = $this->getAll($criteria, array('cid', 'pid', 'title'), false, false);
     if (count($categories) == 0) {
         return $ret;
     }
     $cat_array = array();
     foreach ($categories as $cat) {
         $cat_array[$cat['pid']][$cat['cid']] = $cat;
     }
     if (!isset($cat_array[0])) {
         return $ret;
     }
     $cat_result = array();
     foreach ($cat_array[0] as $thecat) {
         $level = 0;
         $this->getSubCatArray($thecat, $level, $cat_array, $cat_result);
     }
     return $theresult;
 }
コード例 #8
0
ファイル: groupperm.php プロジェクト: jlm69/alumni-26x
 public function updatePerms($cid, $groups = array())
 {
     $module_id = Alumni::getInstance()->getModule()->getVar('mid');
     $groups_exists = parent::getGroupIds('alumni_view', $cid, $module_id);
     $groups_exists = array_values($groups_exists);
     $groups_delete = array_diff(array_values($groups_exists), $groups);
     $groups_add = array_diff($groups, array_values($groups_exists));
     $groups1_exists = parent::getGroupIds('alumni_submit', $cid, $module_id);
     $groups1_exists = array_values($groups1_exists);
     $groups1_delete = array_diff(array_values($groups1_exists), $groups);
     $groups1_add = array_diff($groups, array_values($groups1_exists));
     $groups2_exists = parent::getGroupIds('alumni_premium', $cid, $module_id);
     $groups2_exists = array_values($groups2_exists);
     $groups2_delete = array_diff(array_values($groups2_exists), $groups);
     $groups2_add = array_diff($groups, array_values($groups2_exists));
     // delete alumni_view
     if (count($groups_delete) != 0) {
         $criteria = $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('gperm_itemid', $cid));
         $criteria->add(new Criteria('gperm_modid', $module_id));
         $criteria->add(new Criteria('gperm_name', 'alumni_view', '='));
         $criteria->add(new Criteria('gperm_groupid', '(' . implode(', ', $groups_delete) . ')', 'IN'));
         if (parent::deleteAll($criteria)) {
         }
     }
     // delete alumni_view
     if (count($groups1_delete) != 0) {
         $criteria = $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('gperm_itemid', $cid));
         $criteria->add(new Criteria('gperm_modid', $module_id));
         $criteria->add(new Criteria('gperm_name', 'alumni_submit', '='));
         $criteria->add(new Criteria('gperm_groupid', '(' . implode(', ', $groups1_delete) . ')', 'IN'));
         if (parent::deleteAll($criteria)) {
         }
     }
     // delete alumni_view
     if (count($groups2_delete) != 0) {
         $criteria = $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('gperm_itemid', $cid));
         $criteria->add(new Criteria('gperm_modid', $module_id));
         $criteria->add(new Criteria('gperm_name', 'alumni_premium', '='));
         $criteria->add(new Criteria('gperm_groupid', '(' . implode(', ', $groups2_delete) . ')', 'IN'));
         if (parent::deleteAll($criteria)) {
         }
     }
     // Add alumni_view
     if (count($groups_add) != 0) {
         foreach ($groups_add as $group_id) {
             parent::addRight('alumni_view', $cid, $group_id, $module_id);
         }
     }
     // Add alumni_submit
     if (count($groups1_add) != 0) {
         foreach ($groups1_add as $group_id) {
             parent::addRight('alumni_submit', $cid, $group_id, $module_id);
         }
     }
     // Add alumni_submit
     if (count($groups2_add) != 0) {
         foreach ($groups2_add as $group_id) {
             parent::addRight('alumni_premium', $cid, $group_id, $module_id);
         }
     }
 }