コード例 #1
0
 /**
  * Upload files and attach them to an issue or a comment.
  *
  * @param   array  $files      Array containing the uploaded files.
  * @param   int    $issueId    ID of the issue/comment where to attach the files.
  * @param   int    $commentId  One of 'issue' or 'comment', indicating if the files should be attached to an issue or a comment.
  *
  * @return  boolean   True on success, false otherwise.
  */
 public function upload($files, $issueId, $commentId = null)
 {
     if (!$issueId || !is_array($files)) {
         return false;
     }
     jimport('joomla.filesystem.file');
     if ($commentId) {
         $type = 'comment';
         $id = $commentId;
     } else {
         $type = 'issue';
         $id = $issueId;
     }
     foreach ($files as $file) {
         $rand = MonitorHelper::genRandHash();
         $pathParts = array($type, $id, $rand . '-' . $file[0]['name']);
         $path = JPath::clean(implode(DIRECTORY_SEPARATOR, $pathParts));
         $values = array('issue_id' => $issueId, 'comment_id' => $commentId, 'path' => $path, 'name' => $file[0]['name']);
         if (!JFile::upload($file[0]['tmp_name'], $this->pathPrefix . $path)) {
             JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MONITOR_ATTACHMENT_UPLOAD_FAILED', $file[0]['name']));
             return false;
         }
         $query = $this->db->getQuery(true);
         $query->insert('#__monitor_attachments')->set(MonitorHelper::sqlValues($values, $query));
         $this->db->setQuery($query);
         if ($this->db->execute() === false) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: default.php プロジェクト: Harmageddon/com_monitor
						<a href="<?php 
        echo JRoute::_('index.php?option=com_users&task=user.edit&id=' . (int) $item->author_id);
        ?>
"
							title="<?php 
        echo JText::_('COM_MONITOR_EDIT_USER');
        ?>
">
							<?php 
        echo $this->escape($item->author_name);
        ?>
</a>
					</td>
					<td class="hidden-phone">
						<?php 
        echo $this->escape(MonitorHelper::cutStr($item->text, 50));
        ?>
					</td>
					<td>
						<?php 
        echo $this->escape($item->created);
        ?>
					</td>
					<td>
						<?php 
        if ($item->status_id) {
            echo $this->escape($item->status_name);
        } else {
            echo "<em>" . JText::_('COM_MONITOR_STATUS_NO_CHANGE') . "</em>";
        }
        ?>
コード例 #3
0
 /**
  * Saves a classification entity.
  *
  * @param   JInput  $input  Holds the data to be saved.
  *
  * @return  int   ID of the inserted / saved object.
  *
  * @throws Exception
  */
 public function save($input)
 {
     $query = $this->db->getQuery(true);
     $user = JFactory::getUser();
     $values = array("title" => $input->getString('title'), "access" => $input->getString('access'), "project_id" => $input->getInt('project_id'));
     $values = $this->validate($values);
     if (!$values) {
         return false;
     }
     $id = $input->getInt('id');
     if ($id != 0) {
         $query->update('#__monitor_issue_classifications')->where('id = ' . $id);
     } else {
         $query->insert('#__monitor_issue_classifications');
     }
     $query->set(MonitorHelper::sqlValues($values, $query));
     $this->db->setQuery($query);
     $this->db->execute();
     if ($id != 0) {
         return $id;
     }
     return $this->db->insertid();
 }
コード例 #4
0
ファイル: issue.php プロジェクト: Harmageddon/com_monitor
 /**
  * Saves an issue entity.
  *
  * @param   JInput  $input  Holds the data to be saved.
  *
  * @return  int   ID of the inserted / saved object.
  *
  * @throws Exception
  */
 public function save($input)
 {
     $query = $this->db->getQuery(true);
     $user = JFactory::getUser();
     // Validate form data.
     $values = array("title" => $input->getString('title'), "text" => $input->getString('text'), "version" => $input->getString('version'), "project_id" => $input->getInt('project_id'), "classification" => $input->getInt('classification'));
     $values = $this->validate($values);
     if (!$values) {
         return false;
     }
     // Validate attachments.
     $params = $this->getParams();
     $enableAttachments = $params->get('issue_enable_attachments', 1);
     if ($enableAttachments) {
         $modelAttachments = new MonitorModelAttachments();
         $files = $input->files->get('file', null, 'raw');
         if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) {
             return false;
         }
     }
     $id = $input->getInt('id');
     if ($id != 0) {
         $query->update('#__monitor_issues')->where('id = ' . $id);
     } else {
         $values["author_id"] = $user->id;
         $query->insert('#__monitor_issues');
     }
     $values["created"] = JDate::getInstance()->toSql();
     $query->set(MonitorHelper::sqlValues($values, $query));
     $this->db->setQuery($query);
     $this->db->execute();
     if ($id == 0) {
         $id = $this->db->insertid();
     }
     if ($enableAttachments) {
         // Upload attachments
         $modelAttachments->upload($files, $id);
     }
     return $id;
 }
コード例 #5
0
ファイル: comment.php プロジェクト: Harmageddon/com_monitor
 /**
  * Saves a comment entity.
  *
  * @param   JInput  $input  Holds the data to be saved.
  *
  * @return  int|boolean  The ID of the inserted/updated comment on success, boolean false on failure.
  *
  * @throws Exception
  */
 public function save($input)
 {
     $user = JFactory::getUser();
     // Validate form data.
     $values = array("issue_id" => $input->getInt('issue_id'), "text" => $input->getString('text'));
     $values = $this->validate($values);
     if (!$values) {
         return false;
     }
     // Validate attachments.
     $params = $this->getParams();
     $enableAttachments = $params->get('comment_enable_attachments', 1);
     if ($enableAttachments) {
         $modelAttachments = new MonitorModelAttachments();
         $files = $input->files->get('file', null, 'raw');
         if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) {
             return false;
         }
     }
     if ($values["issue_id"] == 0) {
         throw new Exception(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));
     }
     if ($user->authorise('comment.edit.status', 'com_monitor')) {
         $values["status"] = $input->getInt('issue_status');
         if ($values["status"]) {
             $query = $this->db->getQuery(true);
             $query->update('#__monitor_issues')->where('id = ' . $values["issue_id"])->set('status = ' . $values["status"]);
             $this->db->setQuery($query);
             $this->db->execute();
         } else {
             unset($values["status"]);
         }
     }
     $query = $this->db->getQuery(true);
     $id = $input->getInt('id');
     if (!$this->canEdit($user, $id)) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     if ($id != 0) {
         $query->update('#__monitor_comments')->where('id = ' . $id);
     } else {
         $values["author_id"] = $user->id;
         $query->insert('#__monitor_comments');
     }
     $values["created"] = JDate::getInstance()->toSql();
     $query->set(MonitorHelper::sqlValues($values, $query));
     $this->db->setQuery($query);
     $this->db->execute();
     if ($id == 0) {
         $id = $this->db->insertid();
     }
     // Upload attachments
     if ($enableAttachments) {
         $modelAttachments->upload($files, $values["issue_id"], $id);
     }
     return $id;
 }
