public final function runAfter(WflSetObjectPropertiesRequest $req, WflSetObjectPropertiesResponse &$resp)
 {
     require_once BASEDIR . '/server/bizclasses/BizObject.class.php';
     $username = BizSession::getShortUserName();
     $object = BizObject::getObject($req->MetaData->BasicMetaData->ID, $username, false, 'none', array());
     require_once dirname(__FILE__) . '/config.php';
     require_once dirname(__FILE__) . '/toXML.class.php';
     if ($object->MetaData->BasicMetaData->Type == 'Article') {
         $eventCall = unserialize(TO_XML_STATUS);
         $whatToDo = -1;
         global $stateBefore;
         if ($stateBefore == $eventCall[0]) {
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[1] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[2] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[3] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[4]) {
                 $whatToDo = 0;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
                 $whatToDo = 0;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
                 $whatToDo = 1;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
         }
         if ($stateBefore == $eventCall[1]) {
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[1] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[2] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[3] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[4] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
                 $whatToDo = 1;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
         }
         if ($stateBefore == $eventCall[2]) {
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[3] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[4] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
                 $whatToDo = 1;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
         }
         if ($stateBefore == $eventCall[3]) {
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[4] || $object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
                 $whatToDo = 1;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
         }
         if ($stateBefore == $eventCall[4]) {
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
                 $whatToDo = 1;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
         }
         if ($stateBefore != $eventCall[5]) {
             if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
                 $whatToDo = 2;
                 toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
             }
         }
         if ($object->MetaData->WorkflowMetaData->State->Name == $eventCall[5]) {
             $whatToDo = 3;
             toXML::processFor($req->MetaData->BasicMetaData->ID, $req->Ticket, $whatToDo);
         }
     }
     if ($resp->MetaData->BasicMetaData->Type == 'Layout') {
         toXML::finalProcess($resp->MetaData->BasicMetaData->ID, $req->Ticket, $resp->Targets[0]->Issue->Id);
     }
 }
