/**
  * Renders the element
  *
  * @access	public
  * @param string $name name of the element combined with $control_name like "$control_name[$name]"
  * @param mixed $value pre-selected value of the element
  * @param object $node reference to the XML node that defined this element
  * @param string $control_name HTML element Array name , combined with $name like "$control_name[$name]"
  * @return string HTML output that renders the element
  */
 function fetchElement($name, $value, &$node, $control_name)
 {
     $htmlId = $node->attributes('id') ? 'id="' . $node->attributes('id') . '"' : '';
     $pManager =& getPluginManager();
     $pManager->loadPlugins('component');
     $output = JHTML::_('jwf.startJSBlock', 2);
     $output .= JHTML::_('jwf.indentedLine', "defaultWorkflow.category = '{$value}';", 3);
     $output .= JHTML::_('jwf.indentedLine', 'var categoriesData = {', 3);
     $categoryLists = $pManager->invokeMethod('component', 'getCategories', null, null);
     foreach ($categoryLists as $contentType => $data) {
         if ($data) {
             $output .= JHTML::_('jwf.indentedLine', "{$contentType}:{", 4);
             foreach ($data as $id => $obj) {
                 $output .= JHTML::_('jwf.indentedLine', $obj->getId() . ' : \'' . $obj->getTitle() . '\',', 5);
                 if (count($obj->getChildren())) {
                     $output .= $this->fetchChildren($obj, 1);
                 }
             }
             if (count($data)) {
                 $output = JHTML::_('jwf.trimComma', $output);
             }
             $output .= JHTML::_('jwf.indentedLine', "},", 4);
         }
     }
     $output = JHTML::_('jwf.trimComma', $output);
     $output .= JHTML::_('jwf.indentedLine', '};', 3);
     $output .= JHTML::_('jwf.endJSBlock', 2);
     $output .= JHTML::_('jwf.indentedLine', "<select multiple='multiple' name='{$control_name}[{$name}][]' {$htmlId} size='5'></select>", 2);
     return $output;
 }
Beispiel #2
0
 function onArrival($hookParameters, $workflow, $currentStation, $currentStep)
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $tempResponse = null;
     $tempResponse = $pManager->invokeMethod('acl', 'getUsers', array($workflow->acl), array($currentStation->group));
     $userList = $tempResponse[$workflow->acl];
     $tempResponse = $pManager->invokeMethod('acl', 'getUsers', array($workflow->acl), array($workflow->admin_gid));
     $adminList = $tempResponse[$workflow->acl];
     $mail = JFactory::getMailer();
     if (intval($hookParameters->SendAdmin) && count($adminList)) {
         $mail->IsHTML(true);
         foreach ($adminList as $admin) {
             $mail->AddRecipient($admin->email);
         }
         $mail->SetSubject(JText::_('Item moved'));
         $translatedMessage = $this->_translate($hookParameters->AdminText, $hookParameters, $workflow, $currentStation, $currentStep);
         $mail->SetBody($translatedMessage);
         $mail->Send();
     }
     if (intval($hookParameters->SendUser) && count($userList)) {
         $mail->IsHTML(true);
         foreach ($userList as $user) {
             $mail->AddRecipient($user->email);
         }
         $mail->SetSubject(JText::_('New task awaits'));
         $translatedMessage = $this->_translate($hookParameters->UserText, $hookParameters, $workflow, $currentStation);
         $mail->SetBody($translatedMessage);
         $mail->Send();
     }
 }
 /**
  * Renders the element
  * 
  * @access	public
  * @param string $name name of the element combined with $control_name like "$control_name[$name]"
  * @param mixed $value pre-selected value of the element
  * @param object $node reference to the XML node that defined this element
  * @param string $control_name HTML element Array name , combined with $name like "$control_name[$name]"
  * @return string HTML output that renders the element
  */
 function fetchElement($name, $value, &$node, $control_name)
 {
     $htmlId = $node->attributes('id') ? $node->attributes('id') : '';
     $disabled = $value ? 'disabled="disabled"' : '';
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $aclData = $pManager->invokeMethod('acl', 'getACL', null, null);
     $aclHandlersList = array();
     $aclHandlersList[] = JHTML::_('select.option', 0, JText::_('Please Select'));
     $jsOutput = JHTML::_('jwf.indentedLine', 'var aclLists = {', 3);
     foreach ($pManager->settings['acl'] as $p) {
         if ($aclData[$p->id] == null) {
             continue;
         }
         $jsOutput .= JHTML::_('jwf.indentedLine', "'{$p->id}' : {", 4);
         foreach ($aclData[$p->id] as $groupID => $groupTitle) {
             $jsOutput .= JHTML::_('jwf.indentedLine', "{$groupID} : '{$groupTitle}',", 5);
         }
         $jsOutput = JHTML::_('jwf.trimComma', $jsOutput);
         $jsOutput .= JHTML::_('jwf.indentedLine', '},', 4);
         $aclHandlersList[] = JHTML::_('select.option', $p->id, $p->name);
     }
     $jsOutput = JHTML::_('jwf.trimComma', $jsOutput);
     $jsOutput .= JHTML::_('jwf.indentedLine', '};', 3);
     $output = JHTML::_('jwf.startJSBlock', 2);
     $output .= JHTML::_('jwf.indentedLine', "defaultWorkflow.acl = '{$value}';", 3);
     $output .= $jsOutput;
     $output .= JHTML::_('jwf.endJSBlock', 2);
     $output .= JHTML::_('select.genericlist', $aclHandlersList, "{$control_name}[{$name}]", "{$disabled} class='inputbox' size='1' onchange='selectACLSystemFromList(this)'", 'value', 'text', $value, $htmlId);
     return $output;
 }
