本文整理汇总了PHP中CKunenaTools类的典型用法代码示例。如果您正苦于以下问题:PHP CKunenaTools类的具体用法?PHP CKunenaTools怎么用?PHP CKunenaTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CKunenaTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _deleteUser
/**
* Delete a user
*
* @access protected
* @param unknown_type $UserID
* @return boolean
*/
protected function _deleteUser($UserID)
{
// Sanitize parameters!
$UserID = intval($UserID);
if (!CKunenaTools::isAdmin($this->_my->id)) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_NOT_ADMIN');
return false;
}
if ($UserID == $this->_my->id) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_USER_DELETE_YOURSELF');
return false;
}
if (!$UserID) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_USER_DELETE_ANONYMOUS');
return false;
}
$user = JUser::getInstance($UserID);
if (!$user->id) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_USER_DELETE_NO_USER', $UserID);
return false;
}
// Nobody can delete admins
if (CKunenaTools::isAdmin($UserID)) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_USER_DELETE_ADMIN', $user->username);
return false;
}
$user->delete();
$this->_db->setQuery("DELETE FROM #__kunena_users WHERE `userid`={$this->_db->Quote($UserID)};");
$this->_db->query();
if (KunenaError::checkDatabaseError()) {
return false;
}
return true;
}
示例2: 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']);
}
}
示例3: convertDate
function convertDate($date)
{
// used for non-FB dates only!
$format = _KUNENA_USRL_DATE_FORMAT;
if ($date != "0000-00-00 00:00:00" && preg_match('`(\\d{4})-(\\d{2})-(\\d{2})[[:space:]](\\d{2}):(\\d{2}):(\\d{2})`', $date, $regs)) {
$date = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
$date = $date > -1 ? strftime($format, CKunenaTools::fbGetShowTime($date, 'UTC')) : '-';
} else {
$date = _KUNENA_USRL_NEVER;
}
return $date;
}
示例4: convertDate
function convertDate($date)
{
// used for non-FB dates only!
$format = _KUNENA_USRL_DATE_FORMAT;
if ($date != "0000-00-00 00:00:00" && ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs)) {
$date = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
$date = $date > -1 ? strftime($format, CKunenaTools::fbGetShowTime($date, 'UTC')) : '-';
} else {
$date = _KUNENA_USRL_NEVER;
}
return $date;
}
示例5: __construct
function __construct()
{
$this->_db =& JFactory::getDBO();
$this->_my =& JFactory::getUser();
$this->_session =& KunenaFactory::getSession();
$this->_config = KunenaFactory::getConfig();
$this->_isimage = false;
$this->_isfile = false;
if (CKunenaTools::isModerator($this->_my->id) || $this->_my->id && $this->_config->allowimageregupload || !$this->_my->id && $this->_config->allowimageupload) {
$this->validImageExts = explode(',', $this->_config->imagetypes);
}
if (CKunenaTools::isModerator($this->_my->id) || $this->_my->id && $this->_config->allowfileregupload || !$this->_my->id && $this->_config->allowfileupload) {
$this->validFileExts = explode(',', $this->_config->filetypes);
}
$this->setImageResize(intval($this->_config->imagesize) * 1024, intval($this->_config->imagewidth), intval($this->_config->imageheight), intval($this->_config->imagequality));
}
示例6: KUNENA_timeformat
function KUNENA_timeformat($logTime, $show_today = true)
{
// formatts a time in Display space! Don't pass internal times!
// ToDo: Pass format!
$usertime_format = _KUNENA_DT_DATETIME_FMT;
$app =& JFactory::getApplication();
$time = $logTime;
$todayMod = 2;
// We can't have a negative date (on Windows, at least.)
if ($time < 0) {
$time = 0;
}
// Today and Yesterday?
if ($show_today === true) {
// Get the current time.
$nowtime = CKunenaTools::fbGetShowTime();
$then = @getdate($time);
$now = @getdate($nowtime);
// Try to make something of a time format string...
$s = strpos($usertime_format, '%S') === false ? '' : ':%S';
if (strpos($usertime_format, '%H') === false && strpos($usertime_format, '%T') === false) {
$today_fmt = '%I:%M' . $s . ' %p';
} else {
$today_fmt = '%H:%M' . $s;
}
// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
return '' . _TIME_TODAY . '' . KUNENA_timeformat($logTime, $today_fmt);
}
// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($todayMod == '2' && ($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year'] || $now['yday'] == 0 && $then['year'] == $now['year'] - 1 && $then['mon'] == 12 && $then['mday'] == 31)) {
return '' . _TIME_YESTERDAY . '' . KUNENA_timeformat($logTime, $today_fmt);
}
}
$str = !is_bool($show_today) ? $show_today : $usertime_format;
// Do-it-yourself time localization. Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) {
if (strpos($str, $token) !== false) {
$str = str_replace($token, $GLOBALS['KUNENA_DT_txt'][$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
}
}
if (strpos($str, '%p')) {
$str = str_replace('%p', strftime('%H', $time) < 12 ? 'am' : 'pm', $str);
}
// Format any other characters..
return strftime($str, $time);
}
示例7: display
function display()
{
if (!$this->config->showannouncement) {
return;
}
$do = JRequest::getVar("do", "");
$id = intval(JRequest::getVar("id", ""));
switch ($do) {
case 'read':
$this->getAnnouncement($id, 1);
CKunenaTools::loadTemplate('/announcement/read.php');
break;
case 'show':
$this->getAnnouncements(0, 5);
CKunenaTools::loadTemplate('/announcement/show.php');
break;
case 'edit':
if (!$this->canEdit) {
while (@ob_end_clean()) {
}
$this->app->redirect(CKunenaLink::GetKunenaURL(false), JText::_('COM_KUNENA_POST_NOT_MODERATOR'));
return;
}
$this->getAnnouncement($id, 0);
// Continue
// Continue
case 'add':
if (!$this->canEdit) {
while (@ob_end_clean()) {
}
$this->app->redirect(CKunenaLink::GetKunenaURL(false), JText::_('COM_KUNENA_POST_NOT_MODERATOR'));
return;
}
CKunenaTools::loadTemplate('/announcement/edit.php');
break;
case 'delete':
$this->delete($id);
break;
case 'doedit':
$this->edit($id);
break;
default:
$this->getAnnouncements(0, 5);
CKunenaTools::loadTemplate('/announcement/show.php');
}
}
示例8: while
}
$kunena_app->redirect(CKunenaLink::GetLatestPageAutoRedirectURL($pid, $kunena_config->messages_per_page, $catid));
} else {
while (@ob_end_clean()) {
}
$kunena_app->redirect(CKunenaLink::GetMyProfileURL($userid));
}
return;
}
// This checkes to see if it's not too soon for a new karma change
if (!CKunenaTools::isModerator($kunena_my->id, $catid)) {
$userprofile = KunenaFactory::getUser($kunena_my->id);
$karma_time_old = $userprofile->karma_time;
$karma_time_diff = $time - $karma_time_old;
}
if (CKunenaTools::isModerator($kunena_my->id, $catid) || $karma_time_diff >= $karma_min_seconds) {
if ($do == "increase") {
$kunena_db->setQuery("UPDATE #__kunena_users SET karma_time={$kunena_db->Quote($time)} WHERE userid={$kunena_db->Quote($kunena_my->id)} ");
$kunena_db->query();
if (KunenaError::checkDatabaseError()) {
return;
}
$kunena_db->setQuery("UPDATE #__kunena_users SET karma=karma+1 WHERE userid={$kunena_db->Quote($userid)}");
$kunena_db->query();
if (KunenaError::checkDatabaseError()) {
return;
}
// Activity integration
$activity = KunenaFactory::getActivityIntegration();
$activity->onAfterKarma($userid, $kunena_my->id, 1);
if ($pid) {
示例9: dofreePDF
function dofreePDF($kunena_db)
{
global $aro_group;
$app =& JFactory::getApplication();
$kunena_acl =& JFactory::getACL();
$kunena_my =& JFactory::getUser();
$fbConfig =& CKunenaConfig::getInstance();
require_once KUNENA_PATH_LIB . DS . 'kunena.authentication.php';
$is_Mod = 0;
$catid = JRequest::getInt('catid', 2);
if (!$is_admin) {
$kunena_db->setQuery("SELECT userid FROM #__fb_moderation WHERE catid='{$catid}' AND userid='{$kunena_my->id}'");
if ($kunena_db->loadResult()) {
$is_Mod = 1;
}
} else {
$is_Mod = 1;
}
//superadmins always are
if (!$is_Mod) {
//get all the info on this forum:
$kunena_db->setQuery("SELECT id, pub_access, pub_recurse, admin_access, admin_recurse FROM #__fb_categories WHERE id='{$catid}'");
$row = $kunena_db->loadObjectList();
check_dberror("Unable to load category detail.");
$allow_forum = explode(',', CKunenaTools::getAllowedForums($kunena_my->id, $aro_group->id, $kunena_acl));
}
if ($is_Mod || in_array($catid, $allow_forum)) {
$id = JRequest::getInt('id', 1);
$catid = JRequest::getInt('catid', 2);
//first get the thread id for the current post to later on determine the parent post
$kunena_db->setQuery("SELECT thread FROM #__fb_messages WHERE id='{$id}' AND catid='{$catid}'");
$threadid = $kunena_db->loadResult();
//load topic post and details
$kunena_db->setQuery("SELECT a.*, b.* FROM #__fb_messages AS a, #__fb_messages_text AS b WHERE a.thread='{$threadid}' AND a.catid='{$catid}' AND a.parent='0' AND a.id=b.mesid");
$row = $kunena_db->loadObjectList();
check_dberror("Unable to load message details.");
if (file_exists(KUNENA_ROOT_PATH . DS . 'includes/class.ezpdf.php')) {
include KUNENA_ROOT_PATH . DS . 'includes/class.ezpdf.php';
$pdf = new Cezpdf('a4', 'P');
//A4 Portrait
} elseif (class_exists('JDocument')) {
$pdf = new fbpdfwrapper();
} else {
echo 'No supported pdf class found!';
exit;
}
if (empty($row)) {
//if the messages doesn't exist don't need to continue
//Doesn't work Fatal error: Call to undefined method CKunenaLink::GetKunenaURL()
//$app->redirect ( CKunenaLink::GetKunenaURL(true), _KUNENA_PDF_NOT_GENERATED_MESSAGE_DELETED );
} else {
$mes_text = $row[0]->message;
filterHTML($mes_text);
$pdf->ezSetCmMargins(2, 1.5, 1, 1);
$pdf->selectFont('./fonts/Helvetica.afm');
//choose font
$all = $pdf->openObject();
$pdf->saveState();
$pdf->setStrokeColor(0, 0, 0, 1);
// footer
$pdf->line(10, 40, 578, 40);
$pdf->line(10, 822, 578, 822);
$pdf->addText(30, 34, 6, $fbConfig->board_title . ' - ' . $app->getCfg('sitename'));
$strtmp = _KUNENA_PDF_VERSION;
$strtmp = str_replace('%version%', "NEW VERSION GOES HERE", $strtmp);
// TODO: fxstein - Need to change version handling
$pdf->addText(250, 34, 6, $strtmp);
$strtmp = _KUNENA_PDF_DATE;
$strtmp = str_replace('%date%', date('j F, Y, H:i', CKunenaTools::fbGetShowTime()), $strtmp);
$pdf->addText(450, 34, 6, $strtmp);
$pdf->restoreState();
$pdf->closeObject();
$pdf->addObject($all, 'all');
$pdf->ezSetDy(30);
$txt0 = $row[0]->subject;
$pdf->ezText($txt0, 14);
$pdf->ezText(_VIEW_POSTED . " " . $row[0]->name . " - " . date(_DATETIME, $row[0]->time), 8);
$pdf->ezText("_____________________________________", 8);
//$pdf->line( 10, 780, 578, 780 );
$txt3 = "\n";
$txt3 .= stripslashes($mes_text);
$pdf->ezText($txt3, 10);
$pdf->ezText("\n============================================================================\n\n", 8);
//now let's try to see if there's more...
$kunena_db->setQuery("SELECT a.*, b.* FROM #__fb_messages AS a, #__fb_messages_text AS b WHERE a.catid='{$catid}' AND a.thread='{$threadid}' AND a.id=b.mesid AND a.parent!='0' ORDER BY a.time ASC");
$replies = $kunena_db->loadObjectList();
check_dberror("Unable to load messages & detail.");
$countReplies = count($replies);
if ($countReplies > 0) {
foreach ($replies as $reply) {
$mes_text = $reply->message;
filterHTML($mes_text);
$txt0 = $reply->subject;
$pdf->ezText($txt0, 14);
$pdf->ezText(_VIEW_POSTED . " " . $reply->name . " - " . date(_DATETIME, $reply->time), 8);
$pdf->ezText("_____________________________________", 8);
$txt3 = "\n";
$txt3 .= stripslashes($mes_text);
$pdf->ezText($txt3, 10);
$pdf->ezText("\n============================================================================\n\n", 8);
//.........这里部分代码省略.........
示例10: fbMovePosts
function fbMovePosts($catid, $isMod, $return)
{
$app =& JFactory::getApplication();
$backUrl = $app->getUserState("com_kunena.ActionBulk");
$kunena_db =& JFactory::getDBO();
$kunena_my =& JFactory::getUser();
// $isMod if user is moderator in the current category
if (!$isMod) {
// Test also if user is a moderator in some other category
$kunena_db->setQuery("SELECT userid FROM #__fb_moderation WHERE userid='{$kunena_my->id}'");
$isMod = $kunena_db->loadResult();
check_dberror("Unable to load moderation info.");
}
$isAdmin = CKunenaTools::isModOrAdmin();
//isMod will stay until better group management comes in
if (!$isAdmin && !$isMod) {
$app->redirect($return, _POST_NOT_MODERATOR);
}
$catid = (int) $catid;
if ($catid > 0) {
$items = fbGetArrayInts("fbDelete");
// start iterating here
foreach ($items as $id => $value) {
$id = (int) $id;
$kunena_db->setQuery("SELECT subject, catid, time AS timestamp FROM #__fb_messages WHERE id='{$id}'");
$oldRecord = $kunena_db->loadObjectList();
check_dberror("Unable to load message detail.");
$newCatObj = new jbCategory($kunena_db, $oldRecord[0]->catid);
if (fb_has_moderator_permission($kunena_db, $newCatObj, $kunena_my->id, $isAdmin)) {
$newSubject = _MOVED_TOPIC . " " . $oldRecord[0]->subject;
$kunena_db->setQuery("SELECT MAX(time) AS timestamp FROM #__fb_messages WHERE thread='{$id}'");
$lastTimestamp = $kunena_db->loadResult();
check_dberror("Unable to load messages max(time).");
if ($lastTimestamp == "") {
$lastTimestamp = $oldRecord[0]->timestamp;
}
//perform the actual move
$kunena_db->setQuery("UPDATE #__fb_messages SET `catid`='{$catid}' WHERE `id`='{$id}' OR `thread`='{$id}'");
$kunena_db->query();
check_dberror("Unable to move thread.");
$err = _POST_SUCCESS_MOVE;
} else {
$err = _POST_NOT_MODERATOR;
}
}
//end foreach
} else {
$err = _POST_NO_DEST_CATEGORY;
}
CKunenaTools::reCountBoards();
$app->redirect($return, $err);
}
示例11: switch
$app->redirect(htmlspecialchars_decode(JRoute::_(KUNENA_LIVEURLREL . '&func=showcat&catid=' . $catid)), _GEN_FORUM_MARKED);
break;
#########################################################################################
#########################################################################################
case 'karma':
include KUNENA_PATH_LIB . DS . 'kunena.karma.php';
break;
#########################################################################################
#########################################################################################
case 'bulkactions':
switch ($do) {
case "bulkDel":
CKunenaTools::fbDeletePosts($is_Moderator, $return);
break;
case "bulkMove":
CKunenaTools::fbMovePosts($catid, $is_Moderator, $return);
break;
}
break;
######################
/* template chooser */
######################
/* template chooser */
case "templatechooser":
$fb_user_template = strval(JRequest::getVar('fb_user_template', '', 'COOKIE'));
$fb_user_img_template = strval(JRequest::getVar('fb_user_img_template', $fb_user_img_template));
$fb_change_template = strval(JRequest::getVar('fb_change_template', $fb_user_template));
$fb_change_img_template = strval(JRequest::getVar('fb_change_img_template', $fb_user_img_template));
if ($fb_change_template) {
// clean template name
$fb_change_template = preg_replace('#\\W#', '', $fb_change_template);
示例12: trashrestore
function trashrestore($option, $cid)
{
$kunena_app =& JFactory::getApplication();
$kunena_db =& JFactory::getDBO();
JArrayHelper::toInteger($cid);
if ($cid) {
foreach ($cid as $id) {
$kunena_db->setQuery("SELECT * FROM #__kunena_messages WHERE id={$id} AND hold=2");
$mes = $kunena_db->loadObject();
if (KunenaError::checkDatabaseError()) {
return;
}
$kunena_db->setQuery("UPDATE #__kunena_messages SET hold=0 WHERE hold IN (2,3) AND thread={$mes->thread} ");
$kunena_db->query();
if (KunenaError::checkDatabaseError()) {
return;
}
CKunenaTools::reCountUserPosts();
CKunenaTools::reCountBoards();
}
}
while (@ob_end_clean()) {
}
$kunena_app->redirect(JURI::base() . "index.php?option={$option}&task=showtrashview", JText::_('COM_KUNENA_TRASH_RESTORE_DONE'));
}
示例13: showForm
public function showForm()
{
if (!$this->reportAllowed()) {
return false;
}
CKunenaTools::loadTemplate('/plugin/report/report.php');
}
示例14:
$this->displayContents();
?>
</td>
<td rowspan="2" class="kprofile-right">
<?php
$this->displayProfile('vertical');
?>
</td>
</tr>
<tr>
<td class="kbuttonbar-right">
<?php
$this->displayActions();
?>
<?php
$this->displayThankyou();
?>
</td>
</tr>
</tbody>
</table>
<?php
}
?>
<!-- Begin: Message Module Position -->
<?php
CKunenaTools::showModulePosition('kunena_msg_' . $this->mmm);
?>
<!-- Finish: Message Module Position -->
示例15: isset
// TODO: Enable split when it's fixed
// $msg_split = CKunenaLink::GetTopicPostLink('split', $catid, $fmessage->id , isset($fbIcons['split']) ? '<img src="' . KUNENA_URLICONSPATH . $fbIcons['split'] . '" alt="' . _GEN_SPLIT . '" border="0" title="' . _GEN_SPLIT . '" />':_GEN_SPLIT);
}
if ($fbConfig->useredit && $kunena_my->id != "") {
//Now, if the viewer==author and the viewer is allowed to edit his/her own post then offer an 'edit' link
$allowEdit = 0;
if ($kunena_my->id == $userinfo->userid) {
if ((int) $fbConfig->useredittime == 0) {
$allowEdit = 1;
} else {
//Check whether edit is in time
$modtime = $fmessage->modified_time;
if (!$modtime) {
$modtime = $fmessage->time;
}
if ($modtime + (int) $fbConfig->useredittime >= CKunenaTools::fbGetInternalTime()) {
$allowEdit = 1;
}
}
}
if ($allowEdit) {
$msg_edit = CKunenaLink::GetTopicPostLink('edit', $catid, $fmessage->id, isset($fbIcons['edit']) ? '<img src="' . KUNENA_URLICONSPATH . $fbIcons['edit'] . '" alt="Edit" border="0" title="' . _VIEW_EDIT . '" />' : _GEN_EDIT);
$showedEdit = 1;
}
}
if ($is_Moderator && $showedEdit != 1) {
//Offer a moderator always the edit link except when it is already showing..
$msg_edit = CKunenaLink::GetTopicPostLink('edit', $catid, $fmessage->id, isset($fbIcons['edit']) ? '<img src="' . KUNENA_URLICONSPATH . $fbIcons['edit'] . '" alt="Edit" border="0" title="' . _VIEW_EDIT . '" />' : _GEN_EDIT);
}
//(JJ)
if (file_exists(KUNENA_ABSTMPLTPATH . '/message.php')) {