private function saveUnProvides() { $db = Zend_Registry::get('my_db'); foreach ($this->unProvideObjects as $object) { $ap = new AgentProvisions($db); $where = 'agent_id = ' . $this->agent->agentId . ' and context_id = ' . $object->contextId . ' and object_type_id = ' . $object->objectId . ' and zone_id = ' . $_SESSION['ZONE_ID']; $ap->delete($where); // $db->delete(DBConvertor::convertCase('agent_provisions'), 'agent_id = '.$this->agent->agentId.' and context_id = '.$object->contextId.' and object_type_id = '.$object->objectId.' and zone_id = '.$_SESSION['ZONE_ID']); } }
public static function saveProvides($dataObjects, $agentId) { $db = Zend_Registry::get('my_db'); foreach ($dataObjects as $object) { $alreadyProviding = DataObject::alreadyProviding($object->objectId, $object->contextId, $agentId); if (!$alreadyProviding) { $agt_pro = null; $agt_pro = new AgentProvisions($db); $data = array(DBConvertor::convertCase('agent_id') => $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('publish_add') => '1', DBConvertor::convertCase('publish_delete') => '1', DBConvertor::convertCase('publish_change') => '1', DBConvertor::convertCase('zone_id') => $_SESSION['ZONE_ID']); $agt_pro->insert($data); } } }
public function unRegister() { $db = Zend_Registry::get('my_db'); $agentsR = new AgentRegistered($db); $where = 'agent_id = ' . $this->agentId . ' and unregister_timestamp is null and context_id = ' . $_SESSION['CONTEXT_ID'] . ' and zone_id =' . $_SESSION['ZONE_ID']; $data = array(DBConvertor::convertCase('unregister_timestamp') => new Zend_Db_Expr(DBConvertor::convertCurrentTime())); $n = $agentsR->update($data, $where); if ($n == 1) { $where = 'agent_id = ' . $this->agentId . ' and context_id = ' . $_SESSION['CONTEXT_ID'] . ' and zone_id = ' . $_SESSION['ZONE_ID']; $agentPro = new AgentProvisions($db); $agentPro->delete($where); $agentSub = new AgentSubscriptions($db); $agentSub->delete($where); switch (DB_TYPE) { case 'mysql': $where = 'zone_id = ' . $_SESSION['ZONE_ID'] . ' and context_id = ' . $_SESSION['CONTEXT_ID'] . ' and agt_id_out = ' . $this->agentId; $queue = new MessageQueues($db); $queue->delete($where); break; case 'oci8': null; break; } return true; } else { return false; } }
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 function unRegister() { $db = Zend_Registry::get('my_db'); $agentsR = new AgentRegistered($db); $where = 'agent_id = ' . $this->agentId . ' and unregister_timestamp is null and context_id = ' . $_SESSION['CONTEXT_ID'] . ' and zone_id = ' . $_SESSION['ZONE_ID']; $data = array(DBConvertor::convertCase('unregister_timestamp') => new Zend_Db_Expr(DBConvertor::convertCurrentTime())); $n = $agentsR->update($data, $where); if ($n == 1) { $where = 'agent_id = ' . $this->agentId . ' and context_id = ' . $_SESSION['CONTEXT_ID'] . ' and zone_id = ' . $_SESSION['ZONE_ID']; $agentPro = new AgentProvisions($db); $agentPro->delete($where); $agentSub = new AgentSubscriptions($db); $agentSub->delete($where); return true; } else { return false; } }