コード例 #1
0
ファイル: attachments.php プロジェクト: rich20/Kunena
	function delete() {
		$app =  JFactory::getApplication ();
		$db = JFactory::getDBO ();

		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		$cids = JRequest::getVar ( 'cid', array (), 'post', 'array' );

		if (! $cids) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_NO_ATTACHMENTS_SELECTED' ), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		foreach( $cids as $id ) {
			kimport ('kunena.forum.message.attachment.helper');
			$attachment = KunenaForumMessageAttachmentHelper::get($id);
			$attachment->delete();
		}

		$app->enqueueMessage ( JText::_('COM_KUNENA_ATTACHMENTS_DELETED_SUCCESSFULLY') );
		$app->redirect ( KunenaRoute::_($this->baseurl, false) );
	}
コード例 #2
0
 function delete()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $cids = JRequest::getVar('cid', array(), 'post', 'array');
     if (!$cids) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ATTACHMENTS_SELECTED'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     foreach ($cids as $id) {
         $attachment = KunenaForumMessageAttachmentHelper::get($id);
         $attachment->delete();
     }
     $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETED_SUCCESSFULLY'));
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
コード例 #3
0
ファイル: bbcode.php プロジェクト: madcsaba/li-de
 function DoAttachment($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCODE_CHECK) {
         return true;
     }
     // Display tag in activity streams etc..
     if (!empty($bbcode->parent->forceMinimal) || !is_object($bbcode->parent) && !isset($bbcode->parent->attachments)) {
         $filename = basename(trim(strip_tags($content)));
         return '[' . JText::_('COM_KUNENA_FILEATTACH') . ' ' . basename(!empty($params["name"]) ? $params["name"] : trim(strip_tags($content))) . ']';
     }
     $attachments =& $bbcode->parent->attachments;
     $attachment = null;
     if (!empty($default)) {
         $attachment = KunenaForumMessageAttachmentHelper::get($default);
         if (is_object($attachment)) {
             unset($attachments[$attachment->id]);
         }
     } elseif (empty($content)) {
         $attachment = array_shift($attachments);
     } elseif (!empty($attachments)) {
         foreach ($attachments as $att) {
             if ($att->filename == $content) {
                 $attachment = $att;
                 unset($attachments[$att->id]);
                 break;
             }
         }
     }
     if (!$attachment && !empty($bbcode->parent->inline_attachments)) {
         foreach ($bbcode->parent->inline_attachments as $att) {
             if ($att->filename == trim(strip_tags($content))) {
                 $attachment = $att;
                 break;
             }
         }
     }
     if (!is_object($attachment)) {
         return htmlspecialchars($content);
     } elseif ($attachment->exists() && (!$attachment->authorise() || $attachment->disabled)) {
         // Hide between content from non registered users
         $link = $attachment->getTextLink();
         return '<div class="kmsgattach">' . $link . '</div>';
     } elseif ($attachment->exists() && is_file(JPATH_ROOT . "/{$attachment->folder}/{$attachment->filename}")) {
         $bbcode->parent->inline_attachments[$attachment->id] = $attachment;
         // TODO: use absolute / relative url depending on where BBCode is shown
         $link = JUri::root() . "{$attachment->folder}/{$attachment->filename}";
         $image = $attachment->getImageLink();
         if (empty($image)) {
             return "<div class=\"kmsgattach\"><h4>" . JText::_('COM_KUNENA_FILEATTACH') . "</h4>" . JText::_('COM_KUNENA_FILENAME') . " <a href=\"" . $link . "\" target=\"_blank\" rel=\"nofollow\">" . $attachment->filename . "</a><br />" . JText::_('COM_KUNENA_FILESIZE') . ' ' . number_format(intval($attachment->size) / 1024, 0, '', ',') . ' KB' . "</div>";
         } else {
             return "<div class=\"kmsgimage\">{$attachment->getImageLink()}</div>";
         }
     } else {
         return '<div class="kmsgattach"><h4>' . JText::sprintf('COM_KUNENA_ATTACHMENT_DELETED', htmlspecialchars($content)) . '</h4></div>';
     }
 }
コード例 #4
0
ファイル: user.php プロジェクト: rich20/Kunena
	function delfile() {
		$app = JFactory::getApplication ();
		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->redirectBack ();
		}
		$cids = JRequest::getVar ( 'cid', array (), 'post', 'array' );

		$number = count($cids);

		foreach( $cids as $id ) {
			kimport ('kunena.forum.message.attachment.helper');
			$attachment = KunenaForumMessageAttachmentHelper::get($id);
			$attachment->delete();
		}

		$app->enqueueMessage ( JText::sprintf( 'COM_KUNENA_ATTACHMENTS_DELETE_SUCCESSFULLY', $number) );
		$this->redirectBack ();
	}
