Proyectos de Subversion LeadersLinked - Services

Rev

Rev 626 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 626 Rev 629
Línea 151... Línea 151...
151
    {
151
    {
152
        $prototype = new User();
152
        $prototype = new User();
153
        $select = $this->sql->select(self::_TABLE);
153
        $select = $this->sql->select(self::_TABLE);
154
        $select->where->equalTo('email', $email);
154
        $select->where->equalTo('email', $email);
155
        $select->where->equalTo('network_id', $network_id);
155
        $select->where->equalTo('network_id', $network_id);
156
              
156
 
157
        return $this->executeFetchOneObject($select, $prototype);
157
        return $this->executeFetchOneObject($select, $prototype);
158
    }
158
    }
Línea 159... Línea 159...
159
 
159
 
160
    /**
160
    /**
Línea 185... Línea 185...
185
    public function fetchOneByUsernameXmpp($username_xmpp)
185
    public function fetchOneByUsernameXmpp($username_xmpp)
186
    {
186
    {
187
        $prototype = new User();
187
        $prototype = new User();
188
        $select = $this->sql->select(self::_TABLE);
188
        $select = $this->sql->select(self::_TABLE);
189
        $select->where->equalTo('username_xmpp', $username_xmpp);
189
        $select->where->equalTo('username_xmpp', $username_xmpp);
190
        
190
 
191
        //echo $select->getSqlString($this->adapter->platform); exit;
191
        //echo $select->getSqlString($this->adapter->platform); exit;
192
        
192
 
193
        return $this->executeFetchOneObject($select, $prototype);
193
        return $this->executeFetchOneObject($select, $prototype);
194
    }
194
    }
195
    
195
 
196
    
196
 
197
    /**
197
    /**
198
     *
198
     *
199
     * @param $username_xmpp
199
     * @param $username_xmpp
200
     * @return void|User
200
     * @return void|User
201
     */
201
     */
Línea 203... Línea 203...
203
    {
203
    {
204
        $prototype = new User();
204
        $prototype = new User();
205
        $select = $this->sql->select(self::_TABLE);
205
        $select = $this->sql->select(self::_TABLE);
206
        $select->where->like('username_xmpp', $username_xmpp . '%');
206
        $select->where->like('username_xmpp', $username_xmpp . '%');
207
        $select->order('id desc');
207
        $select->order('id desc');
208
        
208
 
209
        return $this->executeFetchOneObject($select, $prototype);
209
        return $this->executeFetchOneObject($select, $prototype);
210
    }
210
    }
211
    
211
 
212
    /**
212
    /**
213
     *
213
     *
214
     * @param $username_xmpp
214
     * @param $username_xmpp
215
     * @return void|User
215
     * @return void|User
216
     */
216
     */
Línea 219... Línea 219...
219
        $prototype = new User();
219
        $prototype = new User();
220
        $select = $this->sql->select(self::_TABLE);
220
        $select = $this->sql->select(self::_TABLE);
221
        $select->where->equalTo('username_xmpp', $username_xmpp);
221
        $select->where->equalTo('username_xmpp', $username_xmpp);
222
        $select->where->equalTo('status', User::STATUS_ACTIVE);
222
        $select->where->equalTo('status', User::STATUS_ACTIVE);
223
        $select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
223
        $select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
224
        
224
 
225
        //echo $select->getSqlString($this->adapter->platform); exit;
225
        //echo $select->getSqlString($this->adapter->platform); exit;
226
        
226
 
227
        return $this->executeFetchOneObject($select, $prototype);
227
        return $this->executeFetchOneObject($select, $prototype);
228
    }
228
    }
Línea 229... Línea 229...
229
 
229
 
