private function saveProvisions() { $db = Zend_Registry::get('my_db'); $agt_pro = new AgentProvisions($db); $agt_sub = new AgentSubscriptions($db); $agt_req = new AgentRequester($db); $agt_res = new AgentResponder($db); $where = 'agent_id = ' . $this->agent->agentId . ' and zone_id = ' . $_SESSION['ZONE_ID']; $agt_pro->delete($where); $agt_sub->delete($where); $agt_req->delete($where); $agt_res->delete($where); if (count($this->requestObjects) > 0) { foreach ($this->requestObjects as $object) { $data = array(DBConvertor::convertCase('agent_id') => $this->agent->agentId, DBConvertor::convertCase('object_type_id') => $object->objectId, DBConvertor::convertCase('requester_timestamp') => new zend_db_expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('context_id') => $object->contextId, DBConvertor::convertCase('zone_id') => $_SESSION['ZONE_ID']); $agt_req->insert($data); } } if (count($this->respondObjects) > 0) { foreach ($this->respondObjects as $object) { $data = array(DBConvertor::convertCase('agent_id') => $this->agent->agentId, DBConvertor::convertCase('object_type_id') => $object->objectId, DBConvertor::convertCase('responder_timestamp') => new zend_db_expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('context_id') => $object->contextId, DBConvertor::convertCase('zone_id') => $_SESSION['ZONE_ID']); $agt_res->insert($data); // $db->insert('agent_responder', $data); } } if (count($this->provideObjects) > 0) { foreach ($this->provideObjects as $object) { $data = array(DBConvertor::convertCase('agent_id') => $this->agent->agentId, DBConvertor::convertCase('object_type_id') => $object->objectId, DBConvertor::convertCase('provision_timestamp') => new zend_db_expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('context_id') => $object->contextId, DBConvertor::convertCase('zone_id') => $_SESSION['ZONE_ID']); // $db->insert('agent_provisions', $data); $agt_pro->insert($data); } } if (count($this->subscribeObjects) > 0) { foreach ($this->subscribeObjects as $object) { $data = array(DBConvertor::convertCase('agent_id') => $this->agent->agentId, DBConvertor::convertCase('object_type_id') => $object->objectId, DBConvertor::convertCase('subscribe_timestamp') => new zend_db_expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('context_id') => $object->contextId, DBConvertor::convertCase('zone_id') => $_SESSION['ZONE_ID']); // $db->insert('agent_subscriptions', $data); $agt_sub->insert($data); } } if (count($this->publishAddObjects) > 0) { foreach ($this->publishAddObjects as $object) { $data = array(DBConvertor::convertCase('publish_add') => '1'); $where = 'agent_id = ' . $this->agent->agentId . ' and object_type_id = ' . $object->objectId . ' and context_id = ' . $object->contextId; $agt_pro->update($data, $where); // $db->update('agent_provisions', $data, 'agent_id = '.$this->agent->agentId.' and object_type_id = '.$object->objectId.' and context_id = '.$object->contextId); } } if (count($this->publishChangeObjects) > 0) { foreach ($this->publishChangeObjects as $object) { $data = array(DBConvertor::convertCase('publish_change') => '1'); $where = 'agent_id = ' . $this->agent->agentId . ' and object_type_id = ' . $object->objectId . ' and context_id = ' . $object->contextId; $agt_pro->update($data, $where); // $db->update('agent_provisions', $data, 'agent_id = '.$this->agent->agentId.' and object_type_id = '.$object->objectId.' and context_id = '.$object->contextId); } } if (count($this->publishDeleteObjects) > 0) { foreach ($this->publishDeleteObjects as $object) { $data = array(DBConvertor::convertCase('publish_delete') => '1'); $where = 'agent_id = ' . $this->agent->agentId . ' and object_type_id = ' . $object->objectId . ' and context_id = ' . $object->contextId; $agt_pro->update($data, $where); // $db->update('agent_provisions', $data, 'agent_id = '.$this->agent->agentId.' and object_type_id = '.$object->objectId.' and context_id = '.$object->contextId); } } }
public static function getProviderId($objectName) { try { $empty = null; $id = $empty; $objectId = DataObject::getDataObjectId($objectName); if ($objectId == null) { return 0; } $db = Zend_Registry::get('my_db'); /* $pdo = new ProvisionDataObjectVW($db); $where = " lower(object_name) = lower('".$objectName."')" ." and version_id = ".$_SESSION['ZONE_VERSION_ID'] ." and context_id = ".$_SESSION['CONTEXT_ID']." and zone_id = ".$_SESSION['ZONE_ID']; */ $pdo = new AgentResponder($db); $where = " object_type_id = " . $objectId . " and context_id = " . $_SESSION['CONTEXT_ID'] . " and zone_id = " . $_SESSION['ZONE_ID']; $result = $pdo->fetchAll($where); $row = $result->count(); if ($row != 0) { switch (DB_TYPE) { case 'mysql': $id = $result[0]->agent_id; break; case 'oci8': $id = $result[0]->AGENT_ID; break; } } if ($id == $empty) { return 0; } else { return $id; } } catch (Exception $e) { ZitLog::writeToErrorLog("[getProviderId]", "Errors:{$e->getTraceAsString}()", "getProviderId", $_SESSION['ZONE_ID']); return 0; } }