Example #1
0
 /**
  * Delete a group from a project
  *
  * @param mixed Group
  */
 public function deleteGroup($group)
 {
     $group_id = 0;
     if (is_object($group)) {
         $group_id = $group->id;
     } elseif (is_numeric($group)) {
         $group_id = intval($group);
     }
     if ($group_id) {
         $table_groupstoproject = new USVN_Db_Table_GroupsToProjects();
         $p = $table_groupstoproject->getAdapter()->quoteInto("projects_id = ?", $this->id);
         $g = $table_groupstoproject->getAdapter()->quoteInto("groups_id = ?", $group_id);
         if ($table_groupstoproject->delete(array($p, $g)) == 0) {
             throw new USVN_Exception(T_("Invalid group %s for project %s."), $group_id, $this->id);
         }
         $table_groupstofilesrights = new USVN_Db_Table_GroupsToFilesRights();
         $rights = $table_groupstofilesrights->fetchAll($g);
         $file_rights = new USVN_Db_Table_FilesRights();
         foreach ($rights as $right) {
             $file_right = $file_rights->find($right->files_rights_id)->current();
             if ($file_right->projects_id == $this->id) {
                 $right->delete();
             }
         }
     } else {
         throw new USVN_Exception(T_("Invalid group %s for project %s."), $group, $this->id);
     }
 }
Example #2
0
 private function unsetRightByPath($group_id, $path)
 {
     $filesRightsId = array();
     $tableFilesRights = new USVN_Db_Table_FilesRights();
     $whereFilesRights = $tableFilesRights->getAdapter()->quoteInto("files_rights_path LIKE ? ", $path);
     $whereFilesRights .= $tableFilesRights->getAdapter()->quoteInto(" AND projects_id = ? ", $this->_project);
     foreach ($tableFilesRights->fetchAll($whereFilesRights) as $filesRights) {
         $filesRightsId[] = $filesRights->id;
     }
     if (count($filesRightsId) > 0) {
         $table = new USVN_Db_Table_GroupsToFilesRights();
         $where = $table->getAdapter()->quoteInto("files_rights_id IN (?) ", $filesRightsId);
         $where .= $table->getAdapter()->quoteInto("and groups_id = ? ", $group_id);
         $table->delete($where);
         $where = $table->getAdapter()->quoteInto("files_rights_id IN (?) ", $filesRightsId);
         if (count($table->fetchAll($where)) == 0) {
             $tableFilesRights->delete($whereFilesRights);
         }
     }
 }