예제 #1
0
파일: issue.php 프로젝트: Ricardolau/imc
 /**
  * Method to get an ojbect.
  *
  * @param	integer	The id of the object to get.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('issue.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = JArrayHelper::toObject($properties, 'JObject');
         } elseif ($error = $table->getError()) {
             $this->setError($error);
         }
     }
     if (is_object($this->_item)) {
         $step = ImcFrontendHelper::getStepByStepId($this->_item->stepid);
         if ($step) {
             $this->_item->stepid_title = $step['stepid_title'];
             $this->_item->stepid_color = $step['stepid_color'];
         }
         if (isset($this->_item->created_by)) {
             $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
         }
         $category = JCategories::getInstance('Imc')->get($this->_item->catid);
         if ($category) {
             $prms = json_decode($category->params);
             // if(isset($prms->imc_category_emails))
             //     $this->_item->notification_emails = explode("\n", $prms->imc_category_emails);
             // else
             //     $this->_item->notification_emails = array();
             if (isset($prms->image)) {
                 $this->_item->category_image = $prms->image;
             } else {
                 $this->_item->category_image = '';
             }
             $this->_item->catid_title = $category->title;
         } else {
             $this->_item->category_image = '';
             $this->_item->catid_title = 'CATEGORY IS NO LONGER PUBLISHED';
         }
     }
     return $this->_item;
 }
예제 #2
0
파일: timecreated.php 프로젝트: viru48/imc
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     $time_created = $this->value;
     if (!strtotime($time_created)) {
         $time_created = ImcFrontendHelper::convert2UTC(date("Y-m-d H:i:s"));
     }
     $hidden = (bool) $this->element['hidden'];
     if ($hidden == null || !$hidden) {
         $jdate = new JDate(ImcFrontendHelper::convertFromUTC($time_created));
         $pretty_date = $jdate->format(JText::_('DATE_FORMAT_LC2'));
         $html[] = "<span>" . $pretty_date . "</span>";
     }
     $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_created . '" />';
     return implode("\n", $html);
 }
예제 #3
0
파일: api.json.php 프로젝트: viru48/imc
 public function intervals()
 {
     $result = null;
     $app = JFactory::getApplication();
     try {
         self::validateRequest();
         if ($app->input->getMethod() != 'GET') {
             throw new Exception('You cannot use other method than GET to fetch intervals');
         }
         //get necessary arguments
         $by_step = $app->input->getString('by_step', null);
         $by_category = $app->input->getString('by_category', null);
         $by_step = $by_step === 'true';
         $by_category = $by_category === 'true';
         $ts = $app->input->getString('ts', null);
         $prior_to = $app->input->getString('prior_to', null);
         if (!is_null($ts) && !ImcFrontendHelper::isValidTimeStamp($ts)) {
             throw new Exception('Invalid timestamp ts');
         }
         if (!is_null($prior_to) && !ImcFrontendHelper::isValidTimeStamp($prior_to)) {
             throw new Exception('Invalid timestamp prior_to');
         }
         //get date from ts
         if (!is_null($ts)) {
             $ts = gmdate('Y-m-d H:i:s', $ts);
         }
         if (!is_null($prior_to)) {
             $prior_to = gmdate('Y-m-d H:i:s', $prior_to);
         }
         //handle unexpected warnings
         set_error_handler(array($this, 'exception_error_handler'));
         $result = ImcFrontendHelper::intervals($by_step, $by_category, $ts, $prior_to);
         restore_error_handler();
         echo new JResponseJson($result, 'Intervals fetched successfully');
     } catch (Exception $e) {
         header("HTTP/1.0 202 Accepted");
         echo new JResponseJson($e);
     }
 }
예제 #4
0
파일: issue.php 프로젝트: Ricardolau/imc
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     //A: inform log table about the new issue
     if ($validData['id'] == 0) {
         $log = JTable::getInstance('Log', 'ImcTable', array());
         $catTitle = ImcFrontendHelper::getCategoryNameByCategoryId($validData['catid']);
         $data2['id'] = 0;
         $data2['state'] = 1;
         $data2['action'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT');
         $data2['issueid'] = $model->getItem()->get('id');
         $data2['stepid'] = $validData['stepid'];
         $data2['description'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT') . ' ' . JText::_('COM_IMC_LOGS_AT_CATEGORY') . ' ' . $catTitle;
         $data2['created'] = $validData['created'];
         $data2['created_by'] = $validData['created_by'];
         $data2['updated'] = $validData['created'];
         $data2['language'] = $validData['language'];
         $data2['rules'] = $validData['rules'];
         if (!$log->bind($data2)) {
             JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
         }
         if (!$log->save($data2)) {
             JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
         }
         try {
             $dispatcher = JEventDispatcher::getInstance();
             $results = $dispatcher->trigger('onAfterNewIssueAdded', array($model, $validData));
             // Check the returned results. This is for plugins that don't throw
             // exceptions when they encounter serious errors.
             if (in_array(false, $results)) {
                 throw new Exception($dispatcher->getError(), 500);
             }
         } catch (Exception $e) {
             // Handle a caught exception.
             throw $e;
         }
     } else {
         //a. check for step modification
         if (isset($validData['is_step_modified']) && $validData['is_step_modified'] === 'true') {
             $user = JFactory::getUser();
             $log = JTable::getInstance('Log', 'ImcTable', array());
             $data2['id'] = 0;
             $data2['state'] = 1;
             $data2['action'] = JText::_('COM_IMC_LOGS_ACTION_STEP_MODIFIED');
             $data2['issueid'] = $validData['id'];
             $data2['stepid'] = $validData['stepid'];
             $data2['description'] = $validData['step_modified_description'];
             $data2['created'] = $validData['updated'];
             $data2['created_by'] = $user->id;
             $data2['updated'] = $validData['updated'];
             $data2['language'] = $validData['language'];
             $data2['rules'] = $validData['rules'];
             if (!$log->bind($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
             }
             if (!$log->save($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
             }
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onAfterStepModified', array($model, $validData));
         }
         //b. check for category modification
         if (isset($validData['is_category_modified']) && $validData['is_category_modified'] === 'true') {
             $user = JFactory::getUser();
             $log = JTable::getInstance('Log', 'ImcTable', array());
             $data2['id'] = 0;
             $data2['state'] = 1;
             $data2['action'] = JText::_('COM_IMC_LOGS_ACTION_CATEGORY_MODIFIED');
             $data2['issueid'] = $validData['id'];
             $data2['stepid'] = $validData['stepid'];
             $data2['description'] = $validData['category_modified_description'];
             $data2['created'] = $validData['updated'];
             $data2['created_by'] = $user->id;
             $data2['updated'] = $validData['updated'];
             $data2['language'] = $validData['language'];
             $data2['rules'] = $validData['rules'];
             if (!$log->bind($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
             }
             if (!$log->save($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
             }
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onAfterCategoryModified', array($model, $validData));
         }
     }
     //B: move any images only if record is new
     if ($validData['id'] == 0) {
         //check if any files uploaded
         $obj = json_decode($validData['photo']);
         if (empty($obj->files)) {
             return;
         }
         $srcDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $obj->id;
         $dstDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $model->getItem()->get('id');
         $success = rename($srcDir, $dstDir);
         if ($success) {
             //update photo json isnew, id
             unset($obj->isnew);
             $obj->id = $model->getItem()->get('id');
             $photo = json_encode($obj);
             // Create an object for the record we are going to update.
             $object = new stdClass();
             $object->id = $model->getItem()->get('id');
             $object->photo = $photo;
             // Update photo
             $result = JFactory::getDbo()->updateObject('#__imc_issues', $object, 'id');
         } else {
             JFactory::getApplication()->enqueueMessage('Cannot move ' . $srcDir . ' to ' . $dstDir . '. Check folder rights', 'error');
         }
     }
 }
예제 #5
0
파일: api.json.php 프로젝트: Ricardolau/imc
 public function issue()
 {
     $result = null;
     $app = JFactory::getApplication();
     try {
         $userid = self::validateRequest();
         //get necessary arguments
         $id = $app->input->getInt('id', null);
         switch ($app->input->getMethod()) {
             //fetch existing issue
             case 'GET':
                 if ($id == null) {
                     throw new Exception('Id is not set');
                 }
                 //get issue model
                 $issueModel = JModelLegacy::getInstance('Issue', 'ImcModel', array('ignore_request' => true));
                 //handle unexpected warnings from model
                 set_error_handler(array($this, 'exception_error_handler'));
                 $data = $issueModel->getData($id);
                 restore_error_handler();
                 if (!is_object($data)) {
                     throw new Exception('Issue does not exist');
                 }
                 $result = ImcFrontendHelper::sanitizeIssue($data, $userid);
                 //check for any restrictions
                 if (!$result->myIssue && $result->moderation) {
                     throw new Exception('Issue is under moderation');
                 }
                 if ($result->state != 1) {
                     throw new Exception('Issue is not published');
                 }
                 //be consistent return as array (of size 1)
                 $result = array($result);
                 break;
                 //create new issue
             //create new issue
             case 'POST':
                 if ($id != null) {
                     throw new Exception('You cannot use POST to fetch issue. Use GET instead');
                 }
                 //get necessary arguments
                 $args = array('catid' => $app->input->getInt('catid'), 'title' => $app->input->getString('title'), 'description' => $app->input->getString('description'), 'address' => $app->input->getString('address'), 'latitude' => $app->input->getString('lat'), 'longitude' => $app->input->getString('lng'));
                 ImcFrontendHelper::checkNullArguments($args);
                 $args['userid'] = $userid;
                 $args['created_by'] = $userid;
                 $args['stepid'] = ImcFrontendHelper::getPrimaryStepId();
                 $args['id'] = 0;
                 $args['created'] = date('Y-m-d H:i:s');
                 $args['updated'] = $args['created'];
                 $args['language'] = '*';
                 $args['note'] = 'modality=' . $app->input->getInt('m_id');
                 $args['subgroup'] = 0;
                 $args['photo'] = json_encode(array('isnew' => 1, 'id' => time(), 'imagedir' => 'images/imc', 'files' => array()), JSON_UNESCAPED_SLASHES);
                 // '{"isnew":1,"id":1440286789,"imagedir":"images/imc","files":[]}';
                 //get issueForm model
                 //JModelLegacy::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/models');
                 $issueFormModel = JModelLegacy::getInstance('IssueForm', 'ImcModel', array('ignore_request' => true));
                 //handle unexpected warnings from model
                 set_error_handler(array($this, 'exception_error_handler'));
                 $issueFormModel->save($args);
                 $insertid = JFactory::getApplication()->getUserState('com_imc.edit.issue.insertid');
                 //call post save hook
                 require_once JPATH_COMPONENT . '/controllers/issueform.php';
                 $issueFormController = new ImcControllerIssueForm();
                 $issueFormController->postSaveHook($issueFormModel, $args);
                 restore_error_handler();
                 $result = 'Newly submitted issue ID is ' . $insertid;
                 break;
                 //update existing issue
             //update existing issue
             case 'PUT':
             case 'PATCH':
                 if ($id == null) {
                     throw new Exception('Id is not set');
                 }
                 break;
             default:
                 throw new Exception('HTTP method is not supported');
         }
         echo new JResponseJson($result, 'Issue action completed successfully');
     } catch (Exception $e) {
         echo new JResponseJson($e);
     }
 }
예제 #6
0
파일: edit_print.php 프로젝트: viru48/imc
?>
		<span style="color: <?php 
echo $step['stepid_color'];
?>
"><?php 
echo $step['stepid_title'];
?>
</span>
		</p>

		<p><strong><?php 
echo JText::_('COM_IMC_FORM_LBL_ISSUE_CATID');
?>
</strong>: 
		<?php 
echo ImcFrontendHelper::getCategoryNameByCategoryId($this->item->catid);
?>
</p>
		
		<p><strong><?php 
echo JText::_('COM_IMC_FORM_LBL_ISSUE_ADDRESS');
?>
</strong>: 
		<?php 
echo $this->item->address;
?>
</p>
		
		<p><strong><?php 
echo JText::_('COM_IMC_FORM_LBL_ISSUE_DESCRIPTION');
?>
예제 #7
0
파일: edit.php 프로젝트: viru48/imc
?>
</th>
	        				<th><?php 
echo JText::_("COM_IMC_LOGS_DESCRIPTION");
?>
</th>
	        				</tr>
	        		</thead>
	        		<tbody>
	        			<?php 
foreach ($this->logs as $log) {
    ?>
	        			<tr>

	        				<td><?php 
    echo ImcFrontendHelper::convertFromUTC($log['created']);
    ?>
</td>
	        				<td><?php 
    echo $log['action'];
    ?>
</td>
	        				<td><?php 
    echo $log['created_by'];
    ?>
</td>
	        				<td>
	        					<span style="font-size: 20px;color: <?php 
    echo $log['stepid_color'];
    ?>
">&marker;</span>
예제 #8
0
 public function onAfterStepModified($model, $validData, $id = null)
 {
     $details = $this->getDetails($id, $model);
     $app = JFactory::getApplication();
     $showMsgsFrontend = $this->params->get('messagesfrontend') && !$app->isAdmin();
     $showMsgsBackend = $this->params->get('messagesbackend') && $app->isAdmin();
     $step = ImcFrontendHelper::getStepByStepId($validData['stepid']);
     $MENUALIAS = $this->params->get('menualias');
     $appSite = JApplication::getInstance('site');
     $router = $appSite->getRouter();
     $uri = $router->build('index.php?option=com_imc&view=issue&id=' . (int) ($id == null ? $validData['id'] : $id));
     $parsed_url = $uri->toString();
     $parsed_url = str_replace('administrator/', '', $parsed_url);
     $parsed_url = str_replace('component/imc', $MENUALIAS, $parsed_url);
     $issueLink = $_SERVER['HTTP_HOST'] . $parsed_url;
     //Prepare email for admins
     if ($this->params->get('mailstatuschangeadmins')) {
         $subject = sprintf(JText::_('PLG_IMC_MAIL_NOTIFIER_ADMINS_STEP_MODIFIED_SUBJECT'), $id == null ? $validData['id'] : $id);
         $body = sprintf(JText::_('PLG_IMC_MAIL_NOTIFIER_ADMINS_STEP_MODIFIED_BODY'), $validData['title'], $step['stepid_title'], JFactory::getUser()->name);
         if (empty($details->emails) || $details->emails[0] == '') {
             if ($showMsgsBackend) {
                 $app->enqueueMessage(JText::_('PLG_IMC_MAIL_NOTIFIER_ADMINS_MAIL_NOT_SET') . ImcFrontendHelper::getCategoryNameByCategoryId($validData['catid']), 'warning');
             }
         } else {
             $recipients = implode(',', $details->emails);
             if ($this->sendMail($subject, $body, $details->emails)) {
                 if ($showMsgsBackend) {
                     $app->enqueueMessage(JText::_('PLG_IMC_MAIL_NOTIFIER_ADMINS_MAIL_CONFIRM') . $recipients);
                 }
             } else {
                 if ($showMsgsBackend) {
                     $app->enqueueMessage(JText::_('PLG_IMC_MAIL_NOTIFIER_MAIL_FAILED') . $recipients, 'error');
                 }
             }
         }
     }
     //Prepare email for user
     if ($this->params->get('mailstatuschangeuser')) {
         $subject = sprintf(JText::_('PLG_IMC_MAIL_NOTIFIER_USER_STEP_MODIFIED_SUBJECT'), $id == null ? $validData['id'] : $id);
         $body = sprintf(JText::_('PLG_IMC_MAIL_NOTIFIER_USER_STEP_MODIFIED_BODY'), $validData['title'], $step['stepid_title'], $issueLink);
         $body .= '<a href="http://' . $issueLink . '">' . $issueLink . '</a>';
         if ($this->sendMail($subject, $body, $details->usermail)) {
             if ($showMsgsBackend) {
                 $app->enqueueMessage(JText::_('PLG_IMC_MAIL_NOTIFIER_MAIL_STEP_MODIFIED_CONFIRM') . $details->usermail . ' (' . $details->username . ')');
             }
             if ($showMsgsFrontend) {
                 $app->enqueueMessage(JText::_('PLG_IMC_MAIL_NOTIFIER_MAIL_STEP_MODIFIED_CONFIRM') . $details->usermail . ' (' . $details->username . ')');
             }
         } else {
             $app->enqueueMessage(JText::_('PLG_IMC_MAIL_NOTIFIER_MAIL_FAILED') . $recipients, 'error');
         }
     }
 }
예제 #9
0
파일: issueform.php 프로젝트: viru48/imc
 public function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $insertid = JFactory::getApplication()->getUserState('com_imc.edit.issue.insertid');
     //A: inform log table about the new issue
     if ($validData['id'] == 0) {
         JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
         $log = JTable::getInstance('Log', 'ImcTable', array());
         $catTitle = ImcFrontendHelper::getCategoryNameByCategoryId($validData['catid']);
         $data2['id'] = 0;
         $data2['state'] = 1;
         $data2['action'] = 'step';
         //enum(step|category)
         $data2['issueid'] = $insertid;
         //$model->getItem()->get('id');
         $data2['stepid'] = $validData['stepid'];
         $data2['description'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT') . ' ' . JText::_('COM_IMC_LOGS_AT_CATEGORY') . ' ' . $catTitle;
         $data2['created'] = $validData['created'];
         $data2['created_by'] = $validData['created_by'];
         $data2['updated'] = $validData['created'];
         $data2['language'] = $validData['language'];
         if (isset($data2['rules'])) {
             $data2['rules'] = $validData['rules'];
         }
         if (!$log->bind($data2)) {
             JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
         }
         if (!$log->save($data2)) {
             JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
         }
         $dispatcher = JEventDispatcher::getInstance();
         $results = $dispatcher->trigger('onAfterNewIssueAdded', array($model, $validData, $insertid));
     } else {
         //a. check for step modification
         if (isset($validData['is_step_modified']) && $validData['is_step_modified'] === 'true') {
             $user = JFactory::getUser();
             $log = JTable::getInstance('Log', 'ImcTable', array());
             $data2['id'] = 0;
             $data2['state'] = 1;
             $data2['action'] = 'step';
             //enum(step|category)
             $data2['issueid'] = $validData['id'];
             $data2['stepid'] = $validData['stepid'];
             $data2['description'] = $validData['step_modified_description'];
             $data2['created'] = $validData['updated'];
             $data2['created_by'] = $user->id;
             $data2['updated'] = $validData['updated'];
             $data2['language'] = $validData['language'];
             if (isset($data2['rules'])) {
                 $data2['rules'] = $validData['rules'];
             }
             if (!$log->bind($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
             }
             if (!$log->save($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
             }
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onAfterStepModified', array($model, $validData, $insertid));
         }
         //b. check for category modification
         if (isset($validData['is_category_modified']) && $validData['is_category_modified'] === 'true') {
             $user = JFactory::getUser();
             $log = JTable::getInstance('Log', 'ImcTable', array());
             $data2['id'] = 0;
             $data2['state'] = 1;
             $data2['action'] = 'category';
             //enum(step|category)
             $data2['issueid'] = $validData['id'];
             $data2['stepid'] = $validData['stepid'];
             $data2['description'] = $validData['category_modified_description'];
             $data2['created'] = $validData['updated'];
             $data2['created_by'] = $user->id;
             $data2['updated'] = $validData['updated'];
             $data2['language'] = $validData['language'];
             $data2['rules'] = $validData['rules'];
             if (!$log->bind($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
             }
             if (!$log->save($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
             }
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onAfterCategoryModified', array($model, $validData, $insertid));
         }
     }
     //B: move any images only if record is new
     if ($validData['id'] == 0) {
         //check if any files uploaded
         $obj = json_decode($validData['photo']);
         if (empty($obj->files)) {
             return;
         }
         $srcDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $obj->id;
         $dstDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $insertid;
         $success = rename($srcDir, $dstDir);
         if ($success) {
             //update photo json isnew, id
             unset($obj->isnew);
             //update files url
             foreach ($obj->files as &$file) {
                 $file->url = str_replace($obj->id, $insertid, $file->url);
                 $file->mediumUrl = str_replace($obj->id, $insertid, $file->mediumUrl);
                 $file->thumbnailUrl = str_replace($obj->id, $insertid, $file->thumbnailUrl);
             }
             //update id
             $obj->id = $insertid;
             $photo = json_encode($obj);
             // Create an object for the record we are going to update.
             $object = new stdClass();
             $object->id = $insertid;
             $object->photo = $photo;
             // Update photo
             $result = JFactory::getDbo()->updateObject('#__imc_issues', $object, 'id');
         } else {
             JFactory::getApplication()->enqueueMessage('Cannot move ' . $srcDir . ' to ' . $dstDir . '. Check folder rights', 'error');
         }
     }
 }
예제 #10
0
파일: imc.php 프로젝트: viru48/imc
 public static function getRelativeTime($time)
 {
     if (strtotime($time) <= 0) {
         return '';
     }
     $time = ImcFrontendHelper::convertFromUTC($time);
     // Load the parameters.
     $app = JFactory::getApplication();
     /*		$params	= $app->getParams();
     		$showrelativedates = $params->get('showrelativedates');		
     		$dateformat = $params->get('dateformat');		
     		
     		if(!$showrelativedates){
     			//$item->reported_rel = date("d/m/Y",strtotime($item->reported));
     			return date($dateformat,strtotime($time));
     		}
     */
     $SECOND = 1;
     $MINUTE = 60 * $SECOND;
     $HOUR = 60 * $MINUTE;
     $DAY = 24 * $HOUR;
     $MONTH = 30 * $DAY;
     $delta = time() - strtotime($time);
     if ($delta < 1 * $MINUTE) {
         return $delta == 1 ? JText::_('ONE_SECOND_AGO') : sprintf(JText::_('SECONDS_AGO'), $delta);
     }
     if ($delta < 2 * $MINUTE) {
         return JText::_('A_MINUTE_AGO');
     }
     if ($delta < 45 * $MINUTE) {
         return sprintf(JText::_('MINUTES_AGO'), floor($delta / $MINUTE));
     }
     if ($delta < 90 * $MINUTE) {
         return JText::_('AN_HOUR_AGO');
     }
     if ($delta < 24 * $HOUR) {
         return sprintf(JText::_('HOURS_AGO'), floor($delta / $HOUR));
     }
     if ($delta < 48 * $HOUR) {
         return JText::_('YESTERDAY');
     }
     if ($delta < 30 * $DAY) {
         return sprintf(JText::_('DAYS_AGO'), floor($delta / $DAY));
     }
     if ($delta < 12 * $MONTH) {
         $months = floor($delta / $DAY / 30);
         return $months <= 1 ? JText::_('ONE_MONTH_AGO') : sprintf(JText::_('MONTHS_AGO'), $months);
     } else {
         $years = floor($delta / $DAY / 365);
         if ($years < 100) {
             //TODO: needed for versions older than PHP5.3
             return $years <= 1 ? JText::_('ONE_YEAR_AGO') : sprintf(JText::_('YEARS_AGO'), $years);
         } else {
             return '';
         }
     }
 }
