Esempio n. 1
0
 /**
  * Queries org.openpsa.sales for suspected task links and saves them
  */
 function get_suspected_sales_links()
 {
     debug_add('called');
     //Safety
     if (!$this->_suspects_classes_present()) {
         debug_add('required classes not present, aborting', MIDCOM_LOG_WARN);
         return;
     }
     // Do no seek if we already have confirmed links
     $mc = new org_openpsa_relatedto_collector($this->guid, array('org_openpsa_salesproject_dba', 'org_openpsa_salesproject_deliverable_dba'));
     $mc->add_constraint('status', '=', org_openpsa_relatedto_dba::CONFIRMED);
     $links = $mc->get_related_guids();
     if (!empty($links)) {
         $cnt = count($links);
         debug_add("Found {$cnt} confirmed links already, skipping seek");
         return;
     }
     $link_def = $this->_suspect_defaults();
     $sales_suspect_links = org_openpsa_relatedto_suspect::find_links_object_component($this, 'org.openpsa.sales', $link_def);
     foreach ($sales_suspect_links as $linkdata) {
         debug_add("processing sales link {$linkdata['other_obj']->guid}, (class: " . get_class($linkdata['other_obj']) . ")");
         $stat = $linkdata['link']->create();
         if ($stat) {
             debug_add("saved link to {$linkdata['other_obj']->guid} (link id #{$linkdata['link']->id})", MIDCOM_LOG_INFO);
         } else {
             debug_add("could not save link to {$linkdata['other_obj']->guid}, errstr" . midcom_connection::get_error_string(), MIDCOM_LOG_WARN);
         }
     }
     debug_add('done');
     return;
 }