コード例 #5
0
ファイル: user.php プロジェクト: proyectoseb/University
 public function delfile()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     // Array of integers
     JArrayHelper::toInteger($cid);
     if (!empty($cid)) {
         $number = 0;
         foreach ($cid as $id) {
             $attachment = KunenaForumMessageAttachmentHelper::get($id);
             if ($attachment->authorise('delete') && $attachment->delete()) {
                 $number++;
             }
         }
         if ($number > 0) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_ATTACHMENTS_DELETE_SUCCESSFULLY', $number));
             $this->redirectBack();
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETE_FAILED'));
             $this->redirectBack();
         }
     } else {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_NO_ATTACHMENTS_SELECTED'));
         $this->redirectBack();
     }
 }
コード例 #6
0
		<div class="kbody">
			<form action="<?php echo KunenaRoute::_('index.php?option=com_kunena') ?>" method="post" name="adminForm">
				<input type="hidden" name="view" value="user" />
				<input type="hidden" name="task" value="delfile" />
				<input type="hidden" name="boxchecked" value="0" />
				<?php echo JHTML::_( 'form.token' ); ?>

				<ul>
				<?php
				if ( empty($this->items) ):
					 echo '<li>'.JText::_('COM_KUNENA_USER_NO_ATTACHMENTS').'</li>';
					else:
				$i=0;
				$y=1;
				foreach ($this->items as $file) :
					$instance = KunenaForumMessageAttachmentHelper::get($file->id);

					$evenodd = $i % 2;

					if ($evenodd == 0)	$usrl_class="row1";
					else $usrl_class="row2"; ?>

					<li class="kposts-row">
						<table summary="List of all forum categories with posts and replies of each">
							<tbody>
								<tr>
									<td class="kposts-topic">
										<h3><?php echo $y; ?></h3>
									</td>
									<td class="ktopic-icon"><?php echo JHTML::_('grid.id', $i, intval($file->id)) ?></td>
									<td class="kpost-topic">
コード例 #7
0
ファイル: attachment.php プロジェクト: laiello/senluonirvana
 /**
  * Returns KunenaForumMessageAttachment object
  *
  * @access	public
  * @param	identifier		The message to load - Can be only an integer.
  * @return	KunenaForumMessageAttachment		The message object.
  * @since	1.7
  */
 public static function getInstance($identifier = null, $reload = false)
 {
     return KunenaForumMessageAttachmentHelper::get($identifier, $reload);
 }
コード例 #8
0
ファイル: bbcode.php プロジェクト: rich20/Kunena
	function DoAttachment($bbcode, $action, $name, $default, $params, $content) {
		if ($action == BBCODE_CHECK)
			return true;

		if (! is_object ( $bbcode->parent ) && ! isset ( $bbcode->parent->attachments )) {
			return '[Attachment]'; // TODO
		}
		$attachments = &$bbcode->parent->attachments;
		$attachment = null;
		if (! empty ( $default )) {
			$attachment = KunenaForumMessageAttachmentHelper::get ($default);
			if (is_object ( $attachment )) {
				unset ( $attachments [$attachment->id] );
			}
		} elseif (empty ( $content )) {
			$attachment = array_shift ( $attachments );
		} elseif (!empty ( $attachments )) {
			foreach ( $attachments as $att ) {
				if ($att->filename == $content) {
					$attachment = $att;
					unset ( $attachments [$att->id] );
					break;
				}
			}
		}
		if (! $attachment && ! empty ( $bbcode->parent->inline_attachments )) {
			foreach ( $bbcode->parent->inline_attachments as $att ) {
				if ($att->filename == trim($bbcode->UnHTMLEncode(strip_tags($content)))) {
					$attachment = $att;
					break;
				}
			}
		}

		if (is_object ( $attachment ) && ! empty ( $attachment->disabled )) {
			// Hide between content from non registered users
			return '<div class="kmsgattach">' . $attachment->textLink . '</div>';
		} else {
			if (is_object ( $attachment ) && is_file ( JPATH_ROOT . "/{$attachment->folder}/{$attachment->filename}" )) {
				$bbcode->parent->inline_attachments [$attachment->id] = $attachment;
				$link = JURI::base () . "{$attachment->folder}/{$attachment->filename}";
				$image = $attachment->getImageLink();
				if (empty ( $image )) {
					return "<div class=\"kmsgattach\"><h4>" . JText::_ ( 'COM_KUNENA_FILEATTACH' ) . "</h4>" . JText::_ ( 'COM_KUNENA_FILENAME' ) . " <a href=\"" . $link . "\" target=\"_blank\" rel=\"nofollow\">" . $attachment->filename . "</a><br />" . JText::_ ( 'COM_KUNENA_FILESIZE' ) . ' ' . number_format ( intval ( $attachment->size ) / 1024, 0, '', ',' ) . ' KB' . "</div>";
				} else {
					return "<div class=\"kmsgimage\">{$attachment->getImageLink()}</div>";
				}
			} else {
				return '<div class="kmsgattach"><h4>' . JText::sprintf ( 'COM_KUNENA_ATTACHMENT_DELETED', $content ) . '</h4></div>';
			}
		}
	}