本文整理汇总了PHP中Xoops\Core\Request::getInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getInt方法的具体用法?PHP Request::getInt怎么用?PHP Request::getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xoops\Core\Request
的用法示例。
在下文中一共展示了Request::getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
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: testGetInt
/**
* @covers Xoops\Core\Request::getInt
*/
public function testGetInt()
{
$varname = 'RequestTest';
$_REQUEST[$varname] = '9';
$this->assertEquals(9, Request::getInt($varname));
$_REQUEST[$varname] = '123fred5';
$this->assertEquals(123, Request::getInt($varname));
$_REQUEST[$varname] = '-123.45';
$this->assertEquals(-123, Request::getInt($varname));
$_REQUEST[$varname] = 'notanumber';
$this->assertEquals(0, Request::getInt($varname));
$this->assertEquals(0, Request::getInt($varname . 'no-such-key'));
}
示例3: search
public function search($queryArray, $andor, $limit, $offset, $userid)
{
$xoops = Xoops::getInstance();
$helper = $xoops->getModuleHelper('alumni');
$module_id = $helper->getModule()->getVar('mid');
$listing_Handler = $helper->getHandler('listing');
$groups = $xoops->getUserGroups();
$alumni_ids = $xoops->getHandlerGroupPermission()->getItemIds('alumni_view', $groups, $module_id);
$all_ids = implode(', ', $alumni_ids);
$by_cat = Request::getInt('by_cat', 0);
$andor = strtolower($andor) == 'and' ? 'and' : 'or';
$qb = \Xoops::getInstance()->db()->createXoopsQueryBuilder();
$eb = $qb->expr();
$qb->select('DISTINCT *')->fromPrefix('alumni_listing')->where($eb->eq('valid', '1'))->orderBy('lname', 'DESC')->setFirstResult($offset)->setMaxResults($limit);
if (is_array($queryArray) && !empty($queryArray)) {
$queryParts = array();
foreach ($queryArray as $i => $q) {
$query = ':query' . $i;
$qb->setParameter($query, '%' . $q . '%', \PDO::PARAM_STR);
$queryParts[] = $eb->orX($eb->like('name', $query), $eb->like('mname', $query), $eb->like('lname', $query), $eb->like('school', $query), $eb->like('year', $query));
}
$qb->andWhere($eb->in('cid', array($all_ids)));
if ($by_cat) {
$qb->andWhere($eb->eq('cid', $by_cat));
}
if ($andor == 'and') {
$qb->andWhere(call_user_func_array(array($eb, "andX"), $queryParts));
} else {
$qb->andWhere(call_user_func_array(array($eb, "orX"), $queryParts));
}
} else {
$qb->setParameter(':uid', (int) $userid, \PDO::PARAM_INT);
$qb->andWhere($eb->eq('usid', ':uid'));
}
$myts = MyTextSanitizer::getInstance();
$items = array();
$result = $qb->execute();
while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
$items[] = array('title' => $myrow['name'] . " " . $myrow['mname'] . " " . $myrow['lname'] . " --- " . $myrow['school'] . " --- " . $myrow['year'], 'link' => "listing.php?lid=" . $myrow["lid"], 'time' => $myrow['date'], 'uid' => $myrow['usid'], 'image' => 'images/cat/default.gif');
}
return $items;
}
示例4:
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.
*/
use Xoops\Core\Request;
/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package Publisher
* @since 1.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/
include_once __DIR__ . '/header.php';
$xoops = Xoops::getInstance();
$uid = Request::getInt('uid');
if (!$uid) {
$xoops->redirect('index.php', 2, _CO_PUBLISHER_ERROR);
}
$member_handler = $xoops->getHandlerMember();
$thisuser = $member_handler->getUser($uid);
if (!is_object($thisuser)) {
$xoops->redirect('index.php', 2, _CO_PUBLISHER_ERROR);
}
if (!$publisher->getConfig('perm_author_items')) {
$xoops->redirect('index.php', 2, _CO_PUBLISHER_ERROR);
}
$myts = MyTextSanitizer::getInstance();
$xoops->header('publisher_author_items.tpl');
$xoopsTpl = $xoops->tpl();
XoopsLoad::loadFile($publisher->path('footer.php'));
示例5:
* @subpackage Action
* @since 1.0
* @author trabis <lusopoemas@gmail.com>
* @author Sina Asghari (AKA stranger) <stranger@impresscms.ir>
* @version $Id$
*/
include_once __DIR__ . '/header.php';
$xoops = Xoops::getInstance();
$xoops->disableErrorReporting();
if (!$xoops->service('htmltopdf')->isAvailable()) {
$xoops->redirect("javascript:history.go(-1)", 1, _MD_PUBLISHER_NOPDF);
}
$publisher = Publisher::getInstance();
$myts = \Xoops\Core\Text\Sanitizer::getInstance();
$itemid = Request::getInt('itemid');
$item_page_id = Request::getInt('page', -1);
if ($itemid == 0) {
$xoops->redirect("javascript:history.go(-1)", 1, _MD_PUBLISHER_NOITEMSELECTED);
}
// Creating the item object for the selected item
/* @var $itemObj PublisherItem */
$itemObj = $publisher->getItemHandler()->get($itemid);
// if the selected item was not found, exit
if (!$itemObj) {
$xoops->redirect("javascript:history.go(-1)", 1, _MD_PUBLISHER_NOITEMSELECTED);
}
// Creating the category object that holds the selected item
$categoryObj = $publisher->getCategoryHandler()->get($itemObj->getVar('categoryid'));
// Check user permissions to access that category of the selected item
if (!$itemObj->accessGranted()) {
$xoops->redirect("javascript:history.go(-1)", 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
示例6: implode
}
echo $obj->getHtmlErrors();
$form = $xoops->getModuleForm($obj, 'listing');
$form->display();
break;
case 'edit_listing':
$lid = Request::getInt('lid', 0);
$listingHandler = $xoops->getModuleHandler('listing', 'alumni');
$obj = $listingHandler->get($lid);
$form = $xoops->getModuleForm($obj, 'listing');
$form->display();
break;
case 'delete_listing':
$listingHandler = $xoops->getModuleHandler('listing', 'alumni');
$lid = Request::getInt('lid', 0);
$ok = Request::getInt('ok', 0);
$obj = $listingHandler->get($lid);
if ($ok == 1) {
if (!$xoops->security()->check()) {
$xoops->redirect('index.php', 3, implode(',', $xoops->security()->getErrors()));
}
if ($listingHandler->delete($obj)) {
$xoops->redirect('index.php', 3, XoopsLocale::S_DATABASE_UPDATED);
} else {
echo $xoops->alert('error', $obj->getHtmlErrors());
}
} else {
echo $xoops->confirm(array('ok' => 1, 'lid' => $lid, 'op' => 'delete_listing'), 'listing.php', XoopsLocale::Q_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_ITEM . '<br /><span class="red">' . $obj->getvar('lname') . '<span>');
}
break;
}
示例7:
$xoopsMailer->useMail();
$xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/{$moduleDirName}/language/english/mail_template/");
$xoopsMailer->setTemplate('listing_send_friend.tpl');
$xoopsMailer->setFromEmail($ymail);
$xoopsMailer->setToEmails($fmail);
$xoopsMailer->setSubject($subject);
// $xoopsMailer->$xoops->multimailer;
$xoopsMailer->assign($tags);
$xoopsMailer->send();
echo $xoopsMailer->getErrors();
$xoops->redirect('index.php', 3, AlumniLocale::ALUM_SEND);
exit;
}
} else {
global $xoops;
$lid = Request::getInt('lid', 0);
$xoops->header('alumni_sendfriend.tpl');
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
$listingHandler = $xoops->getModuleHandler('listing', 'alumni');
$listing_2_send = $listingHandler->get($lid);
$listing_2_send->getVar('name');
$listing_2_send->getVar('mname');
$listing_2_send->getVar('lname');
ob_start();
$form = new Xoops\Form\ThemeForm(AlumniLocale::SENDTO, 'sendfriend_form', 'sendfriend.php');
$form->setExtra('enctype="multipart/form-data"');
// $GLOBALS['xoopsGTicket']->addTicketXoopsFormElement($form, __LINE__, 1800, 'token');
$form->addElement(new Xoops\Form\Label(AlumniLocale::LISTING_SEND, $listing_2_send->getVar('name') . ' ' . $listing_2_send->getVar('mname') . ' ' . $listing_2_send->getVar('lname') . ''));
if ($xoopsUser) {
$idd = $xoopsUser->getVar('name', 'E');
$idde = $xoopsUser->getVar('email', 'E');
示例8:
use Xoops\Core\Request;
/**
* page module
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package page
* @since 2.6.0
* @author Mage Grégory (AKA Mage)
* @version $Id$
*/
include_once 'header.php';
// Call header
$xoops->header('module:page/page_viewpage.tpl');
// Get ID
$content_id = Request::getInt('id', 0);
// Permission to view
$perm_view = $gperm_Handler->checkRight('page_view_item', $content_id, $groups, $module_id, false);
if (!$perm_view) {
$xoops->redirect('javascript:history.go(-1)', 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
exit;
}
// Get content
$view_content = $content_Handler->get($content_id);
// Test if the page exist
if (count($view_content) == 0 || $view_content->getVar('content_status') == 0) {
$xoops->redirect('index.php', 3, PageLocale::E_NOT_EXIST);
exit;
}
// hits
if ($view_content->getVar('content_author') != $uid && $view_content->getVar('content_dohits') != false) {
示例9: publisher_editCat
function publisher_editCat($showmenu = false, $categoryid = 0, $nb_subcats = 4, $categoryObj = null)
{
$xoops = Xoops::getInstance();
$publisher = Publisher::getInstance();
/* @var $categoryObj PublisherCategory */
// if there is a parameter, and the id exists, retrieve data: we're editing a category
if ($categoryid != 0) {
// Creating the category object for the selected category
$categoryObj = $publisher->getCategoryHandler()->get($categoryid);
if ($categoryObj->notLoaded()) {
$xoops->redirect("category.php", 1, _AM_PUBLISHER_NOCOLTOEDIT);
}
} else {
if (!$categoryObj) {
$categoryObj = $publisher->getCategoryHandler()->create();
}
}
if ($categoryid != 0) {
if ($showmenu) {
//publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_EDITING);
}
echo "<br />\n";
PublisherUtils::openCollapsableBar('edittable', 'edittableicon', _AM_PUBLISHER_EDITCOL, _AM_PUBLISHER_CATEGORY_EDIT_INFO);
} else {
if ($showmenu) {
//publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_CREATINGNEW);
}
PublisherUtils::openCollapsableBar('createtable', 'createtableicon', _AM_PUBLISHER_CATEGORY_CREATE, _AM_PUBLISHER_CATEGORY_CREATE_INFO);
}
/* @var $sform PublisherCategoryForm */
$sform = $publisher->getForm($categoryObj, 'category');
$sform->setSubCatsCount($nb_subcats);
$sform->display();
if (!$categoryid) {
PublisherUtils::closeCollapsableBar('createtable', 'createtableicon');
} else {
PublisherUtils::closeCollapsableBar('edittable', 'edittableicon');
}
//Added by fx2024
if ($categoryid) {
$sel_cat = $categoryid;
PublisherUtils::openCollapsableBar('subcatstable', 'subcatsicon', _AM_PUBLISHER_SUBCAT_CAT, _AM_PUBLISHER_SUBCAT_CAT_DSC);
// Get the total number of sub-categories
$categoriesObj = $publisher->getCategoryHandler()->get($sel_cat);
$totalsubs = $publisher->getCategoryHandler()->getCategoriesCount($sel_cat);
// creating the categories objects that are published
$subcatsObj = $publisher->getCategoryHandler()->getCategories(0, 0, $categoriesObj->getVar('categoryid'));
echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
echo "<tr>";
echo "<td width='60' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATID . "</strong></td>";
echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATCOLNAME . "</strong></td>";
echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_SUBDESCRIPT . "</strong></td>";
echo "<td width='60' class='bg3' align='right'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>";
echo "</tr>";
if ($totalsubs > 0) {
/* @var $subcat PublisherCategory */
foreach ($subcatsObj as $subcat) {
$modify = "<a href='category.php?op=mod&categoryid=" . $subcat->getVar('categoryid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_MODIFY . "' alt='" . _AM_PUBLISHER_MODIFY . "' /></a>";
$delete = "<a href='category.php?op=del&categoryid=" . $subcat->getVar('categoryid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETE . "' alt='" . _AM_PUBLISHER_DELETE . "' /></a>";
echo "<tr>";
echo "<td class='head' align='left'>" . $subcat->getVar('categoryid') . "</td>";
echo "<td class='even' align='left'><a href='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/category.php?categoryid=" . $subcat->getVar('categoryid') . "&parentid=" . $subcat->getVar('parentid') . "'>" . $subcat->getVar('name') . "</a></td>";
echo "<td class='even' align='left'>" . $subcat->getVar('description') . "</td>";
echo "<td class='even' align='right'> {$modify} {$delete} </td>";
echo "</tr>";
}
} else {
echo "<tr>";
echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOSUBCAT . "</td>";
echo "</tr>";
}
echo "</table>\n";
echo "<br />\n";
PublisherUtils::closeCollapsableBar('subcatstable', 'subcatsicon');
PublisherUtils::openCollapsableBar('bottomtable', 'bottomtableicon', _AM_PUBLISHER_CAT_ITEMS, _AM_PUBLISHER_CAT_ITEMS_DSC);
$startitem = Request::getInt('startitem');
// Get the total number of published ITEMS
$totalitems = $publisher->getItemHandler()->getItemsCount($sel_cat, array(_PUBLISHER_STATUS_PUBLISHED));
// creating the items objects that are published
$itemsObj = $publisher->getItemHandler()->getAllPublished($publisher->getConfig('idxcat_perpage'), $startitem, $sel_cat);
$totalitemsOnPage = count($itemsObj);
$allcats = $publisher->getCategoryHandler()->getObjects(null, true);
echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
echo "<tr>";
echo "<td width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . "</strong></td>";
echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCOLNAME . "</strong></td>";
echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMDESC . "</strong></td>";
echo "<td width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . "</strong></td>";
echo "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>";
echo "</tr>";
if ($totalitems > 0) {
for ($i = 0; $i < $totalitemsOnPage; ++$i) {
$categoryObj = $allcats[$itemsObj[$i]->getVar('categoryid')];
$modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITITEM . "' alt='" . _AM_PUBLISHER_EDITITEM . "' /></a>";
$delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'/></a>";
echo "<tr>";
echo "<td class='head' align='center'>" . $itemsObj[$i]->getVar('itemid') . "</td>";
echo "<td class='even' align='left'>" . $categoryObj->getVar('name') . "</td>";
echo "<td class='even' align='left'>" . $itemsObj[$i]->getitemLink() . "</td>";
echo "<td class='even' align='center'>" . $itemsObj[$i]->datesub('s') . "</td>";
//.........这里部分代码省略.........
示例10: time
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package page
* @since 2.6.0
* @author DuGris (aka Laurent JEN)
* @version $Id$
*/
include_once 'header.php';
$xoops->logger()->quiet();
$ret['error'] = 1;
if ($xoops->security()->check()) {
$time = time();
if (!isset($_SESSION['page_rating' . $content_id]) || $_SESSION['page_rating' . $content_id] < $time) {
$content_id = Request::getInt('content_id', 0);
$option = Request::getInt('option', 0);
$_SESSION['page_rating' . $content_id] = $time + $interval;
// Test if the page exist
$contentObj = $content_Handler->get($content_id);
if (count($contentObj) == 0 || $contentObj->getVar('content_status') == 0 || $contentObj->getVar('content_dorating') == 0) {
echo json_encode($ret);
exit;
}
// Permission to view
$perm_view = $gperm_Handler->checkRight('page_view_item', $content_id, $groups, $module_id, false);
// Permission to vote
$perm_vote = $gperm_Handler->checkRight('page_global', 0, $groups, $module_id, false);
if (!$perm_view || !$perm_vote) {
echo json_encode($ret);
exit;
}
示例11:
}
} else {
echo $xoops->confirm(array('ok' => 1, 'related_id' => $related_id, 'op' => 'delete'), 'related.php', XoopsLocale::Q_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_ITEM . '<br /><span class="red">' . $obj->getvar('related_name') . '<span>');
}
break;
case 'update_status':
$related_id = Request::getInt('related_id', 0);
if ($related_id > 0) {
$obj = $related_Handler->get($related_id);
$old = $obj->getVar('related_domenu');
$obj->setVar('related_domenu', !$old);
if ($related_Handler->insert($obj)) {
exit;
}
echo $obj->getHtmlErrors();
}
break;
case 'view':
$related_id = Request::getInt('related_id', 0);
if ($related_id > 0) {
$obj = $related_Handler->get($related_id);
$old = $obj->getVar('related_domenu');
$obj->setVar('related_domenu', !$old);
if ($related_Handler->insert($obj)) {
exit;
}
echo $obj->getHtmlErrors();
}
break;
}
$xoops->footer();
示例12: array
break;
// Send
// Send
case 'send':
$mail_send_to = Request::getArray('mail_send_to', array('mail'));
$mail_inactive = Request::getInt('mail_inactive', 0);
$mail_mailok = Request::getInt('mail_mailok', 0);
$mail_lastlog_min = Request::getString('mail_lastlog_min', '');
$mail_lastlog_max = Request::getString('mail_lastlog_max', '');
$mail_idle_more = Request::getInt('mail_idle_more', 0);
$mail_idle_less = Request::getInt('mail_idle_less', 0);
$mail_regd_min = Request::getString('mail_regd_min', '');
$mail_regd_max = Request::getString('mail_regd_max', '');
$mail_to_group = Request::getArray('mail_to_group', array());
$mail_to_group = array_map("intval", $mail_to_group);
$mail_start = Request::getInt('mail_start', 0);
$mail_to_user = Request::getArray('mail_to_user', array());
$mail_to_user = array_map("intval", $mail_to_user);
$mail_fromname = Request::getString('mail_fromname');
$mail_fromemail = Request::getString('mail_fromemail');
$mail_subject = Request::getString('mail_subject');
$mail_body = Request::getString('mail_body');
$count_criteria = 0;
// user count via criteria;
if (!empty($mail_send_to)) {
$added = array();
$added_id = array();
$criteria = array();
if ($mail_inactive) {
$criteria[] = "level = 0";
} else {
示例13: dirname
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @since 2.6.0
* @author Mage Grégory (AKA Mage)
* @version $Id$
*/
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
XoopsLoad::load('system', 'system');
$xoops = Xoops::getInstance();
$system = System::getInstance();
$helper = Xoops\Module\Helper::getHelper('images');
// Get Action type
$op = Request::getCmd('op', 'list');
$start = Request::getInt('start', 0);
$imgcat_id = Request::getInt('imgcat_id', 0);
$redirect = basename($xoops->getEnv('SCRIPT_NAME'));
if (!$xoops->isUser() || !$xoops->isModule() || !$xoops->user->isAdmin($xoops->module->mid())) {
exit(XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$gperm_handler = $xoops->getHandlerGroupPermission();
$groups = $xoops->getUserGroups();
// check WRITE right by category before continue
if (isset($imgcat_id) && ($op === 'addfile' || $op === 'editcat' || $op === 'updatecat' || $op === 'delcatok' || $op === 'delcat')) {
$imgcat_write = $gperm_handler->checkRight('imgcat_write', $imgcat_id, $groups, $xoops->module->mid());
if (!$imgcat_write) {
$xoops->redirect($redirect, 1);
}
}
// Only website administator can delete categories or images
if (!in_array(FixedGroups::ADMIN, $groups) && ($op === 'delfile' || $op === 'delfileok' || $op === 'delcatok' || $op === 'delcat')) {
示例14: implode
$xoops_upload_url = \XoopsBaseConfig::get('uploads-url');
$warning_msg .= "<img src='" . $xoops_upload_url . '/' . $oldavatar . "' alt=' ' />";
$xoops->tpl()->assign('warning_msg', $xoops->alert('warning', $warning_msg, XoopsLocale::WARNING));
}
// Create form
$obj = $avatar_Handler->create();
$form = $xoops->getModuleForm($obj, 'avatar_user');
// Assign form
$xoops->tpl()->assign('form', $form->render());
break;
case "save":
// Check security
if (!$xoops->security()->check()) {
$xoops->redirect('/index.php', 3, implode('<br />', $xoops->security()->getErrors()));
}
$uid = Request::getInt('uid', 0);
if (empty($uid) || $xoops->user->getVar('uid') != $uid) {
$xoops->redirect('/index.php', 3, XoopsLocale::E_NO_ACCESS_PERMISSION);
exit;
}
$uploader_avatars_img = new XoopsMediaUploader(\XoopsBaseConfig::get('uploads-path') . '/avatars', $mimetypes, $upload_size, $width, $height);
$obj = $avatar_Handler->create();
$error_msg = '';
if ($uploader_avatars_img->fetchMedia('user_avatar')) {
$uploader_avatars_img->setPrefix('savt');
$uploader_avatars_img->fetchMedia('user_avatar');
if (!$uploader_avatars_img->upload()) {
$error_msg .= $uploader_avatars_img->getErrors();
$obj->setVar('avatar_file', 'avatars/blank.gif');
} else {
$obj->setVar('avatar_name', $xoops->user->getVar('uname'));
示例15: sprintf
}
$xoops->redirect('images.php?imgcat_id=' . $imgcat_id, 2, XoopsLocale::S_DATABASE_UPDATED);
}
} else {
$category = $helper->getHandlerCategories()->get($obj->getVar('imgcat_id'));
if ($category->getVar('imgcat_storetype') == 'db') {
$img = \XoopsBaseConfig::get('url') . '/image.php?id=' . $image_id;
} else {
$img = \XoopsBaseConfig::get('uploads-url') . '/' . $obj->getVar('image_name');
}
echo $xoops->confirm(array('op' => 'del', 'ok' => 1, 'image_id' => $image_id, 'imgcat_id' => $obj->getVar('imgcat_id')), \XoopsBaseConfig::get('url') . '/modules/images/admin/images.php', sprintf(_AM_IMAGES_IMG_DELETE, $obj->getVar('image_nicename')) . '<br /><br /><img src="' . $img . '" /><br />');
}
}
break;
case 'display':
$image_id = Request::getInt('image_id', 0);
if ($image_id > 0) {
$obj = $helper->getHandlerImages()->get($image_id);
$old = $obj->getVar('image_display');
$obj->setVar('image_display', !$old);
if (!$helper->getHandlerImages()->insert($obj)) {
$error = true;
}
}
break;
case 'list':
default:
// Get rights
$imgcat_write = $gperm_handler->checkRight('imgcat_write', $imgcat_id, $groups, $xoops->module->mid());
if ($imgcat_write) {
$admin_page->addItemButton(_AM_IMAGES_IMG_ADD, 'images.php?op=add&imgcat_id=' . $imgcat_id, 'add');