Línea 829... Línea 829...
829
    {
829
    {
830
        $hydrator = new ObjectPropertyHydrator();
830
        $hydrator = new ObjectPropertyHydrator();
831
        $values = $hydrator->extract($user);
831
        $values = $hydrator->extract($user);
832
        //$values = $this->removeEmpty($values);
832
        //$values = $this->removeEmpty($values);
Línea 833... Línea 833...
833
 
833
 
Línea 834... Línea 834...
834
        
834
 
835
 
835
 
836
        unset($values['added_on']);
836
        unset($values['added_on']);
837
        $values['updated_on'] = new Expression('NOW()');
837
        $values['updated_on'] = new Expression('NOW()');
838
  
838
 
839
        
839
 
Línea 840... Línea 840...
840
        
840
 
841
        
841
 
842
 
842
 
Línea 843... Línea 843...
843
        $update = $this->sql->update(self::_TABLE);
843
        $update = $this->sql->update(self::_TABLE);
Línea 844... Línea 844...
844
        $update->set($values);
844
        $update->set($values);
845
        $update->where->equalTo('id', $user->id);
845
        $update->where->equalTo('id', $user->id);
Línea 846... Línea 846...
846
 
846
 
Línea 890... Línea 890...
890
        $update->where->equalTo('id', $user->id);
890
        $update->where->equalTo('id', $user->id);
Línea 891... Línea 891...
891
 
891
 
892
        return $this->executeUpdate($update);
892
        return $this->executeUpdate($update);
Línea 893... Línea 893...
893
    }
893
    }
894
 
894
 
895
    
895
 
896
    /**
896
    /**
897
     *
897
     *
898
     * @param User $user
898
     * @param User $user
Línea 903... Línea 903...
903
        $values = [
903
        $values = [
904
            'first_name' => $user->first_name,
904
            'first_name' => $user->first_name,
905
            'last_name' => $user->last_name,
905
            'last_name' => $user->last_name,
906
            'updated_on' => new Expression('NOW()')
906
            'updated_on' => new Expression('NOW()')
907
        ];
907
        ];
908
        
908
 
909
        $update = $this->sql->update(self::_TABLE);
909
        $update = $this->sql->update(self::_TABLE);
910
        $update->set($values);
910
        $update->set($values);
911
        $update->where->equalTo('id', $user->id);
911
        $update->where->equalTo('id', $user->id);
912
        
912
 
913
        return $this->executeUpdate($update);
913
        return $this->executeUpdate($update);
914
    }
914
    }
915
    
915
 
Línea 916... Línea 916...
916
 
916
 
917
    /**
917
    /**
918
     *
918
     *
919
     * @param User $user
919
     * @param User $user
Línea 1022... Línea 1022...
1022
    {
1022
    {
1023
        $select = $this->sql->select();
1023
        $select = $this->sql->select();
1024
        $select->columns(['status', 'backend', 'creator']);
1024
        $select->columns(['status', 'backend', 'creator']);
1025
        $select->from(['tb1' => CompanyUserMapper::_TABLE]);
1025
        $select->from(['tb1' => CompanyUserMapper::_TABLE]);
1026
        $select->join(['tb2' => self::_TABLE], 'tb1.user_id = tb2.id', [
1026
        $select->join(['tb2' => self::_TABLE], 'tb1.user_id = tb2.id', [
-
 
1027
            'id',
-
 
1028
            'uuid',
-
 
1029
            'first_name',
-
 
1030
            'last_name',
-
 
1031
            'email',
1027
            'id', 'uuid', 'first_name', 'last_name', 'email', 'last_activity_on', 'image',
1032
            'last_activity_on',
-
 
1033
            'image',
-
 
1034
            'blocked',
-
 
1035
            'login_attempt',
1028
            'blocked', 'login_attempt', 'email_verified'
1036
            'email_verified'
Línea 1029... Línea 1037...
1029
 
1037
 
Línea 1030... Línea 1038...
1030
        ]);
1038
        ]);
1031
 
1039
 
Línea 1209... Línea 1217...
1209
 
1217
 
Línea 1210... Línea 1218...
1210
        $prototype = new User();
1218
        $prototype = new User();
1211
 
1219
 
1212
        return $this->executeFetchAllObject($select, $prototype);
1220
        return $this->executeFetchAllObject($select, $prototype);
1213
    }
1221
    }
1214
    
1222
 
1215
    
1223
 
1216
    /**
1224
    /**
1217
     *
1225
     *
1218
     * @param int $network_id
1226
     * @param int $network_id
Línea 1223... Línea 1231...
1223
     * 
1231
     * 
1224
     * @return User[]
1232
     * @return User[]
1225
     */
