Exemplo n.º 1
0
 public function __construct(\Fp\Core\Init $O)
 {
     if ($O->glob('crypt_function')) {
         $this->crypt_function = $O->glob('crypt_function');
     }
     /*
     @TODO delete after Table test validation 
     $tableLoginPassword 	 = $this->table;
     $columnLoginPassword  = array('uid','password','password_tmp');
     $this->tableLoginPassword  = Table::set(Db::get_link(), $tableLoginPassword, $columnLoginPassword);
     $this->tableLoginPassword->setPrimary('uid');
     $this->tableLoginPassword->setUnique(array());
     $this->tableLoginPassword->setSortable(array('uid','password','password_tmp'));
     $this->tableLoginPassword->setSearchable(array (
       'uid' => 'bigint',
       'password' => 'varchar',
       'password_tmp' => 'varchar',
     ));
     $this->tableLoginPassword->setAutoIncrement();	
     */
     $dbLink = Db::get_link();
     $this->table = $O->glob('prefix') . $this->table;
     $shemaPassword = array('table' => $this->table, 'column' => array('uid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'password' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1), 'password_tmp' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1)));
     $this->tablePassword = Table::setTable($dbLink, $shemaPassword);
     $this->dbLoginPassword = new Query($this->tablePassword, 'LoginPassword');
 }
Exemplo n.º 2
0
 public function __construct(\Fp\Core\Init $O)
 {
     $tableLoginFacebook = $O->glob('prefix') . $this->table;
     $columnLoginFacebook = array('uid', 'fb_uid', 'app_id');
     $this->tableLoginFacebook = Table::set(Db::get_link(), $tableLoginFacebook, $columnLoginFacebook);
     $this->tableLoginFacebook->setPrimary('uid');
     $this->tableLoginFacebook->setUnique(array('fb_uid', 'uid'));
     $this->tableLoginFacebook->setSortable(array('uid', 'fb_uid'));
     $this->tableLoginFacebook->setSearchable(array('uid' => 'bigint'));
     $this->tableLoginFacebook->setAutoIncrement();
     $this->dbLoginFacebook = new Table_query($this->tableLoginFacebook, 'LoginFacebook');
 }
Exemplo n.º 3
0
 public function __construct(\Fp\Core\Init $O)
 {
     $tableLoginMail = $O->glob('prefix') . $this->table;
     $columnLoginMail = array('uid', 'mail', 'tmp_mail', 'status');
     $this->tableLoginMail = Table::set(Db::get_link(), $tableLoginMail, $columnLoginMail);
     $this->tableLoginMail->setPrimary('uid');
     $this->tableLoginMail->setUnique(array('mail'));
     $this->tableLoginMail->setSortable(array('uid', 'mail', 'tmp_mail', 'status'));
     $this->tableLoginMail->setSearchable(array('uid' => 'bigint', 'tmp_mail' => 'varchar', 'status' => 'int'));
     $this->tableLoginMail->setAutoIncrement();
     $this->dbLoginMail = new Table_query($this->tableLoginMail, 'LoginMail');
 }
Exemplo n.º 4
0
 /**
  * @param string $prefix
  * @return Auth
  */
 public function __construct(\Fp\Core\Init $O)
 {
     $this->O = $O;
     $this->data = array();
     $this->table = $O->glob('prefix') . $this->table;
     $this->session_key = md5($this->salt_session_key);
     $this->session = $O->session();
     $dbLink = Db::get_link();
     $tableLogin = $O->glob('prefix') . $this->table;
     $shemaLogin = array('table' => $tableLogin, 'options' => array('auto_increment' => 1), 'column' => array('uid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'time' => array('type' => 'datetime', 'sortable' => 1, 'searchable' => 1), 'status' => array('type' => 'int', 'sortable' => 1, 'searchable' => 1)));
     $this->tableLogin = Table::setTable($dbLink, $shemaLogin);
     $this->dbLogin = new Query($this->tableLogin, 'Login');
 }
Exemplo n.º 5
0
 /**
  * si $set est un array la fonction ignore les éléments dont les clefs ne sont pas présentes dans la liste des colonnes
  * @param array $set tableau dont les clefs sont colonnes associées aux valeurs à affecter
  * @param string $raw_column chaine contenant les nom de colonnes, séparée par des virgules, dont les valeurs doivent être traitée comme commande sql
  * @return string retourne une clause SET mysql
  */
 protected function set(array $set, $raw_column = null, $fqcn = true)
 {
     if (!is_array($set)) {
         throw new Exception(" no data to set in " . $this->dbTable->table);
     }
     $w = array();
     $raw_column = explode(',', $raw_column);
     foreach ($set as $k => $v) {
         if (!($col = $this->existColumn($k, $fqcn))) {
             continue;
         }
         if ($this->dbTable->validate($k, $v)) {
             $w[] = " {$col}=" . $this->quoteData($k, $v, in_array($k, $raw_column));
         }
     }
     $w = implode(',', $w);
     return $w;
 }
Exemplo n.º 6
0
 private function internalExistColumn($column, $fqcn = true)
 {
     $col = $this->sanitzeSelectColumn($column);
     if ($col['table_alias']) {
         if ($col['table_alias'] == $this->table_alias && $this->dbTable->existColumn($col['name'])) {
             return $this->fqcn($col['table_alias'], $col['name'], $fqcn);
         }
         // si on a des jointures
         if ($this->join && array_key_exists($col['table_alias'], $this->tableJoin)) {
             if ($type = $this->tableJoin[$col['table_alias']]['table']->existColumn($col['name'])) {
                 return $this->fqcn($col['table_alias'], $col['name'], $fqcn);
             }
         }
     } else {
         if ($this->dbTable->existColumn($col['name'])) {
             $alias = $this->table_alias ? $this->table_alias : $this->dbTable->table;
             return $this->fqcn($alias, $col['name'], $fqcn);
         }
     }
     // si l'alias correspond au nom réel de la table
     if ($col['table_alias'] == $this->dbTable->table && $this->dbTable->existColumn($col['name'])) {
         return $this->fqcn($col['table_alias'], $col['name'], $fqcn);
     } else {
         // déclaré par selectFunction as column || pour order By + group
         foreach ($this->selectFunction as $v) {
             if (preg_match('#as[\\s]+' . $col['name'] . '[\\s,]{0,1}#i', $v)) {
                 return $col['name'];
             }
         }
         // peut poser problème si le nom de colonne est ambigu
         // la première correspondance est retournée
         // si on a des jointures
         if ($this->join) {
             foreach ($this->tableJoin as $t) {
                 if ($t['table']->existColumn($col['name'])) {
                     return $this->fqcn($t['alias'], $col['name'], $fqcn);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 public function __construct(\Fp\Core\Init $O)
 {
     $this->O = $O;
     $this->namespace = $this->type_node = get_called_class();
     $dbLink = $O->db();
     /* Db 2 */
     $tabledbNode = $this->O->glob('prefix') . 'node';
     $columndbNode = array('id_node', 'type_node', 'uid', 'gid', 'zid', 'etat', 'rank', 'data', 'date_creation', 'date_modification', 'date_publication');
     $this->tableNode = Table::set($dbLink, $tabledbNode, $columndbNode);
     $this->tableNode->setPrimary('id_node');
     $this->tableNode->setUnique(array());
     $this->tableNode->setSortable(array('id_node', 'uid', 'gid', 'zid', 'etat', 'rank', 'type_node', 'date_creation', 'date_modification', 'date_publication'));
     $this->tableNode->setSearchable(array('id_node' => 'bigint', 'uid' => 'bigint', 'gid' => 'bigint', 'type_node' => 'varchar', 'date_creation' => 'timestamp', 'date_modification' => 'timestamp', 'date_publication' => 'timestamp'));
     $this->tableNode->setAutoIncrement(true);
     $this->dbNode = new Table_query($this->tableNode, 'n');
     //relation 1:n
     $tableRelation = $this->O->glob('prefix') . 'node_relation';
     $columnRelation = array('id_node_parent', 'id_node_enfant', 'position');
     $this->tableRelation = Table::set($dbLink, $tableRelation, $columnRelation);
     $this->tableRelation->setPrimary('id_node_parent');
     $this->tableRelation->setUnique(array());
     $this->tableRelation->setSortable(array('id_node_parent', 'position', 'id_node_enfant'));
     $this->tableRelation->setSearchable(array('id_node_parent' => 'bigint', 'position' => 'int', 'id_node_enfant' => 'bigint'));
     $this->tableRelation->setAutoIncrement();
     $this->dbNodeRelation = new Table_query($this->tableRelation, 'r');
     $this->dbNodeRelation->innerJoin($this->tableNode, 'n', ' n.id_node=r.id_node_parent ');
     $this->dbNodeRelation->selectColumn("n.*");
     //link 1:1
     $tableLink = $this->O->glob('prefix') . 'node_link';
     $columnLink = array('id_node_1', 'id_node_2', 'position');
     $this->tableLink = Table::set($dbLink, $tableLink, $columnLink);
     $this->tableLink->setPrimary('id_node_1');
     $this->tableLink->setUnique(array());
     $this->tableLink->setSortable(array('id_node_1', 'id_node_2', 'position'));
     $this->tableLink->setSearchable(array('id_node_1' => 'bigint', 'id_node_2' => 'bigint', 'position' => 'int'));
     $this->tableLink->setAutoIncrement();
     $this->dbNodeLink = new Table_query($this->tableLink, 'l');
     $this->dbNodeLink->selectColumn("l.*");
     //table media
     $tableMedia = $this->O->glob('prefix') . 'media_files';
     $columnMedia = array('id_media', 'file_protocol', 'file_name', 'file_type', 'file_subtype', 'file_size', 'file_md5', 'file_date', 'ip', 'uid');
     $this->tableMedia = Table::set($dbLink, $tableMedia, $columnMedia);
     $this->tableMedia->setPrimary('id_media');
     $this->tableMedia->setUnique(array());
     $this->tableMedia->setSortable(array('id_media', 'file_name', 'type', 'subtype', 'date', 'uid', 'size'));
     $this->tableMedia->setSearchable(array('id_media' => 'bigint', 'file_name' => 'varchar', 'type' => 'varchar', 'subtype' => 'varchar', 'date' => 'date', 'uid' => 'bigint', 'size' => 'bigint'));
     $this->tableMedia->setAutoIncrement(true);
     $this->dbMedia = new Table_query($this->tableMedia, 'media');
     $tableMedia = $this->O->glob('prefix') . 'node_media';
     $columnMedia = array('id', 'id_node', 'id_media', 'position');
     $this->tableNodeMedia = Table::set($dbLink, $tableMedia, $columnMedia);
     $this->tableNodeMedia->setPrimary('id');
     $this->tableNodeMedia->setUnique(array('id_node', 'id_media'));
     $this->tableNodeMedia->setSortable(array('id_node', 'position', 'id_media'));
     $this->tableNodeMedia->setSearchable(array('id_node' => 'bigint', 'position' => 'int', 'id_media' => 'bigint'));
     $this->tableNodeMedia->setAutoIncrement();
     $this->dbNodeMedia = new Table_query($this->tableNodeMedia, 'nm');
     $this->dbNodeMedia->innerJoin($this->tableMedia, 'media', ' media.id_media=nm.id_media ');
     // node Tags
     $tableNodeTags = $this->O->glob('prefix') . 'node_tags';
     $columnNodeTags = array('id_node', 'tag', 'priority');
     $this->tableNodeTags = Table::set($dbLink, $tableNodeTags, $columnNodeTags);
     $this->tableNodeTags->setPrimary('tags');
     $this->tableNodeTags->setUnique(array());
     $this->tableNodeTags->setSortable(array('id_node', 'tag'));
     $this->tableNodeTags->setSearchable(array('tag' => 'varchar', 'id_node' => 'bigint', 'priority' => 'int'));
     $this->tableNodeTags->setAutoIncrement();
     $this->dbNodeTags = new Table_query($this->tableNodeTags, 'tags');
     // node revisions
     $table = 'node_revisions';
     $column = array('id_version', 'id_node', 'uid', 'label', 'comment', 'md5', 'date_revision', 'data');
     $this->tableNodeRevisions = Table::set($dbLink, $table, $column);
     $this->tableNodeRevisions->setPrimary('id_version');
     $this->tableNodeRevisions->setUnique(array());
     $this->tableNodeRevisions->setSortable(array('id_version', 'id_node', 'uid', 'label', 'date_revision'));
     $this->tableNodeRevisions->setSearchable(array('id_version' => 'bigint', 'id_node' => 'bigint', 'uid' => 'bigint', 'label' => 'varchar', 'date_revision' => 'timestamp'));
     $this->tableNodeRevisions->setAutoIncrement(true);
     $this->dbNodeRevisions = new Table_query($this->tableNodeRevisions, 'revisions');
     $shemaNodeDataBlob = array('table' => 'node_data_blob', 'column' => array('id_node_data_blob' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'id_node' => array('type' => 'bigint', 'sortable' => 1, 'searchable' => 1), 'key_name' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1), 'data' => array('type' => 'longblob')));
     $this->tableNodeDataBlob = Table::setTable($dbLink, $shemaNodeDataBlob);
     $this->tableNodeDataBlob->setPrimary('id_node_data_blob');
     $this->tableNodeDataBlob->setAutoIncrement(true);
     $this->dbNodeDataBlob = new Table_query($this->tableNodeDataBlob);
     $shemaNodeDataChar = array('table' => 'node_data_char', 'column' => array('id_node_data_char' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'id_node' => array('type' => 'bigint', 'sortable' => 1, 'searchable' => 1), 'key_name' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1), 'data' => array('type' => 'varchar', 'sortable' => 1, 'searchable' => 1)));
     $this->tableNodeDataChar = Table::setTable($dbLink, $shemaNodeDataChar);
     $this->tableNodeDataChar->setPrimary('id_node_data_char');
     $this->tableNodeDataChar->setAutoIncrement(true);
     $this->dbNodeDataChar = new Table_query($this->tableNodeDataChar);
     $this->config();
 }
Exemplo n.º 8
0
 public function __construct(\Fp\Core\Init $O)
 {
     $this->O = $O;
     $this->prefix = $O->glob('prefix');
     $dbLink = Db::get_link();
     /*
      * Groupe
      */
     $shema = array('table' => $this->prefix . $this->table_Group, 'options' => array('auto_increment' => 1), 'column' => array('gid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'name' => array('type' => 'varchar', 'unique' => 1, 'sortable' => 1, 'searchable' => 1), 'timestamp' => array('type' => 'timestamp')));
     $this->tableGroup = Table::setTable($dbLink, $shema);
     $this->dbGroup = new Table_query($this->tableGroup, 'g');
     /*
      * Zone
      */
     $shemaZone = array('table' => 'permissions_zone', 'options' => array('auto_increment' => 1), 'column' => array('zid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'name' => array('type' => 'varchar', 'unique' => 1, 'sortable' => 1, 'searchable' => 1), 'timestamp' => array('type' => 'timestamp', 'sortable' => 1, 'searchable' => 1)));
     $this->tableZone = Table::setTable($dbLink, $shemaZone);
     $this->dbZone = new Table_query($this->tableZone, 'z');
     /*
      * GroupUser
      */
     $shemaGroupUser = array('table' => 'permissions_group_user', 'column' => array('gid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'uid' => array('type' => 'bigint', 'sortable' => 1, 'searchable' => 1), 'permission' => array('type' => 'int'), 'timestamp' => array('type' => 'timestamp', 'sortable' => 1, 'searchable' => 1)));
     $this->tableGroupUser = Table::setTable($dbLink, $shemaGroupUser);
     $this->dbGroupUser = new Table_query($this->tableGroupUser, 'gu');
     $this->dbGroupUser->innerJoin($this->tableGroup, 'g', 'gu.gid=g.gid ');
     /*
      * Group Zone
      */
     $shemaGroupZone = array('table' => 'permissions_group_zone', 'column' => array('gid' => array('type' => 'bigint', 'primary' => 1, 'sortable' => 1, 'searchable' => 1), 'zid' => array('type' => 'bigint', 'sortable' => 1, 'searchable' => 1), 'permission' => array('type' => 'int', 'sortable' => 1, 'searchable' => 1), 'timestamp' => array('type' => 'timestamp', 'sortable' => 1, 'searchable' => 1)));
     $this->tableGroupZone = Table::setTable($dbLink, $shemaGroupZone);
     $this->dbGroupZone = new Table_query($this->tableGroupZone, 'gz');
     $this->dbGroupZone->innerJoin($this->tableGroup, 'g', 'gz.gid=g.gid ');
     $this->dbGroupZone->innerJoin($this->tableZone, 'z', 'gz.zid=z.zid ');
 }