Example #1
0
 function getGroups(Am_Record $record)
 {
     switch ($this->_groupMode) {
         case Am_Protect_Databased::GROUP_NONE:
             return null;
         case Am_Protect_Databased::GROUP_MULTI:
             if ($this->_groupTableConfig) {
                 $table = $this->_groupTableConfig[Am_Protect_Table::GROUP_TABLE];
                 $uidField = $this->_groupTableConfig[Am_Protect_Table::GROUP_UID];
                 $gidField = $this->_groupTableConfig[Am_Protect_Table::GROUP_GID];
                 return $this->_db->selectCol("SELECT {$gidField} FROM {$table} WHERE {$uidField}=?", $record->pk());
             }
             break;
         case Am_Protect_Databased::GROUP_SINGLE:
             /// may be a field set
             $field = null;
             foreach ($this->_fieldsMapping as $a) {
                 list($k, $v) = $a;
                 if ($k == Am_Protect_Table::FIELD_GROUP_ID) {
                     $field = $v;
                     break;
                 }
             }
             if ($field) {
                 $v = $record->get($field);
                 return $v;
             }
             break;
     }
     throw new Am_Exception_NotImplemented(get_class($this) . "->getGroups() is not implemented");
 }
Example #2
0
 function __construct(Am_Record $record)
 {
     foreach (get_class_vars(get_class($this)) as $k => $v) {
         if ($k == '_params') {
             continue;
         }
         $this->{$k} = $record->get($k);
     }
     $this->setParams(new JRegistry());
     $this->aid = $this->gid == 18 ? 1 : 2;
     $this->guest = 0;
 }
Example #3
0
 /**
  * Make sure that session is valid. Will check session IP and UserAgent
  * Return true if UserAgent and IP are the same as for current user. 
  * @param Am_Record $session 
  * @return true|false
  * 
  */
 function sessionIsValid(Am_Record $session)
 {
     // If session have different User Agent or IP  do not login user into aMember.
     if (!is_null($this->_ua) && $session->get($this->_ua) && $session->get($this->_ua) != $this->getUserAgent()) {
         return false;
     }
     if (!is_null($this->_ip) && $session->get($this->_ip) && $session->get($this->_ip) != $this->getUserIp()) {
         return false;
     }
     return true;
 }