1233
     */
1226
    public function fetchAllSuggestPaginateByNetworkIdAndSearchAndNotBlocked($network_id, $search, $records_per_page, $page,  $userBlockedIds = [])
1234
    public function fetchAllSuggestPaginateByNetworkIdAndSearchAndNotBlocked($network_id, $search, $records_per_page, $page,  $userBlockedIds = [])
1227
    {
1235
    {
1228
        
1236
 
1229
        $select = $this->sql->select();
1237
        $select = $this->sql->select();
1230
        $select->from(self::_TABLE);
1238
        $select->from(self::_TABLE);
1231
        $select->where->equalTo('network_id', $network_id);
1239
        $select->where->equalTo('network_id', $network_id);
1232
        $select->where->equalTo('status', User::STATUS_ACTIVE);
1240
        $select->where->equalTo('status', User::STATUS_ACTIVE);
1233
        $select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
1241
        $select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
1234
        
1242
 
1235
        if($userBlockedIds) {
1243
        if ($userBlockedIds) {
1236
            $select->where->notIn('id', $userBlockedIds);
1244
            $select->where->notIn('id', $userBlockedIds);
1237
        }
1245
        }
1238
         
1246
 
1239
        if ($search) {
1247
        if ($search) {
1240
            $select->where->nest()
1248
            $select->where->nest()
1241
            ->like('first_name', '%' . $search . '%')
1249
                ->like('first_name', '%' . $search . '%')
1242
            ->or->like('last_name', '%' . $search . '%')
1250
                ->or->like('last_name', '%' . $search . '%')
1243
            ->or->like(new Expression("CONCAT(first_name,' ',last_name)"), '%' . $search . '%')
1251
                ->or->like(new Expression("CONCAT(first_name,' ',last_name)"), '%' . $search . '%')
1244
            ->or->like(new Expression("CONCAT(last_name,' ',first_name)"), '%' . $search . '%')
1252
                ->or->like(new Expression("CONCAT(last_name,' ',first_name)"), '%' . $search . '%')
1245
            ->or->like('email', '%' . $search . '%')
1253
                ->or->like('email', '%' . $search . '%')
1246
            ->unnest();
1254
                ->unnest();
1247
        }
1255
        }
1248
        
1256
 
1249
        $select->order(['first_name', 'last_name']);
1257
        $select->order(['first_name', 'last_name']);
1250
        
1258
 
1251
        // echo $select->getSqlString($this->adapter->platform); exit;
1259
        // echo $select->getSqlString($this->adapter->platform); exit;
1252
        
1260
 
1253
        $prototype = new User();
1261
        $prototype = new User();
1254
        
1262
 
1255
        $hydrator   = new ObjectPropertyHydrator();
1263
        $hydrator   = new ObjectPropertyHydrator();
1256
        $resultset  = new HydratingResultSet($hydrator, $prototype);
1264
        $resultset  = new HydratingResultSet($hydrator, $prototype);
1257
        
1265
 
1258
        $adapter = new DbSelect($select, $this->sql, $resultset);
1266
        $adapter = new DbSelect($select, $this->sql, $resultset);
1259
        $paginator = new Paginator($adapter);
1267
        $paginator = new Paginator($adapter);
1260
        $paginator->setItemCountPerPage($records_per_page);
1268
        $paginator->setItemCountPerPage($records_per_page);
1261
        $paginator->setCurrentPageNumber($page);
1269
        $paginator->setCurrentPageNumber($page);
1262
        
1270
 
1263
        
1271
 
1264
        return $paginator;
1272
        return $paginator;
1265
    }
1273
    }
1266
    
1274
 
Línea 1267... Línea 1275...
1267
 
1275
 
