Example #1
0
 function onNewEntry($workflow, $args)
 {
     $categoriesArray = explode(',', $categories);
     $entry = $args[0];
     if (!in_array($entry->catid, $categoriesArray)) {
         return false;
     }
     //Check to see if this a new Article or an old one being modified
     $id = JRequest::getInt('id', 0, 'post');
     //Exit if this is an old one
     if ($id != 0) {
         return false;
     }
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'item.php';
     $model = new JWFModelItem();
     $firstStation = reset($workflow->stations);
     return $model->enter($workflow->id, $firstStation->id, $entry->id, $entry->title, $entry->version);
 }
Example #2
0
 function onNewEntry($workflow, $args)
 {
     $categoriesArray = explode(',', $workflow->category);
     $entry = $args[0];
     if (!in_array($entry->cat_id, $categoriesArray)) {
         return false;
     }
     //Check to see if this a new Article or an old one being modified
     $id = JRequest::getInt('id', 0, 'post');
     //Create History Entry
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'history.php';
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'item.php';
     $historyModel = new JWFModelHistory();
     $itemModel = new JWFModelItem();
     if ($id == 0) {
         $historyTitle = JText::_('New Item Created');
         $historyMsg = new stdClass();
         $historyMsg->type = 'create';
         $historyMsg->title = $_POST['title'];
         $historyMsg->version = 0;
         $historyItemId = lastInsertId();
         $currentStation = reset($workflow->stations);
         //First station
     } else {
         $historyTitle = JText::_('Item modified');
         $historyMsg = new stdClass();
         $historyMsg->type = 'modify';
         $historyMsg->title = $_POST['title'];
         $historyMsg->version = $this->getLatestRevisionId($id);
         $historyItemId = $id;
         $stationId = $itemModel->getCurrentStationId($workflow->id, $id);
         $currentStation = $workflow->stations[$stationId];
     }
     if ($currentStation != null) {
         $historyModel->add($workflow->id, $currentStation, $historyItemId, 'component.content', $historyTitle, $historyMsg);
     }
     //Done creating history entry
     //Exit if this is an old one
     if ($id != 0) {
         return false;
     }
     $firstStation = reset($workflow->stations);
     $db =& JFactory::getDBO();
     $sql = "UPDATE #__aards_ads a SET a.published=0 WHERE a.id  = {$id}";
     $db->setQuery($sql);
     $db->query();
     return $itemModel->enter($workflow->id, $firstStation->id, $entry->id, $entry->ad_name, 0);
 }