本文整理汇总了PHP中KunenaError类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaError类的具体用法?PHP KunenaError怎么用?PHP KunenaError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sync
function sync() {
// FIXME: remove option:
$usercache = JRequest::getBool ( 'usercache', 0 );
$useradd = JRequest::getBool ( 'useradd', 0 );
$userdel = JRequest::getBool ( 'userdel', 0 );
$userrename = JRequest::getBool ( 'userrename', 0 );
$app = JFactory::getApplication ();
$db = JFactory::getDBO ();
if (!JRequest::checkToken()) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
return;
}
if ($useradd) {
$db->setQuery ( "INSERT INTO #__kunena_users (userid) SELECT a.id FROM #__users AS a LEFT JOIN #__kunena_users AS b ON b.userid=a.id WHERE b.userid IS NULL" );
$db->query ();
if (KunenaError::checkDatabaseError()) return;
$app->enqueueMessage ( JText::_('COM_KUNENA_SYNC_USERS_DO_ADD') . ' ' . $db->getAffectedRows () );
}
if ($userdel) {
$db->setQuery ( "DELETE a FROM #__kunena_users AS a LEFT JOIN #__users AS b ON a.userid=b.id WHERE b.username IS NULL" );
$db->query ();
if (KunenaError::checkDatabaseError()) return;
$app->enqueueMessage ( JText::_('COM_KUNENA_SYNC_USERS_DO_DEL') . ' ' . $db->getAffectedRows () );
}
if ($userrename) {
$model = $this->getModel('Syncusers');
$cnt = $model->KupdateNameInfo ();
$app->enqueueMessage ( JText::_('COM_KUNENA_SYNC_USERS_DO_RENAME') . " $cnt" );
}
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
}
示例2: displayAnnouncement
function displayAnnouncement($tpl = null) {
if (KunenaFactory::getConfig()->showannouncement > 0) {
$moderator = intval($this->me->isModerator('global'));
$cache = JFactory::getCache('com_kunena', 'output');
if ($cache->start("{$this->template->name}.common.announcement.{$moderator}", 'com_kunena.template')) return;
// User needs to be global moderator to edit announcements
if ($moderator) {
$this->canEdit = true;
} else {
$this->canEdit = false;
}
// FIXME: move into model
$db = JFactory::getDBO();
$query = "SELECT * FROM #__kunena_announcement WHERE published='1' ORDER BY created DESC";
$db->setQuery ( $query, 0, 1 );
$this->announcement = $db->loadObject ();
if (KunenaError::checkDatabaseError()) return;
if ($this->announcement) {
$this->annTitle = KunenaHtmlParser::parseText($this->announcement->title);
$this->annDescription = $this->announcement->sdescription ? KunenaHtmlParser::parseBBCode($this->announcement->sdescription) : KunenaHtmlParser::parseBBCode($this->announcement->description, 300);
$this->annDate = KunenaDate::getInstance($this->announcement->created);
$this->annListURL = KunenaRoute::_("index.php?option=com_kunena&view=announcement&layout=list");
$this->annMoreURL = !empty($this->announcement->description) ? KunenaRoute::_("index.php?option=com_kunena&view=announcement&id={$this->announcement->id}") : null;
$result = $this->loadTemplate($tpl);
if (JError::isError($result)) {
return $result;
}
echo $result;
} else {
echo ' ';
}
$cache->end();
} else echo ' ';
}
示例3: _getDefaultMenuItem
protected function _getDefaultMenuItem($menu, $active, $visited = array())
{
if (empty($active->query['defaultmenu']) || $active->id == $active->query['defaultmenu']) {
// There is no highlighted menu item
return null;
}
$item = $menu->getItem($active->query['defaultmenu']);
if (!$item) {
// Menu item points to nowhere, abort
KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NOT_EXISTS'), 'menu');
return null;
} elseif (isset($visited[$item->id])) {
// Menu loop detected, abort
KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_LOOP'), 'menu');
return null;
} elseif (empty($item->component) || $item->component != 'com_kunena' || !isset($item->query['view'])) {
// Menu item doesn't point to Kunena, abort
KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NOT_KUNENA'), 'menu');
return null;
} elseif ($item->query['view'] == 'home') {
// Menu item is pointing to another Home Page, try to find default menu item from there
$visited[$item->id] = 1;
$item = $this->_getDefaultMenuItem($menu, $item->query['defaultmenu'], $visited);
}
return $item;
}
示例4: setUpBeforeClass
/**
* Sets up the fixture.
*/
public static function setUpBeforeClass()
{
$queries[] = "TRUNCATE TABLE #__kunena_categories";
$queries[] = "TRUNCATE TABLE #__kunena_topics";
$queries[] = "TRUNCATE TABLE #__kunena_messages";
$queries[] = "TRUNCATE TABLE #__kunena_messages_text";
$queries[] = "TRUNCATE TABLE #__kunena_users";
$queries[] = "TRUNCATE TABLE #__kunena_users_banned";
$queries[] = "TRUNCATE TABLE #__kunena_user_categories";
$queries[] = "TRUNCATE TABLE #__kunena_user_read";
$queries[] = "TRUNCATE TABLE #__kunena_user_topics";
$queries[] = "TRUNCATE TABLE #__kunena_thankyou";
$queries[] = "TRUNCATE TABLE #__kunena_keywords";
$queries[] = "TRUNCATE TABLE #__kunena_keywords_map";
$queries[] = "TRUNCATE TABLE #__kunena_polls_users";
$queries[] = "TRUNCATE TABLE #__kunena_polls_options";
$queries[] = "TRUNCATE TABLE #__kunena_polls";
$queries[] = "TRUNCATE TABLE #__kunena_sessions";
$db = JFactory::getDBO();
foreach ($queries as $query) {
$db->setQuery($query);
$db->query();
KunenaError::checkDatabaseError();
}
KunenaFactory::loadLanguage();
KunenaFactory::getUser(42)->save();
}
示例5: displayListEmoji
/**
* Return JSON results of smilies available
*
* @param string $tpl
*
* @since K4.0
*
* @return void
*/
public function displayListEmoji($tpl = null)
{
$response = array();
if ($this->me->exists())
{
$search = $this->app->input->get('search');
$db = JFactory::getDBO();
$kquery = new KunenaDatabaseQuery;
$kquery->select('*')->from("{$db->qn('#__kunena_smileys')}")->where("code LIKE '%{$db->escape($search)}%' AND emoticonbar=1");
$db->setQuery($kquery);
$smileys = $db->loadObjectList();
KunenaError::checkDatabaseError();
foreach ($smileys as $smiley)
{
$emojis['key'] = $smiley->code;
$emojis['name'] = $smiley->code;
$emojis['url'] = JUri::root() . 'media/kunena/emoticons/' . $smiley->location;
$response['emojis'][] = $emojis;
}
}
// Set the MIME type and header for JSON output.
$this->document->setMimeEncoding('application/json');
JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.' . $this->getLayout() . '.json"');
echo json_encode($response);
}
示例6: getEmoticons
public static function getEmoticons($grayscale = false, $emoticonbar = false)
{
$db = JFactory::getDBO ();
$grayscale == true ? $column = "greylocation" : $column = "location";
$sql = "SELECT code, {$db->quoteName($column)} AS file FROM #__kunena_smileys";
if ($emoticonbar == true)
{
$sql .= " WHERE emoticonbar='1'";
}
$db->setQuery ( $sql );
$smilies = $db->loadObjectList ();
KunenaError::checkDatabaseError();
$smileyArray = array ();
$template = KunenaFactory::getTemplate();
foreach ( $smilies as $smiley )
{
// We load all smileys in array, so we can sort them
$smileyArray [$smiley->code] = JUri::root(true) .'/'. $template->getSmileyPath($smiley->file);
}
if ($emoticonbar == 0)
{
// don't sort when it's only for use in the emoticonbar
array_multisort ( array_keys ( $smileyArray ), SORT_DESC, $smileyArray );
reset ( $smileyArray );
}
return $smileyArray;
}
示例7: getCatsDetails
public function getCatsDetails($catids)
{
$query = "SELECT * FROM #__kunena_categories WHERE id={$this->_db->Quote($catids)} AND published='1'";
$this->_db->setQuery($query);
$results = $this->_db->loadObject();
KunenaError::checkDatabaseError();
return $results;
}
示例8: _getTopHits
public function _getTopHits($limit=0) {
$db = JFactory::getDBO ();
$query = "SELECT userid AS id, profileviews AS count FROM #__alpha_userpoints WHERE a.profileviews>0 ORDER BY profileviews DESC";
$db->setQuery ( $query, 0, $limit );
$top = $db->loadObjectList ();
KunenaError::checkDatabaseError ();
return $top;
}
示例9: getUserLink
/**
* adds the link for the connect param
* @since 1.7.3
* @param $user pass-by-reference
* @return void
*/
private function getUserLink(&$user)
{
$username = KunenaFactory::getUser($user['userid'])->getName();
if ($user['leapcorrection'] == $this->timeo->format('z', true) + 1) {
$subject = getSubject($username);
$db = JFactory::getDBO();
$query = "SELECT id,catid,subject,time as year FROM #__kunena_messages WHERE subject='{$subject}'";
$db->setQuery($query, 0, 1);
$post = $db->loadAssoc();
if ($db->getErrorMsg()) {
KunenaError::checkDatabaseError();
}
$catid = $this->params->get('bcatid');
$postyear = new JDate($post['year'], $this->soffset);
if (empty($post) && !empty($catid) || !empty($post) && !empty($catid) && $postyear->format('Y', true) < $this->timeo->format('Y', true)) {
$botname = $this->params->get('swkbbotname', JText::_('SW_KBIRTHDAY_FORUMPOST_BOTNAME_DEF'));
$botid = $this->params->get('swkbotid');
$time = CKunenaTimeformat::internalTime();
//Insert the birthday thread into DB
$query = "INSERT INTO #__kunena_messages (catid,name,userid,email,subject,time, ip)\n\t\t \t\tVALUES({$catid},'{$botname}',{$botid}, '','{$subject}', {$time}, '')";
$db->setQuery($query);
$db->query();
if ($db->getErrorMsg()) {
KunenaError::checkDatabaseError();
}
//What ID get our thread?
$messid = (int) $db->insertID();
//Insert the thread message into DB
$message = getMessage($username);
$query = "INSERT INTO #__kunena_messages_text (mesid,message)\n VALUES({$messid},'{$message}')";
$db->setQuery($query);
$db->query();
if ($db->getErrorMsg()) {
KunenaError::checkDatabaseError();
}
//We know the thread ID so we can update the parent thread id with it's own ID because we know it's
//the first post
$query = "UPDATE #__kunena_messages SET thread={$messid} WHERE id={$messid}";
$db->setQuery($query);
$db->query();
if ($db->getErrorMsg()) {
KunenaError::checkDatabaseError();
}
// now increase the #s in categories
CKunenaTools::modifyCategoryStats($messid, 0, $time, $catid);
$user['link'] = CKunenaLink::GetViewLink('view', $messid, $catid, '', $username);
$uri = JFactory::getURI();
if ($uri->getVar('option') == 'com_kunena') {
$app =& JFactory::getApplication();
$app->redirect($uri->toString());
}
} elseif (!empty($post)) {
$user['link'] = CKunenaLink::GetViewLink('view', $post['id'], $post['catid'], '', $username);
}
} else {
$user['link'] = CKunenaLink::GetProfileLink($user['userid']);
}
}
示例10: loadModerators
protected function loadModerators()
{
$db = JFactory::getDBO();
$query = "SELECT u.id AS userid, m.catid\n\t\t\t\tFROM #__users AS u\n\t\t\t\tINNER JOIN #__kunena_users AS ku ON u.id=ku.userid\n\t\t\t\tLEFT JOIN #__kunena_moderation AS m ON u.id=m.userid\n\t\t\t\tLEFT JOIN #__kunena_categories AS c ON m.catid=c.id\n\t\t\t\tWHERE u.block='0' AND ku.moderator='1' AND (m.catid IS NULL OR c.moderated='1')";
$db->setQuery($query);
$list = (array) $db->loadObjectList();
KunenaError::checkDatabaseError();
return parent::loadModerators($list);
}
示例11: _getTopHits
public function _getTopHits($limit = 0)
{
$db = JFactory::getDBO();
$query = "SELECT u.id, ku.uhits AS count\n\t\t\tFROM #__kunena_users AS ku\n\t\t\tINNER JOIN #__users AS u ON u.id=ku.userid\n\t\t\tWHERE ku.uhits>0\n\t\t\tORDER BY ku.uhits DESC";
$db->setQuery($query, 0, $limit);
$top = (array) $db->loadObjectList();
KunenaError::checkDatabaseError();
return $top;
}
示例12: getAnnouncement
public function getAnnouncement() {
$db = JFactory::getDBO();
$query = "SELECT * FROM #__kunena_announcement WHERE published='1' ORDER BY created DESC";
$db->setQuery ( $query, 0, 1 );
$announcement = $db->loadObject ();
if (KunenaError::checkDatabaseError()) return;
return $announcement;
}
示例13: loadModerators
public function loadModerators() {
$db = JFactory::getDBO ();
$query = "SELECT uc.user_id AS userid, category_id AS catid
FROM #__kunena_user_categories AS uc
INNER JOIN #__users AS u ON u.id=uc.user_id AND u.block=0
WHERE uc.role=1";
$db->setQuery ( $query );
$list = (array) $db->loadObjectList ();
KunenaError::checkDatabaseError ();
return $this->storeModerators($list);
}
示例14: getRank
public function getRank() {
$db = JFactory::getDBO ();
if ( $this->getState('item.id') ) {
$db->setQuery ( "SELECT * FROM #__kunena_ranks WHERE rank_id = '{$this->getState('item.id')}'" );
$rankselected = $db->loadObject ();
if (KunenaError::checkDatabaseError()) return;
return $rankselected;
}
return;
}
示例15: _getTopHits
public function _getTopHits($limit=0) {
$db = JFactory::getDBO ();
$query = "SELECT cu.userid AS id, cu.view AS count
FROM #__community_users AS cu
INNER JOIN #__users AS u ON u.id=cu.userid
WHERE cu.view>0
ORDER BY cu.view DESC";
$db->setQuery ( $query, 0, $limit );
$top = (array) $db->loadObjectList ();
KunenaError::checkDatabaseError();
return $top;
}