Example #1
0
 public function fetchAll()
 {
     // get all users from the login app
     $userlist = Zend_Json::decode($this->getApiHelper()->direct(array('admin_id' => $this->getSession()->userid, 'token' => uniqid(), 'app' => $this->getApiHelper()->name('login'), 'key' => $this->getApiHelper()->key('login')), $this->getApiHelper()->endpoint('login') . 'getuserlist'));
     if ($userlist['error'] == 1) {
         throw new Exception('1 - Failed to load userlist.');
     }
     // get all auditors from the review app
     $review = Zend_Json::decode($this->getApiHelper()->direct(array('api_key' => $this->getApiHelper()->key('review'), 'action' => 'getUsers'), $this->getApiHelper()->endpoint('review')));
     if ($review['success'] == false) {
         throw new Exception('2 - Failed to load userlist.');
     }
     // get picture, team and skill from love app
     $love = Zend_Json::decode($this->getApiHelper()->direct(array('action' => 'getUserlist', 'api_key' => $this->getApiHelper()->key('love')), $this->getApiHelper()->endpoint('love')));
     if ($love['success'] == false) {
         throw new Exception('3 - Failed to load userlist.');
     }
     foreach ($userlist as $user) {
         if (is_array($user)) {
             $newUser = new Admin_Model_User($user);
             if (isset($review['userlist']) && isset($review['userlist'][$newUser->getId()])) {
                 $newUser->setAuditor($review['userlist'][$newUser->getId()]['is_auditor'])->setGiver($review['userlist'][$newUser->getId()]['is_giver'])->setReceiver($review['userlist'][$newUser->getId()]['is_receiver']);
             }
             if (isset($love['userlist']) && isset($love['userlist'][$newUser->getId()])) {
                 $newUser->setPicture($love['userlist'][$newUser->getId()]['picture'])->setTeam($love['userlist'][$newUser->getId()]['team'])->setSkill($love['userlist'][$newUser->getId()]['skill']);
             }
             $users[] = $newUser;
         }
     }
     return $users;
 }