コード例 #6
0
ファイル: project.php プロジェクト: Harmageddon/com_monitor
 /**
  * Saves a project entity.
  *
  * @param   JInput  $input  Holds the data to be saved.
  *
  * @return  mixed   A database cursor resource on success, boolean false on failure.
  *
  * @throws Exception
  */
 public function save($input)
 {
     $query = $this->db->getQuery(true);
     $values = array("name" => $input->getString('name'), "alias" => $input->getString('alias'), "url" => $input->getString('url'), "logo" => $input->getString('logo'), "logo_alt" => $input->getString('logo_alt'), "description" => $input->get('description', '', 'raw'), "issue_template" => $input->get('issue_template', '', 'raw'));
     $values = $this->validate($values);
     if (!$values) {
         return false;
     }
     $id = $input->getInt('id');
     if ($id != 0) {
         $query->update('#__monitor_projects')->where('id = ' . $id);
     } else {
         $query->insert('#__monitor_projects');
     }
     if ($values['alias'] == null) {
         if (JFactory::getConfig()->get('unicodeslugs') == 1) {
             $values['alias'] = JFilterOutput::stringURLUnicodeSlug($values['name']);
         } else {
             $values['alias'] = JFilterOutput::stringURLSafe($values['name']);
         }
     }
     $twin = $this->resolveAlias($values['alias']);
     if ($twin && $twin != $id) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_MONITOR_ERROR_DUPLICATE_PROJECT_ALIAS'), 'error');
         return false;
     }
     $query->set(MonitorHelper::sqlValues($values, $query));
     $this->db->setQuery($query);
     return $this->db->execute();
 }
