Beispiel #1
0
 /**
  * Autentifica al usuario en el sistema por medio de su username y password
  * @param string $user El username del usuario
  * @param string $pass El password del usuario
  * @return bool|Regresa true si los datos del usuario son validos en la BD, en caso de fallar regresa false
  */
 public function authenticate($user, $pass)
 {
     $dbs = Model3_Registry::getInstance()->get('databases');
     $em = $dbs[$this->_config['cnx']];
     /* @var $em Doctrine\ORM\EntityManager */
     $user = $em->getRepository($this->_config['table'])->findOneBy(array($this->_config['user'] => $user));
     if ($user) {
         $method = 'get' . ucwords($this->_config['pass']);
         if ($user->{$method}() == $pass) {
             $_SESSION['__M3']['Credentials'] = $user->getData();
             return true;
         }
         return false;
     }
 }
Beispiel #2
0
 public function selectCatalogTypes($entity, $options = array(), $selected = '')
 {
     $dbs = Model3_Registry::getInstance()->get('databases');
     $em = $dbs['DefaultDb'];
     $list = $em->getRepository('DefaultDb_Entity_' . $entity)->findAll();
     $strOptions = '';
     foreach ($options as $key => $option) {
         $strOptions .= $key . '="' . $option . '" ';
     }
     $html = '<select ' . $strOptions . '>';
     $html .= '<option value="">Seleccione</option>';
     $param = '';
     foreach ($list as $row) {
         if ($selected == $row->getId()) {
             $param = 'selected="selected"';
         }
         $html .= '<option value="' . $row->getId() . '" ' . $param . '>' . $row->getName() . '</option>';
         $param = '';
     }
     $html .= '</select>';
     return $html;
 }
Beispiel #3
0
 /**
  * 
  * @param string $dbName
  * @return Doctrine\ORM\EntityManager
  */
 public function getEntityManager($dbName)
 {
     $em = false;
     $dbs = Model3_Registry::getInstance()->get('databases');
     if (array_key_exists($dbName, $dbs) == true) {
         $em = $dbs[$dbName];
     }
     return $em;
 }
Beispiel #4
0
 public static function baseUrl()
 {
     $registry = Model3_Registry::getInstance();
     $config = $registry->get('config');
     $carray = $config->getArray();
     return $carray['general']['url'];
 }