Пример #1
0
 /**
  * Ottiene l'oggetto del Like (OID)
  * @return Entita
  */
 public function oggetto()
 {
     return Entita::daOid($this->oggetto);
 }
Пример #2
0
 private function api_like()
 {
     global $conf;
     $this->richiedi(['oggetto']);
     $oggetto = Entita::daOid($this->par['oggetto']);
     $me = false;
     if ($this->sessione->utente) {
         $me = $this->richiediLogin();
     }
     if (isset($this->par['tipo'])) {
         if (!$me) {
             throw new Errore(1019);
         }
         $t = (int) $this->par['tipo'];
         if ($t !== PIACE && $t !== NON_PIACE) {
             throw new Errore(1020);
         }
         $me->apponiLike($oggetto, $t);
     }
     $p = -1;
     if ($me && ($a = $me->appostoLike($oggetto))) {
         $p = $a->tipo;
     }
     $r = [];
     foreach ($conf['like'] as $tipo => $descrizione) {
         $r[$tipo] = ['nome' => $descrizione, 'numero' => $oggetto->like($tipo), 'apposto' => $p == $tipo];
     }
     return $r;
 }