1268
    /**
1276
    /**
1269
     *
1277
     *
1270
     * @param int $company_id
1278
     * @param int $company_id
Línea 1278... Línea 1286...
1278
        $selectCompanyUsers->columns(['user_id']);
1286
        $selectCompanyUsers->columns(['user_id']);
1279
        $selectCompanyUsers->where->equalTo('company_id', $company_id);
1287
        $selectCompanyUsers->where->equalTo('company_id', $company_id);
1280
        $selectCompanyUsers->where->in('status', [
1288
        $selectCompanyUsers->where->in('status', [
1281
            CompanyUser::STATUS_ACCEPTED,
1289
            CompanyUser::STATUS_ACCEPTED,
1282
            CompanyUser::STATUS_ADMIN_WILL_ADD,
1290
            CompanyUser::STATUS_ADMIN_WILL_ADD,
1283
            
1291
 
1284
        ]);
1292
        ]);
1285
        
1293
 
1286
        //echo $selectCompanyUsers->getSqlString($this->adapter->platform); exit;
1294
        //echo $selectCompanyUsers->getSqlString($this->adapter->platform); exit;
1287
        
1295
 
1288
        $select = $this->sql->select();
1296
        $select = $this->sql->select();
1289
        $select->from(self::_TABLE);
1297
        $select->from(self::_TABLE);
1290
        $select->where->equalTo('network_id', $network_id);
1298
        $select->where->equalTo('network_id', $network_id);
1291
        $select->where->equalTo('status', User::STATUS_ACTIVE);
1299
        $select->where->equalTo('status', User::STATUS_ACTIVE);
1292
        $select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
1300
        $select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
1293
       
1301
 
1294
        
1302
 
1295
        if ($search) {
1303
        if ($search) {
1296
            $select->where->nest()
1304
            $select->where->nest()
1297
            ->like('first_name', '%' . $search . '%')
1305
                ->like('first_name', '%' . $search . '%')
1298
            ->or->like('last_name', '%' . $search . '%')
1306
                ->or->like('last_name', '%' . $search . '%')
1299
            ->or->like('email', '%' . $search . '%')
1307
                ->or->like('email', '%' . $search . '%')
1300
            ->unnest();
1308
                ->unnest();
1301
        }
1309
        }
1302
        
1310
 
1303
        $select->where->In('id', $selectCompanyUsers);
1311
        $select->where->In('id', $selectCompanyUsers);
1304
        
1312
 
1305
        $select->order(['first_name', 'last_name']);
1313
        $select->order(['first_name', 'last_name']);
1306
        
1314
 
1307
       // echo $select->getSqlString($this->adapter->platform); exit;
1315
        // echo $select->getSqlString($this->adapter->platform); exit;
1308
        
1316
 
1309
        $prototype = new User();
1317
        $prototype = new User();
1310
        
1318
 
1311
        return $this->executeFetchAllObject($select, $prototype);
1319
        return $this->executeFetchAllObject($select, $prototype);
1312
    }
1320
    }
1313
    
1321
 
1314
    
1322
 
1315
    /**
1323
    /**
1316
     *
1324
     *
1317
     * @param int $company_id
1325
     * @param int $company_id
1318
     * @param int $network_id
1326
     * @param int $network_id
1319
     * @param string $search
1327
     * @param string $search
Línea 1712... Línea 1720...
1712
        $update->where->equalTo('id', $id);
1720
        $update->where->equalTo('id', $id);
Línea 1713... Línea 1721...
1713
 
1721
 
1714
        return $this->executeUpdate($update);
1722
        return $this->executeUpdate($update);
Línea 1715... Línea -...
1715
    }
-
 
1716
 
1723
    }
1717
 
1724
 
1718
    /**
1725
    /**
1719
     *
1726
     *
1720
     * @param int $company_id
1727
     * @param int $company_id
Línea 1739... Línea 1746...
1739
 
1746
 
Línea 1740... Línea 1747...
1740
        $prototype = User();
1747
        $prototype = User();
1741
 
1748
 
1742
        return $this->executeFetchAllObject($select, $prototype);
1749
        return $this->executeFetchAllObject($select, $prototype);
1743
    }
1750
    }
1744
    
1751
 
1745
    
1752
 
1746
    
1753
 
1747
    /**
1754
    /**
1748
     *
1755
     *
1749
     * @param string $username_inmail
1756
     * @param string $username_inmail
Línea 1755... Línea 1762...
1755
        $prototype = new User();
1762
        $prototype = new User();
1756
        $select = $this->sql->select(self::_TABLE);
1763
        $select = $this->sql->select(self::_TABLE);
1757
        $select->where->equalTo('username_inmail', $username_inmail);
1764
        $select->where->equalTo('username_inmail', $username_inmail);
1758
        $select->where->equalTo('network_id', $network_id);
1765
        $select->where->equalTo('network_id', $network_id);
1759
        $select->where->equalTo('status', User::STATUS_ACTIVE);
1766
        $select->where->equalTo('status', User::STATUS_ACTIVE);
1760
     
1767
 
1761
        
1768
 
1762
        //echo $select->getSqlString($this->adapter->platform); exit;
1769
        //echo $select->getSqlString($this->adapter->platform); exit;
1763
        
1770
 
1764
        return $this->executeFetchOneObject($select, $prototype);
1771
        return $this->executeFetchOneObject($select, $prototype);
1765
    }
1772
    }
-
 
1773
 
-
 
1774
    /**
-
 
1775
     * Update the verification status of a user.
-
 
1776
     *
-
 
1777
     * @param User $user
-
 
1778
     * @param bool $is_verified
-
 
1779
     * @return boolean
-
 
1780
     */