예제 #11
0
 public function comments()
 {
     try {
         // Check for request forgeries.
         if (!JSession::checkToken('get')) {
             throw new Exception('Invalid session token');
         }
         $app = JFactory::getApplication();
         $issueid = $app->input->getInt('issueid', null);
         if (is_null($issueid)) {
             throw new Exception('Invalid issueid');
         }
         $userid = $app->input->getInt('userid', 0);
         //$commentsModel = JModelLegacy::getInstance( 'Comments', 'ImcModel', array('ignore_request' => true) );
         $commentsModel = $this->getModel();
         $commentsModel->setState('imc.filter.issueid', $issueid);
         $commentsModel->setState('imc.filter.userid', $userid);
         $commentsModel->setState('imc.filter.state', 1);
         $items = $commentsModel->getItems();
         //$items contains too much overhead, set only necessary data
         $comments = array();
         foreach ($items as $item) {
             $comment = new StdClass();
             $comment->id = $item->id;
             $comment->created = ImcFrontendHelper::convertFromUTC($item->created);
             $comment->fullname = $item->fullname;
             $comment->description = $item->description;
             $comment->profile_picture_url = JURI::base() . 'components/com_imc/assets/images/user-icon.png';
             if ($item->moderation) {
                 $comment->profile_picture_url = JURI::base() . 'components/com_imc/assets/images/user-icon-moderated.png';
             }
             if ($item->isAdmin) {
                 $comment->profile_picture_url = JURI::base() . 'components/com_imc/assets/images/admin-user-icon.png';
             }
             if ($item->parentid > 0) {
                 $comment->parentid = $item->parentid;
             }
             $comment->created_by_admin = (bool) $item->isAdmin;
             $comment->created_by_current_user = $item->created_by == $userid ? true : false;
             $comments[] = $comment;
         }
         echo new JResponseJson($comments);
     } catch (Exception $e) {
         header("HTTP/1.0 403 Accepted");
         echo new JResponseJson($e);
     }
 }