Example #2
0
 public static function processWSDL($objid)
 {
     // set_time_limit(5);
     try {
         $username = BizSession::getShortUserName();
         $object = BizObject::getObject($objid, $username, false, 'native', array('Targets'));
         $name = $object->MetaData->BasicMetaData->Name;
         $relations = BizRelation::getObjectRelations($objid, $attachGeo = true, $allTargets = false, $related = null);
         if ($relations != null) {
             foreach ($relations as $relacioname) {
                 if ($relacioname->Parent != null && $relacioname->Type == 'Placed') {
                     $layObject = BizObject::getObject($relacioname->Parent, $username, false, 'none', array('Relations', 'Targets'));
                     $layID = $layObject->MetaData->BasicMetaData->ID;
                     $issueId = $layObject->Targets[0]->Issue->Id;
                     $page = $relacioname->Placements[0]->Page;
                 }
             }
         }
         $status = $object->MetaData->WorkflowMetaData->State->Name;
         $brandID = $object->MetaData->BasicMetaData->Publication->Id;
         $categoryID = $object->MetaData->BasicMetaData->Category->Id;
         $dbdriver = DBDriverFactory::gen();
         $sql = "select `publdate` from `smart_issues` where `id` = '{$issueId}'";
         $sth = $dbdriver->query($sql);
         $date = $dbdriver->fetch($sth);
         $fecha = substr($date[publdate], 0, 10);
         $modified = $object->MetaData->WorkflowMetaData->Modified;
         $version = BizVersion::getCurrentVersionNrFromId($objid);
         $route = $object->Files[0]->Content->options['attachment']['filepath'];
         //New validation for export 03h
         $maxDate = $fecha . ' 03:00:00';
         $now = date('Y-m-d H:i:s', time());
         if (strtotime($now) < strtotime($maxDate)) {
             $dom = new DOMDocument('1.0', 'UTF-8');
             $dom->load($route);
             $insertedText = 0;
             $deletedText = 0;
             $movedText = 0;
             $totalChars = 0;
             foreach ($dom->getElementsByTagNameNS('urn:SmartConnection_v3', '*') as $element) {
                 if ($element->localName == 'Story') {
                     foreach ($element->childNodes as $item) {
                         foreach ($item->childNodes as $subitem) {
                             if ($subitem->nodeName === 'ea:SI_Chars') {
                                 $totalChars += $subitem->nodeValue;
                             }
                             if ($subitem->nodeName === 'Story') {
                                 foreach ($subitem->childNodes as $story) {
                                     if ($story->nodeName === 'Change' && $story->getAttribute('ChangeType') === 'InsertedText') {
                                         foreach ($story->childNodes as $paragraph) {
                                             foreach ($paragraph->childNodes as $character) {
                                                 foreach ($character->childNodes as $chars) {
                                                     if ($chars->nodeName === 'Content') {
                                                         $insertedText += strlen($chars->nodeValue);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if ($story->nodeName === 'Change' && $story->getAttribute('ChangeType') === 'DeletedText') {
                                         foreach ($story->childNodes as $paragraph) {
                                             foreach ($paragraph->childNodes as $character) {
                                                 foreach ($character->childNodes as $chars) {
                                                     if ($chars->nodeName === 'Content') {
                                                         $deletedText += strlen($chars->nodeValue);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if ($story->nodeName === 'Change' && $story->getAttribute('ChangeType') === 'MovedText') {
                                         foreach ($story->childNodes as $paragraph) {
                                             foreach ($paragraph->childNodes as $character) {
                                                 foreach ($character->childNodes as $chars) {
                                                     if ($chars->nodeName === 'Content') {
                                                         $movedText += strlen($chars->nodeValue);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     foreach ($story->childNodes as $paragraph) {
                                         foreach ($paragraph->childNodes as $character) {
                                             if ($character->nodeName === 'Change' && $character->getAttribute('ChangeType') === 'InsertedText') {
                                                 foreach ($character->childNodes as $chars) {
                                                     if ($chars->nodeName === 'Content') {
                                                         $insertedText += strlen($chars->nodeValue);
                                                     }
                                                     if ($chars->nodeName === 'ParagraphStyleRange') {
                                                         foreach ($chars->childNodes as $subparagraph) {
                                                             foreach ($subparagraph->childNodes as $subcharacter) {
                                                                 if ($subcharacter->nodeName === 'Content') {
                                                                     $insertedText += strlen($subcharacter->nodeValue);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             if ($character->nodeName === 'Change' && $character->getAttribute('ChangeType') === 'DeletedText') {
                                                 foreach ($character->childNodes as $chars) {
                                                     if ($chars->nodeName === 'Content') {
                                                         $deletedText += strlen($chars->nodeValue);
                                                     }
                                                     if ($chars->nodeName === 'ParagraphStyleRange') {
                                                         foreach ($chars->childNodes as $subparagraph) {
                                                             foreach ($subparagraph->childNodes as $subcharacter) {
                                                                 if ($subcharacter->nodeName === 'Content') {
                                                                     $deletedText += strlen($subcharacter->nodeValue);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             if ($character->nodeName === 'Change' && $character->getAttribute('ChangeType') === 'MovedText') {
                                                 foreach ($character->childNodes as $chars) {
                                                     if ($chars->nodeName === 'Content') {
                                                         $movedText += strlen($chars->nodeValue);
                                                     }
                                                     if ($chars->nodeName === 'ParagraphStyleRange') {
                                                         foreach ($chars->childNodes as $subparagraph) {
                                                             foreach ($subparagraph->childNodes as $subcharacter) {
                                                                 if ($subcharacter->nodeName === 'Content') {
                                                                     $movedText += strlen($subcharacter->nodeValue);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $itrack = array();
             $itrack[Empleado_ID] = $username;
             $itrack[Pagina_ID] = $layID;
             $itrack[Articulo_ID] = $objid;
             $itrack[pubpage] = $page;
             $itrack[CodMarca] = $brandID;
             $itrack[CodCategoria] = $categoryID;
             $itrack[PubDate] = $fecha;
             $itrack[NroCorrelativo] = $version;
             $itrack[TotalCaracteres] = $totalChars;
             $itrack[Modificados] = $movedText;
             $itrack[Eliminados] = $deletedText;
             $itrack[Agregados] = $insertedText;
             $itrack[FechaHoraCheckIn] = $modified;
             $itrack[Estado] = $status;
             $client = new SoapClient("http://10.10.28.20/wsproductividad/WSProductividad.asmx?WSDL");
             $client->__soapCall('InsertTracking_', array($itrack));
         }
     } catch (Exception $e) {
         //throw $e;
         // Send to?
         $to = "*****@*****.**";
         // The Subject
         $subject = "toXML Error Message E-Mail";
         // The message
         $message = $e;
         // In case any of our lines are larger than 70 characters, we should use wordwrap()
         $message = wordwrap($message, 70);
         // Send email
         mail($to, $subject, $message);
     }
 }