Beispiel #4
0
 /**
  * Task handler ( Responds to an Ajax Request )
  * This method act as an AJAX server for "Fields" , recieves requests and redirects them to the correct field handler
  *
  * @see JWFFieldHandler
  * @return void
  */
 function invoke()
 {
     JRequest::checkToken('get') or jexit('0');
     $wid = JRequest::getInt('workflowID', 0);
     $sid = JRequest::getInt('stationID', 0);
     $iid = JRequest::getInt('itemID', 0);
     $tid = JRequest::getInt('stepID', 0);
     $fieldType = JRequest::getVar('fieldType');
     $method = JRequest::getVar('method');
     $data = JRequest::getVar('data');
     $data['wid'] = $wid;
     $data['sid'] = $sid;
     $data['iid'] = $iid;
     $data['tid'] = $tid;
     $iModel =& $this->getModel('item');
     $wModel =& $this->getModel('workflow');
     $fModel =& $this->getModel('field');
     $steps = $iModel->get($wid, $iid);
     $workflow = $wModel->get($wid);
     $fieldData = $fModel->get($wid, $iid);
     $pManager =& getPluginManager();
     $pManager->loadPlugins('field');
     if (array_key_exists($fieldType, $pManager->settings['field'])) {
         $storedData = isset($fieldData) && isset($fieldData[$fieldType]) ? $fieldData[$fieldType] : null;
         $response = $pManager->invokeMethod('field', $method, array($fieldType), array($workflow, $steps, $storedData, $data));
     }
     echo $response[$fieldType];
     jexit(0);
 }
 /**
  * Renders the element
  * 
  * @access	public
  * @param string $name name of the element combined with $control_name like "$control_name[$name]"
  * @param mixed $value pre-selected value of the element
  * @param object $node reference to the XML node that defined this element
  * @param string $control_name HTML element Array name , combined with $name like "$control_name[$name]"
  * @return string HTML output that renders the element
  */
 function fetchElement($name, $value, &$node, $control_name)
 {
     $htmlId = $node->attributes('id') ? $node->attributes('id') : '';
     $pManager =& getPluginManager();
     $pManager->loadPlugins('component');
     $output = JHTML::_('jwf.startJSBlock', 2);
     $output .= JHTML::_('jwf.indentedLine', "defaultWorkflow.component = '{$value}';", 3);
     $output .= JHTML::_('jwf.endJSBlock', 2);
     $contentTypesList = array();
     foreach ($pManager->settings['component'] as $p) {
         $contentTypesList[] = JHTML::_('select.option', $p->id, $p->name);
     }
     $output .= JHTML::_('select.genericlist', $contentTypesList, $control_name . '[' . $name . ']', 'onchange="updateCategoryList(this)" class="inputbox" size="1"', 'value', 'text', $value, $htmlId);
     return $output;
 }
 /**
  * List view display method
  *
  * Displays a list of all workflows available in the database
  *
  * @return void
  **/
 function display($items, $workflow, $fieldsData, $currentStationId, $activeFields)
 {
     JHTML::_('JWF.reloadMootools');
     JHTML::_('script', 'utilities.js', 'media/com_jwf/scripts/');
     if (defined('JWF_FRONTEND_RUNNING')) {
         JHTML::_('stylesheet', 'pending_item-frontend.css', 'media/com_jwf/css/');
         JHTML::_('JWF.backButton');
         JHTML::_('JWF.title', JText::_('JWF'), 'jwf-logo');
     } else {
         JHTML::_('stylesheet', 'pending_item-backend.css', 'media/com_jwf/css/');
         JRequest::setVar('hidemainmenu', 1);
         JToolBarHelper::title(JText::_('JWF'), 'jwf-logo');
         JToolBarHelper::back();
     }
     $pManager =& getPluginManager();
     $pManager->loadPlugins('field');
     foreach ($activeFields as $f) {
         $inputData = array_key_exists($f, $fieldsData) ? $fieldsData[$f] : null;
         $response = $pManager->invokeMethod('field', 'display', array($f), array($items, $workflow, $inputData));
         $fieldsHTML[$f] = $response[$f];
     }
     $nextStation = null;
     $previousStation = null;
     $currentStation = $workflow->stations[$currentStationId];
     $currentStationOrder = $workflow->stations[$currentStationId]->order;
     foreach ($workflow->stations as $s) {
         if ($s->order == $currentStationOrder + 1) {
             $nextStation = $s;
         }
         if ($s->order == $currentStationOrder - 1) {
             $previousStation = $s;
         }
     }
     //Send data to the view
     $this->assignRef('items', $items);
     $this->assignRef('workflow', $workflow);
     $this->assignRef('fields', $fieldsHTML);
     $this->assignRef('nextStation', $nextStation);
     $this->assignRef('previousStation', $previousStation);
     $this->assignRef('currentStation', $currentStation);
     //Display the template
     parent::display(null);
 }
 /**
  * List view display method
  *
  * Displays a list of all workflows available in the database
  *
  * @return void
  **/
 function display($itemHistory, $workflow)
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('component');
     $response = $pManager->invokeMethod('component', 'getItemRevision', array($workflow->component), array($itemHistory[0]->iid, 'head'));
     $itemInformation = $response[$workflow->component];
     $title = JText::_('Item') . ' [' . $itemInformation->title . '] ' . JText::_('History');
     if (defined('JWF_FRONTEND_RUNNING')) {
         JHTML::_('JWF.title', $title, 'jwf-logo');
         JHTML::_('JWF.backButton');
         JHTML::_('stylesheet', 'history-frontend.css', 'media/com_jwf/css/');
     } else {
         JHTML::_('stylesheet', 'history-backend.css', 'media/com_jwf/css/');
         JRequest::setVar('hidemainmenu', 1);
         JToolBarHelper::title($title, 'jwf-logo');
         JToolBarHelper::back();
     }
     //Send data to the view
     $this->assignRef('history', $itemHistory);
     $this->assignRef('currentItem', $itemInformation);
     $this->assignRef('workflow', $workflow);
     //Display the template
     parent::display(null);
 }
