Exemplo n.º 1
0
 public function exportAction()
 {
     try {
         $fileContents = "";
         $fileTitle = "";
         $userId = $this->getParam("userId");
         if ($userId > 0) {
             $user = User_Abstract::getById($userId);
             $userCollection[] = $user;
             $fileContents = PimPon_User_Export::doExport($userCollection);
             $fileTitle = $user->getName();
         } else {
             if ($userId == 0) {
                 $list = new User_List();
                 $list->setCondition("parentId = ?", intval($userId));
                 $list->load();
                 $userCollection = $list->getUsers();
                 $fileContents = PimPon_User_Export::doExport($userCollection);
                 $fileTitle = 'all';
             }
         }
         ob_end_clean();
         header("Content-type: application/json");
         header("Content-Disposition: attachment; filename=\"pimponexport.users." . $fileTitle . ".json\"");
         echo file_get_contents($fileContents);
         exit;
     } catch (Exception $ex) {
         Logger::err($ex->getMessage());
         $this->_helper->json(array("success" => false, "data" => 'error'), false);
     }
 }
Exemplo n.º 2
0
 public static function doExport(array $userCollection)
 {
     self::$exportFile = self::getExportFilePath();
     self::openExportFile();
     array_walk($userCollection, 'PimPon_User_Export::exportUser');
     self::closeExportFile();
     return self::$exportFile;
 }