Exemple #1
0
 public function delete($accountId = null)
 {
     global $objLiveAdmin;
     self::$object = "Account";
     self::$table = "punch_account";
     //*** Delete users.
     $objUsers = $objLiveAdmin->getUsers(array('container' => 'auth', 'filters' => array('account_id' => $this->id)));
     if (is_array($objUsers)) {
         foreach ($objUsers as $objUser) {
             $objLiveAdmin->removeUser($objUser["perm_user_id"]);
         }
     }
     //*** Delete groups.
     $objGroups = $objLiveAdmin->perm->getGroups(array('filters' => array('account_id' => $this->id)));
     if (is_array($objGroups)) {
         foreach ($objGroups as $objGroup) {
             $filters = array('group_id' => $objGroup['group_id']);
             $objLiveAdmin->perm->removeGroup($filters);
         }
     }
     //*** Delete applications, areas and rights.
     $objApps = $objLiveAdmin->perm->getApplications(array('filters' => array('account_id' => $this->id)));
     if (is_array($objApps)) {
         foreach ($objApps as $objApp) {
             $objAreas = $objLiveAdmin->perm->getAreas(array('filters' => array('application_id' => $objApp['application_id'], 'account_id' => $this->id)));
             if (is_array($objAreas)) {
                 foreach ($objAreas as $objArea) {
                     $objRights = $objLiveAdmin->perm->getRights(array('filters' => array('area_id' => $objArea['area_id'], 'account_id' => $this->id)));
                     if (is_array($objRights)) {
                         //*** Delete rights.
                         foreach ($objRights as $objRight) {
                             $filters = array('right_id' => $objRight['right_id']);
                             $objLiveAdmin->perm->removeRight($filters);
                         }
                     }
                     //*** Delete areas.
                     $filters = array('area_id' => $objArea['area_id']);
                     $objLiveAdmin->perm->removeArea($filters);
                 }
             }
             //*** Delete applications.
             $filters = array('application_id' => $objApp['application_id']);
             $objLiveAdmin->perm->removeApplication($filters);
         }
     }
     return parent::delete($accountId);
 }
 public function duplicate()
 {
     self::$object = "Account";
     self::$table = "punch_account";
     return parent::duplicate();
 }