Beispiel #8
0
/**
 * Cron job handler : Deletes orphaned tasks , those are tasks that are pointing to a content element that has been deleted "e.g. an Article that has been deleted outside the workflow control"
 *
 * @return void
 */
function plgJWFDeletedOrphanedTasks()
{
    //Clean up orphans in "steps" table
    $pManager =& getPluginManager();
    $pManager->loadPlugins('component');
    $pManager->invokeMethod('component', 'deleteOrphans', null, null);
    //Clean up orphans in "fields" table
    $db =& JFactory::getDBO();
    $db->setQuery('DELETE FROM `#__jwf_fields` WHERE `tid` NOT IN (SELECT `id` FROM `#__jwf_steps`)');
    $db->query();
}
Beispiel #9
0
 function unlock($id, $aclSystemId, $gid)
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     //Todo: Actual unlock implementation
 }
Beispiel #10
0
			</th>
			<th>
				<?php 
echo JText::_('History');
?>
			</th>
			<th>
				<?php 
echo JText::_('Workflow Title');
?>
			</th>
		</tr>		
	</thead>
	<tbody>
	<?php 
$pManager =& getPluginManager();
$pManager->loadPlugins('acl');
$k = 0;
$config =& JFactory::getConfig();
$db =& JFactory::getDBO();
$now =& JFactory::getDate();
$nullDate = $db->getNullDate();
for ($i = 0, $n = count($this->items); $i < $n; $i++) {
    $row =& $this->items[$i];
    //Only allow administrating groups to view item history
    $canViewHistory = false;
    if (canManageWorkflows()) {
        $canViewHistory = true;
    } else {
        list($adminAclSystem, $adminAclGroup) = explode('.', $row->administratingGroup);
        foreach ($this->aclPairs as $system => $gid) {
Beispiel #11
0
 function save($workflow, $steps, $storedComments, $incomingComment)
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $response = $pManager->invokeMethod('acl', 'getMyGroupId', array($workflow->acl), null);
     $myGroups = $response[$workflow->acl];
     $user =& JFactory::getUser();
     $isNew = intval($incomingComment['commentID']) == -1 ? true : false;
     $isAuthorized = false;
     //The HUGE Authorization routine
     /*
     Global Administrator -> Allowed to do everything
     	
     Old Comment
     	Workflow manager -> Allowed after making sure the supplied WID matches a workflow they have authority upon 
     	Normal user      -> Allowed if s/he's the creator of the comment
     
     New Comment 
     	Workflow manager -> Allow if WID matches a workflow they have authority upon
     	Normal user -> Allowed only if the item is in their station
     */
     if (canManageWorkflows()) {
         $isAuthorized = true;
     } elseif (in_array($workflow->admin_gid, array_keys($myGroups))) {
         $isAuthorized = true;
     } else {
         if ($isNew) {
             //Allow normal users to add comments to the latest step ONLY
             $currentStep = searchObjectArray($steps, 'current', 1);
             foreach ($myGroups as $gid => $name) {
                 if ($workflow->stations[$incomingComment['sid']]->group == $gid) {
                     if ($currentStep->iid == $incomingComment['iid'] && $currentStep->id == $incomingComment['tid']) {
                         $isAuthorized = true;
                     }
                 }
             }
         } else {
             $currentComment = searchObjectArray($storedComments, 'id', $incomingComment['commentID']);
             if ($currentComment != null && $user->get('id') == $currentComment->created_by) {
                 $isAuthorized = true;
             }
         }
     }
     if (!$isAuthorized) {
         return 0;
     }
     $datenow =& JFactory::getDate();
     $incomingComment['type'] = 'comments';
     if (!$isNew) {
         $incomingComment['id'] = intval($incomingComment['commentID']);
         $incomingComment['modified'] = $datenow->toMySQL();
         $incomingComment['modified_by'] = $user->get('id');
     } else {
         $incomingComment['created'] = $datenow->toMySQL();
         $incomingComment['modified'] = $datenow->toMySQL();
         $incomingComment['created_by'] = $user->get('id');
         $incomingComment['modified_by'] = $user->get('id');
     }
     $incomingComment['value'] = base64_encode($incomingComment['text']);
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'history.php';
     $historyModel = new JWFModelHistory();
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'field.php';
     $fieldModel = new JWFModelField();
     if ($fieldModel->save($incomingComment)) {
         $historyObject = new stdClass();
         if ($isNew) {
             $historyObject->type = 'create';
             $historyObject->value = $incomingComment['value'];
             $historyModel->add($workflow->id, $workflow->stations[$incomingComment['sid']], $incomingComment['iid'], 'field.comments', JText::_('Comment Added'), $historyObject);
         } else {
             $historyObject->type = 'modify';
             $historyObject->value = $incomingComment['value'];
             $historyModel->add($workflow->id, $workflow->stations[$incomingComment['sid']], $incomingComment['iid'], 'field.comments', JText::_('Comment Modified'), $historyObject);
         }
         return 1;
     }
     return 0;
 }
 function getPropertiesForm()
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $pManager->loadPlugins('field');
     $pManager->loadPlugins('hook');
     $pManager->loadPlugins('validation');
     $pane =& JPane::getInstance('sliders');
     $output = JHTML::_('jwf.indentedLine', '<div id="properties-container">', 2);
     $output .= JHTML::_('jwf.indentedLine', "<fieldset><legend>" . JText::_('Identification') . "</legend>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label for='properties_input_title'>" . JText::_('Title') . "</label>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<input onchange='saveElement()' type='text' id='properties_input_title' />", 2);
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label for='properties_input_task'>" . JText::_('Task') . "</label>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<textarea onchange='saveElement()' id='properties_input_task'></textarea>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label id='properties_lbl_acl' for='properties_input_acl'>" . JText::_('Group') . "</label>", 2);
     $output .= JHTML::_('select.genericlist', array(), "properties_input_acl", 'onchange="saveElement()" class="inputbox" size="1"', 'value', 'text', '', 'properties_input_acl');
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<input onclick='deleteSelectedElement()' id='properties_input_delete' type='button' value='" . JText::_('Delete Station') . "' />", 2);
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "</fieldset>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<fieldset><legend>" . JText::_('Allocated Time') . "</legend>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label style='width:40px;' id='properties_lbl_hours' for='properties_input_hours'>" . JText::_('Hours') . "</label>", 2);
     $output .= JHTML::_('select.integerlist', 0, 23, 1, "properties_input_hours", 'id="properties_input_hours" style="width:40px;" onchange="saveElement()" class="inputbox" size="1"');
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label style='width:40px;' id='properties_lbl_days' for='properties_input_days'>" . JText::_('Days') . "</label>", 2);
     $output .= JHTML::_('select.integerlist', 0, 30, 1, "properties_input_days", 'id="properties_input_days" style="width:40px;" onchange="saveElement()" class="inputbox" size="1"');
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label style='width:40px;' id='properties_lbl_months' for='properties_input_months'>" . JText::_('Months') . "</label>", 2);
     $output .= JHTML::_('select.integerlist', 0, 11, 1, "properties_input_months", 'id="properties_input_months" style="width:40px;" onchange="saveElement()" class="inputbox" size="1"');
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "</fieldset>", 2);
     $fieldList = array();
     $output .= JHTML::_('jwf.indentedLine', "<label id='properties_lbl_fields' for='properties_input_fields'>" . JText::_('Active fields') . "</label>", 2);
     foreach ($pManager->settings['field'] as $p) {
         $fieldList[] = JHTML::_('select.option', $p->id, JText::_($p->name));
     }
     $output .= JHTML::_('select.genericlist', $fieldList, "properties_input_fields", 'multiple="multiple" class="inputbox field" size="5"', 'value', 'text');
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $validationList = array();
     $output .= JHTML::_('jwf.indentedLine', "<label id='properties_lbl_validations' for='properties_input_validations'>" . JText::_('Active validations') . "</label>", 2);
     foreach ($pManager->settings['validation'] as $p) {
         $validationList[] = JHTML::_('select.option', $p->id, JText::_($p->name));
     }
     $output .= JHTML::_('select.genericlist', $validationList, "properties_input_validations", 'multiple="multiple" class="inputbox validation" size="5"', 'value', 'text');
     $output .= JHTML::_('jwf.indentedLine', "<div class='clear'></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<h2>" . JText::_('Active hooks') . "</h2>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<form id='hook-settings-form'>", 2);
     $hookList = array();
     $paneOutput = JHTML::_('jwf.hiddenPane');
     $paneOutput .= $pane->startPane('hooks-pane');
     foreach ($pManager->settings['hook'] as $p) {
         $form = new JParameter('', $p->xml);
         $params = $form->renderToArray();
         $paneOutput .= JHTML::_('jwf.startJSBlock', 2);
         $paneOutput .= JHTML::_('jwf.indentedLine', 'hookParameters["' . $p->id . '"] = new Array();', 3);
         $i = 0;
         foreach ($params as $key => $value) {
             $paneOutput .= JHTML::_('jwf.indentedLine', 'hookParameters["' . $p->id . '"][' . $i . '] = "' . $key . '"', 3);
             $i++;
         }
         $paneOutput .= JHTML::_('jwf.endJSBlock', 2);
         $title = JText::_($p->name . ' ' . JText::_('Settings'));
         $paneOutput .= '<div class="search-pane-list-handle"></div>';
         $paneOutput .= '<div class="search-pane-list-check"><input value="' . $p->id . '" type="checkbox" class="active-hooks" name="properties_input_hooks[' . $p->id . ']" checked="checked" id="properties_input_hook_' . $p->id . '" /></div>';
         $paneOutput .= $pane->startPanel($title, "form-page");
         $paneOutput .= $form->render('hooks-' . $p->id);
         $paneOutput .= $pane->endPanel();
     }
     $paneOutput .= $pane->endPane();
     $paneOutput .= JHTML::_('jwf.indentedLine', "</form>", 2);
     $output .= $paneOutput;
     $output .= JHTML::_('jwf.indentedLine', '</div>', 2);
     return $output;
 }
