Exemplo n.º 1
0
 /**
  * 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('poi.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 = CitybrandingFrontendHelper::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('Citybranding')->get($this->_item->catid);
         if ($category) {
             $prms = json_decode($category->params);
             // if(isset($prms->citybranding_category_emails))
             //     $this->_item->notification_emails = explode("\n", $prms->citybranding_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;
 }
Exemplo n.º 2
0
 * @author      Ioannis Tsampoulatidis <*****@*****.**> - https://github.com/itsam
 */
// no direct access
defined('_JEXEC') or die;
//Load admin language file
$lang = JFactory::getLanguage();
$lang->load('com_citybranding', JPATH_ADMINISTRATOR);
$user = JFactory::getUser();
$canEdit = $user->authorise('core.edit', 'com_citybranding.poi.' . $this->item->id);
$canChange = $user->authorise('core.edit.state', 'com_citybranding.poi.' . $this->item->id);
$canEditOwn = $user->authorise('core.edit.own', 'com_citybranding.poi.' . $this->item->id);
if (!$canEdit && $user->authorise('core.edit.own', 'com_citybranding.poi.' . $this->item->id)) {
    $canEdit = $user->id == $this->item->created_by;
}
//Edit Own only if poi status is the initial one
$firstStep = CitybrandingFrontendHelper::getStepByStepId($this->item->stepid);
$canEditOnStatus = true;
if ($firstStep['ordering'] != 1) {
    $canEditOnStatus = false;
}
//poi statuses
JFormHelper::addFieldPath(JPATH_ROOT . '/components/com_citybranding/models/fields');
$step = JFormHelper::loadFieldType('Step', false);
$statuses = $step->getOptions();
?>

<script type="text/javascript">
    js = jQuery.noConflict();
    js(document).ready(function() {
		js('#gallery').photobox('a', { thumbs:true, loop:false }, callback);
		// using setTimeout to make sure all images were in the DOM, before the history.load() function is looking them up to match the url hash
 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 = CitybrandingFrontendHelper::getStepByStepId($validData['stepid']);
     $MENUALIAS = $this->params->get('menualias');
     $appSite = JApplication::getInstance('site');
     $router = $appSite->getRouter();
     $uri = $router->build('index.php?option=com_citybranding&view=poi&id=' . (int) ($id == null ? $validData['id'] : $id));
     $parsed_url = $uri->toString();
     $parsed_url = str_replace('administrator/', '', $parsed_url);
     $parsed_url = str_replace('component/citybranding', $MENUALIAS, $parsed_url);
     $poiLink = $_SERVER['HTTP_HOST'] . $parsed_url;
     //Prepare email for admins
     if ($this->params->get('mailstatuschangeadmins')) {
         $subject = sprintf(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_ADMINS_STEP_MODIFIED_SUBJECT'), $id == null ? $validData['id'] : $id);
         $body = sprintf(JText::_('PLG_CITYBRANDING_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_CITYBRANDING_MAIL_NOTIFIER_ADMINS_MAIL_NOT_SET') . CitybrandingFrontendHelper::getCategoryNameByCategoryId($validData['catid']), 'warning');
             }
         } else {
             $recipients = implode(',', $details->emails);
             if ($this->sendMail($subject, $body, $details->emails)) {
                 if ($showMsgsBackend) {
                     $app->enqueueMessage(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_ADMINS_MAIL_CONFIRM') . $recipients);
                 }
             } else {
                 if ($showMsgsBackend) {
                     $app->enqueueMessage(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_MAIL_FAILED') . $recipients, 'error');
                 }
             }
         }
     }
     //Prepare email for user
     if ($this->params->get('mailstatuschangeuser')) {
         $subject = sprintf(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_USER_STEP_MODIFIED_SUBJECT'), $id == null ? $validData['id'] : $id);
         $body = sprintf(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_USER_STEP_MODIFIED_BODY'), $validData['title'], $step['stepid_title'], $poiLink);
         $body .= '<a href="http://' . $poiLink . '">' . $poiLink . '</a>';
         if ($this->sendMail($subject, $body, $details->usermail)) {
             if ($showMsgsBackend) {
                 $app->enqueueMessage(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_MAIL_STEP_MODIFIED_CONFIRM') . $details->usermail . ' (' . $details->username . ')');
             }
             if ($showMsgsFrontend) {
                 $app->enqueueMessage(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_MAIL_STEP_MODIFIED_CONFIRM') . $details->usermail . ' (' . $details->username . ')');
             }
         } else {
             $app->enqueueMessage(JText::_('PLG_CITYBRANDING_MAIL_NOTIFIER_MAIL_FAILED') . $recipients, 'error');
         }
     }
 }