-
 
1781
    public function updateUserEmailVerified($user, $is_verified)
-
 
1782
    {
-
 
1783
 
-
 
1784
        $values = [
-
 
1785
            'email_verified' => $is_verified,
-
 
1786
            'updated_on'  => new Expression('NOW()')
-
 
1787
        ];
-
 
1788
 
-
 
1789
        $update = $this->sql->update(self::_TABLE);
-
 
1790
        $update->set($values);
-
 
1791
        $update->where->equalTo('id', $user->id);
-
 
1792
 
-
 
1793
        return $this->executeUpdate($update);
-
 
1794
    }
-
 
1795
 
-
 
1796
    /**
-
 
1797
     * Update the blocked status of a user.
-
 
1798
     *
-
 
1799
     * @param User $user
-
 
1800
     * @param bool $is_blocked
-
 
1801
     * @return boolean
-
 
1802
     */
-
 
1803
    public function updateUserBlockedStatus($user, $is_blocked)
-
 
1804
    {
-
 
1805
        $values = [
-
 
1806
            'blocked' => $is_blocked,
-
 
1807
            'updated_on' => new Expression('NOW()')
-
 
1808
        ];
-
 
1809
 
-
 
1810
        $update = $this->sql->update(self::_TABLE);
-
 
1811
        $update->set($values);
-
 
1812
        $update->where->equalTo('id', $user->id);
-
 
1813
 
-
 
1814
        return $this->executeUpdate($update);
-
 
1815
    }
-
 
1816
 
-
 
1817
    /**
-
 
1818
     * Update the status of a user.
-
 
1819
     *
-
 
1820
     * @param User $user
-
 
1821
     * @param string $status
-
 
1822
     * @return boolean
-
 
1823
     */
-
 
1824
    public function updateUserStatus($user, $status)
-
 
1825
    {
-
 
1826
        $values = [
-
 
1827
            'status'     => $status,
-
 
1828
            'updated_on' => new Expression('NOW()')
-
 
1829
        ];
-
 
1830
 
-
 
1831
        $update = $this->sql->update(self::_TABLE);
-
 
1832
        $update->set($values);
-
 
1833
        $update->where->equalTo('id', $user->id);
-
 
1834
 
-
 
1835
        return $this->executeUpdate($update);
-
 
1836
    }
1766
}
1837
}