Ejemplo n.º 1
0
 /**
  * function processData
  * <pre>
  * Processes the data for this form.
  * </pre>
  * @return [void]
  */
 function processData()
 {
     // now get list of NEW Groups added to this Account
     $addedList = array();
     for ($indx = 0; $indx < count($this->submittedGroups); $indx++) {
         $id = $this->submittedGroups[$indx];
         // if id not in currentGroupList then add to addList
         if (!isset($this->currentGroupList[$id])) {
             $addedList[] = $id;
         }
     }
     // foreach added group
     $viewerAccessGroup = new RowManager_ViewerAccessGroupManager();
     $accessGroupManager = new RowManager_AccessGroupManager();
     $adminAccessGroupID = $accessGroupManager->getAdminAccessGroupID();
     //print($adminAccessGroupID . "<br>");
     for ($indx = 0; $indx < count($addedList); $indx++) {
         // create new entry
         $viewerAccessGroup->createNewEntry();
         // load values
         $values = array();
         $values['viewer_id'] = $this->viewer_id;
         $values['accessgroup_id'] = $addedList[$indx];
         $viewerAccessGroup->loadFromArray($values);
         // update DB Table
         $viewerAccessGroup->updateDBTable();
         //add to table accountadmin_accountadminaccess if acces group is adminAccesGroup
         if ($values['accessgroup_id'] == $adminAccessGroupID) {
             $aam = new RowManager_AccountAdminAccessManager();
             $aam->setViewerID($this->viewer_id);
             $aam->setGroupPrivilege();
             $aam->createNewEntry();
         }
     }
     // next group
     $languageManager = new RowManager_LanguageManager();
     $languageList = $languageManager->getListIterator();
     $languageList->setFirst();
     while ($language = $languageList->getNext()) {
         $navbar = new RowManager_NavBarCacheManager();
         $navbar->loadByViewerID($this->viewer_id, $language->getID());
         if ($navbar->getID() != -1) {
             $navbar->setCacheInvalid();
             $navbar->updateDBTable();
         }
     }
     // get list of DELETED Groups from this account
     $deletedList = array();
     foreach ($this->currentGroupList as $key => $value) {
         if (!in_array($key, $this->submittedGroups)) {
             $deletedList[] = $key;
         }
     }
     // foreach deleted group
     for ($indx = 0; $indx < count($deletedList); $indx++) {
         // if we can load a manager for this account with this group then
         if ($viewerAccessGroup->loadByViewerAccessGroup($this->viewer_id, $deletedList[$indx])) {
             // delete
             $viewerAccessGroup->deleteEntry();
             if ($deletedList[$indx] == $adminAccessGroupID) {
                 $aam = new RowManager_AccountAdminAccessManager();
                 $aam->setViewerID($this->viewer_id);
                 //$aam->setGroupPrivilege();
                 //print("before delete");
                 $aam->deleteEntry();
             }
         }
     }
     // next group
     // update currentGroupList with submittedGroupList
     $groupList = new ViewerAccessGroupList($this->viewer_id, $this->sortBy);
     $this->currentGroupList = $groupList->getAccessGroupArray();
 }