예제 #12
0
파일: default.php 프로젝트: viru48/imc
<?php

/**
 * @version     3.0.0
 * @package     com_imc
 * @copyright   Copyright (C) 2014. All rights reserved.
 * @license     GNU AFFERO GENERAL PUBLIC LICENSE Version 3; see LICENSE
 * @author      Ioannis Tsampoulatidis <*****@*****.**> - https://github.com/itsam
 */
// no direct access
defined('_JEXEC') or die;
require_once JPATH_COMPONENT_SITE . '/helpers/imc.php';
//TODO: Set this on settings
$firstStep = ImcFrontendHelper::getStepByStepId($this->item->stepid);
if ($firstStep['ordering'] != 1 && isset($this->item->id) && $this->item->id > 0) {
    ?>
	<div class="alert alert-danger"><?php 
    echo JText::_('COM_IMC_ISSUE_CANNOT_EDIT_ANYMORE');
    ?>
</div>
	<?php 
    return;
    ?>
	
<?php 
}
?>

<?php 
JHtml::_('behavior.keepalive');
JHtml::_('behavior.tooltip');
예제 #13
0
파일: default.php 프로젝트: viru48/imc
            ?>
</p>
		    				<?php 
            $first = false;
            ?>
		    			<?php 
        }
        ?>
						

						<p><?php 
        echo $log['description'];
        ?>
</p>
						<span class="cd-date"><?php 
        echo ImcFrontendHelper::getRelativeTime($log['created']);
        ?>
</span>
					</div>
				</div>
			<?php 
        $first = false;
        ?>
	
			<?php 
    }
    ?>
		</section>
	    </div>
    </div>
    </div> <!-- /container -->
예제 #14
0
파일: default.php 프로젝트: Ricardolau/imc
                        <?php 
    if (JFactory::getUser()->id == $item->created_by && $item->votes > 0) {
        ?>
                        <span class="label label-default" title="<?php 
        echo JText::_('COM_IMC_ISSUES_VOTES');
        ?>
">+<?php 
        echo $item->votes;
        ?>
</span>
                        <?php 
    }
    ?>

                        <p><?php 
    echo ImcFrontendHelper::cutString($item->description, 200);
    ?>
</p>

                        <p><a href="<?php 
    echo JRoute::_('index.php?option=com_imc&view=issue&id=' . (int) $item->id);
    ?>
"><?php 
    echo JText::_('COM_IMC_ISSUES_MORE');
    ?>
</a></p>
                        <?php 
    if ($item->moderation == 1) {
        ?>
                            <hr />
                            <p class="imc-warning"><i class="icon-info-sign"></i> <?php