public function store() { $is_new = true; if ($this->id > ID_UNDEFINED) { $is_new = false; } if (parent::store()) { if (!$is_new) { // para cada seguidor no bloqueado, crear notificacion, el usuario ha actualizado sus datos de perfil. if ($amigos = perfil_amigo::get_todos_mis_seguidores()) { foreach ($amigos as $amigo) { if ($amigo->get('bloqueo_destino') == false) { $notificacion = new perfil_notificacion(); $notificacion->set('origen', $this); $notificacion->set('destino', $amigo->get('origen')); $notificacion->set('fecha', new Date()); $notificacion->set('tipo', new perfil_notificacion_tipo(2)); $notificacion->set('enviado', 0); $notificacion->store(); } } } } return true; } else { return false; } }
public function store() { global $ari; $is_new = true; if ($this->id > ID_UNDEFINED) { $is_new = false; } if (parent::store()) { // le mandamos una notificacion al destinatario de que lo estan siguiendo if ($is_new) { $notificacion = new perfil_notificacion(); $notificacion->set('origen', $this->get('origen')); $notificacion->set('destino', $this->get('destino')); $notificacion->set('fecha', new Date()); $notificacion->set('tipo', new perfil_notificacion_tipo(1)); $notificacion->set('enviado', 0); $notificacion->store(); } return true; } else { return false; } }
public function delete() { // cuando borramos un mensaje, lo que hacemos es borrar todas las notificaciones relacionadas con ese mensaje. $id = $this->id(); $filtro[] = array('value' => $id, 'field' => 'origen(perfil_mensaje)', 'type' => 'list'); if ($notificaciones = perfil_notificacion::getFilteredList(0, 0, false, false, $filtro)) { foreach ($notificaciones as $notificacion) { $notificacion->delete(); } } return parent::delete(); }