Beispiel #1
0
 public function exportAction()
 {
     try {
         $fileContents = "";
         $fileTitle = "";
         $roleId = $this->getParam("roleId");
         if ($roleId > 0) {
             $role = User_Abstract::getById($roleId);
             $roleCollection[] = $role;
             $fileContents = PimPon_Role_Export::doExport($roleCollection);
             $fileTitle = $role->getName();
         } else {
             if ($roleId == 0) {
                 $list = new User_Role_List();
                 $list->setCondition("parentId = ?", intval($roleId));
                 $list->load();
                 $roleCollection = $list->getRoles();
                 $fileContents = PimPon_Role_Export::doExport($roleCollection);
                 $fileTitle = 'all';
             }
         }
         ob_end_clean();
         header("Content-type: application/json");
         header("Content-Disposition: attachment; filename=\"pimponexport.roles." . $fileTitle . ".json\"");
         echo file_get_contents($fileContents);
         exit;
     } catch (Exception $ex) {
         Logger::err($ex->getMessage());
         $this->_helper->json(array("success" => false, "data" => 'error'), false);
     }
 }
Beispiel #2
0
 public static function doExport(array $roleCollection)
 {
     self::$exportFile = self::getExportFilePath();
     self::openExportFile();
     array_walk($roleCollection, 'PimPon_Role_Export::exportRole');
     self::closeExportFile();
     return self::$exportFile;
 }