test
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • brentwilliams2 Friend
    #192286

    At the bottom of a job, rather than delete, I need to change it to unpublish. I believe I have added the following correctly, but can you take a look and answer my questions?

    I first changed /administrator/components/com_jajobboard/models/jajobs.php and added this function:

    function unpublish($task = 'unpublish')
    {
    $cid = JRequest::getVar('cid', array(), 'post', 'array');
    $n = count($cid);
    JArrayHelper::toInteger($cid);

    if ($n) {
    if ($task == 'unpublish') {
    $query = "UPDATE #__ja_jobs SET status = 'Non-Approved' WHERE job_id IN(" . implode(" OR id = ", $cid) . ")";
    //$query .= "; UPDATE #__ja_shortlist SET item_id = null, listtype = null WHERE listtype = 'ja_jobs' AND item_id IN(" . implode(" OR id = ", $cid) . ")";

    $db = JFactory::getDbo();
    $db->setQuery($query);
    $n = $db->queryBatch();

    //include_once JPATH_COMPONENT_SITE.'/helper/jb.updater.php';
    //jbAutoUpdate::deleteAllCounter();

    return $n;
    }
    }

    return 0;
    }

    I created this from the original delete function, and two parts I’m not sure if I still need. I have them currently commented out above.
    1) query that references the shortlist
    2) reference to the jb.updater.php

    Are these two parts necessary for unpublishing a job?

    Next, I opened /administrator/components/com_jajobboard/controllers/jajobs.php and added the following function:

    function unpublish()
    {
    // Check for request forgeries
    JRequest::checkToken() or jexit('Invalid Token');

    $cid = JRequest::getVar('cid', array(), 'post', 'array');
    JArrayHelper::toInteger($cid);
    $msg = '';

    foreach ($cid as $id) {
    $applist = getItemByFieldName('ja_applications', 'job_id', $id);
    }

    $model = & $this->getModel('jajobs');

    if (($n = $model->unpublish()) < 0) {
    JError::raiseWarning(500, $n->getError());
    }

    if ($n == 1) {
    $this->setMessage(JText::_('SUCCESSFULLY_REMOVED_ITEM'));
    } else {
    $this->setMessage(JText::_('SUCCESSFULLY_REMOVED_ITEMS'));
    }

    $this->setRedirect("index.php?option=" . JBCOMNAME . "&view=jajobs");
    }

    Again, this was modeled off of the delete function. Does this look ok?

    Lastly, I modified views/jajobs/tmpl/themes/inline/jalist-item.php.

    I changed this code:

    <a class="btn-function" href="javascript:submitbutton_view('remove',<?php echo $item->id; ?>);" onclick="return confirm('<?php echo JText::_('DO_YOU_WANT_TO_DELETE_THIS_JOB', TRUE).'?';?>')">
    <span style="vertical-align: top !important;"><?php echo JText::_('DELETE_JOB'); ?></span>
    </a>  

    To this:

    <a class="btn-function" href="javascript:submitbutton_view('unpublish',<?php echo $item->id; ?>);" onclick="return confirm('<?php echo JText::_('DO_YOU_WANT_TO_DELETE_THIS_JOB', TRUE).'?';?>')">
    <span style="vertical-align: top !important;"><?php echo JText::_('DELETE_JOB'); ?></span>
    </a>  

    I realize I still have to change some language elements in all of this, but do you see a problem with this concept? Will it have any unintended consequences?

    UPDATE: I’ve tried this method on my development server, but for some reason, it always tries to duplicate the job instead. Not sure what is going on…

    HeR0 Friend
    #512285

    Dear Brent,

    You don’t need add new function because this featured is supported. Please change in the layout file

    <img title="<?php echo JText::_('DELETE_JOB'); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/icon_delete.gif' ?>" alt="<?php echo JText::_('DELETE_JOB'); ?>" />  
    <a class="btn-function" href="javascript:submitbutton_view('remove',<?php echo $item->id; ?>);" onclick="return confirm('<?php echo JText::_('DO_YOU_WANT_TO_DELETE_THIS_JOB', TRUE).'?';?>')">
    <span style="vertical-align: top !important;"><?php echo JText::_('DELETE_JOB'); ?></span>
    </a>  

    To

    <a class="btn-function" href="javascript:submitbutton_view('<?php echo (trim(strtolower($item->status))=="approved") ? "non-approved" : "approved"?>',<?php echo $item->id; ?>);" >
    <span style="vertical-align: top !important;"><?php echo (trim(strtolower($item->status))=="approved") ? JText::_('JPUBLISHED') : JText::_('JUNPUBLISHED') ?></span>
    </a>  

    Hope this helps 🙂

    brentwilliams2 Friend
    #512372

    That does help – thank you!!!

    One question: What happens if the job is expired and someone tries to approve it?

    HeR0 Friend
    #512516

    The Job will auto expire when the current date is ahead of Job Expire Date. So the Job will auto expired if someone tries to approve it. Also someone should change job status when the Job in the published date range is changed.

Viewing 4 posts - 1 through 4 (of 4 total)

This topic contains 4 replies, has 2 voices, and was last updated by  HeR0 11 years ago.

We moved to new unified forum. Please post all new support queries in our New Forum