Beispiel #13
0
 /**
  * Stores a Workflow to database
  *
  * @access	public
  * @param object $data Workflow Data to be saved 
  * @return int	ID of the newly saved workflow on success , 0 on failure
  */
 function save($data)
 {
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $row =& JTable::getInstance('Workflow', 'Table');
     $nullDate = $db->getNullDate();
     if (!$row->bind($data)) {
         JError::raiseError(500, $db->stderr());
         return 0;
     }
     $row->id = intval($row->id);
     JArrayHelper::toInteger($data['category']);
     $row->category = implode(',', $data['category']);
     $newEntry = $row->id ? false : true;
     //Copied directly from com_content saveContent()
     // Are we saving from an item edit?
     if (!$newEntry) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     if (strlen(trim($row->publish_up)) == 0) {
         $date =& JFactory::getDate(1, $tzoffset);
     } else {
         $row->publish_up .= ' 00:00:00';
         $date =& JFactory::getDate($row->publish_up, $tzoffset);
     }
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
     }
     // Store the content to the database
     if (!$row->store()) {
         JError::raiseError(500, $db->stderr());
     }
     // Check the form
     $row->checkin();
     //End of faithful copy
     if ($newEntry) {
         $row->id = lastInsertId();
     }
     if (!$newEntry) {
         //Delete stations of this workflow
         $db->setQuery('DELETE FROM #__jwf_stations WHERE wid=' . $row->id);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     $queriesNewId = array();
     $queriesOldId = array();
     foreach ($data['stations'] as $station) {
         $wid = intval($row->id);
         $title = $db->getEscaped($station->title, true);
         $task = $db->getEscaped($station->task, true);
         $allocatedTime = intval($station->allocatedTime);
         $group = intval($station->acl->id);
         $fields = $db->getEscaped($station->fields, true);
         $hooks = $station->activeHooks;
         $validations = $db->getEscaped($station->activeValidations, true);
         $order = intval($station->order);
         if ($station->id == null) {
             $queriesNewId[] = "({$wid}, '{$title}', '{$task}', {$allocatedTime}, {$group}, '{$fields}' , '{$hooks}', '{$validations}', {$order})";
         } else {
             $queriesOldId[] = "({$station->id}, {$wid}, '{$title}', '{$task}', {$allocatedTime}, {$group}, '{$fields}', '{$hooks}', '{$validations}', {$order})";
         }
     }
     if (count($queriesNewId)) {
         $sqlNewIds = implode(',', $queriesNewId);
         $sqlNewIds = 'INSERT INTO `#__jwf_stations` (`wid`,`title`,`task`,`allocatedTime`,`group`,`fields`, `activeHooks`, `activeValidations`,  `order`) VALUES ' . $sqlNewIds;
         $db->setQuery($sqlNewIds);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     if (count($queriesOldId)) {
         $sqlOldIds = implode(',', $queriesOldId);
         $sqlOldIds = 'INSERT INTO `#__jwf_stations` (`id`,`wid`,`title`,`task`,`allocatedTime`,`group`,`fields`,`activeHooks`, `activeValidations`, `order`) VALUES ' . $sqlOldIds;
         $db->setQuery($sqlOldIds);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     //Update trigger cache
     $pManager =& getPluginManager();
     $pManager->loadPlugins('component');
     $plugins = $pManager->settings['component'];
     $trigger = $plugins[$row->component]->trigger;
     $category = $row->category;
     $component = $row->component;
     $triggerDataPath = JWF_FS_PATH . DS . 'triggerCache.ini';
     $triggerCacheData = new JRegistry();
     $triggerCacheData->loadINI(file_get_contents($triggerDataPath));
     $triggerCacheData->setValue($row->id, $trigger . '-' . $component . '-' . $category);
     file_put_contents($triggerDataPath, $triggerCacheData->toString('INI'));
     return $row->id;
 }
Beispiel #14
0
 /**
  * Default Task Handler ( Displays pending tasks for the logged in user )
  *
  * @return void
  */
 function display()
 {
     //Prepare View
     $document =& JFactory::getDocument();
     $viewType = $document->getType();
     $viewName = 'pending_items';
     $viewLayout = 'default';
     //$templatePath = JWF_BACKEND_PATH.DS.'views'.DS.$viewName.DS.'tmpl';
     $view =& $this->getView($viewName, $viewType, '', array('base_path' => $this->_basePath));
     $view->setLayout($viewLayout);
     //Load
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $aclPairs = array();
     foreach ($pManager->settings['acl'] as $handler) {
         $id = $handler->id;
         $response = $pManager->invokeMethod('acl', 'getMyGroupId', array($id), null);
         $aclPairs[$id] = $response[$id];
     }
     // Get/Create the model
     $iModel =& $this->getModel('item');
     $items = $iModel->search(0, 0, $aclPairs, '', true);
     // Display the view
     $view->display($items, $aclPairs);
 }