示例#1
0
文件: Project.php 项目: phpscr/usvn
 /**
  * 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);
     }
 }