コード例 #7
0
ファイル: status.php プロジェクト: Harmageddon/com_monitor
 /**
  * Saves a status entity.
  *
  * @param   JInput  $input  Holds the data to be saved.
  *
  * @return  int   ID of the inserted / saved object.
  *
  * @throws Exception
  */
 public function save($input)
 {
     $query = $this->db->getQuery(true);
     $values = array("name" => $input->getString('name'), "helptext" => $input->getString('helptext'), "open" => $input->getBool('open'), "style" => $input->getString('style'), "project_id" => $input->getInt('project_id'));
     $values = $this->validate($values);
     if (!$values) {
         return false;
     }
     $id = $input->getInt('id');
     if ($id != 0) {
         $query->update('#__monitor_status')->where('id = ' . $id);
     } else {
         $query->insert('#__monitor_status');
         $orderQuery = $this->db->getQuery(true);
         $orderQuery->select('MAX(ordering)')->from('#__monitor_status')->where('project_id = ' . $values["project_id"]);
         $this->db->setQuery($orderQuery)->execute();
         $values["ordering"] = (int) $this->db->loadResult() + 1;
     }
     $query->set(MonitorHelper::sqlValues($values, $query));
     $this->db->setQuery($query);
     return $this->db->execute();
 }
コード例 #8
0
 /**
  * Marks an issue as unread for a single user.
  *
  * @param   int  $issueId    ID of the issue to mark.
  * @param   int  $userId     ID of the user for whom to set the mark.
  * @param   int  $commentId  ID of the new comment.
  *
  * @return  mixed  A database cursor resource on success, boolean false on failure.
  */
 private function markUnreadSingleUser($issueId, $userId, $commentId = null)
 {
     $values = array('issueId' => (int) $issueId, 'userId' => (int) $userId, 'commentId' => $commentId ? (int) $commentId : 'NULL');
     $query = $this->db->getQuery(true);
     $queryString = 'INSERT INTO `#__monitor_unread_issues` ' . 'SET ' . MonitorHelper::sqlValues($values, $query) . ' ON DUPLICATE KEY UPDATE `timestamp` = NOW()';
     $query->setQuery($queryString);
     return $this->db->setQuery($query)->execute();
 }
コード例 #9
0
 /**
  * Adds a subscription for a given project and user.
  * The user will be notified for new issues for the project.
  *
  * @param   int  $id    ID of the project.
  * @param   int  $user  ID of the subscribing user.
  *
  * @return   mixed  A database cursor resource on success, boolean false on failure.
  */
 public function subscribeProject($id, $user)
 {
     $values = array('item_id' => $id, 'user_id' => $user);
     $query = $this->db->getQuery(true);
     $query->insert('#__monitor_subscriptions_projects')->set(MonitorHelper::sqlValues($values, $query));
     return $this->db->setQuery($query)->execute();
 }
コード例 #10
0
	</tr>
	</thead>
	<tbody>
	<?php 
    foreach ($displayData['comments'] as $comment) {
        ?>
		<tr>
			<td>
				<?php 
        $link = 'index.php?option=com_monitor&view=issue&id=' . $comment->issue_id . '#comment-' . $comment->id;
        echo JHtml::_('link', JRoute::_($link), $comment->issue_title);
        ?>
			</td>
			<td>
				<?php 
        echo $this->escape(MonitorHelper::cutStr($comment->text, $params->get('comment_text_length', 100)));
        ?>
			</td>
			<td>
				<?php 
        echo JHtml::_('date', $comment->created, $dateFormat);
        ?>
			</td>
			<td>
				<?php 
        $view = $params->get('project_link_to', '');
        if ($view === 'project') {
            echo JHtml::_('link', JRoute::_('index.php?option=com_monitor&view=project&id=' . $comment->project_id), $comment->project_name);
        } elseif ($view === 'issues') {
            echo JHtml::_('link', JRoute::_('index.php?option=com_monitor&view=issues&project_id=' . $comment->project_id), $comment->project_name);
        } else {