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 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); } $alreadyResponding = DataObject::alreadyResponding($object->objectId, $object->contextId, $agentId); if (!$alreadyResponding) { $agt_res = null; $agt_res = new AgentResponder($db); $data = array(DBConvertor::convertCase('agent_id') => $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); } } }