示例#1
0
文件: Export.php 项目: jv10/pimpon
 private static function getChilds($parentId)
 {
     $list = new User_Role_List();
     $list->setCondition("parentId = ?", $parentId);
     $list->load();
     return $list->getRoles();
 }
示例#2
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);
     }
 }
 public function roleTreeGetChildsByIdAction()
 {
     $list = new User_Role_List();
     $list->setCondition("parentId = ?", intval($this->_getParam("node")));
     $list->load();
     $roles = array();
     if (is_array($list->getItems())) {
         foreach ($list->getItems() as $role) {
             $roles[] = $this->getRoleTreeNodeConfig($role);
         }
     }
     $this->_helper->json($roles);
 }