/** * Remove monitoring of the propel object by the user * * @return BaseObject * @param BaseObject $object * @param int $user_id User primary key **/ public function removeMonitoringUser(BaseObject $object, $user_id) { if (is_null($user_id) or trim((string) $user_id) === '') { throw new deppPropelActAsMonitorableException('Impossible to remove a user monitoring with no user primary key provided'); } // remove the record $c = new Criteria(); $c->add(MonitoringPeer::MONITORABLE_ID, $this->getReferenceKey($object)); $c->add(MonitoringPeer::MONITORABLE_MODEL, get_class($object)); $c->add(MonitoringPeer::USER_ID, $user_id); $m = MonitoringPeer::doSelectOne($c); $m->delete(); // update the caches $user = call_user_func_array(array($this->getMonitorerModel($object) . "Peer", 'retrieveByPK'), array($user_id)); $user->countMonitoredObjects(get_class($object), null, true); $this->countMonitoringUsers($object, true); }
//SOSTITUISCI TAG MONITORATI CON NUOVO TAG $number_monitor_ok = 0; $number_monitor_no = 0; foreach ($tag_old as $k => $old) { $c = new Criteria(); $c->add(MonitoringPeer::MONITORABLE_ID, $old); $c->add(MonitoringPeer::MONITORABLE_MODEL, 'Tag'); $results = MonitoringPeer::doSelect($c); foreach ($results as $rs) { $obj_tag = TagPeer::retrieveByPk($tag_new[$k]); if ($obj_tag) { $c = new Criteria(); $c->add(MonitoringPeer::MONITORABLE_ID, $tag_new[$k]); $c->add(MonitoringPeer::MONITORABLE_MODEL, 'Tag'); $c->add(MonitoringPeer::USER_ID, $rs->getUserId()); $r = MonitoringPeer::doSelectOne($c); if (!$r) { $rs->setMonitorableId($tag_new[$k]); $rs->save(); echo "Monitoraggio cambiato: " . $old . " con " . $tag_new[$k] . " per utente " . $rs->getUserId() . "\n"; $number_monitor_ok = $number_monitor_ok + 1; } else { $rs->delete(); $number_monitor_no = $number_monitor_no + 1; echo "!!!! DOPPIONE" . $old . " con " . $tag_new[$k] . " per utente " . $rs->getUserId() . "\n"; } } } } //Cancella tutte le news legate ai vecchi tags foreach ($tag_old as $k => $old) {