Example #1
0
 public function modificabileDa(Utente $utente)
 {
     $id = $utente->id;
     return (bool) ($this->referente()->id == $id or $utente->admin() or contiene($this, $utente->gruppiDiCompetenza()));
 }
Example #2
0
 /**
  * Informa se un corso è modificabile da un determianto utente
  * @return bool 
  */
 public function modificabileDa(Utente $u)
 {
     if ($u->admin()) {
         return true;
     }
     return (bool) ($u->id == $this->direttore || contiene($this->id, array_map(function ($x) {
         return $x->id;
     }, $u->corsiBaseDiGestione())));
 }
Example #3
0
 public function modificabileDa(Utente $u)
 {
     return (bool) ($u->id == $this->referente || $u->admin() || contiene($this->area, $u->areeDiCompetenza()) || contiene($this, $u->attivitaDiGestione()));
 }
Example #4
0
 /**
  * Verifica se un altro utente ha permessi in scrittura su me
  * @return bool modifica o non modifica
  * @param $altroUtente il modificatore
  */
 public function modificabileDa(Utente $altroUtente)
 {
     if (!$altroUtente) {
         return false;
     }
     if ($altroUtente->admin()) {
         return true;
     }
     $comitatiGestiti = array_merge($altroUtente->comitatiDelegazioni(APP_PRESIDENTE, false, false), $altroUtente->comitatiDelegazioni(APP_SOCI, false, false));
     $comitatiGestiti = array_unique($comitatiGestiti);
     // se sei persona o aspirante devo capire meglio da dove vieni
     if ($this->stato == PERSONA || $this->stato == ASPIRANTE) {
         // la funzione dimesso mi dice il tipo di dimissione (int)
         // in ogni caso se hai dimissioni voglio prendere l'ultimo comitato buono
         $d = $this->dimesso();
         // il secondo check è perchè MEMBRO_DIMESSO è 0
         if ($d || $d === MEMBRO_DIMESSO) {
             $c = $this->ultimaAppartenenza($d)->comitato();
         } else {
             // altrimenti se un ordinario
             $c = $this->unComitato(MEMBRO_ORDINARIO);
         }
     } else {
         // altrimenti hai stato VOLONTARIO e devo capire se sei pendente o no
         $c = $this->unComitato();
         if (!$c) {
             // se non è zuppa è pan bagnato (si spera)
             $c = $this->unComitato(MEMBRO_PENDENTE);
         }
     }
     // se alla fine dello spaghetti code qua sopra risulti essere qualcosa
     // allora verifico se ti posso toccacciare
     if ($c) {
         if ($c instanceof Comitato && contiene($c->locale(), $comitatiGestiti) || contiene($c, $comitatiGestiti)) {
             return true;
         }
         /* Il foreach seguente serve per risolvere 
          * temporaneamente i problemi di permessi
          * fino alla corretta implementazione di copernico
          * #970
          */
         foreach ($comitatiGestiti as $com) {
             if ($c instanceof Comitato && $c->locale()->nome == $com->nome) {
                 return true;
             }
             if ($c->nome == $com->nome) {
                 return true;
             }
         }
     }
     // Dipendente
     if ($this->dipendenteComitato && in_array($this->dipendenteComitato, $altroUtente->comitatiApp([APP_PRESIDENTE, APP_SOCI], false))) {
         return true;
     }
     // se non sei niente
     return false;
 }
Example #5
0
 public function modificabileDa(Utente $altroUtente)
 {
     if (!$altroUtente) {
         return false;
     }
     if ($altroUtente->admin() || $this->unPresidente()->id == $altroUtente->id) {
         return true;
     }
     if ($this instanceof Comitato and $this->superiore()->modificabileDa($altroUtente)) {
         return true;
     }
     if ($this instanceof Locale and $this->nome == $this->superiore()->nome and $this->superiore()->modificabileDa($altroUtente)) {
         return true;
     }
     if ($this instanceof Provinciale and $this->nome == $this->superiore()->nome and $this->superiore()->modificabileDa($altroUtente)) {
         return true;
     }
     return false;
 }